|
@@ -34,6 +34,7 @@ import {
|
|
|
inTrash
|
|
inTrash
|
|
|
} from '../../../../utils/storageBrowserUtils';
|
|
} from '../../../../utils/storageBrowserUtils';
|
|
|
import { SUPPORTED_COMPRESSED_FILE_EXTENTION } from '../../../../utils/constants/storageBrowser';
|
|
import { SUPPORTED_COMPRESSED_FILE_EXTENTION } from '../../../../utils/constants/storageBrowser';
|
|
|
|
|
+import { TFunction } from 'i18next';
|
|
|
|
|
|
|
|
export enum ActionType {
|
|
export enum ActionType {
|
|
|
Copy = 'copy',
|
|
Copy = 'copy',
|
|
@@ -45,7 +46,8 @@ export enum ActionType {
|
|
|
Compress = 'compress',
|
|
Compress = 'compress',
|
|
|
Extract = 'extract',
|
|
Extract = 'extract',
|
|
|
Download = 'download',
|
|
Download = 'download',
|
|
|
- ChangeOwnerAndGroup = 'changeOwnerAndGroup'
|
|
|
|
|
|
|
+ ChangeOwnerAndGroup = 'changeOwnerAndGroup',
|
|
|
|
|
+ ChangePermission = 'changePermission'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const isValidFileOrFolder = (filePath: string): boolean => {
|
|
const isValidFileOrFolder = (filePath: string): boolean => {
|
|
@@ -73,6 +75,8 @@ const isActionEnabled = (file: StorageDirectoryTableData, action: ActionType): b
|
|
|
case ActionType.Copy:
|
|
case ActionType.Copy:
|
|
|
case ActionType.Delete:
|
|
case ActionType.Delete:
|
|
|
case ActionType.Move:
|
|
case ActionType.Move:
|
|
|
|
|
+ case ActionType.ChangeOwnerAndGroup:
|
|
|
|
|
+ case ActionType.ChangePermission:
|
|
|
return isValidFileOrFolder(file.path);
|
|
return isValidFileOrFolder(file.path);
|
|
|
case ActionType.Extract:
|
|
case ActionType.Extract:
|
|
|
return (
|
|
return (
|
|
@@ -84,8 +88,6 @@ const isActionEnabled = (file: StorageDirectoryTableData, action: ActionType): b
|
|
|
return !!config?.enable_extract_uploaded_archive && isHDFS(file.path);
|
|
return !!config?.enable_extract_uploaded_archive && isHDFS(file.path);
|
|
|
case ActionType.Download:
|
|
case ActionType.Download:
|
|
|
return !!config?.enable_file_download_button && file.type === BrowserViewType.file;
|
|
return !!config?.enable_file_download_button && file.type === BrowserViewType.file;
|
|
|
- case ActionType.ChangeOwnerAndGroup:
|
|
|
|
|
- return isValidFileOrFolder(file.path);
|
|
|
|
|
default:
|
|
default:
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -106,6 +108,7 @@ const isMultipleFileActionEnabled = (
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const getEnabledActions = (
|
|
export const getEnabledActions = (
|
|
|
|
|
+ t: TFunction,
|
|
|
files: StorageDirectoryTableData[],
|
|
files: StorageDirectoryTableData[],
|
|
|
isFsSuperUser?: boolean
|
|
isFsSuperUser?: boolean
|
|
|
): {
|
|
): {
|
|
@@ -122,55 +125,60 @@ export const getEnabledActions = (
|
|
|
// order of the elements will be the order of the action menu
|
|
// order of the elements will be the order of the action menu
|
|
|
const actions = [
|
|
const actions = [
|
|
|
{
|
|
{
|
|
|
- enabled: isMultipleFileActionEnabled(files, ActionType.Copy),
|
|
|
|
|
- type: ActionType.Copy,
|
|
|
|
|
- label: 'Copy'
|
|
|
|
|
|
|
+ enabled: isSingleFileActionEnabled(files, ActionType.Rename),
|
|
|
|
|
+ type: ActionType.Rename,
|
|
|
|
|
+ label: t('Rename')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
enabled: isMultipleFileActionEnabled(files, ActionType.Move),
|
|
enabled: isMultipleFileActionEnabled(files, ActionType.Move),
|
|
|
type: ActionType.Move,
|
|
type: ActionType.Move,
|
|
|
- label: 'Move'
|
|
|
|
|
|
|
+ label: t('Move')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- enabled: isSingleFileActionEnabled(files, ActionType.Summary),
|
|
|
|
|
- type: ActionType.Summary,
|
|
|
|
|
- label: 'View Summary'
|
|
|
|
|
|
|
+ enabled: isMultipleFileActionEnabled(files, ActionType.Copy),
|
|
|
|
|
+ type: ActionType.Copy,
|
|
|
|
|
+ label: t('Copy')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- enabled: isSingleFileActionEnabled(files, ActionType.Rename),
|
|
|
|
|
- type: ActionType.Rename,
|
|
|
|
|
- label: 'Rename'
|
|
|
|
|
|
|
+ enabled: isSingleFileActionEnabled(files, ActionType.Download),
|
|
|
|
|
+ type: ActionType.Download,
|
|
|
|
|
+ label: t('Download')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- enabled: isMultipleFileActionEnabled(files, ActionType.Delete),
|
|
|
|
|
- type: ActionType.Delete,
|
|
|
|
|
- label: 'Delete'
|
|
|
|
|
|
|
+ enabled:
|
|
|
|
|
+ !!isFsSuperUser && isMultipleFileActionEnabled(files, ActionType.ChangeOwnerAndGroup),
|
|
|
|
|
+ type: ActionType.ChangeOwnerAndGroup,
|
|
|
|
|
+ label: t('Change Owner / Group')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ enabled: !!isFsSuperUser && isMultipleFileActionEnabled(files, ActionType.ChangePermission),
|
|
|
|
|
+ type: ActionType.ChangePermission,
|
|
|
|
|
+ label: t('Change Permission')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ enabled: isSingleFileActionEnabled(files, ActionType.Summary),
|
|
|
|
|
+ type: ActionType.Summary,
|
|
|
|
|
+ label: t('Summary')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
enabled: isSingleFileActionEnabled(files, ActionType.Replication),
|
|
enabled: isSingleFileActionEnabled(files, ActionType.Replication),
|
|
|
type: ActionType.Replication,
|
|
type: ActionType.Replication,
|
|
|
- label: 'Set Replication'
|
|
|
|
|
|
|
+ label: t('Set Replication')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ enabled: isMultipleFileActionEnabled(files, ActionType.Delete),
|
|
|
|
|
+ type: ActionType.Delete,
|
|
|
|
|
+ label: t('Delete')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
enabled: isMultipleFileActionEnabled(files, ActionType.Compress),
|
|
enabled: isMultipleFileActionEnabled(files, ActionType.Compress),
|
|
|
type: ActionType.Compress,
|
|
type: ActionType.Compress,
|
|
|
- label: 'Compress'
|
|
|
|
|
|
|
+ label: t('Compress')
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
enabled: isSingleFileActionEnabled(files, ActionType.Extract),
|
|
enabled: isSingleFileActionEnabled(files, ActionType.Extract),
|
|
|
type: ActionType.Extract,
|
|
type: ActionType.Extract,
|
|
|
- label: 'Extract'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- enabled: isSingleFileActionEnabled(files, ActionType.Download),
|
|
|
|
|
- type: ActionType.Download,
|
|
|
|
|
- label: 'Download'
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- enabled:
|
|
|
|
|
- !!isFsSuperUser && isMultipleFileActionEnabled(files, ActionType.ChangeOwnerAndGroup),
|
|
|
|
|
- type: ActionType.ChangeOwnerAndGroup,
|
|
|
|
|
- label: 'Change Owner / Group'
|
|
|
|
|
|
|
+ label: t('Extract')
|
|
|
}
|
|
}
|
|
|
].filter(e => e.enabled);
|
|
].filter(e => e.enabled);
|
|
|
|
|
|