9260 refactor multiple record actions and no selection actions (#9314)
Closes #9260 - Refactored multiple record actions and no selection record actions to use config file - Simplified actions registration logic - Updated tests
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
import { DEFAULT_ACTIONS_CONFIG_V1 } from '@/action-menu/actions/record-actions/constants/DefaultActionsConfigV1';
|
||||
import { DEFAULT_ACTIONS_CONFIG_V2 } from '@/action-menu/actions/record-actions/constants/DefaultActionsConfigV2';
|
||||
import { WORKFLOW_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowActionsConfig';
|
||||
import { WORKFLOW_RUNS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig';
|
||||
import { WORKFLOW_VERSIONS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
|
||||
export const getActionConfig = (
|
||||
objectMetadataItem: ObjectMetadataItem,
|
||||
isPageHeaderV2Enabled: boolean,
|
||||
) => {
|
||||
switch (objectMetadataItem.nameSingular) {
|
||||
case CoreObjectNameSingular.Workflow:
|
||||
return WORKFLOW_ACTIONS_CONFIG;
|
||||
case CoreObjectNameSingular.WorkflowVersion:
|
||||
return WORKFLOW_VERSIONS_ACTIONS_CONFIG;
|
||||
case CoreObjectNameSingular.WorkflowRun:
|
||||
return WORKFLOW_RUNS_ACTIONS_CONFIG;
|
||||
default:
|
||||
return isPageHeaderV2Enabled
|
||||
? DEFAULT_ACTIONS_CONFIG_V2
|
||||
: DEFAULT_ACTIONS_CONFIG_V1;
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
import { ActionViewType } from '@/action-menu/actions/types/ActionViewType';
|
||||
import { ContextStoreTargetedRecordsRule } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
|
||||
import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType';
|
||||
|
||||
export const getActionViewType = (
|
||||
contextStoreCurrentViewType: ContextStoreViewType | null,
|
||||
contextStoreTargetedRecordsRule: ContextStoreTargetedRecordsRule,
|
||||
) => {
|
||||
if (contextStoreCurrentViewType === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (contextStoreCurrentViewType === ContextStoreViewType.ShowPage) {
|
||||
return ActionViewType.SHOW_PAGE;
|
||||
}
|
||||
|
||||
if (
|
||||
contextStoreTargetedRecordsRule.mode === 'selection' &&
|
||||
contextStoreTargetedRecordsRule.selectedRecordIds.length === 0
|
||||
) {
|
||||
return ActionViewType.INDEX_PAGE_NO_SELECTION;
|
||||
}
|
||||
|
||||
if (
|
||||
contextStoreTargetedRecordsRule.mode === 'selection' &&
|
||||
contextStoreTargetedRecordsRule.selectedRecordIds.length === 1
|
||||
) {
|
||||
return ActionViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION;
|
||||
}
|
||||
|
||||
return ActionViewType.INDEX_PAGE_BULK_SELECTION;
|
||||
};
|
||||
Reference in New Issue
Block a user