From 8f6a08df3f33222e6d18f8532a700ab9dd07a0ee Mon Sep 17 00:00:00 2001 From: VladaGazizova Date: Fri, 5 Apr 2024 18:34:56 +0300 Subject: [PATCH] Client:Section:Header:Added a context menu to the room name in the navigation in the archive. Corrected actions in the context menu for the archive to be correct. --- .../components/dialogs/DeleteDialog/index.js | 7 +++ .../src/pages/Home/Section/Header/index.js | 58 ++++++++++++------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/packages/client/src/components/dialogs/DeleteDialog/index.js b/packages/client/src/components/dialogs/DeleteDialog/index.js index 3f64c37c56..eaa39217da 100644 --- a/packages/client/src/components/dialogs/DeleteDialog/index.js +++ b/packages/client/src/components/dialogs/DeleteDialog/index.js @@ -137,6 +137,13 @@ const DeleteDialogComponent = (props) => { }; const onClose = () => { + if ( + selection.length === 1 && + selection[0].isArchive && + selection[0].isRootFolder === false + ) { + setSelected("none"); + } setBufferSelection(null); setRemoveMediaItem(null); setIsRoomDelete(false); diff --git a/packages/client/src/pages/Home/Section/Header/index.js b/packages/client/src/pages/Home/Section/Header/index.js index f588c5eb57..779e6cea46 100644 --- a/packages/client/src/pages/Home/Section/Header/index.js +++ b/packages/client/src/pages/Home/Section/Header/index.js @@ -146,11 +146,6 @@ const StyledContainer = styled.div` min-height: 33px; align-items: center; - ${(props) => - props.hideContextMenuInsideArchiveRoom && - `.option-button { - display: none;}`} - @media ${tablet} { height: 61px; } @@ -238,7 +233,6 @@ const SectionHeaderContent = (props) => { isGroupMenuBlocked, onClickBack, - hideContextMenuInsideArchiveRoom, activeFiles, activeFolders, selectedFolder, @@ -312,6 +306,8 @@ const SectionHeaderContent = (props) => { onClickCreateRoom, onCreateAndCopySharedLink, showNavigationButton, + deleteRooms, + setSelection, } = props; const navigate = useNavigate(); @@ -685,6 +681,11 @@ const SectionHeaderContent = (props) => { toastr.success(t("Translations:LinkCopySuccess")); }; + const onDeleteRoomInArchive = () => { + setSelection([selectedFolder]); + deleteRooms(t); + }; + const getContextOptionsFolder = () => { const { t, @@ -709,6 +710,8 @@ const SectionHeaderContent = (props) => { isPublicRoom, } = props; + const isArchive = selectedFolder.rootFolderType === FolderType.Archive; + if (isPublicRoom) { return [ { @@ -778,7 +781,9 @@ const SectionHeaderContent = (props) => { disabled: isRecycleBinFolder || isPersonalRoom || - ((isPublicRoomType || isCustomRoomType) && haveLinksRight), + ((isPublicRoomType || isCustomRoomType) && + haveLinksRight && + !isArchive), icon: InvitationLinkReactSvgUrl, }, { @@ -839,7 +844,10 @@ const SectionHeaderContent = (props) => { } } }, - disabled: (!isPublicRoomType && !isCustomRoomType) || !haveLinksRight, + disabled: + (!isPublicRoomType && !isCustomRoomType) || + !haveLinksRight || + isArchive, }, { id: "header_option_invite-users-to-room", @@ -870,7 +878,7 @@ const SectionHeaderContent = (props) => { label: t("MoveToArchive"), icon: RoomArchiveSvgUrl, onClick: onClickArchiveAction, - disabled: !isRoom || !security?.Move, + disabled: !isRoom || !security?.Move || isArchive, "data-action": "archive", action: "archive", }, @@ -891,7 +899,7 @@ const SectionHeaderContent = (props) => { label: t("LeaveTheRoom"), icon: LeaveRoomSvgUrl, onClick: onLeaveRoom, - disabled: isArchiveFolder || !inRoom || isPublicRoom, + disabled: isArchive || !inRoom || isPublicRoom, }, { id: "header_option_download", @@ -901,6 +909,14 @@ const SectionHeaderContent = (props) => { disabled: !security?.Download, icon: DownloadReactSvgUrl, }, + { + id: "header_option_unarchive-room", + key: "unarchive-room", + label: t("Common:Restore"), + onClick: onClickArchiveAction, + disabled: !isArchive || !isRoom, + icon: MoveReactSvgUrl, + }, { id: "header_option_move-to", key: "move-to", @@ -914,7 +930,9 @@ const SectionHeaderContent = (props) => { key: "copy", label: t("Common:Copy"), onClick: onCopyAction, - disabled: isDisabled || !security?.CopyTo, + disabled: + isDisabled || (isArchive ? !security?.Copy : !security?.CopyTo), + icon: CopyReactSvgUrl, }, { @@ -935,8 +953,8 @@ const SectionHeaderContent = (props) => { id: "header_option_delete", key: "delete", label: t("Common:Delete"), - onClick: onDeleteAction, - disabled: isDisabled || !security?.Delete, + onClick: isArchive ? onDeleteRoomInArchive : onDeleteAction, + disabled: isArchive ? !isRoom : isDisabled || !security?.Delete, icon: CatalogTrashReactSvgUrl, }, ]; @@ -1190,10 +1208,7 @@ const SectionHeaderContent = (props) => { return ( {(context) => ( - + {tableGroupMenuVisible ? ( ) : ( @@ -1314,6 +1329,7 @@ export default inject( clearFiles, categoryType, getPrimaryLink, + setSelection, } = filesStore; const { @@ -1364,6 +1380,7 @@ export default inject( emptyTrashInProgress, moveToPublicRoom, onClickCreateRoom, + deleteRooms, } = filesActionsStore; const { oformsFilter } = oformsStore; @@ -1421,10 +1438,6 @@ export default inject( const isEmptyArchive = !canRestoreAll && !canDeleteAll; - const hideContextMenuInsideArchiveRoom = isArchiveFolderRoot - ? !isArchiveFolder - : false; - const { selectionStore, headerMenuStore, @@ -1523,7 +1536,6 @@ export default inject( isEmptyArchive, isPrivacyFolder, isArchiveFolder, - hideContextMenuInsideArchiveRoom, setIsLoading, @@ -1600,6 +1612,8 @@ export default inject( onCreateAndCopySharedLink, showNavigationButton, haveLinksRight, + deleteRooms, + setSelection, }; }, )(