From 362b2ee48193d2205890cdc0ff07da4b3ba17772 Mon Sep 17 00:00:00 2001 From: Montassar Ghanmy Date: Tue, 5 Sep 2023 15:01:24 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Open=20in=20new=20window?= =?UTF-8?q?=20menu=20option=20(#183)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⭐️ Open in new window menu option --- tdrive/frontend/public/locales/en.json | 1 + tdrive/frontend/public/locales/fr.json | 1 + tdrive/frontend/public/locales/ru.json | 1 + .../app/views/client/body/drive/context-menu.tsx | 13 +++++++++++++ 4 files changed, 16 insertions(+) diff --git a/tdrive/frontend/public/locales/en.json b/tdrive/frontend/public/locales/en.json index 006ced8e..3f3682d0 100644 --- a/tdrive/frontend/public/locales/en.json +++ b/tdrive/frontend/public/locales/en.json @@ -313,6 +313,7 @@ "components.item_context_menu.today": "Today", "components.item_context_menu.last_week": "Last week", "components.item_context_menu.last_month": "Last month", + "components.item_context_menu.open_new_window": "Open in new window", "scenes.app.shared_with_me.shared_with_me": "Shared with me", "scenes.app.shared_with_me.file_type": "File type", "scenes.app.shared_with_me.people": "People", diff --git a/tdrive/frontend/public/locales/fr.json b/tdrive/frontend/public/locales/fr.json index 0fdc284f..4c9e82b6 100644 --- a/tdrive/frontend/public/locales/fr.json +++ b/tdrive/frontend/public/locales/fr.json @@ -312,6 +312,7 @@ "components.item_context_menu.today": "Aujourd'hui", "components.item_context_menu.last_week": "La semaine dernière", "components.item_context_menu.last_month": "Le mois dernier", + "components.item_context_menu.open_new_window": "Open in new window", "scenes.app.shared_with_me.shared_with_me": "Partagé avec moi", "scenes.app.shared_with_me.file_type": "Type de fichier", "scenes.app.shared_with_me.people": "Personnes", diff --git a/tdrive/frontend/public/locales/ru.json b/tdrive/frontend/public/locales/ru.json index d794dc45..bff8909f 100644 --- a/tdrive/frontend/public/locales/ru.json +++ b/tdrive/frontend/public/locales/ru.json @@ -312,6 +312,7 @@ "components.item_context_menu.today": "Сегодня", "components.item_context_menu.last_week": "За неделю", "components.item_context_menu.last_month": "За месяц", + "components.item_context_menu.open_new_window": "Открыть в новом окне", "scenes.app.shared_with_me.shared_with_me": "Доступные мне", "scenes.app.shared_with_me.file_type": "Тип файла", "scenes.app.shared_with_me.people": "Люди", 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 80ee4a57..507fe275 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 @@ -19,6 +19,8 @@ import { ToasterService } from '@features/global/services/toaster-service'; import { copyToClipboard } from '@features/global/utils/CopyClipboard'; import { SharedWithMeFilterState } from '@features/drive/state/shared-with-me-filter'; import { getCurrentUserList } from '@features/users/hooks/use-user-list'; +import RouterServices from '@features/router/services/router-service'; +import useRouterCompany from '@features/router/hooks/use-router-company'; import _ from 'lodash'; import Languages from 'features/global/services/languages-service'; @@ -43,6 +45,8 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s const setPropertiesModalState = useSetRecoilState(PropertiesModalAtom); const setUsersModalState = useSetRecoilState(UsersModalAtom); const { open: preview } = useDrivePreview(); + const company = useRouterCompany(); + function getIdsFromArray(arr: DriveItem[]): string[] { return arr.map((obj) => obj.id); } @@ -87,6 +91,15 @@ export const useOnBuildContextMenu = (children: DriveItem[], initialParentId?: s } }, { type: 'separator' }, + { + type: 'menu', + text: Languages.t('components.item_context_menu.open_new_window'), + onClick: () => { + const route = RouterServices.generateRouteFromState({ companyId: company, viewId: item.parent_id, itemId: item.id }); + window.open(route, '_blank'); + } + }, + { type: 'separator' }, { type: 'menu', text: Languages.t('components.item_context_menu.manage_access'),