diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DefaultActionsConfig.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DefaultActionsConfig.ts index 52803a836..e786900de 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DefaultActionsConfig.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/DefaultActionsConfig.ts @@ -6,6 +6,7 @@ import { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/ import { useCreateNewTableRecordNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useCreateNewTableRecordNoSelectionRecordAction'; import { useImportRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useImportRecordsNoSelectionRecordAction'; import { useSeeDeletedRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeDeletedRecordsNoSelectionRecordAction'; +import { useSeeWorkflowsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction'; import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey'; import { useAddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction'; import { useDeleteSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useDeleteSingleRecordAction'; @@ -35,6 +36,7 @@ import { IconPlus, IconRefresh, IconRotate2, + IconSettingsAutomation, IconTrash, IconTrashX, } from 'twenty-ui'; @@ -276,4 +278,18 @@ export const DEFAULT_ACTIONS_CONFIG: Record< availableOn: [ActionViewType.INDEX_PAGE_BULK_SELECTION], useAction: useRestoreMultipleRecordsAction, }, + seeAllWorkflows: { + type: ActionMenuEntryType.Navigation, + scope: ActionMenuEntryScope.Global, + key: NoSelectionRecordActionKeys.SEE_WORKFLOWS, + label: msg`Go to workflows`, + shortLabel: msg`See workflows`, + position: 17, + Icon: IconSettingsAutomation, + accent: 'default', + isPinned: false, + availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], + useAction: useSeeWorkflowsNoSelectionRecordAction, + hotKeys: ['G', 'W'], + }, }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.ts index 8eb1d76f7..b22c6b277 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowActionsConfig.ts @@ -5,6 +5,7 @@ import { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/ import { useCreateNewTableRecordNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useCreateNewTableRecordNoSelectionRecordAction'; import { useImportRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useImportRecordsNoSelectionRecordAction'; import { useSeeDeletedRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeDeletedRecordsNoSelectionRecordAction'; +import { useSeeRunsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeRunsNoSelectionRecordAction'; import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey'; import { useAddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction'; import { useDeleteSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useDeleteSingleRecordAction'; @@ -347,6 +348,19 @@ export const WORKFLOW_ACTIONS_CONFIG: Record< availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], useAction: useImportRecordsNoSelectionRecordAction, }, + seeAllRuns: { + type: ActionMenuEntryType.Navigation, + scope: ActionMenuEntryScope.Global, + key: NoSelectionRecordActionKeys.SEE_RUNS, + label: msg`Go to runs`, + shortLabel: msg`See runs`, + position: 21, + Icon: IconHistoryToggle, + accent: 'default', + isPinned: true, + availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], + useAction: useSeeRunsNoSelectionRecordAction, + }, // TODO: uncomment when restore is implemented for workflows // restoreSingleRecord: { // type: ActionMenuEntryType.Standard, diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig.ts index 410559e71..6d8ec9a2c 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig.ts @@ -1,12 +1,16 @@ import { useExportMultipleRecordsAction } from '@/action-menu/actions/record-actions/multiple-records/hooks/useExportMultipleRecordsAction'; import { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/multiple-records/types/MultipleRecordsActionKeys'; import { useSeeDeletedRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeDeletedRecordsNoSelectionRecordAction'; +import { useSeeWorkflowsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction'; import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey'; import { useAddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction'; import { useNavigateToNextRecordSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useNavigateToNextRecordSingleRecordAction'; import { useNavigateToPreviousRecordSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useNavigateToPreviousRecordSingleRecordAction'; import { useRemoveFromFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useRemoveFromFavoritesSingleRecordAction'; import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey'; +import { useSeeVersionWorkflowRunSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeVersionWorkflowRunSingleRecordAction'; +import { useSeeWorkflowWorkflowRunSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeWorkflowWorkflowRunSingleRecordAction'; +import { WorkflowRunSingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/workflow-run-actions/types/WorkflowRunSingleRecordActionsKeys'; import { ActionHook } from '@/action-menu/actions/types/ActionHook'; import { ActionViewType } from '@/action-menu/actions/types/ActionViewType'; import { @@ -21,7 +25,9 @@ import { IconDatabaseExport, IconHeart, IconHeartOff, + IconHistory, IconRotate2, + IconSettingsAutomation, } from 'twenty-ui'; export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< @@ -30,13 +36,43 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< useAction: ActionHook; } > = { + seeWorkflowSingleRecord: { + key: WorkflowRunSingleRecordActionKeys.SEE_WORKFLOW, + label: msg`See workflow`, + shortLabel: msg`See workflow`, + position: 0, + isPinned: true, + type: ActionMenuEntryType.Standard, + scope: ActionMenuEntryScope.RecordSelection, + Icon: IconSettingsAutomation, + availableOn: [ + ActionViewType.SHOW_PAGE, + ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, + ], + useAction: useSeeWorkflowWorkflowRunSingleRecordAction, + }, + seeVersionSingleRecord: { + key: WorkflowRunSingleRecordActionKeys.SEE_VERSION, + label: msg`See version`, + shortLabel: msg`See version`, + position: 1, + isPinned: true, + type: ActionMenuEntryType.Standard, + scope: ActionMenuEntryScope.RecordSelection, + Icon: IconHistory, + availableOn: [ + ActionViewType.SHOW_PAGE, + ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, + ], + useAction: useSeeVersionWorkflowRunSingleRecordAction, + }, addToFavoritesSingleRecord: { type: ActionMenuEntryType.Standard, scope: ActionMenuEntryScope.RecordSelection, key: SingleRecordActionKeys.ADD_TO_FAVORITES, label: msg`Add to favorites`, shortLabel: msg`Add to favorites`, - position: 0, + position: 2, isPinned: false, Icon: IconHeart, availableOn: [ @@ -52,7 +88,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< label: msg`Remove from favorites`, shortLabel: msg`Remove from favorites`, isPinned: false, - position: 1, + position: 3, Icon: IconHeartOff, availableOn: [ ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, @@ -65,7 +101,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< scope: ActionMenuEntryScope.RecordSelection, key: SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD, label: msg`Navigate to previous run`, - position: 2, + position: 4, isPinned: true, Icon: IconChevronUp, availableOn: [ActionViewType.SHOW_PAGE], @@ -76,7 +112,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< scope: ActionMenuEntryScope.RecordSelection, key: SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD, label: msg`Navigate to next run`, - position: 3, + position: 5, isPinned: true, Icon: IconChevronDown, availableOn: [ActionViewType.SHOW_PAGE], @@ -88,7 +124,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< key: SingleRecordActionKeys.EXPORT, label: msg`Export run`, shortLabel: msg`Export`, - position: 4, + position: 6, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -104,7 +140,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< key: MultipleRecordsActionKeys.EXPORT, label: msg`Export runs`, shortLabel: msg`Export`, - position: 5, + position: 7, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -117,7 +153,7 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< key: NoSelectionRecordActionKeys.EXPORT_VIEW, label: msg`Export view`, shortLabel: msg`Export`, - position: 6, + position: 8, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -130,11 +166,25 @@ export const WORKFLOW_RUNS_ACTIONS_CONFIG: Record< key: NoSelectionRecordActionKeys.SEE_DELETED_RECORDS, label: msg`See deleted runs`, shortLabel: msg`Deleted runs`, - position: 7, + position: 9, Icon: IconRotate2, accent: 'default', isPinned: false, availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], useAction: useSeeDeletedRecordsNoSelectionRecordAction, }, + seeAllWorkflows: { + type: ActionMenuEntryType.Navigation, + scope: ActionMenuEntryScope.Global, + key: NoSelectionRecordActionKeys.SEE_WORKFLOWS, + label: msg`Go to workflows`, + shortLabel: msg`See workflows`, + position: 10, + Icon: IconSettingsAutomation, + accent: 'default', + isPinned: true, + availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], + useAction: useSeeWorkflowsNoSelectionRecordAction, + hotKeys: ['G', 'W'], + }, }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig.ts index ed40e859c..19b9d3e78 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig.ts @@ -1,6 +1,8 @@ import { useExportMultipleRecordsAction } from '@/action-menu/actions/record-actions/multiple-records/hooks/useExportMultipleRecordsAction'; import { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/multiple-records/types/MultipleRecordsActionKeys'; import { useSeeDeletedRecordsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeDeletedRecordsNoSelectionRecordAction'; +import { useSeeRunsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeRunsNoSelectionRecordAction'; +import { useSeeWorkflowsNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction'; import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey'; import { useAddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction'; import { useNavigateToNextRecordSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useNavigateToNextRecordSingleRecordAction'; @@ -9,6 +11,7 @@ import { useRemoveFromFavoritesSingleRecordAction } from '@/action-menu/actions/ import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey'; import { useSeeRunsWorkflowVersionSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeRunsWorkflowVersionSingleRecordAction'; import { useSeeVersionsWorkflowVersionSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeVersionsWorkflowVersionSingleRecordAction'; +import { useSeeWorkflowWorkflowVersionSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeWorkflowWorkflowVersionSingleRecordAction'; import { useUseAsDraftWorkflowVersionSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useUseAsDraftWorkflowVersionSingleRecordAction'; import { WorkflowVersionSingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/workflow-version-actions/types/WorkflowVersionSingleRecordActionsKeys'; import { ActionHook } from '@/action-menu/actions/types/ActionHook'; @@ -29,6 +32,7 @@ import { IconHistoryToggle, IconPencil, IconRotate2, + IconSettingsAutomation, } from 'twenty-ui'; export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< @@ -52,11 +56,27 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< ], useAction: useUseAsDraftWorkflowVersionSingleRecordAction, }, + seeWorkflowSingleRecord: { + key: WorkflowVersionSingleRecordActionKeys.SEE_WORKFLOW, + label: msg`See workflow`, + shortLabel: msg`See workflow`, + position: 2, + isPinned: true, + type: ActionMenuEntryType.Standard, + scope: ActionMenuEntryScope.RecordSelection, + Icon: IconSettingsAutomation, + availableOn: [ + ActionViewType.SHOW_PAGE, + ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, + ], + useAction: useSeeWorkflowWorkflowVersionSingleRecordAction, + }, seeWorkflowRunsSingleRecord: { key: WorkflowVersionSingleRecordActionKeys.SEE_RUNS, label: msg`See runs`, shortLabel: msg`See runs`, - position: 2, + position: 3, + isPinned: true, type: ActionMenuEntryType.Standard, scope: ActionMenuEntryScope.RecordSelection, Icon: IconHistoryToggle, @@ -70,7 +90,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: WorkflowVersionSingleRecordActionKeys.SEE_VERSIONS, label: msg`See versions history`, shortLabel: msg`See versions`, - position: 3, + position: 4, type: ActionMenuEntryType.Standard, scope: ActionMenuEntryScope.RecordSelection, Icon: IconHistory, @@ -85,7 +105,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< scope: ActionMenuEntryScope.RecordSelection, key: SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD, label: msg`Navigate to previous version`, - position: 4, + position: 5, Icon: IconChevronUp, availableOn: [ActionViewType.SHOW_PAGE], useAction: useNavigateToPreviousRecordSingleRecordAction, @@ -95,7 +115,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< scope: ActionMenuEntryScope.RecordSelection, key: SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD, label: msg`Navigate to next version`, - position: 5, + position: 6, Icon: IconChevronDown, availableOn: [ActionViewType.SHOW_PAGE], useAction: useNavigateToNextRecordSingleRecordAction, @@ -106,7 +126,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: SingleRecordActionKeys.ADD_TO_FAVORITES, label: msg`Add to favorites`, shortLabel: msg`Add to favorites`, - position: 6, + position: 7, isPinned: false, Icon: IconHeart, availableOn: [ @@ -122,7 +142,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< label: msg`Remove from favorites`, shortLabel: msg`Remove from favorites`, isPinned: false, - position: 7, + position: 8, Icon: IconHeartOff, availableOn: [ ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, @@ -136,7 +156,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: SingleRecordActionKeys.EXPORT, label: msg`Export version`, shortLabel: msg`Export`, - position: 8, + position: 9, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -152,7 +172,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: MultipleRecordsActionKeys.EXPORT, label: msg`Export versions`, shortLabel: msg`Export`, - position: 9, + position: 10, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -165,7 +185,7 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: NoSelectionRecordActionKeys.EXPORT_VIEW, label: msg`Export view`, shortLabel: msg`Export`, - position: 10, + position: 11, Icon: IconDatabaseExport, accent: 'default', isPinned: false, @@ -178,11 +198,38 @@ export const WORKFLOW_VERSIONS_ACTIONS_CONFIG: Record< key: NoSelectionRecordActionKeys.SEE_DELETED_RECORDS, label: msg`See deleted versions`, shortLabel: msg`Deleted versions`, - position: 11, + position: 12, Icon: IconRotate2, accent: 'default', isPinned: false, availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], useAction: useSeeDeletedRecordsNoSelectionRecordAction, }, + seeAllWorkflows: { + type: ActionMenuEntryType.Navigation, + scope: ActionMenuEntryScope.Global, + key: NoSelectionRecordActionKeys.SEE_WORKFLOWS, + label: msg`Go to workflows`, + shortLabel: msg`See workflows`, + position: 13, + Icon: IconSettingsAutomation, + accent: 'default', + isPinned: true, + availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], + useAction: useSeeWorkflowsNoSelectionRecordAction, + hotKeys: ['G', 'W'], + }, + seeAllRuns: { + type: ActionMenuEntryType.Navigation, + scope: ActionMenuEntryScope.Global, + key: NoSelectionRecordActionKeys.SEE_RUNS, + label: msg`Go to runs`, + shortLabel: msg`See runs`, + position: 14, + Icon: IconHistoryToggle, + accent: 'default', + isPinned: true, + availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], + useAction: useSeeRunsNoSelectionRecordAction, + }, }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeRunsNoSelectionRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeRunsNoSelectionRecordAction.ts new file mode 100644 index 000000000..0d42d9f4a --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeRunsNoSelectionRecordAction.ts @@ -0,0 +1,22 @@ +import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook'; +import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural'; +import { AppPath } from '@/types/AppPath'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +export const useSeeRunsNoSelectionRecordAction: ActionHookWithoutObjectMetadataItem = + () => { + const navigateApp = useNavigateApp(); + + const shouldBeRegistered = true; + + const onClick = () => { + navigateApp(AppPath.RecordIndexPage, { + objectNamePlural: CoreObjectNamePlural.WorkflowRun, + }); + }; + + return { + shouldBeRegistered, + onClick, + }; + }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction.ts new file mode 100644 index 000000000..8bae60b93 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/hooks/useSeeWorkflowsNoSelectionRecordAction.ts @@ -0,0 +1,28 @@ +import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook'; +import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlural'; +import { AppPath } from '@/types/AppPath'; +import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; +import { FeatureFlagKey } from '~/generated-metadata/graphql'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +export const useSeeWorkflowsNoSelectionRecordAction: ActionHookWithoutObjectMetadataItem = + () => { + const navigateApp = useNavigateApp(); + + const isWorkflowsEnabled = useIsFeatureEnabled( + FeatureFlagKey.IsWorkflowEnabled, + ); + + const shouldBeRegistered = isWorkflowsEnabled; + + const onClick = () => { + navigateApp(AppPath.RecordIndexPage, { + objectNamePlural: CoreObjectNamePlural.Workflow, + }); + }; + + return { + shouldBeRegistered, + onClick, + }; + }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey.ts index 56b034434..9befe3be9 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey.ts @@ -3,4 +3,6 @@ export enum NoSelectionRecordActionKeys { CREATE_NEW_RECORD = 'create-new-record', SEE_DELETED_RECORDS = 'see-deleted-records', IMPORT_RECORDS = 'import-records', + SEE_RUNS = 'see-runs', + SEE_WORKFLOWS = 'see-workflows', } diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeVersionWorkflowRunSingleRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeVersionWorkflowRunSingleRecordAction.ts new file mode 100644 index 000000000..6ea3c516a --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeVersionWorkflowRunSingleRecordAction.ts @@ -0,0 +1,33 @@ +import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow'; +import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; +import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; +import { AppPath } from '@/types/AppPath'; +import { useRecoilValue } from 'recoil'; +import { isDefined } from 'twenty-shared/utils'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +export const useSeeVersionWorkflowRunSingleRecordAction: ActionHookWithoutObjectMetadataItem = + () => { + const recordId = useSelectedRecordIdOrThrow(); + + const workflowRun = useRecoilValue(recordStoreFamilyState(recordId)); + + const navigateApp = useNavigateApp(); + + const shouldBeRegistered = isDefined(workflowRun?.workflowVersion?.id); + + const onClick = () => { + if (!shouldBeRegistered || !workflowRun?.workflowVersion?.id) return; + + navigateApp(AppPath.RecordShowPage, { + objectNameSingular: CoreObjectNameSingular.WorkflowVersion, + objectRecordId: workflowRun.workflowVersion.id, + }); + }; + + return { + shouldBeRegistered, + onClick, + }; + }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeWorkflowWorkflowRunSingleRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeWorkflowWorkflowRunSingleRecordAction.ts new file mode 100644 index 000000000..0fd5b6a18 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/hooks/useSeeWorkflowWorkflowRunSingleRecordAction.ts @@ -0,0 +1,33 @@ +import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow'; +import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; +import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; +import { AppPath } from '@/types/AppPath'; +import { useRecoilValue } from 'recoil'; +import { isDefined } from 'twenty-shared/utils'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +export const useSeeWorkflowWorkflowRunSingleRecordAction: ActionHookWithoutObjectMetadataItem = + () => { + const recordId = useSelectedRecordIdOrThrow(); + + const workflowRun = useRecoilValue(recordStoreFamilyState(recordId)); + + const navigateApp = useNavigateApp(); + + const shouldBeRegistered = isDefined(workflowRun?.workflow?.id); + + const onClick = () => { + if (!shouldBeRegistered || !workflowRun?.workflow?.id) return; + + navigateApp(AppPath.RecordShowPage, { + objectNameSingular: CoreObjectNameSingular.Workflow, + objectRecordId: workflowRun.workflow.id, + }); + }; + + return { + shouldBeRegistered, + onClick, + }; + }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/types/WorkflowRunSingleRecordActionsKeys.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/types/WorkflowRunSingleRecordActionsKeys.ts new file mode 100644 index 000000000..ead093f8c --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-run-actions/types/WorkflowRunSingleRecordActionsKeys.ts @@ -0,0 +1,4 @@ +export enum WorkflowRunSingleRecordActionKeys { + SEE_WORKFLOW = 'see-workflow-workflow-run-single-record', + SEE_VERSION = 'see-version-workflow-run-single-record', +} diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeWorkflowWorkflowVersionSingleRecordAction.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeWorkflowWorkflowVersionSingleRecordAction.ts new file mode 100644 index 000000000..b4fdb2103 --- /dev/null +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/hooks/useSeeWorkflowWorkflowVersionSingleRecordAction.ts @@ -0,0 +1,33 @@ +import { useSelectedRecordIdOrThrow } from '@/action-menu/actions/record-actions/single-record/hooks/useSelectedRecordIdOrThrow'; +import { ActionHookWithoutObjectMetadataItem } from '@/action-menu/actions/types/ActionHook'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; +import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; +import { AppPath } from '@/types/AppPath'; +import { useRecoilValue } from 'recoil'; +import { isDefined } from 'twenty-shared/utils'; +import { useNavigateApp } from '~/hooks/useNavigateApp'; + +export const useSeeWorkflowWorkflowVersionSingleRecordAction: ActionHookWithoutObjectMetadataItem = + () => { + const recordId = useSelectedRecordIdOrThrow(); + + const workflowVersion = useRecoilValue(recordStoreFamilyState(recordId)); + + const navigateApp = useNavigateApp(); + + const shouldBeRegistered = isDefined(workflowVersion?.workflow?.id); + + const onClick = () => { + if (!shouldBeRegistered || !workflowVersion?.workflow?.id) return; + + navigateApp(AppPath.RecordShowPage, { + objectNameSingular: CoreObjectNameSingular.Workflow, + objectRecordId: workflowVersion.workflow.id, + }); + }; + + return { + shouldBeRegistered, + onClick, + }; + }; diff --git a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/types/WorkflowVersionSingleRecordActionsKeys.ts b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/types/WorkflowVersionSingleRecordActionsKeys.ts index d6515b28e..293b2af66 100644 --- a/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/types/WorkflowVersionSingleRecordActionsKeys.ts +++ b/packages/twenty-front/src/modules/action-menu/actions/record-actions/single-record/workflow-version-actions/types/WorkflowVersionSingleRecordActionsKeys.ts @@ -2,4 +2,5 @@ export enum WorkflowVersionSingleRecordActionKeys { SEE_RUNS = 'see-runs-workflow-version-single-record', SEE_VERSIONS = 'see-versions-workflow-version-single-record', USE_AS_DRAFT = 'use-as-draft-workflow-version-single-record', + SEE_WORKFLOW = 'see-workflow-workflow-version-single-record', } diff --git a/packages/twenty-front/src/modules/action-menu/types/ActionMenuEntry.ts b/packages/twenty-front/src/modules/action-menu/types/ActionMenuEntry.ts index 4bfa8185a..f3a2546ea 100644 --- a/packages/twenty-front/src/modules/action-menu/types/ActionMenuEntry.ts +++ b/packages/twenty-front/src/modules/action-menu/types/ActionMenuEntry.ts @@ -8,6 +8,7 @@ export enum ActionMenuEntryType { Standard = 'Standard', WorkflowRun = 'WorkflowRun', Fallback = 'Fallback', + Navigation = 'Navigation', } export enum ActionMenuEntryScope { diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuCommands.tsx b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuCommands.tsx index 0d568c02e..b441d2670 100644 --- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuCommands.tsx +++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuCommands.tsx @@ -17,7 +17,28 @@ export const useCommandMenuCommands = () => { actionMenuEntriesComponentSelector, ); - const navigateCommands = Object.values(COMMAND_MENU_NAVIGATE_COMMANDS); + const navigateCommands = actionMenuEntries + ?.filter( + (actionMenuEntry) => + actionMenuEntry.type === ActionMenuEntryType.Navigation, + ) + ?.map((actionMenuEntry) => ({ + id: actionMenuEntry.key, + label: i18n._(actionMenuEntry.label), + Icon: actionMenuEntry.Icon, + onCommandClick: actionMenuEntry.onClick, + type: CommandType.Navigate, + scope: CommandScope.Global, + hotKeys: actionMenuEntry.hotKeys, + })) as Command[]; + + // TODO: refactor this to use the config + const navigateCommandsFromConstants = Object.values( + COMMAND_MENU_NAVIGATE_COMMANDS, + ); + const allNavigateCommands = navigateCommands.concat( + navigateCommandsFromConstants, + ); const actionRecordSelectionCommands: Command[] = actionMenuEntries ?.filter( @@ -115,7 +136,7 @@ export const useCommandMenuCommands = () => { })); return { - navigateCommands, + navigateCommands: allNavigateCommands, actionRecordSelectionCommands, actionGlobalCommands, actionObjectCommands,