From 0d2d3d5b39ec20d54bbd0f41e07875044482eec4 Mon Sep 17 00:00:00 2001 From: zhu-mingye <934230207@qq.com> Date: Wed, 18 Oct 2023 04:59:38 -0500 Subject: [PATCH] Fix resource delete bug (#2401) * fix resource && resource config * fix resource file * fix resource file * fix resource file * fix resource file * fix resource && resource config * fix resource delete bug * Spotless Apply --------- Co-authored-by: zhu-mingye --- .../dinky/controller/ResourceController.java | 5 +- .../resource/impl/ResourceServiceImpl.java | 31 ++-- .../ExecuteConfig/CommonSql/index.tsx | 170 +++++++++--------- .../ExecuteConfig/FlinkSql/index.tsx | 150 ++++++++-------- .../RightContainer/ExecuteConfig/index.tsx | 38 ++-- dinky-web/src/pages/DataStudio/route.tsx | 8 +- dinky-web/src/pages/DevOps/function.tsx | 64 +++---- .../Resource/components/FileShow/index.tsx | 2 +- .../components/ResourceOverView/index.tsx | 27 ++- .../Resource/components/constants.tsx | 20 ++- 10 files changed, 273 insertions(+), 242 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/controller/ResourceController.java b/dinky-admin/src/main/java/org/dinky/controller/ResourceController.java index 5dd96d2c43..5c0ae8f7ec 100644 --- a/dinky-admin/src/main/java/org/dinky/controller/ResourceController.java +++ b/dinky-admin/src/main/java/org/dinky/controller/ResourceController.java @@ -24,6 +24,7 @@ import org.dinky.data.dto.ResourcesDTO; import org.dinky.data.dto.TreeNodeDTO; import org.dinky.data.enums.BusinessType; +import org.dinky.data.enums.Status; import org.dinky.data.model.Resources; import org.dinky.data.result.Result; import org.dinky.service.resource.ResourcesService; @@ -140,6 +141,8 @@ public Result uploadFile(Integer pid, String desc, @RequestParam("file") M @ApiImplicitParam(name = "id", value = "Resource ID", required = true, dataType = "Integer", paramType = "query") @SaCheckPermission(PermissionConstants.REGISTRATION_RESOURCE_DELETE) public Result remove(Integer id) { - return resourcesService.remove(id) ? Result.succeed() : Result.failed(); + return resourcesService.remove(id) + ? Result.succeed(Status.DELETE_SUCCESS) + : Result.failed(Status.DELETE_FAILED); } } diff --git a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java index b2a241fa0d..d1e71334ff 100644 --- a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.Comparator; -import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; @@ -157,7 +156,7 @@ private static TreeNodeDTO convertTree(Resources resources) { @Override public String getContentByResourceId(Integer id) { Resources resources = getById(id); - Assert.notNull(resources, () -> new BusException("resource is not exists!")); + Assert.notNull(resources, () -> new BusException(Status.RESOURCE_DIR_OR_FILE_NOT_EXIST)); Assert.isFalse(resources.getSize() > ALLOW_MAX_CAT_CONTENT_SIZE, () -> new BusException("file is too large!")); return getBaseResourceManager().getFileContent(resources.getFullName()); } @@ -218,22 +217,23 @@ public boolean remove(Integer id) { remove(new LambdaQueryWrapper().ne(Resources::getId, 0)); } Resources byId = getById(id); - if (!isExistsChildren(id)) { - removeById(id); - } - getBaseResourceManager().remove(byId.getFullName()); - if (byId.getIsDirectory()) { - List resourceByPidToChildren = getResourceByPidToChildren(new ArrayList<>(), byId.getId()); - removeBatchByIds(resourceByPidToChildren); + if (isExistsChildren(id)) { + getBaseResourceManager().remove(byId.getFullName()); + if (byId.getIsDirectory()) { + List resourceByPidToChildren = + getResourceByPidToChildren(new ArrayList<>(), byId.getId()); + removeBatchByIds(resourceByPidToChildren); + } + List resourceByPidToParent = getResourceByPidToParent(new ArrayList<>(), byId.getPid()); + resourceByPidToParent.forEach(x -> x.setSize(x.getSize() - byId.getSize())); + updateBatchById(resourceByPidToParent); + getBaseResourceManager().remove(byId.getFullName()); + return removeById(id); } - List resourceByPidToParent = getResourceByPidToParent(new ArrayList<>(), byId.getPid()); - resourceByPidToParent.forEach(x -> x.setSize(x.getSize() - byId.getSize())); - updateBatchById(resourceByPidToParent); + return removeById(id); } catch (Exception e) { throw new BusException(Status.DELETE_FAILED); } - - return removeById(id); } private boolean isExistsChildren(Integer id) { @@ -305,8 +305,7 @@ private List buildResourcesTree(List resourcesList) { List returnList = new ArrayList<>(); - for (Iterator iterator = resourcesList.iterator(); iterator.hasNext(); ) { - Resources resources = iterator.next(); + for (Resources resources : resourcesList) { // get all child catalogue of parent catalogue id , the -1 is root catalogue if (resources.getPid() == -1) { recursionBuildResourcesAndChildren(resourcesList, resources); diff --git a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql/index.tsx b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql/index.tsx index afd5c0b83f..e80a43c9b7 100644 --- a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql/index.tsx +++ b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql/index.tsx @@ -17,95 +17,99 @@ * */ -import {getCurrentData} from '@/pages/DataStudio/function'; -import {StateType, STUDIO_MODEL} from '@/pages/DataStudio/model'; -import {SWITCH_OPTIONS} from '@/services/constants'; -import {l} from '@/utils/intl'; -import {InfoCircleOutlined} from '@ant-design/icons'; -import {ProForm, ProFormDigit, ProFormGroup, ProFormSelect, ProFormSwitch} from '@ant-design/pro-components'; -import {useForm} from 'antd/es/form/Form'; -import {connect} from 'umi'; -import {DataSources} from "@/types/RegCenter/data"; -import {TagAlignLeft} from "@/components/StyledComponents"; -import {Tag} from "antd"; -import React from "react"; +import { TagAlignLeft } from '@/components/StyledComponents'; +import { getCurrentData } from '@/pages/DataStudio/function'; +import { StateType, STUDIO_MODEL } from '@/pages/DataStudio/model'; +import { DataSources } from '@/types/RegCenter/data'; +import { l } from '@/utils/intl'; +import { ProForm, ProFormDigit, ProFormGroup, ProFormSelect } from '@ant-design/pro-components'; +import { Tag } from 'antd'; +import { useForm } from 'antd/es/form/Form'; +import React from 'react'; +import { connect } from 'umi'; const ExecuteConfigCommonSql = (props: any) => { - const { - dispatch, - tabs: {panes, activeKey}, - databaseData - } = props; - const [form] = useForm(); - const current = getCurrentData(panes, activeKey); - const data: Record = {}; - const databaseDataList = databaseData as DataSources.DataSource[]; - databaseDataList.filter(x => x.type.toLowerCase() === current?.dialect.toLowerCase()).forEach((item: DataSources.DataSource) => { - data[item.id] = ( - {item.type}{item.name} - - ) + const { + dispatch, + tabs: { panes, activeKey }, + databaseData + } = props; + const [form] = useForm(); + const current = getCurrentData(panes, activeKey); + const data: Record = {}; + const databaseDataList = databaseData as DataSources.DataSource[]; + databaseDataList + .filter((x) => x.type.toLowerCase() === current?.dialect.toLowerCase()) + .forEach((item: DataSources.DataSource) => { + data[item.id] = ( + + + {item.type} + + {item.name} + + ); }); - form.setFieldsValue({...current, databaseId: String(current?.databaseId ?? "")}); - const onValuesChange = (change: any, all: any) => { - for (let i = 0; i < panes.length; i++) { - if (panes[i].key === activeKey) { - for (const key in change) { - if (key === 'databaseId') { - panes[i].params.taskData[key] = Number(all[key]); - continue; - } - panes[i].params.taskData[key] = all[key]; - } - break; - } + form.setFieldsValue({ ...current, databaseId: String(current?.databaseId ?? '') }); + const onValuesChange = (change: any, all: any) => { + for (let i = 0; i < panes.length; i++) { + if (panes[i].key === activeKey) { + for (const key in change) { + if (key === 'databaseId') { + panes[i].params.taskData[key] = Number(all[key]); + continue; + } + panes[i].params.taskData[key] = all[key]; } - dispatch({ - type: STUDIO_MODEL.saveTabs, - payload: {...props.tabs} - }); - }; + break; + } + } + dispatch({ + type: STUDIO_MODEL.saveTabs, + payload: { ...props.tabs } + }); + }; - return ( - <> - - - - - - - - - - ); + return ( + <> + + + + + + + + + + ); }; -export default connect(({Studio}: { Studio: StateType }) => ({ - tabs: Studio.tabs, - databaseData: Studio.database.dbData +export default connect(({ Studio }: { Studio: StateType }) => ({ + tabs: Studio.tabs, + databaseData: Studio.database.dbData }))(ExecuteConfigCommonSql); diff --git a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql/index.tsx b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql/index.tsx index 0c73a48d14..1220e1a46b 100644 --- a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql/index.tsx +++ b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql/index.tsx @@ -27,86 +27,86 @@ import { useForm } from 'antd/es/form/Form'; import { connect } from 'umi'; const ExecuteConfigFlinkSql = (props: any) => { - const { - dispatch, - tabs: { panes, activeKey } - } = props; - const [form] = useForm(); - const current = getCurrentData(panes, activeKey); + const { + dispatch, + tabs: { panes, activeKey } + } = props; + const [form] = useForm(); + const current = getCurrentData(panes, activeKey); - form.setFieldsValue(current); - const onValuesChange = (change: any, all: any) => { - for (let i = 0; i < panes.length; i++) { - if (panes[i].key === activeKey) { - for (const key in change) { - panes[i].params.taskData[key] = all[key]; - } - break; - } + form.setFieldsValue(current); + const onValuesChange = (change: any, all: any) => { + for (let i = 0; i < panes.length; i++) { + if (panes[i].key === activeKey) { + for (const key in change) { + panes[i].params.taskData[key] = all[key]; } - dispatch({ - type: STUDIO_MODEL.saveTabs, - payload: { ...props.tabs } - }); - }; + break; + } + } + dispatch({ + type: STUDIO_MODEL.saveTabs, + payload: { ...props.tabs } + }); + }; - return ( - <> - - - - }} - {...SWITCH_OPTIONS()} - /> + return ( + <> + + + + }} + {...SWITCH_OPTIONS()} + /> - - }} - {...SWITCH_OPTIONS()} - /> - - - - }} - {...SWITCH_OPTIONS()} - /> - - - - - ); + + }} + {...SWITCH_OPTIONS()} + /> + + + + }} + {...SWITCH_OPTIONS()} + /> + + + + + ); }; export default connect(({ Studio }: { Studio: StateType }) => ({ - tabs: Studio.tabs + tabs: Studio.tabs }))(ExecuteConfigFlinkSql); diff --git a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/index.tsx b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/index.tsx index f3eadafbd2..aa05ee65fb 100644 --- a/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/index.tsx +++ b/dinky-web/src/pages/DataStudio/RightContainer/ExecuteConfig/index.tsx @@ -17,28 +17,26 @@ * */ -import {getCurrentTab} from '@/pages/DataStudio/function'; -import {StateType, TabsPageSubType} from '@/pages/DataStudio/model'; -import {connect} from 'umi'; -import ExecuteConfigFlinkSql from "@/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql"; -import ExecuteConfigCommonSql from "@/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql"; +import { getCurrentTab } from '@/pages/DataStudio/function'; +import { StateType, TabsPageSubType } from '@/pages/DataStudio/model'; +import ExecuteConfigCommonSql from '@/pages/DataStudio/RightContainer/ExecuteConfig/CommonSql'; +import ExecuteConfigFlinkSql from '@/pages/DataStudio/RightContainer/ExecuteConfig/FlinkSql'; +import { connect } from 'umi'; const ExecuteConfig = (props: any) => { - const { - tabs: {panes, activeKey} - } = props; - const current = getCurrentTab(panes, activeKey); - { - if (current?.subType === TabsPageSubType.flinkSql) { - return ; - } else { - return ; - } + const { + tabs: { panes, activeKey } + } = props; + const current = getCurrentTab(panes, activeKey); + { + if (current?.subType === TabsPageSubType.flinkSql) { + return ; + } else { + return ; } -} + } +}; -export default connect(({Studio}: { - Studio: StateType -}) => ({ - tabs: Studio.tabs +export default connect(({ Studio }: { Studio: StateType }) => ({ + tabs: Studio.tabs }))(ExecuteConfig); diff --git a/dinky-web/src/pages/DataStudio/route.tsx b/dinky-web/src/pages/DataStudio/route.tsx index 24ba7aa596..1c0b081ad5 100644 --- a/dinky-web/src/pages/DataStudio/route.tsx +++ b/dinky-web/src/pages/DataStudio/route.tsx @@ -22,6 +22,7 @@ import Console from '@/pages/DataStudio/BottomContainer/Console'; import Lineage from '@/pages/DataStudio/BottomContainer/Lineage'; import Result from '@/pages/DataStudio/BottomContainer/Result'; import TableData from '@/pages/DataStudio/BottomContainer/TableData'; +import { isSql } from '@/pages/DataStudio/HeaderContainer/service'; import { Catalog } from '@/pages/DataStudio/LeftContainer/Catalog'; import MetaData from '@/pages/DataStudio/LeftContainer/MetaData'; import Project from '@/pages/DataStudio/LeftContainer/Project'; @@ -57,7 +58,6 @@ import { } from '@ant-design/icons'; import { DiffEditor } from '@monaco-editor/react'; import { ReactNode } from 'react'; -import {isSql} from "@/pages/DataStudio/HeaderContainer/service"; export const LeftSide = [ { @@ -98,7 +98,9 @@ export const RightSide: TabProp[] = [ icon: , label: l('menu.datastudio.executeConfig'), children: , - isShow: (type, subType) => type === TabsPageType.project && TabsPageSubType.flinkSql === subType || isSql(subType ?? "") + isShow: (type, subType) => + (type === TabsPageType.project && TabsPageSubType.flinkSql === subType) || + isSql(subType ?? '') }, { auth: '/datastudio/right/savePoint', @@ -302,4 +304,4 @@ export type TabProp = { children: ReactNode; isShow?: (type: TabsPageType, subType?: TabsPageSubType) => boolean; auth?: string; -}; \ No newline at end of file +}; diff --git a/dinky-web/src/pages/DevOps/function.tsx b/dinky-web/src/pages/DevOps/function.tsx index 9a24438ae2..6ce4dc09b8 100644 --- a/dinky-web/src/pages/DevOps/function.tsx +++ b/dinky-web/src/pages/DevOps/function.tsx @@ -15,8 +15,8 @@ * limitations under the License. */ -import {JOB_LIFE_CYCLE, JOB_STATUS} from '@/pages/DevOps/constants'; -import {l} from '@/utils/intl'; +import { JOB_LIFE_CYCLE, JOB_STATUS } from '@/pages/DevOps/constants'; +import { l } from '@/utils/intl'; /** * Generates an array of options for the life cycle filter. @@ -24,11 +24,11 @@ import {l} from '@/utils/intl'; * @returns {Array} - An array of objects representing the life cycle filter options. */ export const LIFECYCLE_FILTER = () => { - return [ - {text: l('global.table.lifecycle.dev'), value: JOB_LIFE_CYCLE.DEVELOP}, - {text: l('global.table.lifecycle.online'), value: JOB_LIFE_CYCLE.ONLINE}, - {text: l('global.table.lifecycle.unknown'), value: JOB_LIFE_CYCLE.UNKNOWN} - ]; + return [ + { text: l('global.table.lifecycle.dev'), value: JOB_LIFE_CYCLE.DEVELOP }, + { text: l('global.table.lifecycle.online'), value: JOB_LIFE_CYCLE.ONLINE }, + { text: l('global.table.lifecycle.unknown'), value: JOB_LIFE_CYCLE.UNKNOWN } + ]; }; /** @@ -37,19 +37,19 @@ export const LIFECYCLE_FILTER = () => { * @returns {Array} - An array of objects representing the job status filter options. */ export const JOB_STATUS_FILTER = () => { - return [ - {text: JOB_STATUS.FINISHED, value: JOB_STATUS.FINISHED}, - {text: JOB_STATUS.RUNNING, value: JOB_STATUS.RUNNING}, - {text: JOB_STATUS.FAILED, value: JOB_STATUS.FAILED}, - {text: JOB_STATUS.CANCELED, value: JOB_STATUS.CANCELED}, - {text: JOB_STATUS.INITIALIZING, value: JOB_STATUS.INITIALIZING}, - {text: JOB_STATUS.RESTARTING, value: JOB_STATUS.RESTARTING}, - {text: JOB_STATUS.CREATED, value: JOB_STATUS.CREATED}, - {text: JOB_STATUS.FAILING, value: JOB_STATUS.FAILING}, - {text: JOB_STATUS.SUSPENDED, value: JOB_STATUS.SUSPENDED}, - {text: JOB_STATUS.CANCELLING, value: JOB_STATUS.CANCELLING}, - {text: JOB_STATUS.UNKNOWN, value: JOB_STATUS.UNKNOWN} - ]; + return [ + { text: JOB_STATUS.FINISHED, value: JOB_STATUS.FINISHED }, + { text: JOB_STATUS.RUNNING, value: JOB_STATUS.RUNNING }, + { text: JOB_STATUS.FAILED, value: JOB_STATUS.FAILED }, + { text: JOB_STATUS.CANCELED, value: JOB_STATUS.CANCELED }, + { text: JOB_STATUS.INITIALIZING, value: JOB_STATUS.INITIALIZING }, + { text: JOB_STATUS.RESTARTING, value: JOB_STATUS.RESTARTING }, + { text: JOB_STATUS.CREATED, value: JOB_STATUS.CREATED }, + { text: JOB_STATUS.FAILING, value: JOB_STATUS.FAILING }, + { text: JOB_STATUS.SUSPENDED, value: JOB_STATUS.SUSPENDED }, + { text: JOB_STATUS.CANCELLING, value: JOB_STATUS.CANCELLING }, + { text: JOB_STATUS.UNKNOWN, value: JOB_STATUS.UNKNOWN } + ]; }; /** @@ -59,16 +59,16 @@ export const JOB_STATUS_FILTER = () => { * @returns {boolean} - True if the job status indicates that the job is done, false otherwise. */ export function isStatusDone(type: string) { - if (!type) { - return true; - } - switch (type) { - case JOB_STATUS.FAILED: - case JOB_STATUS.CANCELED: - case JOB_STATUS.FINISHED: - case JOB_STATUS.UNKNOWN: - return true; - default: - return false; - } + if (!type) { + return true; + } + switch (type) { + case JOB_STATUS.FAILED: + case JOB_STATUS.CANCELED: + case JOB_STATUS.FINISHED: + case JOB_STATUS.UNKNOWN: + return true; + default: + return false; + } } diff --git a/dinky-web/src/pages/RegCenter/Resource/components/FileShow/index.tsx b/dinky-web/src/pages/RegCenter/Resource/components/FileShow/index.tsx index 0861282c80..d02dee6d79 100644 --- a/dinky-web/src/pages/RegCenter/Resource/components/FileShow/index.tsx +++ b/dinky-web/src/pages/RegCenter/Resource/components/FileShow/index.tsx @@ -49,7 +49,7 @@ const FileShow: React.FC = (props) => { * code show props * @type {{code: string, onChange: (val: string) => void, language: string, showFloatButton: boolean, refreshLogCallback: () => void}} */ - const restCodeShowProps = { + const restCodeShowProps: any = { showFloatButton: true, code, onChange: onChange, diff --git a/dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx b/dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx index c5c80e79a7..bfdc69f0be 100644 --- a/dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx +++ b/dinky-web/src/pages/RegCenter/Resource/components/ResourceOverView/index.tsx @@ -19,7 +19,10 @@ import RightContextMenu from '@/components/RightContextMenu'; import { AuthorizedObject, useAccess } from '@/hooks/useAccess'; -import { RIGHT_CONTEXT_MENU } from '@/pages/RegCenter/Resource/components/constants'; +import { + RIGHT_CONTEXT_FILE_MENU, + RIGHT_CONTEXT_FOLDER_MENU +} from '@/pages/RegCenter/Resource/components/constants'; import FileShow from '@/pages/RegCenter/Resource/components/FileShow'; import FileTree from '@/pages/RegCenter/Resource/components/FileTree'; import ResourceModal from '@/pages/RegCenter/Resource/components/ResourceModal'; @@ -117,6 +120,7 @@ const ResourceOverView: React.FC = () => { if (resourceState.rightClickedNode) { setResourceState((prevState) => ({ ...prevState, contextMenuOpen: false })); await handleRemoveById(API_CONSTANTS.RESOURCE_REMOVE, resourceState.rightClickedNode.id); + await refreshTree(); } }; @@ -162,6 +166,7 @@ const ResourceOverView: React.FC = () => { const handleRightClick = (info: any) => { // 获取右键点击的节点信息 const { node, event } = info; + console.log('node', node); setResourceState((prevState) => ({ ...prevState, selectedKeys: [node.key], @@ -180,6 +185,7 @@ const ResourceOverView: React.FC = () => { */ const handleModalCancel = () => { setResourceState((prevState) => ({ ...prevState, editOpen: false })); + refreshTree(); }; /** @@ -197,8 +203,9 @@ const ResourceOverView: React.FC = () => { await handleOption(API_CONSTANTS.RESOURCE_RENAME, l('right.menu.rename'), { ...value, pid }); } }; - const handleUploadCancel = () => { + const handleUploadCancel = async () => { setResourceState((prevState) => ({ ...prevState, uploadOpen: false })); + await refreshTree(); }; /** @@ -212,6 +219,17 @@ const ResourceOverView: React.FC = () => { const access = useAccess(); + const renderRightMenu = () => { + if (!resourceState.rightClickedNode.isLeaf) { + return RIGHT_CONTEXT_FOLDER_MENU.filter( + (menu) => !!!menu.path || !!AuthorizedObject({ path: menu.path, children: menu, access }) + ); + } + return RIGHT_CONTEXT_FILE_MENU.filter( + (menu) => !!!menu.path || !!AuthorizedObject({ path: menu.path, children: menu, access }) + ); + }; + /** * render */ @@ -239,10 +257,7 @@ const ResourceOverView: React.FC = () => { openChange={() => setResourceState((prevState) => ({ ...prevState, contextMenuOpen: false })) } - items={RIGHT_CONTEXT_MENU().filter( - (menu) => - !!!menu.path || !!AuthorizedObject({ path: menu.path, children: menu, access }) - )} + items={renderRightMenu()} onClick={handleMenuClick} /> diff --git a/dinky-web/src/pages/RegCenter/Resource/components/constants.tsx b/dinky-web/src/pages/RegCenter/Resource/components/constants.tsx index 4cab5a6a85..3878068b46 100644 --- a/dinky-web/src/pages/RegCenter/Resource/components/constants.tsx +++ b/dinky-web/src/pages/RegCenter/Resource/components/constants.tsx @@ -31,33 +31,43 @@ import { * @returns {[{icon: JSX.Element, disabled: boolean, label: string, key: string}, {icon: JSX.Element, disabled: boolean, label: string, key: string}, {icon: JSX.Element, disabled: boolean, label: string, key: string}]} * @constructor */ -export const RIGHT_CONTEXT_MENU = (isDisabled = false) => [ +export const RIGHT_CONTEXT_FILE_MENU = [ + { + key: 'delete', + icon: , + label: l('right.menu.delete'), + path: '/registration/resource/delete' + }, + { + key: 'rename', + icon: , + label: l('right.menu.rename'), + path: '/registration/resource/rename' + } +]; +export const RIGHT_CONTEXT_FOLDER_MENU = [ { key: 'createFolder', icon: , label: l('right.menu.createFolder'), - disabled: isDisabled, path: '/registration/resource/addFolder' }, { key: 'upload', icon: , label: l('button.upload'), - disabled: isDisabled, path: '/registration/resource/upload' }, { key: 'delete', icon: , label: l('right.menu.delete'), - disabled: isDisabled, path: '/registration/resource/delete' }, { key: 'rename', icon: , label: l('right.menu.rename'), - disabled: isDisabled, path: '/registration/resource/rename' } ];