|
@@ -32,10 +32,10 @@ import DownloadIcon from '@cloudera/cuix-core/icons/react/DownloadIcon';
|
|
|
import GroupsIcon from '@cloudera/cuix-core/icons/react/GroupsIcon';
|
|
import GroupsIcon from '@cloudera/cuix-core/icons/react/GroupsIcon';
|
|
|
import ConfigureIcon from '@cloudera/cuix-core/icons/react/ConfigureIcon';
|
|
import ConfigureIcon from '@cloudera/cuix-core/icons/react/ConfigureIcon';
|
|
|
|
|
|
|
|
-import { i18nReact } from '../../../../utils/i18nReact';
|
|
|
|
|
-import huePubSub from '../../../../utils/huePubSub';
|
|
|
|
|
|
|
+import { i18nReact } from '../../../../../utils/i18nReact';
|
|
|
|
|
+import huePubSub from '../../../../../utils/huePubSub';
|
|
|
import './StorageBrowserActions.scss';
|
|
import './StorageBrowserActions.scss';
|
|
|
-import { FileStats, FileSystem, StorageDirectoryTableData } from '../../types';
|
|
|
|
|
|
|
+import { FileStats, FileSystem, StorageDirectoryTableData } from '../../../types';
|
|
|
import { ActionType, getEnabledActions } from './StorageBrowserActions.util';
|
|
import { ActionType, getEnabledActions } from './StorageBrowserActions.util';
|
|
|
import MoveCopyModal from './MoveCopyModal/MoveCopyModal';
|
|
import MoveCopyModal from './MoveCopyModal/MoveCopyModal';
|
|
|
import RenameModal from './RenameModal/RenameModal';
|
|
import RenameModal from './RenameModal/RenameModal';
|
|
@@ -44,7 +44,7 @@ import SummaryModal from './SummaryModal/SummaryModal';
|
|
|
import DeletionModal from './DeletionModal/DeletionModal';
|
|
import DeletionModal from './DeletionModal/DeletionModal';
|
|
|
import CompressionModal from './CompressionModal/CompressionModal';
|
|
import CompressionModal from './CompressionModal/CompressionModal';
|
|
|
import ExtractionModal from './ExtractionModal/ExtractionModal';
|
|
import ExtractionModal from './ExtractionModal/ExtractionModal';
|
|
|
-import { DOWNLOAD_API_URL } from '../../api';
|
|
|
|
|
|
|
+import { DOWNLOAD_API_URL } from '../../../api';
|
|
|
import ChangeOwnerAndGroupModal from './ChangeOwnerAndGroupModal/ChangeOwnerAndGroupModal';
|
|
import ChangeOwnerAndGroupModal from './ChangeOwnerAndGroupModal/ChangeOwnerAndGroupModal';
|
|
|
import ChangePermissionModal from './ChangePermissionModal/ChangePermissionModal';
|
|
import ChangePermissionModal from './ChangePermissionModal/ChangePermissionModal';
|
|
|
|
|
|
|
@@ -52,7 +52,8 @@ interface StorageBrowserRowActionsProps {
|
|
|
config: FileSystem['config'];
|
|
config: FileSystem['config'];
|
|
|
currentPath: FileStats['path'];
|
|
currentPath: FileStats['path'];
|
|
|
selectedFiles: StorageDirectoryTableData[];
|
|
selectedFiles: StorageDirectoryTableData[];
|
|
|
- onSuccessfulAction: () => void;
|
|
|
|
|
|
|
+ onActionSuccess: () => void;
|
|
|
|
|
+ onActionError: (error: Error) => void;
|
|
|
setLoadingFiles: (value: boolean) => void;
|
|
setLoadingFiles: (value: boolean) => void;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -74,7 +75,8 @@ const StorageBrowserActions = ({
|
|
|
config,
|
|
config,
|
|
|
currentPath,
|
|
currentPath,
|
|
|
selectedFiles,
|
|
selectedFiles,
|
|
|
- onSuccessfulAction,
|
|
|
|
|
|
|
+ onActionSuccess,
|
|
|
|
|
+ onActionError,
|
|
|
setLoadingFiles
|
|
setLoadingFiles
|
|
|
}: StorageBrowserRowActionsProps): JSX.Element => {
|
|
}: StorageBrowserRowActionsProps): JSX.Element => {
|
|
|
const [selectedAction, setSelectedAction] = useState<ActionType>();
|
|
const [selectedAction, setSelectedAction] = useState<ActionType>();
|
|
@@ -98,14 +100,8 @@ const StorageBrowserActions = ({
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const onApiSuccess = () => {
|
|
const onApiSuccess = () => {
|
|
|
- setLoadingFiles(false);
|
|
|
|
|
closeModal();
|
|
closeModal();
|
|
|
- onSuccessfulAction();
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const onApiError = (error: Error) => {
|
|
|
|
|
- setLoadingFiles(false);
|
|
|
|
|
- huePubSub.publish('hue.error', error);
|
|
|
|
|
|
|
+ onActionSuccess();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const actionItems: MenuItemType[] = useMemo(() => {
|
|
const actionItems: MenuItemType[] = useMemo(() => {
|
|
@@ -134,67 +130,68 @@ const StorageBrowserActions = ({
|
|
|
<DropDownIcon />
|
|
<DropDownIcon />
|
|
|
</Button>
|
|
</Button>
|
|
|
</Dropdown>
|
|
</Dropdown>
|
|
|
- {selectedAction === ActionType.Summary && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.Summary && !!selectedFiles.length && (
|
|
|
<SummaryModal path={selectedFiles[0].path} onClose={closeModal} />
|
|
<SummaryModal path={selectedFiles[0].path} onClose={closeModal} />
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.Rename && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.Rename && !!selectedFiles.length && (
|
|
|
<RenameModal
|
|
<RenameModal
|
|
|
file={selectedFiles[0]}
|
|
file={selectedFiles[0]}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.Replication && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.Replication && !!selectedFiles.length && (
|
|
|
<ReplicationModal
|
|
<ReplicationModal
|
|
|
file={selectedFiles[0]}
|
|
file={selectedFiles[0]}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
- onClose={closeModal}
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
- {(selectedAction === ActionType.Move || selectedAction === ActionType.Copy) && (
|
|
|
|
|
- <MoveCopyModal
|
|
|
|
|
- action={selectedAction}
|
|
|
|
|
- files={selectedFiles}
|
|
|
|
|
- currentPath={currentPath}
|
|
|
|
|
- onSuccess={onApiSuccess}
|
|
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
- setLoadingFiles={setLoadingFiles}
|
|
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.Delete && (
|
|
|
|
|
|
|
+ {(selectedAction === ActionType.Move || selectedAction === ActionType.Copy) &&
|
|
|
|
|
+ !!selectedFiles.length && (
|
|
|
|
|
+ <MoveCopyModal
|
|
|
|
|
+ action={selectedAction}
|
|
|
|
|
+ files={selectedFiles}
|
|
|
|
|
+ currentPath={currentPath}
|
|
|
|
|
+ onSuccess={onApiSuccess}
|
|
|
|
|
+ onError={onActionError}
|
|
|
|
|
+ onClose={closeModal}
|
|
|
|
|
+ setLoadingFiles={setLoadingFiles}
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
|
|
+ {selectedAction === ActionType.Delete && !!selectedFiles.length && (
|
|
|
<DeletionModal
|
|
<DeletionModal
|
|
|
isTrashEnabled={config?.is_trash_enabled}
|
|
isTrashEnabled={config?.is_trash_enabled}
|
|
|
files={selectedFiles}
|
|
files={selectedFiles}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
setLoading={setLoadingFiles}
|
|
setLoading={setLoadingFiles}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.Compress && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.Compress && !!selectedFiles.length && (
|
|
|
<CompressionModal
|
|
<CompressionModal
|
|
|
currentPath={currentPath}
|
|
currentPath={currentPath}
|
|
|
files={selectedFiles}
|
|
files={selectedFiles}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
setLoading={setLoadingFiles}
|
|
setLoading={setLoadingFiles}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.Extract && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.Extract && !!selectedFiles.length && (
|
|
|
<ExtractionModal
|
|
<ExtractionModal
|
|
|
currentPath={currentPath}
|
|
currentPath={currentPath}
|
|
|
file={selectedFiles[0]}
|
|
file={selectedFiles[0]}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
setLoading={setLoadingFiles}
|
|
setLoading={setLoadingFiles}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.ChangeOwnerAndGroup && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.ChangeOwnerAndGroup && !!selectedFiles.length && (
|
|
|
<ChangeOwnerAndGroupModal
|
|
<ChangeOwnerAndGroupModal
|
|
|
files={selectedFiles}
|
|
files={selectedFiles}
|
|
|
superUser={config?.superuser}
|
|
superUser={config?.superuser}
|
|
@@ -202,16 +199,16 @@ const StorageBrowserActions = ({
|
|
|
users={config?.users}
|
|
users={config?.users}
|
|
|
groups={config?.groups}
|
|
groups={config?.groups}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
setLoading={setLoadingFiles}
|
|
setLoading={setLoadingFiles}
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
- {selectedAction === ActionType.ChangePermission && (
|
|
|
|
|
|
|
+ {selectedAction === ActionType.ChangePermission && !!selectedFiles.length && (
|
|
|
<ChangePermissionModal
|
|
<ChangePermissionModal
|
|
|
files={selectedFiles}
|
|
files={selectedFiles}
|
|
|
onSuccess={onApiSuccess}
|
|
onSuccess={onApiSuccess}
|
|
|
- onError={onApiError}
|
|
|
|
|
|
|
+ onError={onActionError}
|
|
|
onClose={closeModal}
|
|
onClose={closeModal}
|
|
|
setLoading={setLoadingFiles}
|
|
setLoading={setLoadingFiles}
|
|
|
/>
|
|
/>
|