Web: Files: disabled item selection when clicking the context menu

This commit is contained in:
Nikita Gopienko 2021-09-30 15:26:20 +03:00
parent ae8d1f6725
commit fd1cdb0217
7 changed files with 62 additions and 20 deletions

View File

@ -107,6 +107,7 @@ class DeleteDialogComponent extends React.Component {
};
onClose = () => {
this.props.setTempSelection(null);
this.props.setRemoveMediaItem(null);
this.props.setDeleteDialogVisible(false);
};
@ -254,7 +255,12 @@ export default inject(
treeFoldersStore,
auth,
}) => {
const { selection, isLoading } = filesStore;
const {
selection,
isLoading,
tempSelection,
setTempSelection,
} = filesStore;
const { deleteAction, unsubscribeAction } = filesActionsStore;
const { isPrivacyFolder, isRecycleBinFolder } = treeFoldersStore;
@ -269,7 +275,11 @@ export default inject(
const { personal } = auth.settingsStore;
return {
selection: removeMediaItem ? [removeMediaItem] : selection,
selection: removeMediaItem
? [removeMediaItem]
: tempSelection
? [tempSelection]
: selection,
isLoading,
isRootFolder: selectedFolderStore.isRootFolder,
visible,
@ -284,6 +294,7 @@ export default inject(
setRemoveMediaItem,
personal,
setTempSelection,
};
}
)(withRouter(observer(DeleteDialog)));

View File

@ -28,6 +28,7 @@ const PureThirdPartyMoveContainer = ({
const deleteAfter = false; // TODO: get from settings
const onClose = () => {
setTempSelection(null);
setDestFolderId(false);
setThirdPartyMoveDialogVisible(false);
};
@ -108,9 +109,11 @@ export default inject(({ filesStore, dialogsStore, filesActionsStore }) => {
destFolderId,
setDestFolderId,
} = dialogsStore;
const { selection } = filesStore;
const { tempSelection, setTempSelection } = filesStore;
const { checkOperationConflict } = filesActionsStore;
const selection = tempSelection ? [tempSelection] : filesStore.selection;
return {
visible,
setThirdPartyMoveDialogVisible,
@ -119,6 +122,7 @@ export default inject(({ filesStore, dialogsStore, filesActionsStore }) => {
provider: selection[0].providerKey,
checkOperationConflict,
selection,
setTempSelection,
};
})(
withTranslation(["ThirdPartyMoveDialog", "Common", "Translations"])(

View File

@ -70,6 +70,7 @@ class ChangeOwnerComponent extends React.Component {
};
onClose = () => {
this.props.setTempSelection(null);
this.props.setChangeOwnerPanelVisible(false);
};
@ -145,17 +146,19 @@ const ChangeOwnerPanel = withTranslation(["ChangeOwnerPanel", "Common"])(
export default inject(({ auth, filesStore, dialogsStore }) => {
const {
selection,
tempSelection,
setFile,
setFolder,
setFilesOwner,
setIsLoading,
isLoading,
setTempSelection,
} = filesStore;
const { ownerPanelVisible, setChangeOwnerPanelVisible } = dialogsStore;
return {
groupsCaption: auth.settingsStore.customNames.groupsCaption,
selection,
selection: tempSelection ? [tempSelection] : selection,
isLoading,
visible: ownerPanelVisible,
@ -164,5 +167,6 @@ export default inject(({ auth, filesStore, dialogsStore }) => {
setIsLoading,
setChangeOwnerPanelVisible,
setFilesOwner,
setTempSelection,
};
})(withRouter(observer(ChangeOwnerPanel)));

View File

@ -25,6 +25,7 @@ const OperationsPanelComponent = (props) => {
setMoveToPanelVisible,
checkOperationConflict,
setThirdPartyMoveDialogVisible,
setTempSelection,
} = props;
const zIndex = 310;
@ -33,6 +34,7 @@ const OperationsPanelComponent = (props) => {
const expandedKeys = props.expandedKeys.map((item) => item.toString());
const onClose = () => {
!provider && setTempSelection(null);
isCopy ? setCopyPanelVisible(false) : setMoveToPanelVisible(false);
setExpandedPanelKeys(null);
};
@ -140,7 +142,7 @@ export default inject(
dialogsStore,
filesActionsStore,
}) => {
const { filter, selection } = filesStore;
const { filter, selection, tempSelection, setTempSelection } = filesStore;
const {
isRecycleBinFolder,
operationsFolders,
@ -158,7 +160,9 @@ export default inject(
setThirdPartyMoveDialogVisible,
} = dialogsStore;
const provider = selection.find((x) => x.providerKey);
const selections = tempSelection ? [tempSelection] : selection;
const provider = selections.find((x) => x.providerKey);
return {
expandedKeys: expandedPanelKeys
@ -170,7 +174,7 @@ export default inject(
operationsFolders,
visible: copyPanelVisible || moveToPanelVisible,
provider,
selection,
selection: selections,
setCopyPanelVisible,
setMoveToPanelVisible,
@ -178,6 +182,7 @@ export default inject(
setThirdPartyMoveDialogVisible,
checkOperationConflict,
setExpandedPanelKeys,
setTempSelection,
};
}
)(withRouter(observer(OperationsPanel)));

View File

@ -39,13 +39,12 @@ const SharingDialog = ({
};
const SharingDialogWrapper = inject(({ dialogsStore, filesStore }) => {
const { getShareUsers, setSelection, selection } = filesStore;
const { getShareUsers, setSelection } = filesStore;
const { setSharingPanelVisible } = dialogsStore;
return {
setSharingPanelVisible,
getShareUsers,
setSelection,
selection,
};
})(observer(SharingDialog));

View File

@ -337,10 +337,16 @@ class SharingPanelComponent extends React.Component {
setShareDataItems = (shareDataItems) => this.setState({ shareDataItems });
onClose = () => {
const { onCancel, setSharingPanelVisible, selectUploadedFile } = this.props;
const {
onCancel,
setSharingPanelVisible,
selectUploadedFile,
setTempSelection,
} = this.props;
setSharingPanelVisible(false);
selectUploadedFile([]);
setTempSelection(null);
onCancel && onCancel();
};
@ -620,6 +626,7 @@ const SharingPanel = inject(
const {
selection,
tempSelection,
canShareOwnerChange,
getAccessOption,
getExternalAccessOption,
@ -631,6 +638,7 @@ const SharingPanel = inject(
getFileInfo,
getFolderInfo,
isLoading,
setTempSelection,
} = filesStore;
const { isPrivacyFolder } = treeFoldersStore;
const { setSharingPanelVisible, sharingPanelVisible } = dialogsStore;
@ -646,7 +654,11 @@ const SharingPanel = inject(
groupsCaption: customNames.groupsCaption,
isDesktop: isDesktopClient,
homepage: config.homepage,
selection: uploadPanelVisible ? selectedUploadFile : selection,
selection: uploadPanelVisible
? selectedUploadFile
: tempSelection
? [tempSelection]
: selection,
isLoading,
isPrivacy: isPrivacyFolder,
selectedUploadFile,
@ -667,6 +679,7 @@ const SharingPanel = inject(
setShareFiles,
getFileInfo,
getFolderInfo,
setTempSelection,
};
}
)(

View File

@ -229,7 +229,12 @@ class FilesActionStore {
setSecondaryProgressBarData,
clearSecondaryProgressData,
} = this.uploadDataStore.secondaryProgressDataStore;
const { selection } = this.filesStore;
const { tempSelection } = this.filesStore;
const selection = tempSelection
? [tempSelection]
: this.filesStore.selection;
const fileIds = [];
const folderIds = [];
const items = [];
@ -308,7 +313,7 @@ class FilesActionStore {
};
onSelectItem = ({ id, isFolder }) => {
const { setSelection, selected, setSelected } = this.filesStore;
const { setTempSelection, selected, setSelected } = this.filesStore;
selected === "close" && setSelected("none");
if (!id) return;
@ -316,7 +321,8 @@ class FilesActionStore {
const item = this.filesStore[isFolder ? "folders" : "files"].find(
(elm) => elm.id === id
);
setSelection([item]);
setTempSelection(item);
};
deleteItemAction = (