Merge pull request #1052 from ONLYOFFICE/bugfix/fix-archived-header-context-menu
Bugfix/fix archived header context menu
This commit is contained in:
commit
0caddaaca2
@ -128,7 +128,7 @@ const ArchiveDialog = withTranslation(["Files", "ArchiveDialog", "Common"])(
|
||||
);
|
||||
|
||||
export default inject(({ filesStore, filesActionsStore, dialogsStore }) => {
|
||||
const { folders, selection, bufferSelection } = filesStore;
|
||||
const { roomsForRestore, selection, bufferSelection } = filesStore;
|
||||
const { setArchiveAction } = filesActionsStore;
|
||||
|
||||
const {
|
||||
@ -142,7 +142,7 @@ export default inject(({ filesStore, filesActionsStore, dialogsStore }) => {
|
||||
} = dialogsStore;
|
||||
|
||||
const items = restoreAll
|
||||
? folders
|
||||
? roomsForRestore
|
||||
: selection.length > 0
|
||||
? selection
|
||||
: [bufferSelection];
|
||||
|
@ -345,6 +345,9 @@ class SectionHeaderContent extends React.Component {
|
||||
onShowInfoPanel,
|
||||
onClickArchive,
|
||||
onClickReconnectStorage,
|
||||
|
||||
canRestoreAll,
|
||||
canDeleteAll,
|
||||
} = this.props;
|
||||
|
||||
const isDisabled = isRecycleBinFolder || isRoom;
|
||||
@ -355,14 +358,14 @@ class SectionHeaderContent extends React.Component {
|
||||
key: "empty-archive",
|
||||
label: t("ArchiveAction"),
|
||||
onClick: this.onEmptyTrashAction,
|
||||
disabled: !isArchiveFolder,
|
||||
disabled: !canRestoreAll,
|
||||
icon: "images/clear.trash.react.svg",
|
||||
},
|
||||
{
|
||||
key: "restore-all",
|
||||
label: t("RestoreAll"),
|
||||
onClick: this.onRestoreAllArchiveAction,
|
||||
disabled: !isArchiveFolder,
|
||||
disabled: !canDeleteAll,
|
||||
icon: "images/subtract.react.svg",
|
||||
},
|
||||
];
|
||||
@ -608,6 +611,7 @@ class SectionHeaderContent extends React.Component {
|
||||
isRoomsFolder,
|
||||
isEmptyPage,
|
||||
canCreateFiles,
|
||||
isEmptyArchive,
|
||||
} = this.props;
|
||||
|
||||
const menuItems = this.getMenuItems();
|
||||
@ -650,7 +654,9 @@ class SectionHeaderContent extends React.Component {
|
||||
onClose={this.onClose}
|
||||
onClickFolder={this.onClickFolder}
|
||||
isRecycleBinFolder={isRecycleBinFolder || isArchiveFolder}
|
||||
isEmptyFilesList={isEmptyFilesList}
|
||||
isEmptyFilesList={
|
||||
isArchiveFolder ? isEmptyArchive : isEmptyFilesList
|
||||
}
|
||||
clearTrash={this.onEmptyTrashAction}
|
||||
onBackToParentFolder={this.onBackToParentFolder}
|
||||
toggleInfoPanel={this.onToggleInfoPanel}
|
||||
@ -705,7 +711,8 @@ export default inject(
|
||||
|
||||
setAlreadyFetchingRooms,
|
||||
|
||||
filesList,
|
||||
roomsForRestore,
|
||||
roomsForDelete,
|
||||
|
||||
categoryType,
|
||||
isEmptyPage,
|
||||
@ -766,6 +773,12 @@ export default inject(
|
||||
|
||||
const { canCreateFiles } = accessRightsStore;
|
||||
|
||||
const canRestoreAll = isArchiveFolder && roomsForRestore.length > 0;
|
||||
|
||||
const canDeleteAll = isArchiveFolder && roomsForDelete.length > 0;
|
||||
|
||||
const isEmptyArchive = !canRestoreAll && !canDeleteAll;
|
||||
|
||||
return {
|
||||
showText: auth.settingsStore.showText,
|
||||
isDesktop: auth.settingsStore.isDesktopClient,
|
||||
@ -809,6 +822,7 @@ export default inject(
|
||||
isRecycleBinFolder,
|
||||
setEmptyTrashDialogVisible,
|
||||
isEmptyFilesList,
|
||||
isEmptyArchive,
|
||||
isPrivacyFolder,
|
||||
isArchiveFolder,
|
||||
|
||||
@ -841,6 +855,10 @@ export default inject(
|
||||
onClickArchive,
|
||||
|
||||
rootFolderType,
|
||||
|
||||
isEmptyArchive,
|
||||
canRestoreAll,
|
||||
canDeleteAll,
|
||||
};
|
||||
}
|
||||
)(
|
||||
|
@ -395,9 +395,9 @@ class FilesActionStore {
|
||||
clearSecondaryProgressData,
|
||||
} = secondaryProgressDataStore;
|
||||
const { isArchiveFolder } = this.treeFoldersStore;
|
||||
const { addActiveItems, folders, getIsEmptyTrash } = this.filesStore;
|
||||
const { addActiveItems, roomsForDelete } = this.filesStore;
|
||||
|
||||
const folderIds = folders.map((f) => f.id);
|
||||
const folderIds = roomsForDelete.map((f) => f.id);
|
||||
if (isArchiveFolder) addActiveItems(null, folderIds);
|
||||
|
||||
setSecondaryProgressBarData({
|
||||
|
@ -2740,6 +2740,14 @@ class FilesStore {
|
||||
isRecentFolder
|
||||
);
|
||||
}
|
||||
|
||||
get roomsForRestore() {
|
||||
return this.folders.filter((f) => getRoomRoleActions(f.access).archive);
|
||||
}
|
||||
|
||||
get roomsForDelete() {
|
||||
return this.folders.filter((f) => getRoomRoleActions(f.access).delete);
|
||||
}
|
||||
}
|
||||
|
||||
export default FilesStore;
|
||||
|
Loading…
Reference in New Issue
Block a user