@sap-ux/preview-middleware 0.23.7 → 0.23.9

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.
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["../../../utils/core", "../table-quick-action-base", "../dialog-enablement-validator"], function (_____utils_core, ___table_quick_action_base, ___dialog_enablement_validator) {
3
+ sap.ui.define(["../../../utils/core", "../table-quick-action-base", "../dialog-enablement-validator", "../control-types"], function (_____utils_core, ___table_quick_action_base, ___dialog_enablement_validator, ___control_types) {
4
4
  "use strict";
5
5
 
6
6
  const getControlById = _____utils_core["getControlById"];
7
7
  const isA = _____utils_core["isA"];
8
8
  const TableQuickActionDefinitionBase = ___table_quick_action_base["TableQuickActionDefinitionBase"];
9
9
  const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
10
+ const M_TABLE_TYPE = ___control_types["M_TABLE_TYPE"];
11
+ const SMART_TABLE_TYPE = ___control_types["SMART_TABLE_TYPE"];
10
12
  const CHANGE_TABLE_COLUMNS = 'change-table-columns';
11
- const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
12
- const M_TABLE_TYPE = 'sap.m.Table';
13
- // maintain order if action id
14
- const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
13
+ const CONTROL_TYPES = [SMART_TABLE_TYPE];
15
14
  class ChangeTableColumnsQuickAction extends TableQuickActionDefinitionBase {
16
15
  constructor(context) {
17
16
  super(CHANGE_TABLE_COLUMNS, CONTROL_TYPES, 'V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS', context, {
18
- includeServiceAction: true
17
+ includeServiceAction: true,
18
+ validatePageVariantManagement: true
19
19
  }, [DIALOG_ENABLEMENT_VALIDATOR]);
20
20
  }
21
21
  async execute(path) {
@@ -7,12 +7,10 @@ import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/qu
7
7
  import { getControlById, isA } from '../../../utils/core';
8
8
  import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
9
9
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
10
+ import { M_TABLE_TYPE, SMART_TABLE_TYPE } from '../control-types';
10
11
 
11
12
  export const CHANGE_TABLE_COLUMNS = 'change-table-columns';
12
- const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
13
- const M_TABLE_TYPE = 'sap.m.Table';
14
- // maintain order if action id
15
- const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
13
+ const CONTROL_TYPES = [SMART_TABLE_TYPE];
16
14
 
17
15
  export class ChangeTableColumnsQuickAction
18
16
  extends TableQuickActionDefinitionBase
@@ -25,7 +23,8 @@ export class ChangeTableColumnsQuickAction
25
23
  'V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS',
26
24
  context,
27
25
  {
28
- includeServiceAction: true
26
+ includeServiceAction: true,
27
+ validatePageVariantManagement: true
29
28
  },
30
29
  [DIALOG_ENABLEMENT_VALIDATOR]
31
30
  );
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog-factory", "../table-quick-action-base", "../dialog-enablement-validator"], function (OverlayRegistry, _____utils_core, ____dialog_factory, ___table_quick_action_base, ___dialog_enablement_validator) {
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog-factory", "../table-quick-action-base", "../dialog-enablement-validator", "../control-types"], function (OverlayRegistry, _____utils_core, ____dialog_factory, ___table_quick_action_base, ___dialog_enablement_validator, ___control_types) {
4
4
  "use strict";
5
5
 
6
6
  const getControlById = _____utils_core["getControlById"];
@@ -9,12 +9,14 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/core", "../../dialog
9
9
  const DialogNames = ____dialog_factory["DialogNames"];
10
10
  const TableQuickActionDefinitionBase = ___table_quick_action_base["TableQuickActionDefinitionBase"];
11
11
  const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
12
+ const GRID_TABLE_TYPE = ___control_types["GRID_TABLE_TYPE"];
13
+ const M_TABLE_TYPE = ___control_types["M_TABLE_TYPE"];
14
+ const SMART_TABLE_TYPE = ___control_types["SMART_TABLE_TYPE"];
15
+ const TREE_TABLE_TYPE = ___control_types["TREE_TABLE_TYPE"];
12
16
  const CREATE_TABLE_ACTION = 'create-table-action';
13
- const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
14
- const M_TABLE_TYPE = 'sap.m.Table';
15
17
  // maintain order if action id
16
18
 
17
- const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
19
+ const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, TREE_TABLE_TYPE, GRID_TABLE_TYPE];
18
20
  class AddTableActionQuickAction extends TableQuickActionDefinitionBase {
19
21
  constructor(context) {
20
22
  super(CREATE_TABLE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_TABLE_ACTION', context, undefined, [DIALOG_ENABLEMENT_VALIDATOR]);
@@ -5,23 +5,19 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
5
5
  import ManagedObject from 'sap/ui/base/ManagedObject';
6
6
  import UI5Element from 'sap/ui/core/Element';
7
7
 
8
- import {
9
- QuickActionContext,
10
- NestedQuickActionDefinition
11
- } from '../../../cpe/quick-actions/quick-action-definition';
8
+ import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
12
9
  import { getControlById, isA } from '../../../utils/core';
13
10
  import { DialogFactory, DialogNames } from '../../dialog-factory';
14
11
  import { TableQuickActionDefinitionBase } from '../table-quick-action-base';
15
12
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
16
13
  import type OverflowToolbar from 'sap/m/OverflowToolbar';
17
14
  import { NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
15
+ import { GRID_TABLE_TYPE, M_TABLE_TYPE, SMART_TABLE_TYPE, TREE_TABLE_TYPE } from '../control-types';
18
16
 
19
17
  export const CREATE_TABLE_ACTION = 'create-table-action';
20
- const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
21
- const M_TABLE_TYPE = 'sap.m.Table';
22
18
  // maintain order if action id
23
19
 
24
- const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
20
+ const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, TREE_TABLE_TYPE, GRID_TABLE_TYPE];
25
21
 
26
22
  export class AddTableActionQuickAction extends TableQuickActionDefinitionBase implements NestedQuickActionDefinition {
27
23
  constructor(context: QuickActionContext) {
@@ -106,6 +106,25 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version", "s
106
106
  });
107
107
  return isAboveOrEqualMinimalVersion || isSupportedPatchVersion;
108
108
  }
109
+ function isVariantManagementEnabledOPPage(context, control) {
110
+ const ownerComponent = Component.getOwnerComponentFor(control);
111
+ if (ownerComponent?.isA('sap.suite.ui.generic.template.ObjectPage.Component')) {
112
+ const id = control.getId();
113
+ if (typeof id !== 'string') {
114
+ throw new Error('Could not retrieve configuration property because control id is not valid!');
115
+ }
116
+ if (!control.isA('sap.ui.comp.smarttable.SmartTable')) {
117
+ // variant management is only supported by SmartTable
118
+ return false;
119
+ }
120
+ let value = context.changeService.getConfigurationPropertyValue(id, 'variantManagement');
121
+ if (value === undefined) {
122
+ value = !!control.getVariantManagement();
123
+ }
124
+ return value;
125
+ }
126
+ return undefined;
127
+ }
109
128
  var __exports = {
110
129
  __esModule: true
111
130
  };
@@ -113,6 +132,7 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version", "s
113
132
  __exports.prepareManifestChange = prepareManifestChange;
114
133
  __exports.isManifestArrayStructured = isManifestArrayStructured;
115
134
  __exports.areManifestChangesSupported = areManifestChangesSupported;
135
+ __exports.isVariantManagementEnabledOPPage = isVariantManagementEnabledOPPage;
116
136
  return __exports;
117
137
  });
118
138
  //# sourceMappingURL=utils.js.map
@@ -9,6 +9,7 @@ import Component from 'sap/ui/core/Component';
9
9
  import type AppComponent from 'sap/suite/ui/generic/template/lib/AppComponent';
10
10
  import type ManagedObject from 'sap/ui/base/ManagedObject';
11
11
  import type TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
12
+ import SmartTableExtended from 'sap/ui/comp/smarttable';
12
13
 
13
14
  /**
14
15
  * Gets app component of a v2 project.
@@ -109,3 +110,25 @@ export async function areManifestChangesSupported(manifest: Manifest): Promise<b
109
110
  return isAboveOrEqualMinimalVersion || isSupportedPatchVersion;
110
111
  }
111
112
 
113
+ export function isVariantManagementEnabledOPPage(
114
+ context: QuickActionContext,
115
+ control: UI5Element
116
+ ): boolean | undefined {
117
+ const ownerComponent = Component.getOwnerComponentFor(control);
118
+ if (ownerComponent?.isA('sap.suite.ui.generic.template.ObjectPage.Component')) {
119
+ const id = control.getId();
120
+ if (typeof id !== 'string') {
121
+ throw new Error('Could not retrieve configuration property because control id is not valid!');
122
+ }
123
+ if (!control.isA<SmartTableExtended>('sap.ui.comp.smarttable.SmartTable')) {
124
+ // variant management is only supported by SmartTable
125
+ return false;
126
+ }
127
+ let value = context.changeService.getConfigurationPropertyValue(id, 'variantManagement');
128
+ if (value === undefined) {
129
+ value = !!control.getVariantManagement();
130
+ }
131
+ return value as boolean;
132
+ }
133
+ return undefined;
134
+ }
@@ -23,16 +23,29 @@ sap.ui.define(["sap/ui/dt/OverlayUtil", "sap/ui/fl/apply/api/FlexRuntimeInfoAPI"
23
23
  const hasVariantManagement = FlexRuntimeInfoAPI.hasVariantManagement({
24
24
  element: smartTable
25
25
  });
26
+ const path = this.children.length.toString();
27
+ const tableHeader = smartTable.getHeader() || 'Unnamed';
28
+ const tableLabel = `'${tableHeader}' table`;
26
29
  if (!hasVariantManagement) {
30
+ this.children.push({
31
+ path,
32
+ label: tableLabel,
33
+ enabled: false,
34
+ tooltip: this.context.resourceBundle.getText('TABLE_ACTION_DISABLED_VARIANT_MANAGEMENT_NOT_AVAILABLE'),
35
+ children: []
36
+ });
37
+ this.tableMap[path] = {
38
+ table: smartTable,
39
+ tableUpdateEventAttachedOnce: false
40
+ };
27
41
  continue;
28
42
  }
29
43
  const actions = await this.context.actionService.get(smartTable.getId());
30
44
  const changeColumnAction = actions.find(action => action.id === ACTION_ID);
31
45
  if (changeColumnAction) {
32
- const path = this.children.length.toString();
33
46
  this.children.push({
34
47
  path,
35
- label: `'${smartTable.getHeader()}' table`,
48
+ label: tableLabel,
36
49
  enabled: true,
37
50
  children: []
38
51
  });
@@ -32,17 +32,33 @@ export class ChangeTableColumnsQuickAction
32
32
  this.controlTypes
33
33
  )) {
34
34
  const hasVariantManagement = FlexRuntimeInfoAPI.hasVariantManagement({ element: smartTable });
35
+ const path = this.children.length.toString();
36
+ const tableHeader = (smartTable as Table).getHeader() || 'Unnamed';
37
+ const tableLabel = `'${tableHeader}' table`;
38
+
35
39
  if (!hasVariantManagement) {
40
+ this.children.push({
41
+ path,
42
+ label: tableLabel,
43
+ enabled: false,
44
+ tooltip: this.context.resourceBundle.getText(
45
+ 'TABLE_ACTION_DISABLED_VARIANT_MANAGEMENT_NOT_AVAILABLE'
46
+ ),
47
+ children: []
48
+ });
49
+ this.tableMap[path] = {
50
+ table: smartTable,
51
+ tableUpdateEventAttachedOnce: false
52
+ };
36
53
  continue;
37
54
  }
38
55
 
39
56
  const actions = await this.context.actionService.get(smartTable.getId());
40
57
  const changeColumnAction = actions.find((action) => action.id === ACTION_ID);
41
58
  if (changeColumnAction) {
42
- const path = this.children.length.toString();
43
59
  this.children.push({
44
60
  path,
45
- label: `'${(smartTable as Table).getHeader()}' table`,
61
+ label: tableLabel,
46
62
  enabled: true,
47
63
  children: []
48
64
  });
@@ -6,8 +6,9 @@ sap.ui.define([
6
6
  '../../utils/core',
7
7
  '../../utils/version',
8
8
  './quick-action-base',
9
- './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) {
9
+ './control-types',
10
+ './fe-v2/utils'
11
+ ], function (___sap_ux_private_control_property_editor_common, OverlayUtil, ____cpe_quick_actions_utils, ____utils_core, ____utils_version, ___quick_action_base, ___control_types, ___fe_v2_utils) {
11
12
  'use strict';
12
13
  const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
13
14
  const getParentContainer = ____cpe_quick_actions_utils['getParentContainer'];
@@ -24,6 +25,7 @@ sap.ui.define([
24
25
  const MDC_TABLE_TYPE = ___control_types['MDC_TABLE_TYPE'];
25
26
  const SMART_TABLE_TYPE = ___control_types['SMART_TABLE_TYPE'];
26
27
  const TREE_TABLE_TYPE = ___control_types['TREE_TABLE_TYPE'];
28
+ const isVariantManagementEnabledOPPage = ___fe_v2_utils['isVariantManagementEnabledOPPage'];
27
29
  const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
28
30
  const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
29
31
  const SETTINGS_ID = 'CTX_SETTINGS';
@@ -249,14 +251,22 @@ sap.ui.define([
249
251
  enabled: true,
250
252
  children: []
251
253
  };
254
+ if (this.options.validatePageVariantManagement) {
255
+ const variantEnabledV2 = isVariantManagementEnabledOPPage(this.context, table);
256
+ if (variantEnabledV2 === false) {
257
+ child.enabled = false;
258
+ child.tooltip = this.context.resourceBundle.getText('TABLE_ACTION_DISABLED_VARIANT_MANAGEMENT_NOT_AVAILABLE');
259
+ return child;
260
+ }
261
+ }
252
262
  if (!this.options.areTableRowsRequired) {
253
263
  return child;
254
264
  }
255
265
  const innerTable = this.getInternalTable(table);
256
- const tableRows = innerTable?.getAggregation('items') || [];
257
- if (isA(M_TABLE_TYPE, innerTable) && !tableRows.length) {
266
+ const tableRows = innerTable?.getAggregation('items') ?? [];
267
+ if (isA(M_TABLE_TYPE, innerTable) && Array.isArray(tableRows) && tableRows.length === 0) {
258
268
  child.enabled = false;
259
- child.tooltip = this.context.resourceBundle.getText('TABLE_CUSTOM_COLUMN_ACTION_NOT_AVAILABLE');
269
+ child.tooltip = this.context.resourceBundle.getText('TABLE_ACTION_DISABLED_ROWS_NOT_AVAILABLE');
260
270
  }
261
271
  return child;
262
272
  }
@@ -25,6 +25,7 @@ import {
25
25
  SMART_TABLE_TYPE,
26
26
  TREE_TABLE_TYPE
27
27
  } from './control-types';
28
+ import { isVariantManagementEnabledOPPage } from './fe-v2/utils';
28
29
 
29
30
  const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
30
31
  const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
@@ -57,6 +58,7 @@ async function getRearrangeToolbarContentActionId(): Promise<string> {
57
58
  export type TableQuickActionsOptions = {
58
59
  includeServiceAction?: boolean;
59
60
  areTableRowsRequired?: boolean;
61
+ validatePageVariantManagement?: boolean;
60
62
  };
61
63
 
62
64
  /**
@@ -346,14 +348,24 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
346
348
  enabled: true,
347
349
  children: []
348
350
  };
351
+ if (this.options.validatePageVariantManagement) {
352
+ const variantEnabledV2 = isVariantManagementEnabledOPPage(this.context, table);
353
+ if (variantEnabledV2 === false) {
354
+ child.enabled = false;
355
+ child.tooltip = this.context.resourceBundle.getText(
356
+ 'TABLE_ACTION_DISABLED_VARIANT_MANAGEMENT_NOT_AVAILABLE'
357
+ );
358
+ return child;
359
+ }
360
+ }
349
361
  if (!this.options.areTableRowsRequired) {
350
362
  return child;
351
363
  }
352
364
  const innerTable = this.getInternalTable(table);
353
- const tableRows = (innerTable?.getAggregation('items') as ManagedObject[]) || [];
354
- if (isA(M_TABLE_TYPE, innerTable) && !tableRows.length) {
365
+ const tableRows = innerTable?.getAggregation('items') ?? [];
366
+ if (isA(M_TABLE_TYPE, innerTable) && Array.isArray(tableRows) && tableRows.length === 0) {
355
367
  child.enabled = false;
356
- child.tooltip = this.context.resourceBundle.getText('TABLE_CUSTOM_COLUMN_ACTION_NOT_AVAILABLE');
368
+ child.tooltip = this.context.resourceBundle.getText('TABLE_ACTION_DISABLED_ROWS_NOT_AVAILABLE');
357
369
  }
358
370
  return child;
359
371
  }
@@ -82,7 +82,8 @@ TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to
82
82
  HIGHER_LAYER_CHANGES_TITLE = Higher Layer Changes Detected
83
83
  HIGHER_LAYER_CHANGES_INFO_MESSAGE=The preview of the project was reloaded due to detected changes in higher layer than the one used in your project.
84
84
 
85
- TABLE_CUSTOM_COLUMN_ACTION_NOT_AVAILABLE=This action has been disabled because the table rows are not available. Please load the table data and try again
85
+ TABLE_ACTION_DISABLED_ROWS_NOT_AVAILABLE=This action has been disabled because the table rows are not available. Please load the table data and try again.
86
+ TABLE_ACTION_DISABLED_VARIANT_MANAGEMENT_NOT_AVAILABLE=This action has been disabled because variant management is disabled. Enable variant management and try again.
86
87
  TABLE_FILTERING_CHANGE_HAS_ALREADY_BEEN_MADE=This option is disabled because table filtering for page variants is already enabled
87
88
  EMPTY_ROW_MODE_IS_ALREADY_ENABLED=This option has been disabled because empty row mode is already enabled for this table
88
89
  EMPTY_ROW_MODE_IS_NOT_SUPPORTED=This action is disabled because empty row mode is not supported for analytical and tree tables
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.23.7",
12
+ "version": "0.23.9",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,12 +25,12 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/adp-tooling": "0.15.26",
29
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.0",
28
+ "@sap-ux/adp-tooling": "0.15.27",
30
29
  "@sap-ux/btp-utils": "1.1.1",
30
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.0",
31
31
  "@sap-ux/feature-toggle": "0.3.1",
32
- "@sap-ux/project-access": "1.30.13",
33
32
  "@sap-ux/logger": "0.7.0",
33
+ "@sap-ux/project-access": "1.30.14",
34
34
  "@sap-ux/system-access": "0.6.16",
35
35
  "@sap-ux/i18n": "0.3.3"
36
36
  },
@@ -50,10 +50,10 @@
50
50
  "nock": "13.4.0",
51
51
  "npm-run-all2": "6.2.0",
52
52
  "supertest": "7.1.4",
53
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.17.0",
53
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.17.1",
54
54
  "@sap-ux/axios-extension": "1.22.7",
55
- "@sap-ux/ui5-info": "0.12.2",
56
- "@sap-ux/store": "1.1.4"
55
+ "@sap-ux/store": "1.1.4",
56
+ "@sap-ux/ui5-info": "0.12.2"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "express": "4"