diff --git a/.changeset/witty-seas-battle.md b/.changeset/witty-seas-battle.md new file mode 100644 index 0000000000..b202eb3935 --- /dev/null +++ b/.changeset/witty-seas-battle.md @@ -0,0 +1,6 @@ +--- +'@sap-ux-private/preview-middleware-client': patch +'@sap-ux/preview-middleware': patch +--- + +Enable quick actions by default diff --git a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/change-table-columns.ts b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/change-table-columns.ts index ed13288bfd..39ca7c8354 100644 --- a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/change-table-columns.ts +++ b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/change-table-columns.ts @@ -1,10 +1,11 @@ import FlexCommand from 'sap/ui/rta/command/FlexCommand'; import type Table from 'sap/m/Table'; import type SmartTable from 'sap/ui/comp/smarttable/SmartTable'; +import ManagedObject from 'sap/ui/base/ManagedObject'; +import { FeatureService } from '../../../cpe/feature-service'; import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition'; import { getControlById, isA } from '../../../utils/core'; -import ManagedObject from 'sap/ui/base/ManagedObject'; import { TableQuickActionDefinitionBase } from './table-quick-action-base'; export const CHANGE_TABLE_COLUMNS = 'change-table-columns'; @@ -21,6 +22,13 @@ export class ChangeTableColumnsQuickAction super(CHANGE_TABLE_COLUMNS, CONTROL_TYPES, 'V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS', context, true); } + initialize(): Promise { + if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) { + return Promise.resolve(); + } + return super.initialize(); + } + async execute(path: string): Promise { const { table, iconTabBarFilterKey, changeColumnActionId, sectionInfo } = this.tableMap[path]; if (!table) { diff --git a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-page-action.ts b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-page-action.ts index ef9998c33f..fc97325598 100644 --- a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-page-action.ts +++ b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-page-action.ts @@ -1,6 +1,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry'; import FlexCommand from 'sap/ui/rta/command/FlexCommand'; +import { FeatureService } from '../../../cpe/feature-service'; import { DialogNames, handler } from '../../init-dialogs'; import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition'; import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base'; @@ -16,6 +17,13 @@ export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase im super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context); } + initialize(): void { + if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) { + return; + } + return super.initialize(); + } + async execute(): Promise { if (this.control) { const overlay = OverlayRegistry.getOverlay(this.control) || []; diff --git a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-table-action.ts b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-table-action.ts index 9abfa4b026..67861e9424 100644 --- a/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-table-action.ts +++ b/packages/preview-middleware-client/src/adp/quick-actions/fe-v2/create-table-action.ts @@ -1,14 +1,15 @@ import FlexCommand from 'sap/ui/rta/command/FlexCommand'; import type Table from 'sap/m/Table'; import type SmartTable from 'sap/ui/comp/smarttable/SmartTable'; +import OverlayRegistry from 'sap/ui/dt/OverlayRegistry'; +import ManagedObject from 'sap/ui/base/ManagedObject'; +import UI5Element from 'sap/ui/core/Element'; import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition'; import { getControlById, isA } from '../../../utils/core'; -import OverlayRegistry from 'sap/ui/dt/OverlayRegistry'; import { DialogNames, handler } from '../../init-dialogs'; +import { FeatureService } from '../../../cpe/feature-service'; import { TableQuickActionDefinitionBase } from './table-quick-action-base'; -import ManagedObject from 'sap/ui/base/ManagedObject'; -import UI5Element from 'sap/ui/core/Element'; export const CREATE_TABLE_ACTION = 'create-table-action'; const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable'; @@ -22,6 +23,13 @@ export class AddTableActionQuickAction extends TableQuickActionDefinitionBase im super(CREATE_TABLE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION', context); } + initialize(): Promise { + if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) { + return Promise.resolve(); + } + return super.initialize(); + } + async execute(path: string): Promise { const { table, iconTabBarFilterKey, sectionInfo } = this.tableMap[path]; if (!table) { diff --git a/packages/preview-middleware-client/src/adp/quick-actions/fe-v4/change-table-columns.ts b/packages/preview-middleware-client/src/adp/quick-actions/fe-v4/change-table-columns.ts index fb9fa0c004..a0a6e07dc1 100644 --- a/packages/preview-middleware-client/src/adp/quick-actions/fe-v4/change-table-columns.ts +++ b/packages/preview-middleware-client/src/adp/quick-actions/fe-v4/change-table-columns.ts @@ -8,6 +8,7 @@ import { NESTED_QUICK_ACTION_KIND } from '@sap-ux-private/control-property-edito import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition'; import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils'; +import { FeatureService } from '../../../cpe/feature-service'; import { getControlById } from '../../../utils/core'; export const CHANGE_TABLE_COLUMNS = 'change-table-columns'; @@ -31,6 +32,9 @@ export class ChangeTableColumnsQuickAction implements NestedQuickActionDefinitio constructor(private context: QuickActionContext) {} async initialize(): Promise { + if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) { + return; + } let index = 0; for (const smartTable of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, [ CONTROL_TYPE diff --git a/packages/preview-middleware-client/src/adp/quick-actions/load.ts b/packages/preview-middleware-client/src/adp/quick-actions/load.ts index e1de66b7b3..16febb1d72 100644 --- a/packages/preview-middleware-client/src/adp/quick-actions/load.ts +++ b/packages/preview-middleware-client/src/adp/quick-actions/load.ts @@ -1,4 +1,3 @@ -import { FeatureService } from '../../cpe/feature-service'; import type { QuickActionDefinitionRegistry } from '../../cpe/quick-actions/registry'; import type { ApplicationType } from '../../utils/application'; @@ -9,9 +8,6 @@ import type { ApplicationType } from '../../utils/application'; * @returns Quick Action registries. */ export async function loadDefinitions(appType: ApplicationType): Promise[]> { - if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) { - return []; - } if (appType === 'fe-v2') { const FEV2QuickActionRegistry = (await import('open/ux/preview/client/adp/quick-actions/fe-v2/registry')) .default; diff --git a/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v2.test.ts b/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v2.test.ts index 731f34e6c2..fe0d6ad825 100644 --- a/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v2.test.ts +++ b/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v2.test.ts @@ -13,6 +13,7 @@ jest.mock('../../../../src/adp/init-dialogs', () => { import { QuickActionService } from '../../../../src/cpe/quick-actions/quick-action-service'; import { OutlineService } from '../../../../src/cpe/outline/service'; +import { FeatureService } from '../../../../src/cpe/feature-service'; import FEV2QuickActionRegistry from '../../../../src/adp/quick-actions/fe-v2/registry'; import { sapCoreMock } from 'mock/window'; @@ -258,6 +259,15 @@ describe('FE V2 quick actions', () => { }); describe('change table columns', () => { + beforeEach(() => { + jest.spyOn(FeatureService, 'isFeatureEnabled').mockImplementation((feature: string) => { + if (feature === 'cpe.beta.quick-actions') { + return true; + } + return false; + }); + FeatureService.isFeatureEnabled; + }); test('initialize and execute', async () => { const pageView = new XMLView(); @@ -394,6 +404,15 @@ describe('FE V2 quick actions', () => { }); describe('create table action', () => { + beforeEach(() => { + jest.spyOn(FeatureService, 'isFeatureEnabled').mockImplementation((feature: string) => { + if (feature === 'cpe.beta.quick-actions') { + return true; + } + return false; + }); + FeatureService.isFeatureEnabled; + }); test('initialize and execute', async () => { const pageView = new XMLView(); @@ -508,6 +527,15 @@ describe('FE V2 quick actions', () => { }); }); describe('add page action', () => { + beforeEach(() => { + jest.spyOn(FeatureService, 'isFeatureEnabled').mockImplementation((feature: string) => { + if (feature === 'cpe.beta.quick-actions') { + return true; + } + return false; + }); + FeatureService.isFeatureEnabled; + }); test('initialize and execute action', async () => { const pageView = new XMLView(); FlexUtils.getViewForControl.mockImplementation(() => { @@ -766,6 +794,15 @@ describe('FE V2 quick actions', () => { }); }); describe('add custom section', () => { + beforeEach(() => { + jest.spyOn(FeatureService, 'isFeatureEnabled').mockImplementation((feature: string) => { + if (feature === 'cpe.beta.quick-actions') { + return true; + } + return false; + }); + FeatureService.isFeatureEnabled; + }); test('initialize and execute action', async () => { const pageView = new XMLView(); FlexUtils.getViewForControl.mockImplementation(() => { diff --git a/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v4.test.ts b/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v4.test.ts index 5eaf0f761f..b6252493cd 100644 --- a/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v4.test.ts +++ b/packages/preview-middleware-client/test/unit/adp/quick-actions/fe-v4.test.ts @@ -12,6 +12,7 @@ jest.mock('../../../../src/adp/init-dialogs', () => { }); import { QuickActionService } from '../../../../src/cpe/quick-actions/quick-action-service'; import { OutlineService } from '../../../../src/cpe/outline/service'; +import { FeatureService } from '../../../../src/cpe/feature-service'; import FEV4QuickActionRegistry from 'open/ux/preview/client/adp/quick-actions/fe-v4/registry'; import { sapCoreMock } from 'mock/window'; @@ -270,6 +271,15 @@ describe('FE V2 quick actions', () => { }); describe('change table columns', () => { + beforeEach(() => { + jest.spyOn(FeatureService, 'isFeatureEnabled').mockImplementation((feature: string) => { + if (feature === 'cpe.beta.quick-actions') { + return true; + } + return false; + }); + FeatureService.isFeatureEnabled; + }); test('initialize and execute action', async () => { const pageView = new XMLView(); jest.spyOn(FlexRuntimeInfoAPI, 'hasVariantManagement').mockReturnValue(true);