import OverlayRegistry from 'sap/ui/dt/OverlayRegistry'; import type FlexCommand from 'sap/ui/rta/command/FlexCommand'; import type ObjectPageLayout from 'sap/uxap/ObjectPageLayout'; import { DialogFactory, DialogNames } from '../../dialog-factory.js'; import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils.js'; import type { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition.js'; import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base.js'; import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator.js'; export const OP_ADD_CUSTOM_SECTION = 'op-add-custom-section'; const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout']; /** * Quick Action for adding a Header Field to an Object Page. */ export class AddCustomSectionQuickAction extends SimpleQuickActionDefinitionBase implements SimpleQuickActionDefinition { constructor(context: QuickActionContext) { super(OP_ADD_CUSTOM_SECTION, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_CUSTOM_SECTION', context, [ DIALOG_ENABLEMENT_VALIDATOR ]); } async execute(): Promise { const objectPageLayout = getRelevantControlFromActivePage( this.context.controlIndex, this.context.view, CONTROL_TYPES )[0] as ObjectPageLayout; const overlay = OverlayRegistry.getOverlay(objectPageLayout) || []; await DialogFactory.createDialog( overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, { aggregation: 'sections', title: 'QUICK_ACTION_OP_ADD_CUSTOM_SECTION' }, { actionName: this.type, telemetryEventIdentifier: this.getTelemetryIdentifier() } ); return []; } }