@sap-ux/preview-middleware 0.17.29 → 0.17.31

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,11 +1,26 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version"], function (CommandFactory, _____utils_version) {
3
+ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version", "sap/ui/core/Component"], function (CommandFactory, _____utils_version, Component) {
4
4
  "use strict";
5
5
 
6
6
  const getUi5Version = _____utils_version["getUi5Version"];
7
7
  const isLowerThanMinimalUi5Version = _____utils_version["isLowerThanMinimalUi5Version"];
8
8
  const isVersionEqualOrHasNewerPatch = _____utils_version["isVersionEqualOrHasNewerPatch"];
9
+ /**
10
+ * Gets app component of a v2 project.
11
+ *
12
+ * @param control - ManagedObject.
13
+ * @returns AppComponent.
14
+ */
15
+ function getV2AppComponent(control) {
16
+ const ownerComponent = Component.getOwnerComponentFor(control);
17
+ let result;
18
+ if (ownerComponent?.isA('sap.suite.ui.generic.template.lib.TemplateComponent')) {
19
+ result = ownerComponent.getAppComponent();
20
+ }
21
+ return result;
22
+ }
23
+
9
24
  /**
10
25
  * Prepares the change for the manifest setting.
11
26
  *
@@ -22,9 +37,11 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version"], f
22
37
  const {
23
38
  flexSettings
24
39
  } = context;
40
+ const appComponent = getV2AppComponent(control);
25
41
  const modifiedValue = {
26
42
  changeType: 'appdescr_ui_generic_app_changePageConfiguration',
27
43
  reference: flexSettings.projectId,
44
+ appComponent,
28
45
  parameters: {
29
46
  parentPage: {
30
47
  component,
@@ -92,6 +109,7 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../utils/version"], f
92
109
  var __exports = {
93
110
  __esModule: true
94
111
  };
112
+ __exports.getV2AppComponent = getV2AppComponent;
95
113
  __exports.prepareManifestChange = prepareManifestChange;
96
114
  __exports.isManifestArrayStructured = isManifestArrayStructured;
97
115
  __exports.areManifestChangesSupported = areManifestChangesSupported;
@@ -5,6 +5,25 @@ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
5
5
  import { QuickActionContext } from '../../../cpe/quick-actions/quick-action-definition';
6
6
  import { getUi5Version, isLowerThanMinimalUi5Version, isVersionEqualOrHasNewerPatch } from '../../../utils/version';
7
7
  import { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
8
+ import Component from 'sap/ui/core/Component';
9
+ import type AppComponent from 'sap/suite/ui/generic/template/lib/AppComponent';
10
+ import type ManagedObject from 'sap/ui/base/ManagedObject';
11
+ import type TemplateComponent from 'sap/suite/ui/generic/template/lib/TemplateComponent';
12
+
13
+ /**
14
+ * Gets app component of a v2 project.
15
+ *
16
+ * @param control - ManagedObject.
17
+ * @returns AppComponent.
18
+ */
19
+ export function getV2AppComponent(control: ManagedObject): AppComponent | undefined {
20
+ const ownerComponent = Component.getOwnerComponentFor(control);
21
+ let result;
22
+ if (ownerComponent?.isA<TemplateComponent>('sap.suite.ui.generic.template.lib.TemplateComponent')) {
23
+ result = ownerComponent.getAppComponent();
24
+ }
25
+ return result;
26
+ }
8
27
 
