From f3e667a651563d2f779b25456cbb1318aa6982c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:02:31 +0100 Subject: [PATCH] 496 add open in full page button on command menu record page (#10659) Closes https://github.com/twentyhq/core-team-issues/issues/496 I upgraded react tabler icons to the latest version to be able to use the newest icons. The option menu was no longer accessible on right drawer record pages, this pr fixes this and creates a new button which opens the record show page. This button is accessible via the shortcut `Command` + `Enter` https://github.com/user-attachments/assets/570071b2-4406-40bd-be48-a0e5e430ed70 --- .nvmrc | 1 - package.json | 2 +- .../RecordShowRightDrawerOpenRecordButton.tsx | 66 +++++++++++++++++++ .../RightDrawerActionMenuDropdown.tsx | 2 +- .../RightDrawerActionMenuDropdown.stories.tsx | 8 +-- .../command-menu/hooks/useCommandMenu.ts | 53 +++++++++++++++ .../components/RightDrawerRecord.tsx | 5 +- .../constants/RightDrawerRecordInstanceId.ts | 1 + .../components/ShowPageSubContainer.tsx | 13 +++- .../display/icon/components/IconMicrosoft.tsx | 2 +- .../icon/components/IconMicrosoftCalendar.tsx | 2 +- .../icon/components/IconMicrosoftOutlook.tsx | 2 +- .../display/icon/components/TablerIcons.ts | 18 ++--- .../icon/providers/internal/AllIcons.ts | 2 + .../src/display/icon/types/IconComponent.ts | 5 +- .../components/CircularProgressBar.tsx | 2 +- .../input/button/components/MainButton.tsx | 4 +- .../src/app/_components/ui/icons/index.ts | 2 +- yarn.lock | 23 ++++--- 19 files changed, 173 insertions(+), 40 deletions(-) delete mode 100644 .nvmrc create mode 100644 packages/twenty-front/src/modules/action-menu/components/RecordShowRightDrawerOpenRecordButton.tsx create mode 100644 packages/twenty-front/src/modules/object-record/record-right-drawer/constants/RightDrawerRecordInstanceId.ts diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 7ec56198d..000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18.17.1 \ No newline at end of file diff --git a/package.json b/package.json index 3dfd1adc8..b8d411fac 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@sniptt/guards": "^0.2.0", "@stoplight/elements": "^8.0.5", "@swc/jest": "^0.2.29", - "@tabler/icons-react": "^2.44.0", + "@tabler/icons-react": "^3.31.0", "@types/dompurify": "^3.0.5", "@types/facepaint": "^1.2.5", "@types/lodash.camelcase": "^4.3.7", diff --git a/packages/twenty-front/src/modules/action-menu/components/RecordShowRightDrawerOpenRecordButton.tsx b/packages/twenty-front/src/modules/action-menu/components/RecordShowRightDrawerOpenRecordButton.tsx new file mode 100644 index 000000000..5bb515f07 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/components/RecordShowRightDrawerOpenRecordButton.tsx @@ -0,0 +1,66 @@ +import { RightDrawerActionMenuDropdownHotkeyScope } from '@/action-menu/types/RightDrawerActionMenuDropdownHotkeyScope'; +import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu'; +import { getLinkToShowPage } from '@/object-metadata/utils/getLinkToShowPage'; +import { ObjectRecord } from '@/object-record/types/ObjectRecord'; +import { AppPath } from '@/types/AppPath'; +import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; +import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope'; +import styled from '@emotion/styled'; +import { Link } from 'react-router-dom'; +import { Button, IconBrowserMaximize, getOsControlSymbol } from 'twenty-ui'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +const StyledLink = styled(Link)` + text-decoration: none; +`; + +type RecordShowRightDrawerOpenRecordButtonProps = { + objectNameSingular: string; + record: ObjectRecord; +}; + +export const RecordShowRightDrawerOpenRecordButton = ({ + objectNameSingular, + record, +}: RecordShowRightDrawerOpenRecordButtonProps) => { + const { closeCommandMenu } = useCommandMenu(); + + const to = getLinkToShowPage(objectNameSingular, record); + + const navigate = useNavigateApp(); + + const handleOpenRecord = () => { + navigate(AppPath.RecordShowPage, { + objectNameSingular, + objectRecordId: record.id, + }); + closeCommandMenu(); + }; + + useScopedHotkeys( + ['ctrl+Enter,meta+Enter'], + handleOpenRecord, + AppHotkeyScope.CommandMenuOpen, + [closeCommandMenu, navigate, objectNameSingular, record.id], + ); + + useScopedHotkeys( + ['ctrl+Enter,meta+Enter'], + handleOpenRecord, + RightDrawerActionMenuDropdownHotkeyScope.RightDrawerActionMenuDropdown, + [closeCommandMenu, navigate, objectNameSingular, record.id], + ); + + return ( + +