The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Open emails and calendar events inside command menu (#9477)
Raphaël Bosie62079ab6da8
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventDetails.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventDetails.tsxindex 581e6599eb1..641a99d68cc 100644--- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventDetails.tsx+++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventDetails.tsx@@ -1,4 +1,3 @@-import React from 'react';import { css, useTheme } from '@emotion/react';import styled from '@emotion/styled';import {diff --git a/packages/twenty-front/src/modules/activities/calendar/right-drawer/components/RightDrawerCalendarEvent.tsx b/packages/twenty-front/src/modules/activities/calendar/right-drawer/components/RightDrawerCalendarEvent.tsxindex 24f78d71539..4e3ee38ae75 100644--- a/packages/twenty-front/src/modules/activities/calendar/right-drawer/components/RightDrawerCalendarEvent.tsx+++ b/packages/twenty-front/src/modules/activities/calendar/right-drawer/components/RightDrawerCalendarEvent.tsx@@ -7,6 +7,7 @@ import { CalendarEvent } from '@/activities/calendar/types/CalendarEvent';import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord';import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';import { RecordValueSetterEffect } from '@/object-record/record-store/components/RecordValueSetterEffect';+import { RecordFieldValueSelectorContextProvider } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext';import { useUpsertRecordsInStore } from '@/object-record/record-store/hooks/useUpsertRecordsInStore';export const RightDrawerCalendarEvent = () => {@@ -26,10 +27,10 @@ export const RightDrawerCalendarEvent = () => {}return (- <>+ <RecordFieldValueSelectorContextProvider><CalendarEventDetailsEffect record={calendarEvent} /><RecordValueSetterEffect recordId={calendarEvent.id} /><CalendarEventDetails calendarEvent={calendarEvent} />- </>+ </RecordFieldValueSelectorContextProvider>);};diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuPages.ts b/packages/twenty-front/src/modules/command-menu/components/CommandMenuPages.tsindex e783f76dee7..378585df6e6 100644--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuPages.ts+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuPages.ts@@ -1,4 +1,6 @@export enum CommandMenuPages {Root = 'root',ViewRecord = 'view-record',+ ViewEmailThread = 'view-email-thread',+ ViewCalendarEvent = 'view-calendar-event',}diff --git a/packages/twenty-front/src/modules/command-menu/constants/CommandMenuPagesConfig.tsx b/packages/twenty-front/src/modules/command-menu/constants/CommandMenuPagesConfig.tsxindex ca1a09097dd..ff03078743a 100644--- a/packages/twenty-front/src/modules/command-menu/constants/CommandMenuPagesConfig.tsx+++ b/packages/twenty-front/src/modules/command-menu/constants/CommandMenuPagesConfig.tsx@@ -1,3 +1,5 @@+import { RightDrawerCalendarEvent } from '@/activities/calendar/right-drawer/components/RightDrawerCalendarEvent';+import { RightDrawerEmailThread } from '@/activities/emails/right-drawer/components/RightDrawerEmailThread';import { CommandMenu } from '@/command-menu/components/CommandMenu';import { CommandMenuPages } from '@/command-menu/components/CommandMenuPages';import { RightDrawerRecord } from '@/object-record/record-right-drawer/components/RightDrawerRecord';@@ -8,4 +10,6 @@ export const COMMAND_MENU_PAGES_CONFIG = new Map<>([[CommandMenuPages.Root, <CommandMenu />],[CommandMenuPages.ViewRecord, <RightDrawerRecord />],+ [CommandMenuPages.ViewEmailThread, <RightDrawerEmailThread />],+ [CommandMenuPages.ViewCalendarEvent, <RightDrawerCalendarEvent />],]);diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.tsindex 57640c7ee82..05c2c4e99ce 100644--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts@@ -3,10 +3,10 @@ import { useRecoilCallback, useRecoilValue } from 'recoil';import { isRightDrawerMinimizedState } from '@/ui/layout/right-drawer/states/isRightDrawerMinimizedState';import { rightDrawerCloseEventState } from '@/ui/layout/right-drawer/states/rightDrawerCloseEventsState';-import { CommandMenuPages } from '@/command-menu/components/CommandMenuPages';import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';import { commandMenuPageState } from '@/command-menu/states/commandMenuPageState';import { emitRightDrawerCloseEvent } from '@/ui/layout/right-drawer/utils/emitRightDrawerCloseEvent';+import { mapRightDrawerPageToCommandMenuPage } from '@/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage';import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';import { FeatureFlagKey } from '~/generated-metadata/graphql';import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';@@ -28,11 +28,11 @@ export const useRightDrawer = () => {const openRightDrawer = useRecoilCallback(({ set }) =>(rightDrawerPage: RightDrawerPages) => {- if (- isCommandMenuV2Enabled &&- rightDrawerPage === RightDrawerPages.ViewRecord- ) {- set(commandMenuPageState, CommandMenuPages.ViewRecord);+ if (isCommandMenuV2Enabled) {+ const commandMenuPage =+ mapRightDrawerPageToCommandMenuPage(rightDrawerPage);++ set(commandMenuPageState, commandMenuPage);openCommandMenu();return;}diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage.tsnew file mode 100644index 00000000000..6a90ea08015--- /dev/null+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage.ts@@ -0,0 +1,17 @@+import { CommandMenuPages } from '@/command-menu/components/CommandMenuPages';+import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';++export const mapRightDrawerPageToCommandMenuPage = (+ rightDrawerPage: RightDrawerPages,+) => {+ switch (rightDrawerPage) {+ case RightDrawerPages.ViewRecord:+ return CommandMenuPages.ViewRecord;+ case RightDrawerPages.ViewEmailThread:+ return CommandMenuPages.ViewEmailThread;+ case RightDrawerPages.ViewCalendarEvent:+ return CommandMenuPages.ViewCalendarEvent;+ default:+ return CommandMenuPages.Root;+ }+};