@sap-ux/preview-middleware 0.23.120 → 0.23.123

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.
package/dist/base/flp.js CHANGED
@@ -50,6 +50,7 @@ const cdm_1 = require("./cdm");
50
50
  const node_fs_1 = require("node:fs");
51
51
  const cards_1 = require("./utils/cards");
52
52
  const i18n_1 = require("@sap-ux/i18n");
53
+ const axios_extension_1 = require("@sap-ux/axios-extension");
53
54
  const DEFAULT_LIVERELOAD_PORT = 35729;
54
55
  /**
55
56
  * Class handling preview of a sandbox FLP.
@@ -907,7 +908,7 @@ class FlpSandbox {
907
908
  this.setupAdpCommonHandlers(adp);
908
909
  return;
909
910
  }
910
- configureRta(this.rta, layer, variant.id, adp.isCloudProject);
911
+ configureRta(this.rta, layer, variant.id, adp.projectType === axios_extension_1.AdaptationProjectType.CLOUD_READY);
911
912
  const descriptor = adp.descriptor;
912
913
  const { name, manifest } = descriptor;
913
914
  await this.init(manifest, name, adp.resources, adp);
@@ -95,7 +95,11 @@ sap.ui.define(["sap/ui/model/json/JSONModel", "sap/ui/dt/OverlayRegistry", "../.
95
95
  } else {
96
96
  await this.createFragmentChange(modifiedValue);
97
97
  }
98
- const templateName = getFragmentTemplateName(this.getRuntimeControl().getId(), targetAggregation);
98
+ const selector = {
99
+ id: this.getRuntimeControl().getId(),
100
+ idIsLocal: false
101
+ };
102
+ const templateName = getFragmentTemplateName(selector, targetAggregation);
99
103
  if (templateName) {
100
104
  CommunicationService.sendAction(setApplicationRequiresReload(true));
101
105
  }
@@ -20,6 +20,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
20
20
 
21
21
  /** sap.ui.fl */
22
22
  import { type AddFragmentChangeContentType } from 'sap/ui/fl/Change';
23
+ import type Selector from 'sap/ui/fl/Selector';
23
24
 
24
25
  import { getResourceModel } from '../../i18n';
25
26
 
@@ -158,7 +159,8 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
158
159
  await this.createFragmentChange(modifiedValue);
159
160
  }
160
161
 
161
- const templateName = getFragmentTemplateName(this.getRuntimeControl().getId(), targetAggregation);
162
+ const selector: Selector = { id: this.getRuntimeControl().getId(), idIsLocal: false };
163
+ const templateName = getFragmentTemplateName(selector, targetAggregation);
162
164
  if (templateName) {
163
165
  CommunicationService.sendAction(setApplicationRequiresReload(true));
164
166
  }
