Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate right drawer record page to the command menu #9459

Merged
merged 23 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/twenty-front/src/generated-metadata/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export type CreateAppTokenInput = {
expiresAt: Scalars['DateTime']['input'];
};

export type CreateDraftFromWorkflowVersionInput = {
/** Workflow ID */
workflowId: Scalars['String']['input'];
/** Workflow version ID */
workflowVersionIdToCopy: Scalars['String']['input'];
};

export type CreateFieldInput = {
defaultValue?: InputMaybe<Scalars['JSON']['input']>;
description?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -387,6 +394,7 @@ export enum FeatureFlagKey {
IsAggregateQueryEnabled = 'IsAggregateQueryEnabled',
IsAirtableIntegrationEnabled = 'IsAirtableIntegrationEnabled',
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
IsCopilotEnabled = 'IsCopilotEnabled',
IsCrmMigrationEnabled = 'IsCrmMigrationEnabled',
IsEventObjectEnabled = 'IsEventObjectEnabled',
Expand All @@ -395,7 +403,6 @@ export enum FeatureFlagKey {
IsGmailSendEmailScopeEnabled = 'IsGmailSendEmailScopeEnabled',
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
IsPageHeaderV2Enabled = 'IsPageHeaderV2Enabled',
IsPostgreSqlIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
IsSsoEnabled = 'IsSSOEnabled',
IsStripeIntegrationEnabled = 'IsStripeIntegrationEnabled',
Expand Down Expand Up @@ -579,6 +586,7 @@ export type Mutation = {
challenge: LoginToken;
checkoutSession: SessionEntity;
computeStepOutputSchema: Scalars['JSON']['output'];
createDraftFromWorkflowVersion: Scalars['Boolean']['output'];
createOIDCIdentityProvider: SetupSsoOutput;
createOneAppToken: AppToken;
createOneField: Field;
Expand Down Expand Up @@ -685,6 +693,11 @@ export type MutationComputeStepOutputSchemaArgs = {
};


export type MutationCreateDraftFromWorkflowVersionArgs = {
input: CreateDraftFromWorkflowVersionInput;
};


export type MutationCreateOidcIdentityProviderArgs = {
input: SetupOidcSsoInput;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export enum FeatureFlagKey {
IsAggregateQueryEnabled = 'IsAggregateQueryEnabled',
IsAirtableIntegrationEnabled = 'IsAirtableIntegrationEnabled',
IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled',
IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled',
IsCopilotEnabled = 'IsCopilotEnabled',
IsCrmMigrationEnabled = 'IsCrmMigrationEnabled',
IsEventObjectEnabled = 'IsEventObjectEnabled',
Expand All @@ -332,7 +333,6 @@ export enum FeatureFlagKey {
IsGmailSendEmailScopeEnabled = 'IsGmailSendEmailScopeEnabled',
IsJsonFilterEnabled = 'IsJsonFilterEnabled',
IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled',
IsPageHeaderV2Enabled = 'IsPageHeaderV2Enabled',
IsPostgreSqlIntegrationEnabled = 'IsPostgreSQLIntegrationEnabled',
IsSsoEnabled = 'IsSSOEnabled',
IsStripeIntegrationEnabled = 'IsStripeIntegrationEnabled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const RecordActionMenuEntriesSetter = () => {
FeatureFlagKey.IsWorkflowEnabled,
);

const isPageHeaderV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsPageHeaderV2Enabled,
const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

if (
Expand All @@ -53,7 +53,7 @@ export const RecordActionMenuEntriesSetter = () => {

const actionConfig = getActionConfig(
objectMetadataItem,
isPageHeaderV2Enabled,
isCommandMenuV2Enabled,
);

const actionsToRegister = isDefined(viewType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';

export const getActionConfig = (
objectMetadataItem: ObjectMetadataItem,
isPageHeaderV2Enabled: boolean,
isCommandMenuV2Enabled: boolean,
) => {
switch (objectMetadataItem.nameSingular) {
case CoreObjectNameSingular.Workflow:
Expand All @@ -18,7 +18,7 @@ export const getActionConfig = (
case CoreObjectNameSingular.WorkflowRun:
return WORKFLOW_RUNS_ACTIONS_CONFIG;
default:
return isPageHeaderV2Enabled
return isCommandMenuV2Enabled
? DEFAULT_ACTIONS_CONFIG_V2
: DEFAULT_ACTIONS_CONFIG_V1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const RecordIndexActionMenu = ({ indexId }: { indexId: string }) => {
FeatureFlagKey.IsWorkflowEnabled,
);

const isPageHeaderV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsPageHeaderV2Enabled,
const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

const isMobile = useIsMobile();
Expand Down Expand Up @@ -54,7 +54,7 @@ export const RecordIndexActionMenu = ({ indexId }: { indexId: string }) => {
},
}}
>
{isPageHeaderV2Enabled ? (
{isCommandMenuV2Enabled ? (
<>{!isMobile && <RecordIndexActionMenuButtons />}</>
) : (
bosiraphael marked this conversation as resolved.
Show resolved Hide resolved
<RecordIndexActionMenuBar />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const RecordShowActionMenu = ({
FeatureFlagKey.IsWorkflowEnabled,
);

const isPageHeaderV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsPageHeaderV2Enabled,
const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

// TODO: refactor RecordShowPageBaseHeader to use the context store
Expand All @@ -48,7 +48,7 @@ export const RecordShowActionMenu = ({
onActionExecutedCallback: () => {},
}}
>
{isPageHeaderV2Enabled ? (
{isCommandMenuV2Enabled ? (
<RecordShowActionMenuButtons />
) : (
<RecordShowPageBaseHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import { Note } from '@/activities/types/Note';
import { Task } from '@/activities/types/Task';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { BlockEditor } from '@/ui/input/editor/components/BlockEditor';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import '@blocknote/core/fonts/inter.css';
import '@blocknote/mantine/style.css';
import '@blocknote/react/style.css';
import { FeatureFlagKey } from '~/generated-metadata/graphql';

type ActivityRichTextEditorProps = {
activityId: string;
Expand All @@ -46,6 +49,10 @@ export const ActivityRichTextEditor = ({
const cache = useApolloClient().cache;
const activity = activityInStore as Task | Note | null;

const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

const { objectMetadataItem: objectMetadataItemActivity } =
useObjectMetadataItem({
objectNameSingular: activityObjectNameSingular,
Expand Down Expand Up @@ -245,7 +252,9 @@ export const ActivityRichTextEditor = ({
editor.setTextCursorPosition(newBlockId, 'end');
editor.focus();
},
RightDrawerHotkeyScope.RightDrawer,
isCommandMenuV2Enabled
? AppHotkeyScope.CommandMenuOpen
: RightDrawerHotkeyScope.RightDrawer,
[],
{
preventDefault: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
import { RightDrawerHotkeyScope } from '@/ui/layout/right-drawer/types/RightDrawerHotkeyScope';
import { RightDrawerPages } from '@/ui/layout/right-drawer/types/RightDrawerPages';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { FeatureFlagKey } from '~/generated-metadata/graphql';

export const useOpenActivityRightDrawer = ({
objectNameSingular,
Expand All @@ -25,6 +28,10 @@ export const useOpenActivityRightDrawer = ({

const setHotkeyScope = useSetHotkeyScope();

const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

return (activityId: string) => {
if (
isRightDrawerOpen &&
Expand All @@ -34,7 +41,12 @@ export const useOpenActivityRightDrawer = ({
return;
}

setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
if (isCommandMenuV2Enabled) {
setHotkeyScope(AppHotkeyScope.CommandMenuOpen, { goto: false });
} else {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
}

setViewableRecordId(activityId);
setViewableRecordNameSingular(objectNameSingular);
openRightDrawer(RightDrawerPages.ViewRecord);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import { isNewViewableRecordLoadingState } from '@/object-record/record-right-drawer/states/isNewViewableRecordLoading';
import { viewableRecordNameSingularState } from '@/object-record/record-right-drawer/states/viewableRecordNameSingularState';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { FeatureFlagKey } from '~/generated-metadata/graphql';
import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';

export const useOpenCreateActivityDrawer = ({
Expand Down Expand Up @@ -60,6 +63,10 @@ export const useOpenCreateActivityDrawer = ({
isUpsertingActivityInDBState,
);

const isCommandMenuV2Enabled = useIsFeatureEnabled(
FeatureFlagKey.IsCommandMenuV2Enabled,
);

const openCreateActivityDrawer = async ({
targetableObjects,
customAssignee,
Expand Down Expand Up @@ -108,7 +115,12 @@ export const useOpenCreateActivityDrawer = ({
setActivityTargetableEntityArray([]);
}

setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
if (isCommandMenuV2Enabled) {
setHotkeyScope(AppHotkeyScope.CommandMenuOpen, { goto: false });
} else {
setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
}

setViewableRecordId(activity.id);

setIsUpsertingActivityInDB(false);
Expand Down
Loading
Loading