Remove actions when record deleted (#12633)

## All Objects
Remove from deleted records view for all object:
- NoSelectionRecordActionKeys.CREATE_NEW_RECORD
- NoSelectionRecordActionKeys.IMPORT_RECORDS
- SingleRecordActionKeys.ADD_TO_FAVORITES
- SingleRecordActionKeys.REMOVE_FROM_FAVORITES

Remove from index view for deleted record:
- DELETE
- ADD_TO_FAVORITES
- REMOVE_FROM_FAVORITES

## Workflows
Remove from deleted workflows view:
- NoSelectionWorkflowRecordActionKeys.GO_TO_RUNS
- SingleRecordActionKeys.EXPORT

Remove from index view for deleted workflow:
- ACTIVATE
- DEACTIVATE
- DISCARD_DRAFT
- SEE_ACTIVE_VERSION
- SEE_RUNS
- SEE_VERSIONS
- TEST
This commit is contained in:
martmull
2025-06-16 17:20:13 +02:00
committed by GitHub
parent 22dade6ef7
commit 878e1dbfd9
2 changed files with 49 additions and 23 deletions

View File

@ -66,8 +66,8 @@ export const DEFAULT_RECORD_ACTIONS_CONFIG: Record<
position: 0, position: 0,
isPinned: true, isPinned: true,
Icon: IconPlus, Icon: IconPlus,
shouldBeRegistered: ({ objectPermissions }) => shouldBeRegistered: ({ objectPermissions, isSoftDeleteFilterActive }) =>
objectPermissions.canUpdateObjectRecords, objectPermissions.canUpdateObjectRecords && !isSoftDeleteFilterActive,
availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION],
component: <CreateNewTableRecordNoSelectionRecordAction />, component: <CreateNewTableRecordNoSelectionRecordAction />,
}, },
@ -96,8 +96,15 @@ export const DEFAULT_RECORD_ACTIONS_CONFIG: Record<
position: 2, position: 2,
isPinned: true, isPinned: true,
Icon: IconHeart, Icon: IconHeart,
shouldBeRegistered: ({ selectedRecord, isFavorite }) => shouldBeRegistered: ({
!selectedRecord?.isRemote && !isFavorite, selectedRecord,
isFavorite,
isSoftDeleteFilterActive,
}) =>
!selectedRecord?.isRemote &&
!isFavorite &&
!isDefined(selectedRecord?.deletedAt) &&
!isSoftDeleteFilterActive,
availableOn: [ availableOn: [
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
@ -113,11 +120,17 @@ export const DEFAULT_RECORD_ACTIONS_CONFIG: Record<
isPinned: true, isPinned: true,
position: 3, position: 3,
Icon: IconHeartOff, Icon: IconHeartOff,
shouldBeRegistered: ({ selectedRecord, isFavorite }) => shouldBeRegistered: ({
selectedRecord,
isFavorite,
isSoftDeleteFilterActive,
}) =>
isDefined(selectedRecord) && isDefined(selectedRecord) &&
!selectedRecord?.isRemote && !selectedRecord?.isRemote &&
isDefined(isFavorite) && isDefined(isFavorite) &&
isFavorite, isFavorite &&
!isDefined(selectedRecord?.deletedAt) &&
!isSoftDeleteFilterActive,
availableOn: [ availableOn: [
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
@ -166,7 +179,8 @@ export const DEFAULT_RECORD_ACTIONS_CONFIG: Record<
Icon: IconFileImport, Icon: IconFileImport,
accent: 'default', accent: 'default',
isPinned: false, isPinned: false,
shouldBeRegistered: () => true, shouldBeRegistered: ({ isSoftDeleteFilterActive }) =>
!isSoftDeleteFilterActive,
availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION],
component: <ImportRecordsNoSelectionRecordAction />, component: <ImportRecordsNoSelectionRecordAction />,
}, },
@ -202,7 +216,8 @@ export const DEFAULT_RECORD_ACTIONS_CONFIG: Record<
isDefined(selectedRecord) && isDefined(selectedRecord) &&
!selectedRecord.isRemote && !selectedRecord.isRemote &&
!isSoftDeleteFilterActive && !isSoftDeleteFilterActive &&
objectPermissions.canSoftDeleteObjectRecords, objectPermissions.canSoftDeleteObjectRecords &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,

View File

@ -39,14 +39,15 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconPower, Icon: IconPower,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) && isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) &&
isDefined(workflowWithCurrentVersion.currentVersion?.steps) && isDefined(workflowWithCurrentVersion.currentVersion?.steps) &&
workflowWithCurrentVersion.currentVersion.steps.length > 0 && workflowWithCurrentVersion.currentVersion.steps.length > 0 &&
(workflowWithCurrentVersion.currentVersion.status === 'DRAFT' || (workflowWithCurrentVersion.currentVersion.status === 'DRAFT' ||
!workflowWithCurrentVersion.versions?.some( !workflowWithCurrentVersion.versions?.some(
(version) => version.status === 'ACTIVE', (version) => version.status === 'ACTIVE',
)), )) &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -62,9 +63,10 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconPlayerPause, Icon: IconPlayerPause,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion) && isDefined(workflowWithCurrentVersion) &&
workflowWithCurrentVersion.currentVersion.status === 'ACTIVE', workflowWithCurrentVersion.currentVersion.status === 'ACTIVE' &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -80,10 +82,11 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconNoteOff, Icon: IconNoteOff,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion) && isDefined(workflowWithCurrentVersion) &&
workflowWithCurrentVersion.versions.length > 1 && workflowWithCurrentVersion.versions.length > 1 &&
workflowWithCurrentVersion.currentVersion.status === 'DRAFT', workflowWithCurrentVersion.currentVersion.status === 'DRAFT' &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -99,9 +102,10 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconVersions, Icon: IconVersions,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ workflowWithCurrentVersion, selectedRecord }) =>
(workflowWithCurrentVersion?.statuses?.includes('ACTIVE') || false) && (workflowWithCurrentVersion?.statuses?.includes('ACTIVE') || false) &&
(workflowWithCurrentVersion?.statuses?.includes('DRAFT') || false), (workflowWithCurrentVersion?.statuses?.includes('DRAFT') || false) &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -117,8 +121,9 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconHistoryToggle, Icon: IconHistoryToggle,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion), isDefined(workflowWithCurrentVersion) &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -134,8 +139,9 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconVersions, Icon: IconVersions,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion), isDefined(workflowWithCurrentVersion) &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -151,14 +157,16 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconPlayerPlay, Icon: IconPlayerPlay,
type: ActionType.Standard, type: ActionType.Standard,
scope: ActionScope.RecordSelection, scope: ActionScope.RecordSelection,
shouldBeRegistered: ({ workflowWithCurrentVersion }) => shouldBeRegistered: ({ selectedRecord, workflowWithCurrentVersion }) =>
isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) && isDefined(workflowWithCurrentVersion?.currentVersion?.trigger) &&
((workflowWithCurrentVersion.currentVersion.trigger.type === 'MANUAL' && ((workflowWithCurrentVersion.currentVersion.trigger.type === 'MANUAL' &&
!isDefined( !isDefined(
workflowWithCurrentVersion.currentVersion.trigger.settings workflowWithCurrentVersion.currentVersion.trigger.settings
.objectType, .objectType,
)) || )) ||
workflowWithCurrentVersion.currentVersion.trigger.type === 'WEBHOOK'), workflowWithCurrentVersion.currentVersion.trigger.type ===
'WEBHOOK') &&
!isDefined(selectedRecord?.deletedAt),
availableOn: [ availableOn: [
ActionViewType.SHOW_PAGE, ActionViewType.SHOW_PAGE,
ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION, ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION,
@ -175,7 +183,8 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
Icon: IconHistoryToggle, Icon: IconHistoryToggle,
accent: 'default', accent: 'default',
isPinned: true, isPinned: true,
shouldBeRegistered: () => true, shouldBeRegistered: ({ isSoftDeleteFilterActive }) =>
!isSoftDeleteFilterActive,
availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION], availableOn: [ActionViewType.INDEX_PAGE_NO_SELECTION],
component: ( component: (
<ActionLink <ActionLink
@ -234,6 +243,8 @@ export const WORKFLOW_ACTIONS_CONFIG = inheritActionsFromDefaultConfig({
[SingleRecordActionKeys.EXPORT]: { [SingleRecordActionKeys.EXPORT]: {
position: 13, position: 13,
label: msg`Export workflow`, label: msg`Export workflow`,
shouldBeRegistered: ({ selectedRecord }) =>
!isDefined(selectedRecord?.deletedAt),
}, },
[MultipleRecordsActionKeys.EXPORT]: { [MultipleRecordsActionKeys.EXPORT]: {
position: 14, position: 14,