Add create new record action to workflows (#9692)

- Added create new record action to `WorkflowActionsConfig`

As @FelixMalfait suggested
[here](https://github.com/twentyhq/core-team-issues/issues/72), we
should introduce an inheritance system for actions.
This commit is contained in:
Raphaël Bosi
2025-01-16 17:10:16 +01:00
committed by GitHub
parent 2eb98bf966
commit 0ff8637469

View File

@ -1,6 +1,7 @@
import { useDeleteMultipleRecordsAction } from '@/action-menu/actions/record-actions/multiple-records/hooks/useDeleteMultipleRecordsAction'; import { useDeleteMultipleRecordsAction } from '@/action-menu/actions/record-actions/multiple-records/hooks/useDeleteMultipleRecordsAction';
import { useExportMultipleRecordsAction } from '@/action-menu/actions/record-actions/multiple-records/hooks/useExportMultipleRecordsAction'; 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 { MultipleRecordsActionKeys } from '@/action-menu/actions/record-actions/multiple-records/types/MultipleRecordsActionKeys';
import { useCreateNewTableRecordNoSelectionRecordAction } from '@/action-menu/actions/record-actions/no-selection/hooks/useCreateNewTableRecordNoSelectionRecordAction';
import { NoSelectionRecordActionKeys } from '@/action-menu/actions/record-actions/no-selection/types/NoSelectionRecordActionsKey'; 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 { useAddToFavoritesSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useAddToFavoritesSingleRecordAction';
import { useDeleteSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useDeleteSingleRecordAction'; import { useDeleteSingleRecordAction } from '@/action-menu/actions/record-actions/single-record/hooks/useDeleteSingleRecordAction';
@ -34,6 +35,7 @@ import {
IconHistoryToggle, IconHistoryToggle,
IconPlayerPause, IconPlayerPause,
IconPlayerPlay, IconPlayerPlay,
IconPlus,
IconPower, IconPower,
IconTrash, IconTrash,
IconTrashX, IconTrashX,
@ -45,12 +47,24 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
actionHook: ActionHook; actionHook: ActionHook;
} }
> = { > = {
createNewRecord: {
type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection,
key: NoSelectionRecordActionKeys.CREATE_NEW_RECORD,
label: 'Create new record',
shortLabel: 'New record',
position: 0,
isPinned: true,
Icon: IconPlus,
availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION],
actionHook: useCreateNewTableRecordNoSelectionRecordAction,
},
activateWorkflowSingleRecord: { activateWorkflowSingleRecord: {
key: WorkflowSingleRecordActionKeys.ACTIVATE, key: WorkflowSingleRecordActionKeys.ACTIVATE,
label: 'Activate Workflow', label: 'Activate Workflow',
shortLabel: 'Activate', shortLabel: 'Activate',
isPinned: true, isPinned: true,
position: 0, position: 1,
Icon: IconPower, Icon: IconPower,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -65,7 +79,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'Deactivate Workflow', label: 'Deactivate Workflow',
shortLabel: 'Deactivate', shortLabel: 'Deactivate',
isPinned: true, isPinned: true,
position: 1, position: 2,
Icon: IconPlayerPause, Icon: IconPlayerPause,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -80,7 +94,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'Discard Draft', label: 'Discard Draft',
shortLabel: 'Discard Draft', shortLabel: 'Discard Draft',
isPinned: true, isPinned: true,
position: 2, position: 3,
Icon: IconTrash, Icon: IconTrash,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -95,7 +109,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'See active version', label: 'See active version',
shortLabel: 'See active version', shortLabel: 'See active version',
isPinned: false, isPinned: false,
position: 3, position: 4,
Icon: IconHistory, Icon: IconHistory,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -110,7 +124,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'See runs', label: 'See runs',
shortLabel: 'See runs', shortLabel: 'See runs',
isPinned: false, isPinned: false,
position: 4, position: 5,
Icon: IconHistoryToggle, Icon: IconHistoryToggle,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -125,7 +139,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'See versions history', label: 'See versions history',
shortLabel: 'See versions', shortLabel: 'See versions',
isPinned: false, isPinned: false,
position: 5, position: 6,
Icon: IconHistory, Icon: IconHistory,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -140,7 +154,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'Test Workflow', label: 'Test Workflow',
shortLabel: 'Test', shortLabel: 'Test',
isPinned: true, isPinned: true,
position: 6, position: 7,
Icon: IconPlayerPlay, Icon: IconPlayerPlay,
type: ActionMenuEntryType.Standard, type: ActionMenuEntryType.Standard,
scope: ActionMenuEntryScope.RecordSelection, scope: ActionMenuEntryScope.RecordSelection,
@ -156,7 +170,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD, key: SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD,
label: 'Navigate to previous workflow', label: 'Navigate to previous workflow',
shortLabel: '', shortLabel: '',
position: 7, position: 8,
Icon: IconChevronUp, Icon: IconChevronUp,
availableOn: [ActionViewType.SHOW_PAGE], availableOn: [ActionViewType.SHOW_PAGE],
actionHook: useNavigateToPreviousRecordSingleRecordAction, actionHook: useNavigateToPreviousRecordSingleRecordAction,
@ -167,7 +181,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD, key: SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD,
label: 'Navigate to next workflow', label: 'Navigate to next workflow',
shortLabel: '', shortLabel: '',
position: 8, position: 9,
Icon: IconChevronDown, Icon: IconChevronDown,
availableOn: [ActionViewType.SHOW_PAGE], availableOn: [ActionViewType.SHOW_PAGE],
actionHook: useNavigateToNextRecordSingleRecordAction, actionHook: useNavigateToNextRecordSingleRecordAction,
@ -178,7 +192,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: SingleRecordActionKeys.ADD_TO_FAVORITES, key: SingleRecordActionKeys.ADD_TO_FAVORITES,
label: 'Add to favorites', label: 'Add to favorites',
shortLabel: 'Add to favorites', shortLabel: 'Add to favorites',
position: 9, position: 10,
isPinned: false, isPinned: false,
Icon: IconHeart, Icon: IconHeart,
availableOn: [ availableOn: [
@ -194,7 +208,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
label: 'Remove from favorites', label: 'Remove from favorites',
shortLabel: 'Remove from favorites', shortLabel: 'Remove from favorites',
isPinned: false, isPinned: false,
position: 10, position: 11,
Icon: IconHeartOff, Icon: IconHeartOff,
availableOn: [ availableOn: [
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -208,7 +222,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: SingleRecordActionKeys.DELETE, key: SingleRecordActionKeys.DELETE,
label: 'Delete record', label: 'Delete record',
shortLabel: 'Delete', shortLabel: 'Delete',
position: 11, position: 12,
Icon: IconTrash, Icon: IconTrash,
accent: 'danger', accent: 'danger',
isPinned: false, isPinned: false,
@ -224,7 +238,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: MultipleRecordsActionKeys.DELETE, key: MultipleRecordsActionKeys.DELETE,
label: 'Delete records', label: 'Delete records',
shortLabel: 'Delete', shortLabel: 'Delete',
position: 12, position: 13,
Icon: IconTrash, Icon: IconTrash,
accent: 'danger', accent: 'danger',
isPinned: true, isPinned: true,
@ -237,7 +251,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: SingleRecordActionKeys.DESTROY, key: SingleRecordActionKeys.DESTROY,
label: 'Permanently destroy record', label: 'Permanently destroy record',
shortLabel: 'Destroy', shortLabel: 'Destroy',
position: 13, position: 14,
Icon: IconTrashX, Icon: IconTrashX,
accent: 'danger', accent: 'danger',
isPinned: false, isPinned: false,
@ -253,7 +267,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: MultipleRecordsActionKeys.EXPORT, key: MultipleRecordsActionKeys.EXPORT,
label: 'Export records', label: 'Export records',
shortLabel: 'Export', shortLabel: 'Export',
position: 14, position: 15,
Icon: IconDatabaseExport, Icon: IconDatabaseExport,
accent: 'default', accent: 'default',
isPinned: false, isPinned: false,
@ -266,7 +280,7 @@ export const WORKFLOW_ACTIONS_CONFIG: Record<
key: NoSelectionRecordActionKeys.EXPORT_VIEW, key: NoSelectionRecordActionKeys.EXPORT_VIEW,
label: 'Export view', label: 'Export view',
shortLabel: 'Export', shortLabel: 'Export',
position: 15, position: 16,
Icon: IconDatabaseExport, Icon: IconDatabaseExport,
accent: 'default', accent: 'default',
isPinned: false, isPinned: false,