Merge pull request #1052 from ONLYOFFICE/bugfix/fix-archived-header-context-menu

Bugfix/fix archived header context menu
This commit is contained in:
Nikita Gopienko 2022-11-18 13:47:31 +03:00 committed by GitHub
commit 0caddaaca2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 8 deletions

View File

@ -128,7 +128,7 @@ const ArchiveDialog = withTranslation(["Files", "ArchiveDialog", "Common"])(
); );
export default inject(({ filesStore, filesActionsStore, dialogsStore }) => { export default inject(({ filesStore, filesActionsStore, dialogsStore }) => {
const { folders, selection, bufferSelection } = filesStore; const { roomsForRestore, selection, bufferSelection } = filesStore;
const { setArchiveAction } = filesActionsStore; const { setArchiveAction } = filesActionsStore;
const { const {
@ -142,7 +142,7 @@ export default inject(({ filesStore, filesActionsStore, dialogsStore }) => {
} = dialogsStore; } = dialogsStore;
const items = restoreAll const items = restoreAll
? folders ? roomsForRestore
: selection.length > 0 : selection.length > 0
? selection ? selection
: [bufferSelection]; : [bufferSelection];

View File

@ -345,6 +345,9 @@ class SectionHeaderContent extends React.Component {
onShowInfoPanel, onShowInfoPanel,
onClickArchive, onClickArchive,
onClickReconnectStorage, onClickReconnectStorage,
canRestoreAll,
canDeleteAll,
} = this.props; } = this.props;
const isDisabled = isRecycleBinFolder || isRoom; const isDisabled = isRecycleBinFolder || isRoom;
@ -355,14 +358,14 @@ class SectionHeaderContent extends React.Component {
key: "empty-archive", key: "empty-archive",
label: t("ArchiveAction"), label: t("ArchiveAction"),
onClick: this.onEmptyTrashAction, onClick: this.onEmptyTrashAction,
disabled: !isArchiveFolder, disabled: !canRestoreAll,
icon: "images/clear.trash.react.svg", icon: "images/clear.trash.react.svg",
}, },
{ {
key: "restore-all", key: "restore-all",
label: t("RestoreAll"), label: t("RestoreAll"),
onClick: this.onRestoreAllArchiveAction, onClick: this.onRestoreAllArchiveAction,
disabled: !isArchiveFolder, disabled: !canDeleteAll,
icon: "images/subtract.react.svg", icon: "images/subtract.react.svg",
}, },
]; ];
@ -608,6 +611,7 @@ class SectionHeaderContent extends React.Component {
isRoomsFolder, isRoomsFolder,
isEmptyPage, isEmptyPage,
canCreateFiles, canCreateFiles,
isEmptyArchive,
} = this.props; } = this.props;
const menuItems = this.getMenuItems(); const menuItems = this.getMenuItems();
@ -650,7 +654,9 @@ class SectionHeaderContent extends React.Component {
onClose={this.onClose} onClose={this.onClose}
onClickFolder={this.onClickFolder} onClickFolder={this.onClickFolder}
isRecycleBinFolder={isRecycleBinFolder || isArchiveFolder} isRecycleBinFolder={isRecycleBinFolder || isArchiveFolder}
isEmptyFilesList={isEmptyFilesList} isEmptyFilesList={
isArchiveFolder ? isEmptyArchive : isEmptyFilesList
}
clearTrash={this.onEmptyTrashAction} clearTrash={this.onEmptyTrashAction}
onBackToParentFolder={this.onBackToParentFolder} onBackToParentFolder={this.onBackToParentFolder}
toggleInfoPanel={this.onToggleInfoPanel} toggleInfoPanel={this.onToggleInfoPanel}
@ -705,7 +711,8 @@ export default inject(
setAlreadyFetchingRooms, setAlreadyFetchingRooms,
filesList, roomsForRestore,
roomsForDelete,
categoryType, categoryType,
isEmptyPage, isEmptyPage,
@ -766,6 +773,12 @@ export default inject(
const { canCreateFiles } = accessRightsStore; const { canCreateFiles } = accessRightsStore;
const canRestoreAll = isArchiveFolder && roomsForRestore.length > 0;
const canDeleteAll = isArchiveFolder && roomsForDelete.length > 0;
const isEmptyArchive = !canRestoreAll && !canDeleteAll;
return { return {
showText: auth.settingsStore.showText, showText: auth.settingsStore.showText,
isDesktop: auth.settingsStore.isDesktopClient, isDesktop: auth.settingsStore.isDesktopClient,
@ -809,6 +822,7 @@ export default inject(
isRecycleBinFolder, isRecycleBinFolder,
setEmptyTrashDialogVisible, setEmptyTrashDialogVisible,
isEmptyFilesList, isEmptyFilesList,
isEmptyArchive,
isPrivacyFolder, isPrivacyFolder,
isArchiveFolder, isArchiveFolder,
@ -841,6 +855,10 @@ export default inject(
onClickArchive, onClickArchive,
rootFolderType, rootFolderType,
isEmptyArchive,
canRestoreAll,
canDeleteAll,
}; };
} }
)( )(

View File

@ -395,9 +395,9 @@ class FilesActionStore {
clearSecondaryProgressData, clearSecondaryProgressData,
} = secondaryProgressDataStore; } = secondaryProgressDataStore;
const { isArchiveFolder } = this.treeFoldersStore; 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); if (isArchiveFolder) addActiveItems(null, folderIds);
setSecondaryProgressBarData({ setSecondaryProgressBarData({

View File

@ -2740,6 +2740,14 @@ class FilesStore {
isRecentFolder 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; export default FilesStore;