Commit ed86c059 by zhaochengxiang

资产权限

parent e3f1510c
......@@ -4,7 +4,7 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';
import MetadataInfo from './MetadataInfo';
import { dispatch } from '../../../../model';
import { highlightSearchContentByTerms, showMessage } from '../../../../util';
import { highlightSearchContentByTerms, showMessage, getAssetRange } from '../../../../util';
import { AppContext } from '../../../../App';
import Tag from '../../Tag';
import Separate from './Separate';
......@@ -15,7 +15,7 @@ import PermissionButton from '../../../../util/Component/PermissionButton';
import { CancelSvg, EditSvg, SaveSvg, FullScreenSvg, CancelFullScreenSvg } from './AssetSvg';
const AssetAction = (props) => {
const { id, dirId, action, terms, onChange, readOnly = false, form, onMetadataChange, onElementsChange } = props;
const { id, dirId, action, terms, onChange, readOnly = false, form, onMetadataChange, onElementsChange, reference } = props;
const [ currentAction, setCurrentAction ] = useState(action);
const [ assetParams, setAssetParams ] = useState({ assets: {}, attributes: [], attributesFoldMap: {} });
......@@ -131,6 +131,7 @@ const AssetAction = (props) => {
dispatch({
type: 'assetmanage.getDataAssetDetail',
payload: {
range: getAssetRange(reference),
dataAssetId: id,
dirId: dirId,
checkPermission: readOnly
......
......@@ -4,7 +4,7 @@ import { Drawer, Form } from 'antd';
import AssetAction from './AssetAction';
const AssetDetailDrawer = (props) => {
const { onCancel, visible, id, dirId } = props;
const { onCancel, visible, id, dirId, reference } = props;
const [ form ] = Form.useForm();
......@@ -21,7 +21,7 @@ const AssetDetailDrawer = (props) => {
}}
>
{
visible && <AssetAction form={form} id={id} dirId={dirId} action='detail' readOnly />
visible && <AssetAction form={form} id={id} dirId={dirId} action='detail' reference={reference} readOnly />
}
</Drawer>
)
......
......@@ -1161,6 +1161,7 @@ const AssetTable = (props) => {
<AssetDetailDrawer
id={selectItem?.id}
dirId={selectItem?.dirId}
reference={reference}
visible={assetDetailDrawerVisible}
onCancel={onAssetDetailDrawerCancel}
/>
......
import React, { useEffect, useState, useRef } from 'react';
import React, { useEffect, useState, useRef, useMemo } from 'react';
import {Card, Spin, Tooltip, Tree, Modal, AutoComplete} from 'antd';
import { ReloadOutlined, SettingOutlined } from '@ant-design/icons';
import { useContextMenu, Menu as RcMenu, Item as RcItem } from "react-contexify";
import { dispatch } from '../../../../model';
import CustomDirectoryModal from './CustomDirectoryModal';
import { showMessage, getQueryParam } from '../../../../util';
import { showMessage, getQueryParam, getAssetRange } from '../../../../util';
import { AnchorTimestamp, AnchorId, AssetBrowseReference, ResourceBrowseReference, AnchorDirId } from '../../../../util/constant';
import { highlightSearchContentByTerms } from '../../../../util';
import PermissionRcItem from '../../../../util/Component/PermissionRcItem';
import './AssetTree.less';
import 'react-contexify/dist/ReactContexify.css';
......@@ -52,6 +53,7 @@ const AssetTree = (props) => {
const [ customDirectoryAction, setCustomDirectoryAction ] = useState('');
const [options, setOptions] = useState([]);
const [ loadedKeys, setLoadedKeys ] = useState([]);
const [ permissions, setPermissions ] = useState([]);
const [modal, contextHolder] = Modal.useModal();
......@@ -63,12 +65,12 @@ const AssetTree = (props) => {
const dataListRef = useRef([]);
useEffect(() => {
window?.addEventListener("storage", storageChange);
getPermissions();
window?.addEventListener("storage", storageChange);
return () => {
window?.removeEventListener("storage", storageChange);
}
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
......@@ -97,6 +99,10 @@ const AssetTree = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps
}, [centerId])
const haveCustomPermission = useMemo(() => {
return (permissions||[]).findIndex(item => item === 'customDirectory') !== -1
}, [permissions])
const storageChange = (e) => {
if (e.key === 'assetDirChangeEvent') {
if ((e.dirId||'') !== '') {
......@@ -107,6 +113,18 @@ const AssetTree = (props) => {
}
}
const getPermissions = () => {
dispatch({
type: 'assetmanage.getPrivilegeByRange',
payload: {
range: getAssetRange(reference),
},
callback: data => {
setPermissions(data);
}
});
}
const getDataAssetLocationThenGetTreeData = () => {
setLoading(true);
dispatch({
......@@ -392,6 +410,8 @@ const AssetTree = (props) => {
}
const customDir = () => {
if (!haveCustomPermission) return;
setCustomDirectoryAction('add');
setCustomDirectoryModalVisible(true);
}
......@@ -518,8 +538,8 @@ const AssetTree = (props) => {
<Tooltip title="刷新目录">
<ReloadOutlined className='default' onClick={refreshTree} style={{ fontSize:16,cursor:'pointer',flex:1}} />
</Tooltip>
<Tooltip title="自定义目录">
<SettingOutlined className='default' onClick={customDir} style={{ fontSize:16,cursor:'pointer',flex:1}} />
<Tooltip title={haveCustomPermission?"自定义目录":"暂无权限"}>
<SettingOutlined className={(!haveCustomPermission)?'disable': 'default'} onClick={customDir} style={{ fontSize:16,cursor:(!haveCustomPermission)?'not-allowed':'pointer',flex:1}} />
</Tooltip>
<div style={{ flex: 3 }}></div>
</div>
......@@ -581,19 +601,31 @@ const AssetTree = (props) => {
{
<RcMenu id={MENU_ID}>
{
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <RcItem id="up" onClick={() => { moveNode(1); }}>
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <PermissionRcItem
id="up"
onClick={() => { moveNode(1); }}
defaultPermission={haveCustomPermission}
>
上移目录
</RcItem>
</PermissionRcItem>
}
{
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <RcItem id="up" onClick={() => { moveNode(-1); }}>
currentRightClickDir && currentRightClickDir.level>1 && currentRightClickDir.type==='custom' && <PermissionRcItem
id="up"
onClick={() => { moveNode(-1); }}
defaultPermission={haveCustomPermission}
>
下移目录
</RcItem>
</PermissionRcItem>
}
{
currentRightClickDir && currentRightClickDir.level===2 && currentRightClickDir.type==='custom' && !currentRightClickDir.adminCreate && <RcItem id="up" onClick={deleteDir}>
currentRightClickDir && currentRightClickDir.level===2 && currentRightClickDir.type==='custom' && !currentRightClickDir.adminCreate && <PermissionRcItem
id="up"
onClick={deleteDir}
defaultPermission={haveCustomPermission}
>
删除目录
</RcItem>
</PermissionRcItem>
}
</RcMenu>
}
......
......@@ -98,7 +98,7 @@ const AssetManage = (props) => {
</div>
<Separate width='15px' />
<div className='right'>
<AssetAction form={form} id={assetId} dirId={assetDirId} action='detail' onChange={onAssetActionChange} />
<AssetAction form={form} id={assetId} dirId={assetDirId} action='detail' reference={AssetManageReference} onChange={onAssetActionChange} />
</div>
</div>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment