@sap-ux/preview-middleware 0.16.156 → 0.16.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/client/adp/controllers/AddFragment.controller.js +0 -1
  2. package/dist/client/adp/controllers/AddFragment.controller.ts +0 -1
  3. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +0 -1
  4. package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +0 -1
  5. package/dist/client/adp/controllers/BaseDialog.controller.ts +0 -4
  6. package/dist/client/adp/dialog-factory.js +115 -0
  7. package/dist/client/adp/dialog-factory.ts +134 -0
  8. package/dist/client/adp/extension-point.js +6 -6
  9. package/dist/client/adp/extension-point.ts +2 -2
  10. package/dist/client/adp/init-dialogs.js +5 -62
  11. package/dist/client/adp/init-dialogs.ts +5 -77
  12. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +6 -5
  13. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +5 -3
  14. package/dist/client/adp/quick-actions/common/create-page-action.js +7 -6
  15. package/dist/client/adp/quick-actions/common/create-page-action.ts +7 -4
  16. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +6 -5
  17. package/dist/client/adp/quick-actions/common/op-add-custom-section.ts +6 -3
  18. package/dist/client/adp/quick-actions/common/op-add-header-field.js +7 -6
  19. package/dist/client/adp/quick-actions/common/op-add-header-field.ts +7 -4
  20. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +26 -0
  21. package/dist/client/adp/quick-actions/dialog-enablement-validator.ts +18 -0
  22. package/dist/client/adp/quick-actions/enablement-validator.js +6 -0
  23. package/dist/client/adp/quick-actions/enablement-validator.ts +18 -0
  24. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +3 -2
  25. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +11 -3
  26. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +6 -5
  27. package/dist/client/adp/quick-actions/fe-v2/create-table-action.ts +6 -3
  28. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +6 -5
  29. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.ts +25 -13
  30. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +6 -2
  31. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.ts +8 -3
  32. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +19 -9
  33. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.ts +36 -15
  34. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +3 -2
  35. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +4 -1
  36. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +6 -5
  37. package/dist/client/adp/quick-actions/fe-v4/create-table-action.ts +16 -7
  38. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +6 -5
  39. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.ts +8 -5
  40. package/dist/client/adp/quick-actions/fe-v4/table-quick-action-base.js +8 -14
  41. package/dist/client/adp/quick-actions/fe-v4/table-quick-action-base.ts +10 -14
  42. package/dist/client/adp/quick-actions/quick-action-base.js +55 -0
  43. package/dist/client/adp/quick-actions/quick-action-base.ts +55 -0
  44. package/dist/client/adp/quick-actions/simple-quick-action-base.js +8 -13
  45. package/dist/client/adp/quick-actions/simple-quick-action-base.ts +10 -18
  46. package/dist/client/adp/quick-actions/table-quick-action-base.js +7 -9
  47. package/dist/client/adp/quick-actions/table-quick-action-base.ts +10 -14
  48. package/dist/client/cpe/changes/service.js +30 -0
  49. package/dist/client/cpe/changes/service.ts +46 -0
  50. package/dist/client/cpe/quick-actions/quick-action-definition.ts +5 -1
  51. package/dist/client/cpe/quick-actions/quick-action-service.js +10 -4
  52. package/dist/client/cpe/quick-actions/quick-action-service.ts +9 -3
  53. package/dist/client/messagebundle.properties +1 -0
  54. package/package.json +5 -5
