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