Unverified Commit 3695aaf9 authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Optimization] Optimizing replication types for resource paths (#3443)

parent 280ef090
...@@ -985,7 +985,12 @@ export default { ...@@ -985,7 +985,12 @@ export default {
'Support for a single or bulk upload. Strictly prohibited from uploading company data or\n other banned files.', 'Support for a single or bulk upload. Strictly prohibited from uploading company data or\n other banned files.',
'rc.resource.filelist': 'File list', 'rc.resource.filelist': 'File list',
'rc.resource.sync': 'Sync remote files', 'rc.resource.sync': 'Sync remote files',
'rc.resource.copy': 'Copy as: {fillValue}', 'rc.resource.copy_to_add_custom_jar': 'Copy as ADD CUSTOMJAR syntax',
'rc.resource.copy_to_add_jar': 'Copy as ADD JAR syntax',
'rc.resource.copy_to_add_file': 'Copy as ADD FILE syntax',
'rc.resource.copy_to_add_rs_path': 'Copy RS protocol resource path',
'rc.resource.copy_success':
'Copy successfully, The value is: [{fillValue}] has been copied to the clipboard. Please paste it to the desired location for use',
'rc.resource.enable': 'Resource management function is not enabled', 'rc.resource.enable': 'Resource management function is not enabled',
'rc.resource.enable.tips': 'rc.resource.enable.tips':
'Please go to [Setting Center -> Global Settings -> Resource Configuration] to enable the resource management function!!!', 'Please go to [Setting Center -> Global Settings -> Resource Configuration] to enable the resource management function!!!',
......
...@@ -943,7 +943,12 @@ export default { ...@@ -943,7 +943,12 @@ export default {
'rc.resource.upload.tip2': '支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。', 'rc.resource.upload.tip2': '支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。',
'rc.resource.filelist': '文件列表', 'rc.resource.filelist': '文件列表',
'rc.resource.sync': '同步目录结构', 'rc.resource.sync': '同步目录结构',
'rc.resource.copy': '复制为: {fillValue}', 'rc.resource.copy_to_add_custom_jar': '复制为 ADD CUSTOMJAR 语法',
'rc.resource.copy_to_add_jar': '复制为 ADD JAR 语法',
'rc.resource.copy_to_add_file': '复制为 ADD FILE 语法',
'rc.resource.copy_to_add_rs_path': '复制 RS 协议资源路径',
'rc.resource.copy_success':
'复制成功,值为:[{fillValue}] 已复制到剪贴板。请粘贴到需要的地方进行使用',
'rc.resource.enable': '未启用资源管理功能', 'rc.resource.enable': '未启用资源管理功能',
'rc.resource.enable.tips': '请前往 [配置中心 -> 全局配置 -> Resource 配置] 中启用资源管理功能!!!', 'rc.resource.enable.tips': '请前往 [配置中心 -> 全局配置 -> Resource 配置] 中启用资源管理功能!!!',
......
...@@ -21,22 +21,11 @@ import { TagAlignCenter } from '@/components/StyledComponents'; ...@@ -21,22 +21,11 @@ import { TagAlignCenter } from '@/components/StyledComponents';
import { ResourceInfo } from '@/types/RegCenter/data'; import { ResourceInfo } from '@/types/RegCenter/data';
import { parseByteStr, renderIcon } from '@/utils/function'; import { parseByteStr, renderIcon } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { Typography } from 'antd';
const buildTitleLabel = (showCopy = false, item: ResourceInfo) => {
const fillValue = `ADD FILE 'rs:${item.fullName}';`;
const buildTitleLabel = (item: ResourceInfo) => {
return ( return (
<> <>
{!item.isDirectory && showCopy ? (
<Typography.Text
copyable={{ text: fillValue, tooltips: l('rc.resource.copy', '', { fillValue }) }}
>
{item.fileName} {item.fileName}
</Typography.Text>
) : (
item.fileName
)}
{!item.isDirectory && ( {!item.isDirectory && (
<span style={{ color: 'gray' }}> <span style={{ color: 'gray' }}>
{' '} {' '}
...@@ -92,8 +81,7 @@ function filterEmpty( ...@@ -92,8 +81,7 @@ function filterEmpty(
export const buildResourceTreeData = ( export const buildResourceTreeData = (
data: ResourceInfo[] = [], data: ResourceInfo[] = [],
isFilterEmptyChildren = false, isFilterEmptyChildren = false,
filterSuffixList: string[] = [], filterSuffixList: string[] = []
showCopy: boolean = false
): any => ): any =>
data data
.filter((item: ResourceInfo) => filterEmpty(isFilterEmptyChildren, item, filterSuffixList)) .filter((item: ResourceInfo) => filterEmpty(isFilterEmptyChildren, item, filterSuffixList))
...@@ -105,12 +93,12 @@ export const buildResourceTreeData = ( ...@@ -105,12 +93,12 @@ export const buildResourceTreeData = (
label: item.fileName, label: item.fileName,
icon: <TagAlignCenter>{renderIcon(item.fileName, '.', item.isDirectory)}</TagAlignCenter>, icon: <TagAlignCenter>{renderIcon(item.fileName, '.', item.isDirectory)}</TagAlignCenter>,
path: item.fullName, path: item.fullName,
title: buildTitleLabel(showCopy, item), title: buildTitleLabel(item),
fullInfo: item, fullInfo: item,
key: item.id, key: item.id,
id: item.id, id: item.id,
children: children:
item.children && item.children &&
buildResourceTreeData(item.children, isFilterEmptyChildren, filterSuffixList, showCopy) buildResourceTreeData(item.children, isFilterEmptyChildren, filterSuffixList)
}; };
}); });
...@@ -50,7 +50,7 @@ const FileTree: React.FC<FileTreeProps> = (props) => { ...@@ -50,7 +50,7 @@ const FileTree: React.FC<FileTreeProps> = (props) => {
selectedKeys={selectedKeys} selectedKeys={selectedKeys}
onSelect={(_, info) => onNodeClick(info)} onSelect={(_, info) => onNodeClick(info)}
onRightClick={(info) => onRightClick(info)} onRightClick={(info) => onRightClick(info)}
treeData={buildResourceTreeData(treeData, false, [], true)} treeData={buildResourceTreeData(treeData, false, [])}
/> />
) : ( ) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import RightContextMenu from '@/components/RightContextMenu'; import RightContextMenu from '@/components/RightContextMenu';
import { AuthorizedObject, useAccess } from '@/hooks/useAccess'; import { AuthorizedObject, useAccess } from '@/hooks/useAccess';
import { import {
ResourceRightMenuKey,
RIGHT_CONTEXT_FILE_MENU, RIGHT_CONTEXT_FILE_MENU,
RIGHT_CONTEXT_FOLDER_MENU RIGHT_CONTEXT_FOLDER_MENU
} from '@/pages/RegCenter/Resource/components/constants'; } from '@/pages/RegCenter/Resource/components/constants';
...@@ -41,6 +42,7 @@ import { InitResourceState } from '@/types/RegCenter/init.d'; ...@@ -41,6 +42,7 @@ import { InitResourceState } from '@/types/RegCenter/init.d';
import { ResourceState } from '@/types/RegCenter/state.d'; import { ResourceState } from '@/types/RegCenter/state.d';
import { unSupportView } from '@/utils/function'; import { unSupportView } from '@/utils/function';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { SuccessMessage } from '@/utils/messages';
import { SplitPane } from '@andrewray/react-multi-split-pane'; import { SplitPane } from '@andrewray/react-multi-split-pane';
import { Pane } from '@andrewray/react-multi-split-pane/dist/lib/Pane'; import { Pane } from '@andrewray/react-multi-split-pane/dist/lib/Pane';
import { WarningOutlined } from '@ant-design/icons'; import { WarningOutlined } from '@ant-design/icons';
...@@ -119,7 +121,7 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -119,7 +121,7 @@ const ResourceOverView: React.FC<connect> = (props) => {
*/ */
const handleCreateFolder = () => { const handleCreateFolder = () => {
if (resourceState.rightClickedNode) { if (resourceState.rightClickedNode) {
setEditModal('createFolder'); setEditModal(ResourceRightMenuKey.CREATE_FOLDER);
const { id } = resourceState.rightClickedNode; const { id } = resourceState.rightClickedNode;
setResourceState((prevState) => ({ setResourceState((prevState) => ({
...prevState, ...prevState,
...@@ -153,7 +155,7 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -153,7 +155,7 @@ const ResourceOverView: React.FC<connect> = (props) => {
*/ */
const handleRename = () => { const handleRename = () => {
if (resourceState.rightClickedNode) { if (resourceState.rightClickedNode) {
setEditModal('rename'); setEditModal(ResourceRightMenuKey.RENAME);
const { id, name, desc } = resourceState.rightClickedNode; const { id, name, desc } = resourceState.rightClickedNode;
setResourceState((prevState) => ({ setResourceState((prevState) => ({
...prevState, ...prevState,
...@@ -164,20 +166,50 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -164,20 +166,50 @@ const ResourceOverView: React.FC<connect> = (props) => {
} }
}; };
async function handleCopyTo(fillValue: string) {
await navigator.clipboard.writeText(fillValue);
await SuccessMessage(l('rc.resource.copy_success', '', { fillValue }));
}
const handleMenuClick = async (node: MenuInfo) => { const handleMenuClick = async (node: MenuInfo) => {
const { fullInfo } = resourceState.rightClickedNode;
switch (node.key) { switch (node.key) {
case 'createFolder': case ResourceRightMenuKey.CREATE_FOLDER:
handleCreateFolder(); handleCreateFolder();
break; break;
case 'upload': case ResourceRightMenuKey.UPLOAD:
handleUpload(); handleUpload();
break; break;
case 'delete': case ResourceRightMenuKey.DELETE:
await handleDelete(); await handleDelete();
break; break;
case 'rename': case ResourceRightMenuKey.RENAME:
handleRename(); handleRename();
break; break;
case ResourceRightMenuKey.COPY_TO_ADD_CUSTOM_JAR:
if (fullInfo) {
const fillValue = `ADD CUSTOMJAR 'rs:${fullInfo.fullName}';`;
await handleCopyTo(fillValue);
}
break;
case ResourceRightMenuKey.COPY_TO_ADD_JAR:
if (fullInfo) {
const fillValue = `ADD JAR 'rs:${fullInfo.fullName}';`;
await handleCopyTo(fillValue);
}
break;
case ResourceRightMenuKey.COPY_TO_ADD_FILE:
if (fullInfo) {
const fillValue = `ADD FILE 'rs:${fullInfo.fullName}';`;
await handleCopyTo(fillValue);
}
break;
case ResourceRightMenuKey.COPY_TO_ADD_RS_PATH:
if (fullInfo) {
const fillValue = `rs:${fullInfo.fullName}`;
await handleCopyTo(fillValue);
}
break;
default: default:
break; break;
} }
...@@ -188,10 +220,10 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -188,10 +220,10 @@ const ResourceOverView: React.FC<connect> = (props) => {
* @param info * @param info
*/ */
const handleRightClick = (info: any) => { const handleRightClick = (info: any) => {
// 获取右键点击的节点信息 // Obtain the node information for right-click
const { node, event } = info; const { node, event } = info;
// 判断右键的位置是否超出屏幕 , 如果超出屏幕则设置为屏幕的最大值 往上偏移 75 (需要根据具体的右键菜单数量合理设置) // Determine if the position of the right button exceeds the screen. If it exceeds the screen, set it to the maximum value of the screen offset upwards by 75 (it needs to be reasonably set according to the specific number of right button menus)
if (event.clientY + 150 > window.innerHeight) { if (event.clientY + 150 > window.innerHeight) {
event.clientY = window.innerHeight - 75; event.clientY = window.innerHeight - 75;
} }
...@@ -229,7 +261,7 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -229,7 +261,7 @@ const ResourceOverView: React.FC<connect> = (props) => {
*/ */
const handleModalSubmit = async (value: Partial<ResourceInfo>) => { const handleModalSubmit = async (value: Partial<ResourceInfo>) => {
const { id: pid } = resourceState.rightClickedNode; const { id: pid } = resourceState.rightClickedNode;
if (editModal === 'createFolder') { if (editModal === ResourceRightMenuKey.CREATE_FOLDER) {
await handleOption( await handleOption(
API_CONSTANTS.RESOURCE_CREATE_FOLDER, API_CONSTANTS.RESOURCE_CREATE_FOLDER,
l('right.menu.createFolder'), l('right.menu.createFolder'),
...@@ -239,7 +271,7 @@ const ResourceOverView: React.FC<connect> = (props) => { ...@@ -239,7 +271,7 @@ const ResourceOverView: React.FC<connect> = (props) => {
}, },
() => handleModalCancel() () => handleModalCancel()
); );
} else if (editModal === 'rename') { } else if (editModal === ResourceRightMenuKey.RENAME) {
await handleOption( await handleOption(
API_CONSTANTS.RESOURCE_RENAME, API_CONSTANTS.RESOURCE_RENAME,
l('right.menu.rename'), l('right.menu.rename'),
......
...@@ -20,12 +20,24 @@ ...@@ -20,12 +20,24 @@
import { PermissionConstants } from '@/types/Public/constants'; import { PermissionConstants } from '@/types/Public/constants';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { import {
CopyOutlined,
DeleteOutlined, DeleteOutlined,
EditOutlined, EditOutlined,
PlusCircleOutlined, PlusCircleOutlined,
UploadOutlined UploadOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
export enum ResourceRightMenuKey {
COPY_TO_ADD_CUSTOM_JAR = 'copy_to_add_custom_jar',
COPY_TO_ADD_JAR = 'copy_to_add_jar',
COPY_TO_ADD_FILE = 'copy_to_add_file',
COPY_TO_ADD_RS_PATH = 'copy_to_add_rs_path',
DELETE = 'delete',
RENAME = 'rename',
CREATE_FOLDER = 'createFolder',
UPLOAD = 'upload'
}
/** /**
* the right context menu * the right context menu
* @param {boolean} isDisabled - is disabled or not , if disabled , the menu will be disabled too * @param {boolean} isDisabled - is disabled or not , if disabled , the menu will be disabled too
...@@ -34,13 +46,37 @@ import { ...@@ -34,13 +46,37 @@ import {
*/ */
export const RIGHT_CONTEXT_FILE_MENU = [ export const RIGHT_CONTEXT_FILE_MENU = [
{ {
key: 'delete', key: ResourceRightMenuKey.COPY_TO_ADD_CUSTOM_JAR,
icon: <CopyOutlined />,
label: l('rc.resource.copy_to_add_custom_jar'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
},
{
key: ResourceRightMenuKey.COPY_TO_ADD_JAR,
icon: <CopyOutlined />,
label: l('rc.resource.copy_to_add_jar'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
},
{
key: ResourceRightMenuKey.COPY_TO_ADD_FILE,
icon: <CopyOutlined />,
label: l('rc.resource.copy_to_add_file'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
},
{
key: ResourceRightMenuKey.COPY_TO_ADD_RS_PATH,
icon: <CopyOutlined />,
label: l('rc.resource.copy_to_add_rs_path'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
},
{
key: ResourceRightMenuKey.DELETE,
icon: <DeleteOutlined />, icon: <DeleteOutlined />,
label: l('right.menu.delete'), label: l('right.menu.delete'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
}, },
{ {
key: 'rename', key: ResourceRightMenuKey.RENAME,
icon: <EditOutlined />, icon: <EditOutlined />,
label: l('right.menu.rename'), label: l('right.menu.rename'),
path: PermissionConstants.REGISTRATION_RESOURCE_RENAME path: PermissionConstants.REGISTRATION_RESOURCE_RENAME
...@@ -48,25 +84,25 @@ export const RIGHT_CONTEXT_FILE_MENU = [ ...@@ -48,25 +84,25 @@ export const RIGHT_CONTEXT_FILE_MENU = [
]; ];
export const RIGHT_CONTEXT_FOLDER_MENU = [ export const RIGHT_CONTEXT_FOLDER_MENU = [
{ {
key: 'createFolder', key: ResourceRightMenuKey.CREATE_FOLDER,
icon: <PlusCircleOutlined />, icon: <PlusCircleOutlined />,
label: l('right.menu.createFolder'), label: l('right.menu.createFolder'),
path: PermissionConstants.REGISTRATION_RESOURCE_ADD_FOLDER path: PermissionConstants.REGISTRATION_RESOURCE_ADD_FOLDER
}, },
{ {
key: 'upload', key: ResourceRightMenuKey.UPLOAD,
icon: <UploadOutlined />, icon: <UploadOutlined />,
label: l('button.upload'), label: l('button.upload'),
path: PermissionConstants.REGISTRATION_RESOURCE_UPLOAD path: PermissionConstants.REGISTRATION_RESOURCE_UPLOAD
}, },
{ {
key: 'delete', key: ResourceRightMenuKey.DELETE,
icon: <DeleteOutlined />, icon: <DeleteOutlined />,
label: l('right.menu.delete'), label: l('right.menu.delete'),
path: PermissionConstants.REGISTRATION_RESOURCE_DELETE path: PermissionConstants.REGISTRATION_RESOURCE_DELETE
}, },
{ {
key: 'rename', key: ResourceRightMenuKey.RENAME,
icon: <EditOutlined />, icon: <EditOutlined />,
label: l('right.menu.rename'), label: l('right.menu.rename'),
path: PermissionConstants.REGISTRATION_RESOURCE_RENAME path: PermissionConstants.REGISTRATION_RESOURCE_RENAME
......
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