From 0aa23be2e44f4dcd110e4d30145d61fcc28aaf00 Mon Sep 17 00:00:00 2001 From: Monta Date: Sun, 29 Sep 2024 23:00:29 +0100 Subject: [PATCH 1/3] fix: #664 extra dividing line in action menu --- .../src/app/views/client/body/drive/context-menu.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx index 1880d56a..91256504 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx @@ -88,7 +88,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s hide: access === 'read' || getPublicLinkToken() || inTrash, onClick: () => setAccessModalState({ open: true, id: item.id }), }, - { type: 'separator' }, + { type: 'separator', hide: inTrash }, { type: 'menu', icon: 'download-alt', @@ -100,7 +100,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s } else { download(item.id); } - } + }, }, /*TODO: fix loading of preview in new window and uncomment. See https://github.com/linagora/twake-drive/issues/603 . { @@ -150,7 +150,10 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s type: 'menu', icon: 'link', text: Languages.t('components.item_context_menu.copy_link'), - hide: !item.access_info.public?.level || item.access_info.public?.level === 'none' || inTrash, + hide: + !item.access_info.public?.level || + item.access_info.public?.level === 'none' || + inTrash, onClick: () => { copyToClipboard(getPublicLink(item || parent?.item)); ToasterService.success( @@ -165,7 +168,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s hide: item.is_directory || inTrash, onClick: () => setVersionModal({ open: true, id: item.id }), }, - { type: 'separator', hide: access !== 'manage' || inTrash, }, + { type: 'separator', hide: access !== 'manage' || inTrash }, { type: 'menu', icon: 'trash', From 2f2b77a14158d7d1e887160201cd5860d49c3dd6 Mon Sep 17 00:00:00 2001 From: Monta Date: Sun, 29 Sep 2024 23:35:24 +0100 Subject: [PATCH 2/3] fix: #667 irrelevant warning when renaming a file shared with me by link --- .../drive/hooks/use-drive-actions.tsx | 4 ++-- .../app/views/client/body/drive/browser.tsx | 2 +- .../views/client/body/drive/context-menu.tsx | 22 ++++++++++++------- .../body/drive/modals/properties/index.tsx | 12 +++++++--- .../app/views/client/body/drive/shared.tsx | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx index cbb7eb3d..426fec9a 100644 --- a/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx +++ b/tdrive/frontend/src/app/features/drive/hooks/use-drive-actions.tsx @@ -13,7 +13,7 @@ import { useUserQuota } from 'features/users/hooks/use-user-quota'; * Returns the children of a drive item * @returns */ -export const useDriveActions = () => { +export const useDriveActions = (inPublicSharing?: boolean) => { const companyId = useRouterCompany(); const sharedFilter = useRecoilValue(SharedWithMeFilterState); const sortItem = useRecoilValue(DriveItemSort); @@ -142,7 +142,7 @@ export const useDriveActions = () => { try { await DriveApiClient.update(companyId, id, update); await refresh(id || '', true); - await refresh(parentId || '', true); + if (!inPublicSharing) await refresh(parentId || '', true); if (update?.parent_id !== parentId) await refresh(update?.parent_id || '', true); } catch (e) { ToasterService.error(Languages.t('hooks.use-drive-actions.unable_update_file')); diff --git a/tdrive/frontend/src/app/views/client/body/drive/browser.tsx b/tdrive/frontend/src/app/views/client/body/drive/browser.tsx index 93349498..ac223b9b 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/browser.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/browser.tsx @@ -160,7 +160,7 @@ export default memo( const selectedCount = Object.values(checked).filter(v => v).length; - const onBuildContextMenu = useOnBuildContextMenu(children, initialParentId); + const onBuildContextMenu = useOnBuildContextMenu(children, initialParentId, inPublicSharing); const onBuildSortContextMenu = useOnBuildSortContextMenu(); const handleDragOver = (event: { preventDefault: () => void }) => { diff --git a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx index 91256504..97ebe6b1 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/context-menu.tsx @@ -31,7 +31,11 @@ import { hasAnyPublicLinkAccess } from '@features/files/utils/access-info-helper /** * This will build the context menu in different contexts */ -export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: string) => { +export const useOnBuildContextMenu = ( + children: DriveItem[], + initialParentId?: string, + inPublicSharing?: boolean, +) => { const [checkedIds, setChecked] = useRecoilState(DriveItemSelectedList); const checked = children.filter(c => checkedIds[c.id]); @@ -55,7 +59,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s const company = useRouterCompany(); function getIdsFromArray(arr: DriveItem[]): string[] { - return arr.map((obj) => obj.id); + return arr.map(obj => obj.id); } return useCallback( @@ -63,7 +67,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s if (!parent || !parent.access) return []; try { - const inTrash = parent.path?.[0]?.id.includes('trash') || viewId?.includes("trash"); + const inTrash = parent.path?.[0]?.id.includes('trash') || viewId?.includes('trash'); const isPersonal = item?.scope === 'personal'; const selectedCount = checked.length; @@ -144,7 +148,7 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s icon: 'file-edit-alt', text: Languages.t('components.item_context_menu.rename'), hide: access === 'read' || inTrash, - onClick: () => setPropertiesModalState({ open: true, id: item.id }), + onClick: () => setPropertiesModalState({ open: true, id: item.id, inPublicSharing }), }, { type: 'menu', @@ -307,10 +311,12 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s if (parent.children && parent.children.length > 0) { downloadZip([parent.item!.id]); } else if (parent.item) { - console.log("Download folder itself"); + console.log('Download folder itself'); download(parent.item.id); } else { - console.error("Very strange, everything is null, you are trying to download undefined"); + console.error( + 'Very strange, everything is null, you are trying to download undefined', + ); } }, }, @@ -325,13 +331,13 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s ); }, }, - { type: 'separator', hide: parent.item!.id != 'root', }, + { type: 'separator', hide: parent.item!.id != 'root' }, { type: 'menu', text: Languages.t('components.item_context_menu.manage_users'), hide: parent.item!.id != 'root', onClick: () => setUsersModalState({ open: true }), - } + }, ]; if (menu.length && newMenuActions.filter(a => !a.hide).length) { menu = [...menu, { type: 'separator' }]; diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/properties/index.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/properties/index.tsx index e3c75e8b..41a0bdcd 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/properties/index.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/properties/index.tsx @@ -11,6 +11,7 @@ import Languages from '@features/global/services/languages-service'; export type PropertiesModalType = { open: boolean; id: string; + inPublicSharing?: boolean; }; export const PropertiesModalAtom = atom({ @@ -18,6 +19,7 @@ export const PropertiesModalAtom = atom({ default: { open: false, id: '', + inPublicSharing: false, }, }); @@ -27,15 +29,19 @@ export const PropertiesModal = () => { return ( setState({ ...state, open: false })}> {!!state.id && ( - setState({ ...state, open: false })} /> + setState({ ...state, open: false })} + inPublicSharing={state.inPublicSharing} + /> )} ); }; -const PropertiesModalContent = ({ id, onClose }: { id: string; onClose: () => void }) => { +const PropertiesModalContent = ({ id, onClose, inPublicSharing }: { id: string; onClose: () => void, inPublicSharing?: boolean }) => { const { item, refresh } = useDriveItem(id); - const { update } = useDriveActions(); + const { update } = useDriveActions(inPublicSharing); const [loading, setLoading] = useState(false); const [name, setName] = useState(''); diff --git a/tdrive/frontend/src/app/views/client/body/drive/shared.tsx b/tdrive/frontend/src/app/views/client/body/drive/shared.tsx index 4fdecc63..df3c3529 100755 --- a/tdrive/frontend/src/app/views/client/body/drive/shared.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/shared.tsx @@ -82,7 +82,7 @@ export default () => {
- +
From 3b4431c8f85de25eb80db7feff17a3c63f3f42b3 Mon Sep 17 00:00:00 2001 From: MontaGhanmy Date: Mon, 30 Sep 2024 13:58:14 +0100 Subject: [PATCH 3/3] fix: #666 change tdrive to twake drive --- tdrive/frontend/src/app/views/client/body/drive/shared.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tdrive/frontend/src/app/views/client/body/drive/shared.tsx b/tdrive/frontend/src/app/views/client/body/drive/shared.tsx index df3c3529..8c9f9af1 100755 --- a/tdrive/frontend/src/app/views/client/body/drive/shared.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/shared.tsx @@ -68,7 +68,7 @@ export default () => { )} - {group.name} + Twake Drive