@@ -3,18 +3,18 @@
3
3
  sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], function (____utils_core, ____adp_quick_actions_control_types) {
4
4
  "use strict";
5
5
 
6
- const getControlById = ____utils_core["getControlById"];
6
+ const getControlBySelector = ____utils_core["getControlBySelector"];
7
7
  const findViewByControl = ____utils_core["findViewByControl"];
8
8
  const ANALYTICAL_TABLE_TYPE = ____adp_quick_actions_control_types["ANALYTICAL_TABLE_TYPE"];
9
9
  const GRID_TABLE_TYPE = ____adp_quick_actions_control_types["GRID_TABLE_TYPE"];
10
10
  const MDC_TABLE_TYPE = ____adp_quick_actions_control_types["MDC_TABLE_TYPE"];
11
11
  const TREE_TABLE_TYPE = ____adp_quick_actions_control_types["TREE_TABLE_TYPE"];
12
- function getAddXMLAdditionalInfo(change) {
13
- const selectorId = change.getSelector()?.id ?? '';
12
+ function getAddXMLAdditionalInfo(change, appComponent) {
13
+ const selector = change.getSelector();
14
14
  const targetAggregation = change.getContent()?.targetAggregation ?? '';
15
- const targetControl = getControlById(selectorId);
15
+ const targetControl = getControlBySelector(selector, appComponent);
16
16
  const controlType = targetControl?.getMetadata().getName() ?? '';
17
- const templateName = getFragmentTemplateName(selectorId, targetAggregation);
17
+ const templateName = getFragmentTemplateName(selector, targetAggregation, appComponent);
18
18
  const viewName = targetControl ? findViewByControl(targetControl)?.getViewName() ?? '' : '';
19
19
  const result = {};
20
20
  if (templateName) {
@@ -27,8 +27,8 @@ sap.ui.define(["../../utils/core", "../../adp/quick-actions/control-types"], fun
27
27
  }
28
28
  return Object.keys(result).length > 0 ? result : undefined;
29
29
  }
30
- function getFragmentTemplateName(selectorId, targetAggregation) {
31
- const control = getControlById(selectorId);
30
+ function getFragmentTemplateName(selector, targetAggregation, appComponent) {
31
+ const control = getControlBySelector(selector, appComponent);
32
32
  if (!control) {
33
33
  return '';
34
34
  }
@@ -1,5 +1,5 @@
1
1
  import FlexChange from 'sap/ui/fl/Change';
2
- import { getControlById, findViewByControl } from '../../utils/core';
2
+ import { getControlBySelector, findViewByControl } from '../../utils/core';
3
3
  import {
4
4
  ANALYTICAL_TABLE_TYPE,
5
5
  GRID_TABLE_TYPE,
@@ -7,6 +7,8 @@ import {
7
7
  TREE_TABLE_TYPE
8
8
  } from '../../adp/quick-actions/control-types';
9
9
  import Element from 'sap/ui/core/Element';
10
+ import type Component from 'sap/ui/core/Component';
11
+ import type Selector from 'sap/ui/fl/Selector';
10
12
 
11
13
  export type AddXMLAdditionalInfo = {
12
14
  templateName?: string;
@@ -19,12 +21,15 @@ export type AddXMLChangeContent = {
19
21
  targetAggregation?: string;
20
22
  };
21
23
 
22
- export function getAddXMLAdditionalInfo(change: FlexChange<AddXMLChangeContent>): AddXMLAdditionalInfo | undefined {
23
- const selectorId = change.getSelector()?.id ?? '';
24
+ export function getAddXMLAdditionalInfo(
25
+ change: FlexChange<AddXMLChangeContent>,
26
+ appComponent?: Component
27
+ ): AddXMLAdditionalInfo | undefined {
28
+ const selector = change.getSelector();
24
29
  const targetAggregation = change.getContent()?.targetAggregation ?? '';
25
- const targetControl = getControlById(selectorId);
30
+ const targetControl = getControlBySelector(selector, appComponent);
26
31
  const controlType = targetControl?.getMetadata().getName() ?? '';
27
- const templateName = getFragmentTemplateName(selectorId, targetAggregation);
32
+ const templateName = getFragmentTemplateName(selector, targetAggregation, appComponent);
28
33
  const viewName = targetControl ? (findViewByControl(targetControl)?.getViewName() ?? '') : '';
29
34
 
30
35
  const result: AddXMLAdditionalInfo = {};
@@ -40,8 +45,12 @@ export function getAddXMLAdditionalInfo(change: FlexChange<AddXMLChangeContent>)
40
45
  return Object.keys(result).length > 0 ? result : undefined;
41
46
  }
42
47
 
43
- export function getFragmentTemplateName(selectorId: string, targetAggregation: string): string {
44
- const control = getControlById(selectorId);
48
+ export function getFragmentTemplateName(
49
+ selector: Selector | undefined,
50
+ targetAggregation: string,
51
+ appComponent?: Component
52
+ ): string {
53
+ const control = getControlBySelector(selector, appComponent);
45
54
 
46
55
  if (!control) {
47
56
  return '';
@@ -354,7 +354,7 @@ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
354
354
  * @returns {Promise<void>} A promise that resolves when the command is handled.
355
355
  */
356
356
  async handleCommand(command, inactiveCommandCount, index, pendingChanges) {
357
- setAdditionalChangeInfo(command?.getPreparedChange?.());
357
+ setAdditionalChangeInfo(command?.getPreparedChange?.(), this.options.rta.getRootControlInstance());
358
358
  const pendingChange = await this.prepareChangeType(command, inactiveCommandCount, index);
359
359
  if (pendingChange) {
360
360
  pendingChanges.push(pendingChange);
@@ -416,7 +416,7 @@ export class ChangeService extends EventTarget {
416
416
  index: number,
417
417
  pendingChanges: PendingChange[]
418
418
  ): Promise<void> {
419
- setAdditionalChangeInfo(command?.getPreparedChange?.());
419
+ setAdditionalChangeInfo(command?.getPreparedChange?.(), this.options.rta.getRootControlInstance());
420
420
  const pendingChange = await this.prepareChangeType(command, inactiveCommandCount, index);
421
421
  if (pendingChange) {
422
422
  pendingChanges.push(pendingChange);
@@ -10,15 +10,16 @@ sap.ui.define(["../cpe/additional-change-info/add-xml-additional-info"], functio
10
10
  * This function is used to set additional change information for a given change.
11
11
  *
12
12
  * @param change - The change object for which additional information is to be set.
13
+ * @param appComponent - The app component (optional), used to resolve controls in projects with local IDs.
13
14
  */
14
- function setAdditionalChangeInfo(change) {
15
+ function setAdditionalChangeInfo(change, appComponent) {
15
16
  if (!change) {
16
17
  return;
17
18
  }
18
19
  let additionalChangeInfo;
19
20
  const key = change.getDefinition().fileName;
20
21
  if (change?.getChangeType?.() === 'addXML') {
21
- additionalChangeInfo = getAddXMLAdditionalInfo(change);
22
+ additionalChangeInfo = getAddXMLAdditionalInfo(change, appComponent);
22
23
  }
23
24
  if (additionalChangeInfo) {
24
25
  const existingInfo = additionalChangeInfoMap.get(key);
@@ -5,6 +5,7 @@ import {
5
5
  type AddXMLChangeContent
6
6
  } from '../cpe/additional-change-info/add-xml-additional-info';
7
7
  import { FlexChange as Change } from '../flp/common';
8
+ import type Component from 'sap/ui/core/Component';
8
9
 
9
10
  export type AdditionalChangeInfo = AddXMLAdditionalInfo | undefined;
10
11
 
@@ -14,8 +15,12 @@ const additionalChangeInfoMap = new Map<string, AdditionalChangeInfo>();
14
15
  * This function is used to set additional change information for a given change.
15
16
  *
16
17
  * @param change - The change object for which additional information is to be set.
18
+ * @param appComponent - The app component (optional), used to resolve controls in projects with local IDs.
17
19
  */
18
- export function setAdditionalChangeInfo(change: FlexChange<AddXMLChangeContent> | undefined): void {
20
+ export function setAdditionalChangeInfo(
21
+ change: FlexChange<AddXMLChangeContent> | undefined,
22
+ appComponent?: Component
23
+ ): void {
19
24
  if (!change) {
20
25
  return;
21
26
  }
@@ -23,7 +28,7 @@ export function setAdditionalChangeInfo(change: FlexChange<AddXMLChangeContent>
23
28
  let additionalChangeInfo;
24
29
  const key = change.getDefinition().fileName;
25
30
  if (change?.getChangeType?.() === 'addXML') {
26
- additionalChangeInfo = getAddXMLAdditionalInfo(change);
31
+ additionalChangeInfo = getAddXMLAdditionalInfo(change, appComponent);
27
32
  }
28
33
 
29
34
  if (additionalChangeInfo) {
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Component, Element) {
3
+ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element", "sap/ui/core/util/reflection/JsControlTreeModifier", "sap/base/Log", "./error"], function (Component, Element, JsControlTreeModifier, Log, ___error) {
4
4
  "use strict";
5
5
 
6
+ const getError = ___error["getError"];
6
7
  /**
7
8
  * Gets Component by id.
8
9
  *
@@ -35,6 +36,29 @@ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Compon
35
36
  }
36
37
  }
37
38
 
39
+ /**
40
+ * Gets target control by trying getControlById first, then falling back to JsControlTreeModifier.bySelector
41
+ * for projects where the control may not be found by global ID.
42
+ *
43
+ * @param selector - The selector object from the change.
44
+ * @param appComponent - The app component (optional).
45
+ * @returns The target control element or undefined.
46
+ */
47
+ function getControlBySelector(selector, appComponent) {
48
+ if (!selector?.id) {
49
+ return undefined;
50
+ }
51
+ let control = getControlById(selector.id);
52
+ if (!control && appComponent && selector) {
53
+ try {
54
+ control = JsControlTreeModifier.bySelector(selector, appComponent);
55
+ } catch (error) {
56
+ Log.warning('Failed to get control by selector:', getError(error));
57
+ }
58
+ }
59
+ return control;
60
+ }
61
+
38
62
  /**
39
63
  * Checks wether this object is an instance of a ManagedObject.
40
64
  *
@@ -109,6 +133,7 @@ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/Element"], function (Compon
109
133
  };
110
134
  __exports.getComponent = getComponent;
111
135
  __exports.getControlById = getControlById;
136
+ __exports.getControlBySelector = getControlBySelector;
112
137
  __exports.isManagedObject = isManagedObject;
113
138
  __exports.isA = isA;
114
139
  __exports.hasParent = hasParent;
@@ -3,6 +3,10 @@ import type { ID } from 'sap/ui/core/library';
3
3
  import type ManagedObject from 'sap/ui/base/ManagedObject';
4
4
  import Element from 'sap/ui/core/Element';
5
5
  import View from 'sap/ui/core/mvc/View';
6
+ import type Selector from 'sap/ui/fl/Selector';
7
+ import JsControlTreeModifier from 'sap/ui/core/util/reflection/JsControlTreeModifier';
8
+ import Log from 'sap/base/Log';
9
+ import { getError } from './error';
6
10
 
7
11
  /**
8
12
  * Gets Component by id.
@@ -36,6 +40,34 @@ export function getControlById<T extends Element = Element>(id: string): T | und
36
40
  }
37
41
  }
38
42
 
43
+ /**
44
+ * Gets target control by trying getControlById first, then falling back to JsControlTreeModifier.bySelector
45
+ * for projects where the control may not be found by global ID.
46
+ *
47
+ * @param selector - The selector object from the change.
48
+ * @param appComponent - The app component (optional).
49
+ * @returns The target control element or undefined.
50
+ */
51
+ export function getControlBySelector<T extends Element = Element>(
52
+ selector: Selector | undefined,
53
+ appComponent?: Component
54
+ ): T | undefined {
55
+ if (!selector?.id) {
56
+ return undefined;
57
+ }
58
+
59
+ let control = getControlById<T>(selector.id);
60
+ if (!control && appComponent && selector) {
61
+ try {
62
+ control = JsControlTreeModifier.bySelector(selector, appComponent) as unknown as T | undefined;
63
+ } catch (error) {
64
+ Log.warning('Failed to get control by selector:', getError(error));
65
+ }
66
+ }
67
+
68
+ return control;
69
+ }
70
+
39
71
  /**
40
72
  * Checks wether this object is an instance of a ManagedObject.
41
73
  *
@@ -110,4 +142,4 @@ export function findNestedElements(
110
142
  ): Element[] {
111
143
  const ownerId = ownerElement.getId();
112
144
  return candidates.filter((item) => hasParent(item, ownerId));
113
- }
145
+ }
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.120",
12
+ "version": "0.23.123",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -26,15 +26,15 @@
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "qrcode": "1.5.4",
29
- "@sap/bas-sdk": "3.13.2",
30
- "@sap-ux/adp-tooling": "0.18.63",
31
- "@sap-ux/btp-utils": "1.1.8",
29
+ "@sap/bas-sdk": "3.13.3",
30
+ "@sap-ux/adp-tooling": "0.18.65",
32
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.11",
33
32
  "@sap-ux/feature-toggle": "0.3.6",
33
+ "@sap-ux/btp-utils": "1.1.9",
34
+ "@sap-ux/project-access": "1.35.4",
35
+ "@sap-ux/i18n": "0.3.7",
34
36
  "@sap-ux/logger": "0.8.1",
35
- "@sap-ux/project-access": "1.35.3",
36
- "@sap-ux/system-access": "0.6.51",
37
- "@sap-ux/i18n": "0.3.7"
37
+ "@sap-ux/system-access": "0.6.53"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@sap-ux-private/playwright": "0.2.6",
@@ -53,10 +53,10 @@
53
53
  "nock": "13.4.0",
54
54
  "npm-run-all2": "6.2.0",
55
55
  "supertest": "7.1.4",
56
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.17",
57
- "@sap-ux/axios-extension": "1.25.11",
56
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.18.18",
58
57
  "@sap-ux/store": "1.5.6",
59
- "@sap-ux/ui5-info": "0.13.12"
58
+ "@sap-ux/ui5-info": "0.13.12",
59
+ "@sap-ux/axios-extension": "1.25.13"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "express": "4"