From 22624f127ae6013afc32d8163acd9526b0a4a113 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 3 Nov 2023 15:24:38 +0800 Subject: [PATCH] =?UTF-8?q?(*)=20=E4=B8=9A=E5=8A=A1=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=AE=A1=E7=90=86=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/businessDatabaseModal.js | 5 +++-- .../containers/businessDatabaseTable.js | 11 ++++++----- .../containers/businessFilesTable.js | 11 ++++++----- .../metadataManagement/containers/businessMetadata.js | 11 +++++++++-- .../containers/businessRestapisTable.js | 11 ++++++----- .../metadataManagement/containers/businessTab.js | 8 ++++---- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js b/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js index 376f38f..07af42f 100644 --- a/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js +++ b/web/client/src/sections/metadataManagement/components/businessDatabaseModal.js @@ -6,7 +6,7 @@ const basicInfo = [{ name: '元数据名称:', key: 'name' }, { name: '上下文路径:', key: 'path' }, { name: '元数据详情:', key: 'description' }]; const BusinessDatabaseModal = (props) => { - const { onConfirm, onCancel, editData, metadataModels, resourceCatalogPath, businessType } = props; + const { onConfirm, onCancel, editData, metadataModels, resourceCatalogPath, businessType, isAdmin } = props; const [form] = Form.useForm(); useEffect(() => { }, []); @@ -66,6 +66,7 @@ const BusinessDatabaseModal = (props) => { return ( handleOk(null)} onCancel={onCancel}> {editData.record && editData.record.businessMetadata.length ? @@ -87,7 +88,7 @@ const BusinessDatabaseModal = (props) => { ({ getFieldValue, validateFields }) => ({ validator(_, value) { return validatorNull(_, value, getFieldValue, validateFields, item.name) } })]}> - + )} diff --git a/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js b/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js index f9de168..17ccef9 100644 --- a/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessDatabaseTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessDatabaseTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -201,13 +201,13 @@ const BusinessDatabaseTable = (props) => { if (record.businessMetadataDatabases.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataDatabases[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -329,7 +329,8 @@ const BusinessDatabaseTable = (props) => { editData={editData} onCancel={() => setModalVisible(false)} onConfirm={onConfirm} - resourceCatalogPath={resourceCatalogPath} /> : '' + resourceCatalogPath={resourceCatalogPath} + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessFilesTable.js b/web/client/src/sections/metadataManagement/containers/businessFilesTable.js index 49e91bb..bc18f9d 100644 --- a/web/client/src/sections/metadataManagement/containers/businessFilesTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessFilesTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessFilesTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -190,13 +190,13 @@ const BusinessFilesTable = (props) => { if (record.businessMetadataFiles.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataFiles[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -317,7 +317,8 @@ const BusinessFilesTable = (props) => { onCancel={() => setModalVisible(false)} onConfirm={onConfirm} resourceCatalogPath={resourceCatalogPath} - businessType='文件' /> : '' + businessType='文件' + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessMetadata.js b/web/client/src/sections/metadataManagement/containers/businessMetadata.js index 23e115d..67be5d6 100644 --- a/web/client/src/sections/metadataManagement/containers/businessMetadata.js +++ b/web/client/src/sections/metadataManagement/containers/businessMetadata.js @@ -4,10 +4,12 @@ import { Spin, Row, Col, Tree, Tooltip, Input } from 'antd'; import BusinessTab from './businessTab'; let expandedKeysData = []; let allTreeNodeKeys = []; +let resourceCatalogRawData = []; const BusinessMetadata = (props) => { const { user, dispatch, actions, clientHeight, isRequesting, resourceCatalog } = props; const { metadataManagement } = actions; + const [isAdmin, setIsAdmin] = useState(false); const [resourceCatalogData, setResourceCatalogData] = useState([]); const [selectedKeys, setSelectedKeys] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]); @@ -23,6 +25,7 @@ const BusinessMetadata = (props) => { dispatch(metadataManagement.getResourceCatalog()).then(res => { const { data } = res.payload; if (res.success) { + resourceCatalogRawData = data; allTreeNodeKeys = [] const resourceCatalogData = getTreeNodeData(data, null, 'rc', [], null); setResourceCatalogData(resourceCatalogData); @@ -44,7 +47,10 @@ const BusinessMetadata = (props) => { const keyArr = selectedData[0].split('-'); keyArr.shift();//['rc-2-5']->返回'rc';keyArr:['2','5'] const allExpandedKeys = allTreeNodeKeys.filter(k => keyArr.includes(k.id.toString())); - setResourceCatalogId(keyArr.pop()); + const resourceCatalogId = keyArr.pop(); + setResourceCatalogId(resourceCatalogId); + setIsAdmin(user?.username === 'SuperAdmin' + || (user?.role === '系统管理员' && user?.orgId == resourceCatalogRawData.find(a => a.id == resourceCatalogId)?.orgId)); setResourceCatalogKey(selectedData[0]); const resourceCatalogPath = allExpandedKeys.map(a => a.name); setResourceCatalogPath(resourceCatalogPath); @@ -161,7 +167,8 @@ const BusinessMetadata = (props) => { + resourceCatalogPath={resourceCatalogPath} + isAdmin={isAdmin} /> diff --git a/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js b/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js index 7c79801..0c8e8c6 100644 --- a/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js +++ b/web/client/src/sections/metadataManagement/containers/businessRestapisTable.js @@ -6,7 +6,7 @@ import FileSaver from 'file-saver'; import BusinessDatabaseModal from '../components/businessDatabaseModal'; const BusinessFilesTable = (props) => { const { user, dispatch, actions, clientHeight, resourceCatalogId, - resourceCatalogPath, isRequesting, metadataModels } = props; + resourceCatalogPath, isRequesting, metadataModels, isAdmin } = props; const { metadataManagement } = actions; const SortValues = { 'ascend': 'asc', 'descend': 'desc' }; const [tableData, setTableData] = useState([]); @@ -190,13 +190,13 @@ const BusinessFilesTable = (props) => { if (record.businessMetadataRestapis.length) { return
onAdd(record, false)}>查看 - confirmDelete(record.businessMetadataRestapis[0].id)} - > 删除 + > 删除}
} else - return onAdd(record, true)}>新建 + return isAdmin && onAdd(record, true)}>新建 } }]; @@ -317,7 +317,8 @@ const BusinessFilesTable = (props) => { onCancel={() => setModalVisible(false)} onConfirm={onConfirm} resourceCatalogPath={resourceCatalogPath} - businessType='接口' /> : '' + businessType='接口' + isAdmin={isAdmin} /> : '' } } diff --git a/web/client/src/sections/metadataManagement/containers/businessTab.js b/web/client/src/sections/metadataManagement/containers/businessTab.js index 2fcda8f..cfca376 100644 --- a/web/client/src/sections/metadataManagement/containers/businessTab.js +++ b/web/client/src/sections/metadataManagement/containers/businessTab.js @@ -6,7 +6,7 @@ import BusinessFilesTable from './businessFilesTable'; import BusinessRestapisTable from './businessRestapisTable'; const BusinessTab = (props) => { - const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch } = props; + const { resourceCatalogId, resourceCatalogKey, resourceCatalogPath, actions, dispatch, isAdmin } = props; const [activeKey, setActiveKey] = useState('databases'); useEffect(() => { setActiveKey('databases'); @@ -36,11 +36,11 @@ const BusinessTab = (props) => { { activeKey === 'databases' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : activeKey === 'files' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : activeKey === 'restapis' && resourceCatalogId ? : + resourceCatalogKey={resourceCatalogKey} resourceCatalogPath={resourceCatalogPath} isAdmin={isAdmin} /> : null }