-
-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): add function list context menu (#1825)
* feat(web): add function list context menu * fix popover trigger click * fix delete with new function render & fix contextmenu hide after delete
- Loading branch information
1 parent
3e17727
commit bcde132
Showing
13 changed files
with
222 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
web/src/pages/app/functions/mods/FunctionPanel/ContextMenu/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.contexify { | ||
box-shadow: none !important; | ||
border: 1px solid #e2e8f0 !important; | ||
min-width: 0 !important; | ||
justify-content: center; | ||
width: 120px; | ||
padding: 2px !important; | ||
} | ||
|
||
.contexify_theme-dark { | ||
background-color: #212630 !important; | ||
border: 1px solid rgba(255, 255, 255, 0.16) !important; | ||
} | ||
|
||
.contexify_itemContent { | ||
background: none !important; | ||
width: 100% !important; | ||
height: 100% !important; | ||
} |
72 changes: 72 additions & 0 deletions
72
web/src/pages/app/functions/mods/FunctionPanel/ContextMenu/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Item, Menu } from "react-contexify"; | ||
import "./index.scss" | ||
import "react-contexify/dist/ReactContexify.css"; | ||
import CreateModal from "../CreateModal"; | ||
import { TFunction } from "@/apis/typing"; | ||
import IconText from "@/components/IconText"; | ||
import { EditIconLine, LinkIcon, RecycleDeleteIcon } from "@/components/CommonIcon"; | ||
import { useTranslation } from "react-i18next"; | ||
import ConfirmButton from "@/components/ConfirmButton"; | ||
import { useDeleteFunctionMutation } from "../../../service"; | ||
import useGlobalStore from "@/pages/globalStore"; | ||
import CopyText from "@/components/CopyText"; | ||
import { COLOR_MODE } from "@/constants"; | ||
import { useColorMode } from "@chakra-ui/react"; | ||
|
||
|
||
export default function ContextMenu(props: { functionItem: TFunction, tagsList: string[], hideAll: () => void }) { | ||
const { functionItem, tagsList, hideAll } = props; | ||
const { t } = useTranslation(); | ||
const deleteFunctionMutation = useDeleteFunctionMutation(); | ||
const { showSuccess, currentApp } = useGlobalStore(); | ||
const darkMode = useColorMode().colorMode === COLOR_MODE.dark; | ||
|
||
return ( | ||
<Menu id={functionItem._id} animation="fade" className="flex" theme={darkMode ? "dark" : "light"}> | ||
<Item closeOnClick={false}> | ||
<CreateModal | ||
functionItem={functionItem} tagList={tagsList} hideContextMenu={hideAll}> | ||
<IconText | ||
icon={ | ||
<div className="flex h-5 items-center"> | ||
<EditIconLine /> | ||
</div> | ||
} | ||
text={t("Edit")} | ||
/> | ||
</CreateModal> | ||
</Item> | ||
<Item> | ||
<ConfirmButton | ||
onSuccessAction={async () => { | ||
const res = await deleteFunctionMutation.mutateAsync(functionItem); | ||
if (!res.error) { | ||
showSuccess(t("DeleteSuccess")); | ||
} | ||
}} | ||
headerText={String(t("Delete"))} | ||
bodyText={String(t("FunctionPanel.DeleteConfirm"))} | ||
hideContextMenu={hideAll} | ||
> | ||
<IconText | ||
icon={<div className="h-5 flex items-center"><RecycleDeleteIcon fontSize={16} /></div>} | ||
text={t("Delete")} | ||
className="hover:!text-error-600" | ||
/> | ||
</ConfirmButton> | ||
</Item> | ||
<Item> | ||
<CopyText | ||
text={`${currentApp.origin}/${functionItem.name}`} | ||
hideToolTip | ||
> | ||
<IconText | ||
icon={<div className="h-5 flex items-center"><LinkIcon fontSize={22} /></div>} | ||
text={t("Copy")} | ||
className="hover:!text-primary-400" | ||
/> | ||
</CopyText> | ||
</Item> | ||
</Menu> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.