@@ -5,8 +5,9 @@ sap.ui.define([
5
5
  '../../cpe/quick-actions/utils',
6
6
  '../../utils/core',
7
7
  '../../utils/version',
8
+ './quick-action-base',
8
9
  './control-types'
9
- ], function (___sap_ux_private_control_property_editor_common, OverlayUtil, ____cpe_quick_actions_utils, ____utils_core, ____utils_version, ___control_types) {
10
+ ], function (___sap_ux_private_control_property_editor_common, OverlayUtil, ____cpe_quick_actions_utils, ____utils_core, ____utils_version, ___quick_action_base, ___control_types) {
10
11
  'use strict';
11
12
  const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
12
13
  const getParentContainer = ____cpe_quick_actions_utils['getParentContainer'];
@@ -16,6 +17,7 @@ sap.ui.define([
16
17
  const isManagedObject = ____utils_core['isManagedObject'];
17
18
  const getUi5Version = ____utils_version['getUi5Version'];
18
19
  const isLowerThanMinimalUi5Version = ____utils_version['isLowerThanMinimalUi5Version'];
20
+ const QuickActionDefinitionBase = ___quick_action_base['QuickActionDefinitionBase'];
19
21
  const ANALYTICAL_TABLE_TYPE = ___control_types['ANALYTICAL_TABLE_TYPE'];
20
22
  const GRID_TABLE_TYPE = ___control_types['GRID_TABLE_TYPE'];
21
23
  const M_TABLE_TYPE = ___control_types['M_TABLE_TYPE'];
@@ -40,15 +42,8 @@ sap.ui.define([
40
42
  SETTINGS_ID
41
43
  ];
42
44
  }
43
- class TableQuickActionDefinitionBase {
44
- kind = NESTED_QUICK_ACTION_KIND;
45
- get id() {
46
- return `${ this.context.key }-${ this.type }`;
47
- }
45
+ class TableQuickActionDefinitionBase extends QuickActionDefinitionBase {
48
46
  isApplicable = false;
49
- get tooltip() {
50
- return undefined;
51
- }
52
47
  children = [];
53
48
  tableMap = {};
54
49
  get textKey() {
@@ -56,11 +51,14 @@ sap.ui.define([
56
51
  }
57
52
  constructor(type, controlTypes, defaultTextKey, context) {
58
53
  let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
54
+ let enablementValidators = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
55
+ super(type, NESTED_QUICK_ACTION_KIND, defaultTextKey, context, enablementValidators);
59
56
  this.type = type;
60
57
  this.controlTypes = controlTypes;
61
58
  this.defaultTextKey = defaultTextKey;
62
59
  this.context = context;
63
60
  this.options = options;
61
+ this.enablementValidators = enablementValidators;
64
62
  }
65
63
  async initialize() {
66
64
  const version = await getUi5Version();
@@ -15,6 +15,8 @@ import ObjectPageSection from 'sap/uxap/ObjectPageSection';
15
15
  import ObjectPageSubSection from 'sap/uxap/ObjectPageSubSection';
16
16
  import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
17
17
  import ManagedObject from 'sap/ui/base/ManagedObject';
18
+ import { EnablementValidator } from './enablement-validator';
19
+ import { QuickActionDefinitionBase } from './quick-action-base';
18
20
  import {
19
21
  ANALYTICAL_TABLE_TYPE,
20
22
  GRID_TABLE_TYPE,
@@ -50,20 +52,11 @@ export type TableQuickActionsOptions = {
50
52
  /**
51
53
  * Base class for table quick actions.
52
54
  */
53
- export abstract class TableQuickActionDefinitionBase {
54
- readonly kind = NESTED_QUICK_ACTION_KIND;
55
- public get id(): string {
56
- return `${this.context.key}-${this.type}`;
57
- }
58
-
55
+ export abstract class TableQuickActionDefinitionBase extends QuickActionDefinitionBase<
56
+ typeof NESTED_QUICK_ACTION_KIND
57
+ > {
59
58
  public isApplicable = false;
60
59
 
61
- protected isDisabled: boolean | undefined;
62
-
63
- public get tooltip(): string | undefined {
64
- return undefined;
65
- }
66
-
67
60
  public children: NestedQuickActionChild[] = [];
68
61
  public tableMap: Record<
69
62
  string,
@@ -92,8 +85,11 @@ export abstract class TableQuickActionDefinitionBase {
92
85
  protected readonly controlTypes: string[],
93
86
  protected readonly defaultTextKey: string,
94
87
  protected readonly context: QuickActionContext,
95
- protected options: TableQuickActionsOptions = {}
96
- ) {}
88
+ protected options: TableQuickActionsOptions = {},
89
+ protected readonly enablementValidators: EnablementValidator[] = []
90
+ ) {
91
+ super(type, NESTED_QUICK_ACTION_KIND, defaultTextKey, context, enablementValidators);
92
+ }
97
93
 
98
94
  /**
99
95
  * Initializes action object instance
@@ -356,6 +356,34 @@ sap.ui.define([
356
356
  }
357
357
  return result;
358
358
  }
359
+ prepareV2ConfigurationChange(command, fileName, index, inactiveCommandCount) {
360
+ const {entityPropertyChange, page} = command.getProperty('parameters');
361
+ const propertyName = Object.keys(entityPropertyChange.propertyValue)[0];
362
+ const propertyValue = entityPropertyChange.propertyValue[propertyName];
363
+ const controlId = this.getCommandSelectorId(command) ?? '';
364
+ const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
365
+ const key = getConfigMapControlIdMap(page, propertyPathSegments);
366
+ const isActive = index >= inactiveCommandCount;
367
+ const controlIds = this.configPropertyControlIdMap?.get(key) || [controlId];
368
+ const result = {
369
+ type: PENDING_CHANGE_TYPE,
370
+ kind: CONFIGURATION_CHANGE_KIND,
371
+ controlIds,
372
+ propertyPath: getCompactV4ConfigPath(propertyPathSegments) || page,
373
+ propertyName,
374
+ isActive,
375
+ value: propertyValue,
376
+ fileName
377
+ };
378
+ for (const id of result.controlIds) {
379
+ if (!this.pendingConfigChangeMap.get(id)) {
380
+ this.pendingConfigChangeMap.set(id, []);
381
+ }
382
+ const pendingChanges = this.pendingConfigChangeMap.get(id);
383
+ pendingChanges?.push(result);
384
+ }
385
+ return result;
386
+ }
359
387
  async prepareChangeType(command, inactiveCommandCount, index) {
360
388
  const change = command?.getPreparedChange?.();
361
389
  const selectorId = typeof change?.getSelector === 'function' ? await this.getControlIdByChange(change) : this.getCommandSelectorId(command);
@@ -389,6 +417,8 @@ sap.ui.define([
389
417
  } else if (changeType === 'appdescr_fe_changePageConfiguration') {
390
418
  const value = command.getProperty('parameters').entityPropertyChange.propertyValue;
391
419
  return this.prepareV4ConfigurationChange(command, value, fileName, index, inactiveCommandCount);
420
+ } else if (changeType === 'appdescr_ui_generic_app_changePageConfiguration') {
421
+ return this.prepareV2ConfigurationChange(command, fileName, index, inactiveCommandCount);
392
422
  } else {
393
423
  let result = {
394
424
  type: PENDING_CHANGE_TYPE,
@@ -558,6 +558,50 @@ export class ChangeService extends EventTarget {
558
558
  return result;
559
559
  }
560
560
 
561
+ private prepareV2ConfigurationChange(
562
+ command: FlexCommand,
563
+ fileName: string,
564
+ index: number,
565
+ inactiveCommandCount: number
566
+ ): PendingConfigurationChange {
567
+ const { entityPropertyChange, page } = command.getProperty('parameters') as {
568
+ entityPropertyChange: {
569
+ propertyPath: string;
570
+ propertyValue: Record<string, string>;
571
+ };
572
+ page: string;
573
+ };
574
+ const propertyName = Object.keys(entityPropertyChange.propertyValue)[0];
575
+ const propertyValue = entityPropertyChange.propertyValue[propertyName];
576
+ const controlId = this.getCommandSelectorId(command) ?? '';
577
+ const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
578
+
579
+ const key = getConfigMapControlIdMap(page, propertyPathSegments);
580
+
581
+ const isActive = index >= inactiveCommandCount;
582
+ const controlIds = this.configPropertyControlIdMap?.get(key) || [controlId];
583
+
584
+ const result: PendingConfigurationChange = {
585
+ type: PENDING_CHANGE_TYPE,
586
+ kind: CONFIGURATION_CHANGE_KIND,
587
+ controlIds,
588
+ propertyPath: getCompactV4ConfigPath(propertyPathSegments) || page,
589
+ propertyName,
590
+ isActive,
591
+ value: propertyValue,
592
+ fileName
593
+ };
594
+ for (const id of result.controlIds) {
595
+ if (!this.pendingConfigChangeMap.get(id)) {
596
+ this.pendingConfigChangeMap.set(id, []);
597
+ }
598
+ const pendingChanges = this.pendingConfigChangeMap.get(id);
599
+ pendingChanges?.push(result);
600
+ }
601
+
602
+ return result;
603
+ }
604
+
561
605
  /**
562
606
  * Prepares the type of change based on the command and other parameters.
563
607
  *
@@ -613,6 +657,8 @@ export class ChangeService extends EventTarget {
613
657
  command.getProperty('parameters') as { entityPropertyChange: { propertyValue: ConfigurationValue } }
614
658
  ).entityPropertyChange.propertyValue;
615
659
  return this.prepareV4ConfigurationChange(command, value, fileName, index, inactiveCommandCount);
660
+ } else if (changeType === 'appdescr_ui_generic_app_changePageConfiguration') {
661
+ return this.prepareV2ConfigurationChange(command, fileName, index, inactiveCommandCount);
616
662
  } else {
617
663
  let result: PendingChange = {
618
664
  type: PENDING_CHANGE_TYPE,
@@ -62,9 +62,13 @@ interface QuickActionDefinitionBase {
62
62
  */
63
63
  isApplicable: boolean;
64
64
  /**
65
- * Initializes the action and checks if it should be enabled in current context.
65
+ * Initializes the action and checks if it should be displayed in current context.
66
66
  */
67
67
  initialize: () => void | Promise<void>;
68
+ /**
69
+ * Runs enablement validators to check if the action should be enabled.
70
+ */
71
+ runEnablementValidators: () => void | Promise<void>;
68
72
  }
69
73
 
70
74
  export interface SimpleQuickActionDefinition extends QuickActionDefinitionBase {
@@ -2,8 +2,9 @@
2
2
  sap.ui.define([
3
3
  'sap/base/Log',
4
4
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
- '../../i18n'
6
- ], function (Log, ___sap_ux_private_control_property_editor_common, ____i18n) {
5
+ '../../i18n',
6
+ '../../adp/dialog-factory'
7
+ ], function (Log, ___sap_ux_private_control_property_editor_common, ____i18n, ____adp_dialog_factory) {
7
8
  'use strict';
8
9
  const executeQuickAction = ___sap_ux_private_control_property_editor_common['executeQuickAction'];
9
10
  const quickActionListChanged = ___sap_ux_private_control_property_editor_common['quickActionListChanged'];
@@ -11,6 +12,7 @@ sap.ui.define([
11
12
  const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
12
13
  const updateQuickAction = ___sap_ux_private_control_property_editor_common['updateQuickAction'];
13
14
  const getTextBundle = ____i18n['getTextBundle'];
15
+ const DialogFactory = ____adp_dialog_factory['DialogFactory'];
14
16
  class QuickActionService {
15
17
  sendAction = () => {
16
18
  };
@@ -47,6 +49,9 @@ sap.ui.define([
47
49
  this.changeService.onStackChange(async () => {
48
50
  await this.reloadQuickActions(this.controlTreeIndex);
49
51
  });
52
+ DialogFactory.onOpenDialogStatusChange(async () => {
53
+ await this.reloadQuickActions(this.controlTreeIndex);
54
+ });
50
55
  }
51
56
  async reloadQuickActions(controlIndex) {
52
57
  const context = {
@@ -74,7 +79,7 @@ sap.ui.define([
74
79
  try {
75
80
  const instance = new Definition(actionContext);
76
81
  await instance.initialize();
77
- this.addAction(group, instance);
82
+ await this.addAction(group, instance);
78
83
  } catch {
79
84
  Log.warning(`Failed to initialize ${ Definition.name } quick action.`);
80
85
  }
@@ -84,8 +89,9 @@ sap.ui.define([
84
89
  }
85
90
  this.sendAction(quickActionListChanged(groups));
86
91
  }
87
- addAction(group, instance) {
92
+ async addAction(group, instance) {
88
93
  if (instance.isApplicable) {
94
+ await instance.runEnablementValidators();
89
95
  const quickAction = instance.getActionObject();
90
96
  group.actions.push(quickAction);
91
97
  this.actions.push(instance);
@@ -20,6 +20,7 @@ import { QuickActionDefinitionRegistry } from './registry';
20
20
  import { OutlineService } from '../outline/service';
21
21
  import { getTextBundle, TextBundle } from '../../i18n';
22
22
  import { ChangeService } from '../changes';
23
+ import { DialogFactory } from '../../adp/dialog-factory';
23
24
 
24
25
  /**
25
26
  * Service providing Quick Actions.
@@ -33,7 +34,7 @@ export class QuickActionService implements Service {
33
34
  private texts: TextBundle;
34
35
 
35
36
  /**
36
- * Qucik action service constructor.zrf
37
+ * Quick action service constructor.
37
38
  *
38
39
  * @param rta - RTA object.
39
40
  * @param outlineService - Outline service instance.
@@ -85,6 +86,10 @@ export class QuickActionService implements Service {
85
86
  this.changeService.onStackChange(async () => {
86
87
  await this.reloadQuickActions(this.controlTreeIndex);
87
88
  });
89
+
90
+ DialogFactory.onOpenDialogStatusChange(async () => {
91
+ await this.reloadQuickActions(this.controlTreeIndex);
92
+ });
88
93
  }
89
94
 
90
95
  /**
@@ -119,7 +124,7 @@ export class QuickActionService implements Service {
119
124
  try {
120
125
  const instance = new Definition(actionContext);
121
126
  await instance.initialize();
122
- this.addAction(group, instance);
127
+ await this.addAction(group, instance);
123
128
  } catch {
124
129
  Log.warning(`Failed to initialize ${Definition.name} quick action.`);
125
130
  }
@@ -131,8 +136,9 @@ export class QuickActionService implements Service {
131
136
  this.sendAction(quickActionListChanged(groups));
132
137
  }
133
138
 
134
- private addAction(group: QuickActionGroup, instance: QuickActionDefinition): void {
139
+ private async addAction(group: QuickActionGroup, instance: QuickActionDefinition): Promise<void> {
135
140
  if (instance.isApplicable) {
141
+ await instance.runEnablementValidators();
136
142
  const quickAction = instance.getActionObject();
137
143
  group.actions.push(quickAction);
138
144
  this.actions.push(instance);
@@ -31,6 +31,7 @@ ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" fragm
31
31
  ADP_ADD_TWO_FRAGMENTS_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" and "{1}.fragment.xml" fragments will be created once you save the changes.
32
32
  ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Controller extensions are not supported for such views and will be disabled.
33
33
  ADP_REUSE_COMPONENTS_MESSAGE = Reuse components are detected for some views in this application. Controller extensions, adding fragments and manifest changes are not supported for such views and will be disabled.
34
+ ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open
34
35
 
35
36
  CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.
36
37
 
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.16.156",
12
+ "version": "0.16.157",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,9 +27,9 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.3",
30
- "@sap-ux/adp-tooling": "0.12.101",
31
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.29",
32
30
  "@sap-ux/btp-utils": "0.17.2",
31
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.30",
32
+ "@sap-ux/adp-tooling": "0.12.101",
33
33
  "@sap-ux/project-access": "1.28.10"
34
34
  },
35
35
  "devDependencies": {
@@ -46,9 +46,9 @@
46
46
  "supertest": "6.3.3",
47
47
  "@sap-ux-private/playwright": "0.1.0",
48
48
  "dotenv": "16.3.1",
49
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.44",
50
- "@sap-ux/axios-extension": "1.17.8",
49
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.45",
51
50
  "@sap-ux/store": "1.0.0",
51
+ "@sap-ux/axios-extension": "1.17.8",
52
52
  "@sap-ux/ui5-info": "0.8.3",
53
53
  "@sap-ux/i18n": "0.2.0"
54
54
  },