9
28
  /**
10
29
  * Prepares the change for the manifest setting.
@@ -27,10 +46,11 @@ export async function prepareManifestChange(
27
46
  propertyValue: object | string
28
47
  ): Promise<FlexCommand[]> {
29
48
  const { flexSettings } = context;
30
-
49
+ const appComponent = getV2AppComponent(control);
31
50
  const modifiedValue = {
32
51
  changeType: 'appdescr_ui_generic_app_changePageConfiguration',
33
52
  reference: flexSettings.projectId,
53
+ appComponent,
34
54
  parameters: {
35
55
  parentPage: {
36
56
  component,
@@ -62,7 +82,6 @@ export function isManifestArrayStructured(manifest: Manifest): boolean {
62
82
  return Array.isArray(manifest['sap.ui.generic.app']?.pages);
63
83
  }
64
84
 
65
-
66
85
  /**
67
86
  * Checks if the current UI5 version and manifest structure is supported in v2 applications.
68
87
  *
@@ -4,7 +4,7 @@ sap.ui.define(["../../../utils/core", "sap/ui/rta/command/CommandFactory", "../.
4
4
  "use strict";
5
5
 
6
6
  const getControlById = _____utils_core["getControlById"];
7
- const getAppComponent = _____utils_fe_v4["getAppComponent"];
7
+ const getV4AppComponent = _____utils_fe_v4["getV4AppComponent"];
8
8
  const getPageName = _____utils_fe_v4["getPageName"];
9
9
  const getReference = _____utils_fe_v4["getReference"];
10
10
  async function executeToggleAction(context, isButtonEnabled, controlType, propertyPath) {
@@ -24,7 +24,7 @@ sap.ui.define(["../../../utils/core", "sap/ui/rta/command/CommandFactory", "../.
24
24
  }
25
25
  const modifiedValue = {
26
26
  reference: getReference(modifiedControl),
27
- appComponent: getAppComponent(modifiedControl),
27
+ appComponent: getV4AppComponent(modifiedControl),
28
28
  changeType: 'appdescr_fe_changePageConfiguration',
29
29
  parameters: {
30
30
  page: getPageName(parent),
@@ -2,7 +2,7 @@ import { getControlById } from '../../../utils/core';
2
2
  import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
3
  import { QuickActionContext } from '../../../cpe/quick-actions/quick-action-definition';
4
4
  import CommandFactory from 'sap/ui/rta/command/CommandFactory';
5
- import { getAppComponent, getPageName, getReference } from '../../../utils/fe-v4';
5
+ import { getV4AppComponent, getPageName, getReference } from '../../../utils/fe-v4';
6
6
 
7
7
  export async function executeToggleAction(
8
8
  context: QuickActionContext,
@@ -26,7 +26,7 @@ export async function executeToggleAction(
26
26
 
27
27
  const modifiedValue = {
28
28
  reference: getReference(modifiedControl),
29
- appComponent: getAppComponent(modifiedControl),
29
+ appComponent: getV4AppComponent(modifiedControl),
30
30
  changeType: 'appdescr_fe_changePageConfiguration',
31
31
  parameters: {
32
32
  page: getPageName(parent),
@@ -50,8 +50,8 @@ sap.ui.define([
50
50
  const getConfigMapControlIdMap = ____utils_fe_v4['getConfigMapControlIdMap'];
51
51
  const TITLE_MAP = { appdescr_app_addAnnotationsToOData: 'Add New Annotation File' };
52
52
  const STACK_CHANGE_EVENT = 'STACK_CHANGED';
53
- const PROPRTY_CHANGE = 'propertyChange';
54
- const PROPRTY_BINDING_CHANGE = 'propertyBindingChange';
53
+ const PROPERTY_CHANGE = 'propertyChange';
54
+ const PROPERTY_BINDING_CHANGE = 'propertyBindingChange';
55
55
  const MANIFEST_V4_CHANGE = 'appdescr_fe_changePageConfiguration';
56
56
  function assertProperties(properties, target) {
57
57
  for (const property of properties) {
@@ -361,10 +361,10 @@ sap.ui.define([
361
361
  }
362
362
  prepareV2ConfigurationChange(command, fileName, index, inactiveCommandCount) {
363
363
  const {entityPropertyChange, page} = command.getProperty('parameters');
364
- const propertyName = Object.keys(entityPropertyChange.propertyValue)[0];
365
- const propertyValue = entityPropertyChange.propertyValue[propertyName];
366
- const controlId = this.getCommandSelectorId(command) ?? '';
367
364
  const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
365
+ const propertyName = Object.keys(entityPropertyChange.propertyValue)?.[0] ?? propertyPathSegments[propertyPathSegments.length - 1];
366
+ const propertyValue = entityPropertyChange.propertyValue?.[propertyName] ?? entityPropertyChange.propertyValue;
367
+ const controlId = this.getCommandSelectorId(command) ?? '';
368
368
  const key = getConfigMapControlIdMap(page, propertyPathSegments);
369
369
  const isActive = index >= inactiveCommandCount;
370
370
  const controlIds = this.configPropertyControlIdMap?.get(key) || [controlId];
@@ -75,12 +75,12 @@ interface BaseChange {
75
75
  selector: ChangeSelector;
76
76
  }
77
77
 
78
- const PROPRTY_CHANGE = 'propertyChange';
79
- const PROPRTY_BINDING_CHANGE = 'propertyBindingChange';
78
+ const PROPERTY_CHANGE = 'propertyChange';
79
+ const PROPERTY_BINDING_CHANGE = 'propertyBindingChange';
80
80
  const MANIFEST_V4_CHANGE = 'appdescr_fe_changePageConfiguration';
81
81
 
82
82
  interface PropertyChange extends BaseChange {
83
- changeType: typeof PROPRTY_CHANGE | typeof PROPRTY_BINDING_CHANGE;
83
+ changeType: typeof PROPERTY_CHANGE | typeof PROPERTY_BINDING_CHANGE;
84
84
  controlId: string;
85
85
  propertyName: string;
86
86
  content: ChangeContent;
@@ -578,10 +578,12 @@ export class ChangeService extends EventTarget {
578
578
  };
579
579
  page: string;
580
580
  };
581
- const propertyName = Object.keys(entityPropertyChange.propertyValue)[0];
582
- const propertyValue = entityPropertyChange.propertyValue[propertyName];
583
- const controlId = this.getCommandSelectorId(command) ?? '';
584
581
  const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
582
+ const propertyName =
583
+ Object.keys(entityPropertyChange.propertyValue)?.[0] ??
584
+ propertyPathSegments[propertyPathSegments.length - 1];
585
+ const propertyValue = entityPropertyChange.propertyValue?.[propertyName] ?? entityPropertyChange.propertyValue;
586
+ const controlId = this.getCommandSelectorId(command) ?? '';
585
587
 
586
588
  const key = getConfigMapControlIdMap(page, propertyPathSegments);
587
589
 
@@ -11,7 +11,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
11
11
  * @param control - ManagedObject.
12
12
  * @returns AppComponent.
13
13
  */
14
- function getAppComponent(control) {
14
+ function getV4AppComponent(control) {
15
15
  const ownerComponent = Component.getOwnerComponentFor(control);
16
16
  if (ownerComponent?.isA('sap.fe.core.TemplateComponent')) {
17
17
  return ownerComponent.getAppComponent();
@@ -26,7 +26,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
26
26
  * @returns string.
27
27
  */
28
28
  function getReference(control) {
29
- const manifest = getAppComponent(control)?.getManifest();
29
+ const manifest = getV4AppComponent(control)?.getManifest();
30
30
  return manifest?.['sap.app']?.id ?? '';
31
31
  }
32
32
 
@@ -109,7 +109,7 @@ sap.ui.define(["sap/ui/core/Component", "./core", "sap/ui/rta/command/CommandFac
109
109
  var __exports = {
110
110
  __esModule: true
111
111
  };
112
- __exports.getAppComponent = getAppComponent;
112
+ __exports.getV4AppComponent = getV4AppComponent;
113
113
  __exports.getReference = getReference;
114
114
  __exports.getV4PageType = getV4PageType;
115
115
  __exports.getPageName = getPageName;
@@ -16,7 +16,7 @@ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
16
16
  * @param control - ManagedObject.
17
17
  * @returns AppComponent.
18
18
  */
19
- export function getAppComponent(control: ManagedObject): AppComponent | undefined {
19
+ export function getV4AppComponent(control: ManagedObject): AppComponent | undefined {
20
20
  const ownerComponent = Component.getOwnerComponentFor(control);
21
21
  if (ownerComponent?.isA<TemplateComponent>('sap.fe.core.TemplateComponent')) {
22
22
  return ownerComponent.getAppComponent();
@@ -31,7 +31,7 @@ export function getAppComponent(control: ManagedObject): AppComponent | undefine
31
31
  * @returns string.
32
32
  */
33
33
  export function getReference(control: ManagedObject): string {
34
- const manifest = getAppComponent(control)?.getManifest() as Manifest;
34
+ const manifest = getV4AppComponent(control)?.getManifest() as Manifest;
35
35
  return manifest?.['sap.app']?.id ?? '';
36
36
  }
37
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.17.29",
12
+ "version": "0.17.31",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -28,9 +28,9 @@
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.3",
30
30
  "@sap-ux/btp-utils": "1.0.1",
31
- "@sap-ux/adp-tooling": "0.12.127",
31
+ "@sap-ux/adp-tooling": "0.12.128",
32
32
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.37",
33
- "@sap-ux/project-access": "1.29.6"
33
+ "@sap-ux/project-access": "1.29.7"
34
34
  },
35
35
  "devDependencies": {
36
36
  "connect": "^3.7.0",
@@ -48,10 +48,10 @@
48
48
  "supertest": "6.3.3",
49
49
  "@sap-ux-private/playwright": "0.1.0",
50
50
  "dotenv": "16.3.1",
51
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.61",
51
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.62",
52
52
  "@sap-ux/axios-extension": "1.18.5",
53
- "@sap-ux/store": "1.0.0",
54
53
  "@sap-ux/ui5-info": "0.8.3",
54
+ "@sap-ux/store": "1.0.0",
55
55
  "@sap-ux/i18n": "0.2.1"
56
56
  },
57
57
  "peerDependencies": {