Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable quick actions #2477

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/witty-seas-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sap-ux-private/preview-middleware-client': patch
'@sap-ux/preview-middleware': patch
---

Enable quick actions by default
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +22,13 @@ export class ChangeTableColumnsQuickAction
super(CHANGE_TABLE_COLUMNS, CONTROL_TYPES, 'V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS', context, true);
}

initialize(): Promise<void> {
if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
return Promise.resolve();
}
return super.initialize();
}

async execute(path: string): Promise<FlexCommand[]> {
const { table, iconTabBarFilterKey, changeColumnActionId, sectionInfo } = this.tableMap[path];
if (!table) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<FlexCommand[]> {
if (this.control) {
const overlay = OverlayRegistry.getOverlay(this.control) || [];
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<void> {
if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
return Promise.resolve();
}
return super.initialize();
}

async execute(path: string): Promise<FlexCommand[]> {
const { table, iconTabBarFilterKey, sectionInfo } = this.tableMap[path];
if (!table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -31,6 +32,9 @@ export class ChangeTableColumnsQuickAction implements NestedQuickActionDefinitio
constructor(private context: QuickActionContext) {}

async initialize(): Promise<void> {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FeatureService } from '../../cpe/feature-service';
import type { QuickActionDefinitionRegistry } from '../../cpe/quick-actions/registry';
import type { ApplicationType } from '../../utils/application';

Expand All @@ -9,9 +8,6 @@ import type { ApplicationType } from '../../utils/application';
* @returns Quick Action registries.
*/
export async function loadDefinitions(appType: ApplicationType): Promise<QuickActionDefinitionRegistry<string>[]> {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
Loading