@sap-ux/preview-middleware 0.19.8 → 0.19.10

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.
@@ -71,9 +71,9 @@ sap.ui.define([
71
71
  this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
72
72
  },
73
73
  onCreateBtnPress: async function _onCreateBtnPress(event) {
74
- await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
75
74
  const source = event.getSource();
76
75
  source.setEnabled(false);
76
+ await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
77
77
  const fragmentName = this.model.getProperty('/newFragmentName');
78
78
  const index = this.model.getProperty('/selectedIndex');
79
79
  const targetAggregation = this.model.getProperty('/selectedAggregation/value');
@@ -142,10 +142,11 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
142
142
  * @param event Event
143
143
  */
144
144
  async onCreateBtnPress(event: Event) {
145
- await super.onCreateBtnPressHandler();
146
145
  const source = event.getSource<Button>();
147
146
  source.setEnabled(false);
148
147
 
148
+ await super.onCreateBtnPressHandler();
149
+
149
150
  const fragmentName = this.model.getProperty('/newFragmentName');
150
151
  const index = this.model.getProperty('/selectedIndex');
151
152
  const targetAggregation = this.model.getProperty('/selectedAggregation/value');
@@ -80,8 +80,8 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
80
80
  * @param event Event
81
81
  */
82
82
  onCreateBtnPress: async function _onCreateBtnPress(event) {
83
- await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
84
83
  const source = event.getSource();
84
+ await BaseDialog.prototype.onCreateBtnPressHandler.call(this);
85
85
  const controllerExists = this.model.getProperty('/controllerExists');
86
86
  if (!controllerExists) {
87
87
  source.setEnabled(false);
@@ -128,8 +128,10 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
128
128
  * @param event Event
129
129
  */
130
130
  async onCreateBtnPress(event: Event) {
131
- await super.onCreateBtnPressHandler();
132
131
  const source = event.getSource<Button>();
132
+
133
+ await super.onCreateBtnPressHandler();
134
+
133
135
  const controllerExists = this.model.getProperty('/controllerExists');
134
136
 
135
137
  if (!controllerExists) {
@@ -1,26 +1,27 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/rta/util/hasStableId", "sap/ui/fl/Utils", "../cpe/utils", "./dialog-factory"], function (hasStableId, FlUtils, ___cpe_utils, ___dialog_factory) {
3
+ sap.ui.define(["sap/ui/rta/util/hasStableId", "sap/ui/fl/Utils", "./dialog-factory", "../i18n", "./utils"], function (hasStableId, FlUtils, ___dialog_factory, ___i18n, ___utils) {
4
4
  "use strict";
5
5
 
6
- const isReuseComponent = ___cpe_utils["isReuseComponent"];
7
6
  const DialogFactory = ___dialog_factory["DialogFactory"];
8
7
  const DialogNames = ___dialog_factory["DialogNames"];
8
+ const getTextBundle = ___i18n["getTextBundle"];
9
+ const getReuseComponentChecker = ___utils["getReuseComponentChecker"];
9
10
  /**
10
11
  * Handler for enablement of Extend With Controller context menu entry
11
12
  *
12
13
  * @param control UI5 control.
13
14
  * @param syncViewsIds Runtime Authoring
14
- * @param ui5VersionInfo UI5 version information
15
+ * @param isReuseComponent Function to check if the control is a reuse component.
15
16
  * @param isCloud Whether the application is running in the cloud
16
17
  *
17
18
  * @returns boolean whether menu item is enabled or not
18
19
  */
19
- function isControllerExtensionEnabledForControl(control, syncViewsIds, ui5VersionInfo, isCloud) {
20
- const clickedControlId = FlUtils.getViewForControl(control).getId();
21
- const isControlInSyncView = syncViewsIds.includes(clickedControlId);
20
+ function isControllerExtensionEnabledForControl(control, syncViewsIds, isReuseComponent, isCloud) {
21
+ const viewId = FlUtils.getViewForControl(control).getId();
22
+ const isControlInSyncView = syncViewsIds.includes(viewId);
22
23
  if (isCloud) {
23
- const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
24
+ const isClickedControlReuseComponent = isReuseComponent(control.getId());
24
25
  return !isControlInSyncView && !isClickedControlReuseComponent;
25
26
  }
26
27
  return !isControlInSyncView;
@@ -31,44 +32,71 @@ sap.ui.define(["sap/ui/rta/util/hasStableId", "sap/ui/fl/Utils", "../cpe/utils",
31
32
  *
32
33
  * @param overlays Control overlays
33
34
  * @param syncViewsIds Runtime Authoring
34
- * @param ui5VersionInfo UI5 version information
35
+ * @param isReuseComponent Function to check if the control is a reuse component.
35
36
  * @param isCloud Whether the application is running in the cloud
36
37
  *
37
38
  * @returns boolean whether menu item is enabled or not
38
39
  */
39
- const isControllerExtensionEnabled = (overlays, syncViewsIds, ui5VersionInfo, isCloud) => {
40
+ const isControllerExtensionEnabled = (overlays, syncViewsIds, isReuseComponent, isCloud) => {
40
41
  if (overlays.length === 0 || overlays.length > 1) {
41
42
  return false;
42
43
  }
43
- return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo, isCloud);
44
+ return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, isReuseComponent, isCloud);
44
45
  };
45
46
 
46
47
  /**
47
48
  * Determines whether the fragment command should be enabled based on the provided overlays.
48
49
  *
49
50
  * @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
50
- * @param ui5VersionInfo UI5 version information
51
+ * @param {isReuseComponentApi} isReuseComponent - Function to check if the control is a reuse component.
52
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
51
53
  * @returns {boolean} True if the fragment command is enabled, false otherwise.
52
54
  */
53
- const isFragmentCommandEnabled = (overlays, ui5VersionInfo) => {
55
+ const isFragmentCommandEnabled = (overlays, isReuseComponent, isCloud) => {
54
56
  if (overlays.length === 0 || overlays.length > 1) {
55
57
  return false;
56
58
  }
57
59
  const control = overlays[0].getElement();
58
- return hasStableId(overlays[0]) && !isReuseComponent(control.getId(), ui5VersionInfo);
60
+ const stableId = hasStableId(overlays[0]);
61
+ if (isCloud) {
62
+ return stableId && !isReuseComponent(control.getId());
63
+ }
64
+ return stableId;
59
65
  };
60
66
 
61
67
  /**
62
68
  * Determines the text that should be displayed for the Add Fragment context menu item.
63
69
  *
64
70
  * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
71
+ * @param {isReuseComponentApi} isReuseComponentChecker - Function to check if the control is a reuse component.
72
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
73
+ * @param {TextBundle} resources - The text bundle.
65
74
  * @returns {string} The text of the Add Fragment context menu item.
66
75
  */
67
- const getAddFragmentItemText = overlay => {
76
+ const getAddFragmentItemText = (overlay, isReuseComponentChecker, isCloud, resources) => {
77
+ if (isCloud && isReuseComponentChecker(overlay.getElement().getId())) {
78
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT');
79
+ }
68
80
  if (!hasStableId(overlay)) {
69
- return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
81
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID');
82
+ }
83
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM');
84
+ };
85
+
86
+ /**
87
+ * Determines the text that should be displayed for Controller Extension context menu item.
88
+ *
89
+ * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
90
+ * @param {isReuseComponentApi} isReuseComponentChecker - Function to check if the control is a reuse component.
91
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
92
+ * @param {TextBundle} resources - The text bundle.
93
+ * @returns {string} The text of the Add Fragment context menu item.
94
+ */
95
+ const getExtendControllerItemText = (overlay, isReuseComponentChecker, isCloud, resources) => {
96
+ if (isCloud && isReuseComponentChecker(overlay.getElement().getId())) {
97
+ return resources.getText('ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT');
70
98
  }
71
- return 'Add: Fragment';
99
+ return resources.getText('ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM');
72
100
  };
73
101
 
74
102
  /**
@@ -78,22 +106,24 @@ sap.ui.define(["sap/ui/rta/util/hasStableId", "sap/ui/fl/Utils", "../cpe/utils",
78
106
  * @param syncViewsIds Ids of all application sync views
79
107
  * @param ui5VersionInfo UI5 version information
80
108
  */
81
- const initDialogs = (rta, syncViewsIds, ui5VersionInfo) => {
109
+ const initDialogs = async (rta, syncViewsIds, ui5VersionInfo) => {
82
110
  const contextMenu = rta.getDefaultPlugins().contextMenu;
83
111
  const isCloud = rta.getFlexSettings().isCloud;
112
+ const resources = await getTextBundle();
113
+ const isReuseComponentChecker = await getReuseComponentChecker(ui5VersionInfo);
84
114
  contextMenu.addMenuItem({
85
115
  id: 'ADD_FRAGMENT',
86
- text: getAddFragmentItemText,
116
+ text: overlay => getAddFragmentItemText(overlay, isReuseComponentChecker, isCloud, resources),
87
117
  handler: async overlays => await DialogFactory.createDialog(overlays[0], rta, DialogNames.ADD_FRAGMENT),
88
118
  icon: 'sap-icon://attachment-html',
89
- enabled: overlays => isFragmentCommandEnabled(overlays, ui5VersionInfo)
119
+ enabled: overlays => isFragmentCommandEnabled(overlays, isReuseComponentChecker, isCloud)
90
120
  });
91
121
  contextMenu.addMenuItem({
92
122
  id: 'EXTEND_CONTROLLER',
93
- text: 'Extend With Controller',
123
+ text: overlay => getExtendControllerItemText(overlay, isReuseComponentChecker, isCloud, resources),
94
124
  handler: async overlays => await DialogFactory.createDialog(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
95
125
  icon: 'sap-icon://create-form',
96
- enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds, ui5VersionInfo, isCloud)
126
+ enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds, isReuseComponentChecker, isCloud)
97
127
  });
98
128
  };
99
129
  var __exports = {
@@ -103,6 +133,7 @@ sap.ui.define(["sap/ui/rta/util/hasStableId", "sap/ui/fl/Utils", "../cpe/utils",
103
133
  __exports.isControllerExtensionEnabled = isControllerExtensionEnabled;
104
134
  __exports.isFragmentCommandEnabled = isFragmentCommandEnabled;
105
135
  __exports.getAddFragmentItemText = getAddFragmentItemText;
136
+ __exports.getExtendControllerItemText = getExtendControllerItemText;
106
137
  __exports.initDialogs = initDialogs;
107
138
  return __exports;
108
139
  });
@@ -12,16 +12,18 @@ import FlUtils from 'sap/ui/fl/Utils';
12
12
  import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
13
13
 
14
14
  import ManagedObject from 'sap/ui/base/ManagedObject';
15
- import { isReuseComponent } from '../cpe/utils';
16
- import { Ui5VersionInfo } from '../utils/version';
17
15
  import { DialogFactory, DialogNames } from './dialog-factory';
16
+ import type { IsReuseComponentApi } from '../cpe/types';
17
+ import { getTextBundle, type TextBundle } from '../i18n';
18
+ import { getReuseComponentChecker } from './utils';
19
+ import type { Ui5VersionInfo } from '../utils/version';
18
20
 
19
21
  /**
20
22
  * Handler for enablement of Extend With Controller context menu entry
21
23
  *
22
24
  * @param control UI5 control.
23
25
  * @param syncViewsIds Runtime Authoring
24
- * @param ui5VersionInfo UI5 version information
26
+ * @param isReuseComponent Function to check if the control is a reuse component.
25
27
  * @param isCloud Whether the application is running in the cloud
26
28
  *
27
29
  * @returns boolean whether menu item is enabled or not
@@ -29,14 +31,14 @@ import { DialogFactory, DialogNames } from './dialog-factory';
29
31
  export function isControllerExtensionEnabledForControl(
30
32
  control: ManagedObject,
31
33
  syncViewsIds: string[],
32
- ui5VersionInfo: Ui5VersionInfo,
34
+ isReuseComponent: IsReuseComponentApi,
33
35
  isCloud: boolean
34
36
  ): boolean {
35
- const clickedControlId = FlUtils.getViewForControl(control).getId();
36
- const isControlInSyncView = syncViewsIds.includes(clickedControlId);
37
+ const viewId = FlUtils.getViewForControl(control).getId();
38
+ const isControlInSyncView = syncViewsIds.includes(viewId);
37
39
 
38
40
  if(isCloud) {
39
- const isClickedControlReuseComponent = isReuseComponent(clickedControlId, ui5VersionInfo);
41
+ const isClickedControlReuseComponent = isReuseComponent(control.getId());
40
42
  return !isControlInSyncView && !isClickedControlReuseComponent;
41
43
  }
42
44
  return !isControlInSyncView;
@@ -47,7 +49,7 @@ export function isControllerExtensionEnabledForControl(
47
49
  *
48
50
  * @param overlays Control overlays
49
51
  * @param syncViewsIds Runtime Authoring
50
- * @param ui5VersionInfo UI5 version information
52
+ * @param isReuseComponent Function to check if the control is a reuse component.
51
53
  * @param isCloud Whether the application is running in the cloud
52
54
  *
53
55
  * @returns boolean whether menu item is enabled or not
@@ -55,44 +57,72 @@ export function isControllerExtensionEnabledForControl(
55
57
  export const isControllerExtensionEnabled = (
56
58
  overlays: ElementOverlay[],
57
59
  syncViewsIds: string[],
58
- ui5VersionInfo: Ui5VersionInfo,
60
+ isReuseComponent: IsReuseComponentApi,
59
61
  isCloud: boolean
60
62
  ): boolean => {
61
63
  if (overlays.length === 0 || overlays.length > 1) {
62
64
  return false;
63
65
  }
64
- return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, ui5VersionInfo, isCloud);
66
+ return isControllerExtensionEnabledForControl(overlays[0].getElement(), syncViewsIds, isReuseComponent, isCloud);
65
67
  };
66
68
 
67
69
  /**
68
70
  * Determines whether the fragment command should be enabled based on the provided overlays.
69
71
  *
70
72
  * @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
71
- * @param ui5VersionInfo UI5 version information
73
+ * @param {isReuseComponentApi} isReuseComponent - Function to check if the control is a reuse component.
74
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
72
75
  * @returns {boolean} True if the fragment command is enabled, false otherwise.
73
76
  */
74
- export const isFragmentCommandEnabled = (overlays: ElementOverlay[], ui5VersionInfo: Ui5VersionInfo): boolean => {
77
+ export const isFragmentCommandEnabled = (overlays: ElementOverlay[], isReuseComponent: IsReuseComponentApi, isCloud: boolean): boolean => {
75
78
  if (overlays.length === 0 || overlays.length > 1) {
76
79
  return false;
77
80
  }
78
81
 
79
82
  const control = overlays[0].getElement();
83
+ const stableId = hasStableId(overlays[0]);
84
+ if (isCloud) {
85
+ return stableId && !isReuseComponent(control.getId());
86
+ }
80
87
 
81
- return hasStableId(overlays[0]) && !isReuseComponent(control.getId(), ui5VersionInfo);
88
+ return stableId;
82
89
  };
83
90
 
84
91
  /**
85
92
  * Determines the text that should be displayed for the Add Fragment context menu item.
86
93
  *
87
94
  * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
95
+ * @param {isReuseComponentApi} isReuseComponentChecker - Function to check if the control is a reuse component.
96
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
97
+ * @param {TextBundle} resources - The text bundle.
88
98
  * @returns {string} The text of the Add Fragment context menu item.
89
99
  */
90
- export const getAddFragmentItemText = (overlay: ElementOverlay) => {
100
+ export const getAddFragmentItemText = (overlay: ElementOverlay, isReuseComponentChecker: IsReuseComponentApi, isCloud: boolean, resources: TextBundle) => {
101
+ if (isCloud && isReuseComponentChecker(overlay.getElement().getId())) {
102
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT');
103
+ }
91
104
  if (!hasStableId(overlay)) {
92
- return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
105
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID');
106
+ }
107
+
108
+ return resources.getText('ADP_ADD_FRAGMENT_MENU_ITEM');
109
+ };
110
+
111
+ /**
112
+ * Determines the text that should be displayed for Controller Extension context menu item.
113
+ *
114
+ * @param {ElementOverlay} overlay - An ElementOverlay object representing the UI overlay.
115
+ * @param {isReuseComponentApi} isReuseComponentChecker - Function to check if the control is a reuse component.
116
+ * @param {boolean} isCloud - Whether the application is running in the cloud.
117
+ * @param {TextBundle} resources - The text bundle.
118
+ * @returns {string} The text of the Add Fragment context menu item.
119
+ */
120
+ export const getExtendControllerItemText = (overlay: ElementOverlay, isReuseComponentChecker: IsReuseComponentApi, isCloud: boolean, resources: TextBundle) => {
121
+ if (isCloud && isReuseComponentChecker(overlay.getElement().getId())) {
122
+ return resources.getText('ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT');
93
123
  }
94
124
 
95
- return 'Add: Fragment';
125
+ return resources.getText('ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM');
96
126
  };
97
127
 
98
128
  /**
@@ -102,25 +132,27 @@ export const getAddFragmentItemText = (overlay: ElementOverlay) => {
102
132
  * @param syncViewsIds Ids of all application sync views
103
133
  * @param ui5VersionInfo UI5 version information
104
134
  */
105
- export const initDialogs = (rta: RuntimeAuthoring, syncViewsIds: string[], ui5VersionInfo: Ui5VersionInfo): void => {
135
+ export const initDialogs = async (rta: RuntimeAuthoring, syncViewsIds: string[], ui5VersionInfo: Ui5VersionInfo): Promise<void> => {
106
136
  const contextMenu = rta.getDefaultPlugins().contextMenu;
107
137
  const isCloud = rta.getFlexSettings().isCloud;
138
+ const resources = await getTextBundle();
139
+ const isReuseComponentChecker = await getReuseComponentChecker(ui5VersionInfo);
108
140
 
109
141
  contextMenu.addMenuItem({
110
142
  id: 'ADD_FRAGMENT',
111
- text: getAddFragmentItemText,
143
+ text: (overlay: ElementOverlay) => getAddFragmentItemText(overlay, isReuseComponentChecker, isCloud, resources),
112
144
  handler: async (overlays: UI5Element[]) =>
113
145
  await DialogFactory.createDialog(overlays[0], rta, DialogNames.ADD_FRAGMENT),
114
146
  icon: 'sap-icon://attachment-html',
115
- enabled: (overlays: ElementOverlay[]) => isFragmentCommandEnabled(overlays, ui5VersionInfo)
147
+ enabled: (overlays: ElementOverlay[]) => isFragmentCommandEnabled(overlays, isReuseComponentChecker, isCloud)
116
148
  });
117
149
 
118
150
  contextMenu.addMenuItem({
119
151
  id: 'EXTEND_CONTROLLER',
120
- text: 'Extend With Controller',
152
+ text: (overlay: ElementOverlay) => getExtendControllerItemText(overlay, isReuseComponentChecker, isCloud, resources),
121
153
  handler: async (overlays: UI5Element[]) =>
122
154
  await DialogFactory.createDialog(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
123
155
  icon: 'sap-icon://create-form',
124
- enabled: (overlays: ElementOverlay[]) => isControllerExtensionEnabled(overlays, syncViewsIds, ui5VersionInfo, isCloud)
156
+ enabled: (overlays: ElementOverlay[]) => isControllerExtensionEnabled(overlays, syncViewsIds, isReuseComponentChecker, isCloud)
125
157
  });
126
158
  };
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  }
48
48
  const ui5VersionInfo = await getUi5Version();
49
49
  const syncViewsIds = await getAllSyncViewsIds(ui5VersionInfo);
50
- initDialogs(rta, syncViewsIds, ui5VersionInfo);
50
+ await initDialogs(rta, syncViewsIds, ui5VersionInfo);
51
51
  if (!isLowerThanMinimalUi5Version(ui5VersionInfo, {
52
52
  major: 1,
53
53
  minor: 78
@@ -22,7 +22,8 @@ export default async function (rta: RuntimeAuthoring) {
22
22
 
23
23
  const ui5VersionInfo = await getUi5Version();
24
24
  const syncViewsIds = await getAllSyncViewsIds(ui5VersionInfo);
25
- initDialogs(rta, syncViewsIds, ui5VersionInfo);
25
+
26
+ await initDialogs(rta, syncViewsIds, ui5VersionInfo);
26
27
 
27
28
  if (!isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 78 })) {
28
29
  const ExtensionPointService = (await import('open/ux/preview/client/adp/extension-point')).default;
@@ -6,6 +6,7 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/version", "../../uti
6
6
  const getUi5Version = _____utils_version["getUi5Version"];
7
7
  const getAllSyncViewsIds = ____utils["getAllSyncViewsIds"];
8
8
  const getControllerInfoForControl = ____utils["getControllerInfoForControl"];
9
+ const getReuseComponentChecker = ____utils["getReuseComponentChecker"];
9
10
  const getRelevantControlFromActivePage = _____cpe_quick_actions_utils["getRelevantControlFromActivePage"];
10
11
  const DialogFactory = ____dialog_factory["DialogFactory"];
11
12
  const DialogNames = ____dialog_factory["DialogNames"];
@@ -25,13 +26,14 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/version", "../../uti
25
26
  }
26
27
  controllerExists = false;
27
28
  async initialize() {
29
+ const version = await getUi5Version();
30
+ const isReuseComponent = await getReuseComponentChecker(version);
28
31
  for (const control of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)) {
29
- const version = await getUi5Version();
30
32
  const syncViewsIds = await getAllSyncViewsIds(version);
31
33
  const controlInfo = getControllerInfoForControl(control);
32
34
  const data = await getExistingController(controlInfo.controllerName);
33
35
  this.controllerExists = data?.controllerExists;
34
- const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, version, this.context.flexSettings.isCloud);
36
+ const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, isReuseComponent, this.context.flexSettings.isCloud);
35
37
  this.control = isActiveAction ? control : undefined;
36
38
  break;
37
39
  }
@@ -2,7 +2,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
2
2
  import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
3
 
4
4
  import { getUi5Version } from '../../../utils/version';
5
- import { getAllSyncViewsIds, getControllerInfoForControl } from '../../utils';
5
+ import { getAllSyncViewsIds, getControllerInfoForControl, getReuseComponentChecker } from '../../utils';
6
6
  import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
7
7
  import type {
8
8
  QuickActionContext,
@@ -31,22 +31,19 @@ export class AddControllerToPageQuickAction
31
31
  private controllerExists = false;
32
32
 
33
33
  async initialize(): Promise<void> {
34
+ const version = await getUi5Version();
35
+ const isReuseComponent = await getReuseComponentChecker(version);
36
+
34
37
  for (const control of getRelevantControlFromActivePage(
35
38
  this.context.controlIndex,
36
39
  this.context.view,
37
40
  CONTROL_TYPES
38
41
  )) {
39
- const version = await getUi5Version();
40
42
  const syncViewsIds = await getAllSyncViewsIds(version);
41
43
  const controlInfo = getControllerInfoForControl(control);
42
44
  const data = await getExistingController(controlInfo.controllerName);
43
45
  this.controllerExists = data?.controllerExists;
44
- const isActiveAction = isControllerExtensionEnabledForControl(
45
- control,
46
- syncViewsIds,
47
- version,
48
- this.context.flexSettings.isCloud
49
- );
46
+ const isActiveAction = isControllerExtensionEnabledForControl(control, syncViewsIds, isReuseComponent, this.context.flexSettings.isCloud);
50
47
  this.control = isActiveAction ? control : undefined;
51
48
  break;
52
49
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap/ui/fl/Utils", "../utils/error", "../utils/version"], function (MessageToast, Element, Log, FlexUtils, ___utils_error, ___utils_version) {
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap/ui/fl/Utils", "../utils/core", "../utils/error", "../utils/version"], function (MessageToast, Element, Log, FlexUtils, ___utils_core, ___utils_error, ___utils_version) {
4
4
  "use strict";
5
5
 
6
6
  function __ui5_require_async(path) {
@@ -20,8 +20,18 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap
20
20
  });
21
21
  });
22
22
  }
23
+ const getControlById = ___utils_core["getControlById"];
23
24
  const getError = ___utils_error["getError"];
24
25
  const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
26
+ let reuseComponentChecker;
27
+
28
+ /**
29
+ * Resets the reuse component checker.
30
+ */
31
+ function resetReuseComponentChecker() {
32
+ reuseComponentChecker = undefined;
33
+ }
34
+
25
35
  /**
26
36
  * Defers the resolution of the promise, stores resolve/reject functions so that they can be accessed at a later stage.
27
37
  *
@@ -148,15 +158,63 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap
148
158
  const control = overlayControl.getElement();
149
159
  return getControllerInfoForControl(control);
150
160
  }
161
+
162
+ /**
163
+ * Gets the reuse component checker function.
164
+ *
165
+ * @param ui5VersionInfo UI5 version information.
166
+ * @returns The reuse component checker function.
167
+ */
168
+ async function getReuseComponentChecker(ui5VersionInfo) {
169
+ if (reuseComponentChecker) {
170
+ return reuseComponentChecker;
171
+ }
172
+ let reuseComponentApi;
173
+ if (!isLowerThanMinimalUi5Version(ui5VersionInfo, {
174
+ major: 1,
175
+ minor: 134
176
+ })) {
177
+ reuseComponentApi = (await __ui5_require_async('sap/ui/rta/util/isReuseComponent')).default;
178
+ }
179
+ reuseComponentChecker = function isReuseComponent(controlId) {
180
+ const ui5Control = getControlById(controlId);
181
+ if (!ui5Control) {
182
+ return false;
183
+ }
184
+ const component = FlexUtils.getComponentForControl(ui5Control);
185
+ if (reuseComponentApi) {
186
+ return reuseComponentApi.isReuseComponent(component);
187
+ }
188
+ if (!component) {
189
+ return false;
190
+ }
191
+ const appComponent = FlexUtils.getAppComponentForControl(component);
192
+ if (!appComponent) {
193
+ return false;
194
+ }
195
+ const manifest = component.getManifest();
196
+ const appManifest = appComponent.getManifest();
197
+ const componentName = manifest?.['sap.app']?.id;
198
+
199
+ // Look for component name in component usages of app component manifest
200
+ const componentUsages = appManifest?.['sap.ui5']?.componentUsages;
201
+ return Object.values(componentUsages || {}).some(componentUsage => {
202
+ return componentUsage.name === componentName;
203
+ });
204
+ };
205
+ return reuseComponentChecker;
206
+ }
151
207
  var __exports = {
152
208
  __esModule: true
153
209
  };
210
+ __exports.resetReuseComponentChecker = resetReuseComponentChecker;
154
211
  __exports.createDeferred = createDeferred;
155
212
  __exports.matchesFragmentName = matchesFragmentName;
156
213
  __exports.notifyUser = notifyUser;
157
214
  __exports.getAllSyncViewsIds = getAllSyncViewsIds;
158
215
  __exports.getControllerInfoForControl = getControllerInfoForControl;
159
216
  __exports.getControllerInfo = getControllerInfo;
217
+ __exports.getReuseComponentChecker = getReuseComponentChecker;
160
218
  return __exports;
161
219
  });
162
220
  //# sourceMappingURL=utils.js.map
@@ -6,6 +6,9 @@ import type ManagedObject from 'sap/ui/base/ManagedObject';
6
6
  import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
7
7
  import Log from 'sap/base/Log';
8
8
  import FlexUtils from 'sap/ui/fl/Utils';
9
+ import IsReuseComponentApi from 'sap/ui/rta/util/isReuseComponent';
10
+ import { getControlById } from '../utils/core';
11
+ import type { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
9
12
 
10
13
  import { getError } from '../utils/error';
11
14
  import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../utils/version';
@@ -22,6 +25,17 @@ export interface FragmentChange {
22
25
  };
23
26
  }
24
27
 
28
+ export type ReuseComponentChecker = (controlId: string) => boolean;
29
+
30
+ let reuseComponentChecker: ReuseComponentChecker | undefined;
31
+
32
+ /**
33
+ * Resets the reuse component checker.
34
+ */
35
+ export function resetReuseComponentChecker(): void {
36
+ reuseComponentChecker = undefined;
37
+ }
38
+
25
39
  /**
26
40
  * Defers the resolution of the promise, stores resolve/reject functions so that they can be accessed at a later stage.
27
41
  *
@@ -146,3 +160,54 @@ export function getControllerInfo(overlayControl: ElementOverlay): ControllerInf
146
160
  const control = overlayControl.getElement();
147
161
  return getControllerInfoForControl(control);
148
162
  }
163
+
164
+ /**
165
+ * Gets the reuse component checker function.
166
+ *
167
+ * @param ui5VersionInfo UI5 version information.
168
+ * @returns The reuse component checker function.
169
+ */
170
+ export async function getReuseComponentChecker(ui5VersionInfo: Ui5VersionInfo): Promise<ReuseComponentChecker> {
171
+ if (reuseComponentChecker) {
172
+ return reuseComponentChecker;
173
+ }
174
+
175
+ let reuseComponentApi: IsReuseComponentApi;
176
+ if (!isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 134 })) {
177
+ reuseComponentApi = (await import('sap/ui/rta/util/isReuseComponent')).default;
178
+ }
179
+
180
+ reuseComponentChecker = function isReuseComponent(controlId: string): boolean {
181
+ const ui5Control = getControlById(controlId);
182
+ if (!ui5Control) {
183
+ return false;
184
+ }
185
+
186
+ const component = FlexUtils.getComponentForControl(ui5Control);
187
+
188
+ if (reuseComponentApi) {
189
+ return reuseComponentApi.isReuseComponent(component);
190
+ }
191
+
192
+ if (!component) {
193
+ return false;
194
+ }
195
+
196
+ const appComponent = FlexUtils.getAppComponentForControl(component);
197
+ if (!appComponent) {
198
+ return false;
199
+ }
200
+
201
+ const manifest = component.getManifest() as Manifest;
202
+ const appManifest = appComponent.getManifest() as Manifest;
203
+ const componentName = manifest?.['sap.app']?.id;
204
+
205
+ // Look for component name in component usages of app component manifest
206
+ const componentUsages = appManifest?.['sap.ui5']?.componentUsages;
207
+ return Object.values(componentUsages || {}).some((componentUsage) => {
208
+ return componentUsage.name === componentName;
209
+ });
210
+ };
211
+
212
+ return reuseComponentChecker;
213
+ }
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../../utils/error", "../utils", "./editable", "../../utils/fe-v4"], function (Log, ____utils_version, ____utils_core, ____utils_error, ___utils, ___editable, ____utils_fe_v4) {
3
+ sap.ui.define(["sap/base/Log", "../../utils/core", "../../utils/error", "../utils", "./editable", "../../utils/fe-v4"], function (Log, ____utils_core, ____utils_error, ___utils, ___editable, ____utils_fe_v4) {
4
4
  "use strict";
5
5
 
6
- const getUi5Version = ____utils_version["getUi5Version"];
7
6
  const getControlById = ____utils_core["getControlById"];
8
7
  const getError = ____utils_error["getError"];
9
8
  const getOverlay = ___utils["getOverlay"];
10
- const isReuseComponent = ___utils["isReuseComponent"];
11
9
  const isEditable = ___editable["isEditable"];
12
10
  const getConfigMapControlIdMap = ____utils_fe_v4["getConfigMapControlIdMap"];
13
11
  const getPageName = ____utils_fe_v4["getPageName"];
@@ -111,16 +109,14 @@ sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../..
111
109
  *
112
110
  * @param input outline view node
113
111
  * @param scenario type of project
114
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
115
112
  * @param controlIndex Control tree index
116
113
  * @param changeService ChangeService for change stack event handling.
117
114
  * @param propertyIdMap ChangeService for change stack event handling.
118
115
  * @returns transformed outline tree nodes
119
116
  */
120
- async function transformNodes(input, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap) {
117
+ async function transformNodes(input, scenario, controlIndex, changeService, propertyIdMap) {
121
118
  const stack = [...input];
122
119
  const items = [];
123
- const ui5VersionInfo = await getUi5Version();
124
120
  while (stack.length) {
125
121
  try {
126
122
  const current = stack.shift();
@@ -133,7 +129,7 @@ sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../..
133
129
  text
134
130
  } = getAdditionalData(current.id);
135
131
  const technicalName = current.technicalName.split('.').slice(-1)[0];
136
- const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap) : await transformNodes(children, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap);
132
+ const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, controlIndex, changeService, propertyIdMap) : await transformNodes(children, scenario, controlIndex, changeService, propertyIdMap);
137
133
  const node = {
138
134
  controlId: current.id,
139
135
  controlType: current.technicalName,
@@ -144,7 +140,6 @@ sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../..
144
140
  };
145
141
  indexNode(controlIndex, node);
146
142
  addToPropertyIdMap(node, propertyIdMap);
147
- fillReuseComponents(reuseComponentsIds, current, scenario, ui5VersionInfo);
148
143
  items.push(node);
149
144
  }
150
145
  if (isAdp && isExtPoint) {
@@ -175,32 +170,18 @@ sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../..
175
170
  return items;
176
171
  }
177
172
 
178
- /**
179
- * Fill reuse components ids.
180
- *
181
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
182
- * @param node view node
183
- * @param scenario type of project
184
- * @param ui5VersionInfo UI5 version information
185
- */
186
- function fillReuseComponents(reuseComponentsIds, node, scenario, ui5VersionInfo) {
187
- if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, ui5VersionInfo)) {
188
- reuseComponentsIds.add(node.id);
189
- }
190
- }
191
173
  /**
192
174
  * Handles duplicate nodes that are retrieved from extension point default content and created controls,
193
175
  * if they exist under an extension point these controls are removed from the children array
194
176
  *
195
177
  * @param children outline view node children
196
178
  * @param scenario type of project
197
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
198
179
  * @param controlIndex Control tree index
199
180
  * @param changeService ChangeService for change stack event handling.
200
181
  * @param propertyIdMap Map<string, string[]>.
201
182
  * @returns transformed outline tree nodes
202
183
  */
203
- async function handleDuplicateNodes(children, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap) {
184
+ async function handleDuplicateNodes(children, scenario, controlIndex, changeService, propertyIdMap) {
204
185
  const extPointIDs = new Set();
205
186
  children.forEach(child => {
206
187
  if (child.type === 'extensionPoint') {
@@ -212,7 +193,7 @@ sap.ui.define(["sap/base/Log", "../../utils/version", "../../utils/core", "../..
212
193
  }
213
194
  });
214
195
  const uniqueChildren = children.filter(child => !extPointIDs.has(child.id));
215
- return transformNodes(uniqueChildren, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap);
196
+ return transformNodes(uniqueChildren, scenario, controlIndex, changeService, propertyIdMap);
216
197
  }
217
198
  var __exports = {
218
199
  __esModule: true
@@ -3,12 +3,11 @@ import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
3
3
  import type { Scenario } from 'sap/ui/fl/Scenario';
4
4
  import Log from 'sap/base/Log';
5
5
 
6
- import { getUi5Version, Ui5VersionInfo } from '../../utils/version';
7
6
  import { getControlById } from '../../utils/core';
8
7
  import { getError } from '../../utils/error';
9
8
 
10
9
  import type { ControlTreeIndex } from '../types';
11
- import { getOverlay, isReuseComponent } from '../utils';
10
+ import { getOverlay } from '../utils';
12
11
 
13
12
  import { isEditable } from './editable';
14
13
  import { ChangeService } from '../changes';
@@ -127,7 +126,6 @@ function addToPropertyIdMap(node: OutlineNode, propertyIdMap: Map<string, string
127
126
  *
128
127
  * @param input outline view node
129
128
  * @param scenario type of project
130
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
131
129
  * @param controlIndex Control tree index
132
130
  * @param changeService ChangeService for change stack event handling.
133
131
  * @param propertyIdMap ChangeService for change stack event handling.
@@ -136,14 +134,12 @@ function addToPropertyIdMap(node: OutlineNode, propertyIdMap: Map<string, string
136
134
  export async function transformNodes(
137
135
  input: OutlineViewNode[],
138
136
  scenario: Scenario,
139
- reuseComponentsIds: Set<string>,
140
137
  controlIndex: ControlTreeIndex,
141
138
  changeService: ChangeService,
142
139
  propertyIdMap: Map<string, string[]>
143
140
  ): Promise<OutlineNode[]> {
144
141
  const stack = [...input];
145
142
  const items: OutlineNode[] = [];
146
- const ui5VersionInfo = await getUi5Version();
147
143
  while (stack.length) {
148
144
  try {
149
145
  const current = stack.shift();
@@ -160,7 +156,6 @@ export async function transformNodes(
160
156
  ? await handleDuplicateNodes(
161
157
  children,
162
158
  scenario,
163
- reuseComponentsIds,
164
159
  controlIndex,
165
160
  changeService,
166
161
  propertyIdMap
@@ -168,7 +163,6 @@ export async function transformNodes(
168
163
  : await transformNodes(
169
164
  children,
170
165
  scenario,
171
- reuseComponentsIds,
172
166
  controlIndex,
173
167
  changeService,
174
168
  propertyIdMap
@@ -184,7 +178,6 @@ export async function transformNodes(
184
178
 
185
179
  indexNode(controlIndex, node);
186
180
  addToPropertyIdMap(node, propertyIdMap);
187
- fillReuseComponents(reuseComponentsIds, current, scenario, ui5VersionInfo);
188
181
 
189
182
  items.push(node);
190
183
  }
@@ -217,31 +210,12 @@ export async function transformNodes(
217
210
  return items;
218
211
  }
219
212
 
220
- /**
221
- * Fill reuse components ids.
222
- *
223
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
224
- * @param node view node
225
- * @param scenario type of project
226
- * @param ui5VersionInfo UI5 version information
227
- */
228
- function fillReuseComponents(
229
- reuseComponentsIds: Set<string>,
230
- node: OutlineViewNode,
231
- scenario: Scenario,
232
- ui5VersionInfo: Ui5VersionInfo
233
- ): void {
234
- if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, ui5VersionInfo)) {
235
- reuseComponentsIds.add(node.id);
236
- }
237
- }
238
213
  /**
239
214
  * Handles duplicate nodes that are retrieved from extension point default content and created controls,
240
215
  * if they exist under an extension point these controls are removed from the children array
241
216
  *
242
217
  * @param children outline view node children
243
218
  * @param scenario type of project
244
- * @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
245
219
  * @param controlIndex Control tree index
246
220
  * @param changeService ChangeService for change stack event handling.
247
221
  * @param propertyIdMap Map<string, string[]>.
@@ -250,7 +224,6 @@ function fillReuseComponents(
250
224
  export async function handleDuplicateNodes(
251
225
  children: OutlineViewNode[],
252
226
  scenario: Scenario,
253
- reuseComponentsIds: Set<string>,
254
227
  controlIndex: ControlTreeIndex,
255
228
  changeService: ChangeService,
256
229
  propertyIdMap: Map<string, string[]>
@@ -266,5 +239,5 @@ export async function handleDuplicateNodes(
266
239
 
267
240
  const uniqueChildren = children.filter((child) => !extPointIDs.has(child.id));
268
241
 
269
- return transformNodes(uniqueChildren, scenario, reuseComponentsIds, controlIndex, changeService, propertyIdMap);
242
+ return transformNodes(uniqueChildren, scenario, controlIndex, changeService, propertyIdMap);
270
243
  }
@@ -3,16 +3,11 @@ sap.ui.define([
3
3
  'sap/base/Log',
4
4
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
5
  '../../utils/error',
6
- '../../i18n',
7
6
  './nodes'
8
- ], function (Log, ___sap_ux_private_control_property_editor_common, ____utils_error, ____i18n, ___nodes) {
7
+ ], function (Log, ___sap_ux_private_control_property_editor_common, ____utils_error, ___nodes) {
9
8
  'use strict';
10
9
  const outlineChanged = ___sap_ux_private_control_property_editor_common['outlineChanged'];
11
- const SCENARIO = ___sap_ux_private_control_property_editor_common['SCENARIO'];
12
- const showInfoCenterMessage = ___sap_ux_private_control_property_editor_common['showInfoCenterMessage'];
13
- const MessageBarType = ___sap_ux_private_control_property_editor_common['MessageBarType'];
14
10
  const getError = ____utils_error['getError'];
15
- const getTextBundle = ____i18n['getTextBundle'];
16
11
  const transformNodes = ___nodes['transformNodes'];
17
12
  const OUTLINE_CHANGE_EVENT = 'OUTLINE_CHANGED';
18
13
  class OutlineService extends EventTarget {
@@ -23,31 +18,16 @@ sap.ui.define([
23
18
  }
24
19
  async init(sendAction) {
25
20
  const outline = await this.rta.getService('outline');
26
- const {scenario, isCloud} = this.rta.getFlexSettings();
27
- const resourceBundle = await getTextBundle();
28
- const titleKey = 'ADP_REUSE_COMPONENTS_MESSAGE_TITLE';
29
- const descriptionKey = 'ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION';
30
- const title = resourceBundle.getText(titleKey);
31
- const description = resourceBundle.getText(descriptionKey);
32
- let hasSentWarning = false;
33
- const reuseComponentsIds = new Set();
21
+ const {scenario} = this.rta.getFlexSettings();
34
22
  const syncOutline = async () => {
35
23
  try {
36
24
  const viewNodes = await outline.get();
37
25
  const controlIndex = {};
38
26
  const configPropertyIdMap = new Map();
39
- const outlineNodes = await transformNodes(viewNodes, scenario, reuseComponentsIds, controlIndex, this.changeService, configPropertyIdMap);
27
+ const outlineNodes = await transformNodes(viewNodes, scenario, controlIndex, this.changeService, configPropertyIdMap);
40
28
  const event = new CustomEvent(OUTLINE_CHANGE_EVENT, { detail: { controlIndex } });
41
29
  this.dispatchEvent(event);
42
30
  sendAction(outlineChanged(outlineNodes));
43
- if (reuseComponentsIds.size > 0 && scenario === SCENARIO.AdaptationProject && !hasSentWarning && isCloud) {
44
- sendAction(showInfoCenterMessage({
45
- type: MessageBarType.warning,
46
- title: title,
47
- description: description
48
- }));
49
- hasSentWarning = true;
50
- }
51
31
  await this.changeService.updateConfigurationProps(configPropertyIdMap);
52
32
  } catch (error) {
53
33
  Log.error('Outline sync failed!', getError(error));
@@ -4,14 +4,10 @@ import type RTAOutlineService from 'sap/ui/rta/command/OutlineService';
4
4
 
5
5
  import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
6
6
  import {
7
- outlineChanged,
8
- SCENARIO,
9
- showInfoCenterMessage,
10
- MessageBarType
7
+ outlineChanged
11
8
  } from '@sap-ux-private/control-property-editor-common';
12
9
 
13
10
  import { getError } from '../../utils/error';
14
- import { getTextBundle } from '../../i18n';
15
11
  import { ControlTreeIndex } from '../types';
16
12
  import { transformNodes } from './nodes';
17
13
  import { ChangeService } from '../changes';
@@ -25,7 +21,10 @@ export interface OutlineChangedEventDetail {
25
21
  * A Class of WorkspaceConnectorService
26
22
  */
27
23
  export class OutlineService extends EventTarget {
28
- constructor(private readonly rta: RuntimeAuthoring, private readonly changeService: ChangeService) {
24
+ constructor(
25
+ private readonly rta: RuntimeAuthoring,
26
+ private readonly changeService: ChangeService
27
+ ) {
29
28
  super();
30
29
  }
31
30
 
@@ -36,14 +35,7 @@ export class OutlineService extends EventTarget {
36
35
  */
37
36
  public async init(sendAction: (action: ExternalAction) => void): Promise<void> {
38
37
  const outline = await this.rta.getService<RTAOutlineService>('outline');
39
- const { scenario, isCloud } = this.rta.getFlexSettings();
40
- const resourceBundle = await getTextBundle();
41
- const titleKey = 'ADP_REUSE_COMPONENTS_MESSAGE_TITLE';
42
- const descriptionKey = 'ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION';
43
- const title = resourceBundle.getText(titleKey);
44
- const description = resourceBundle.getText(descriptionKey);
45
- let hasSentWarning = false;
46
- const reuseComponentsIds = new Set<string>();
38
+ const { scenario } = this.rta.getFlexSettings();
47
39
  const syncOutline = async () => {
48
40
  try {
49
41
  const viewNodes = await outline.get();
@@ -52,7 +44,6 @@ export class OutlineService extends EventTarget {
52
44
  const outlineNodes = await transformNodes(
53
45
  viewNodes,
54
46
  scenario,
55
- reuseComponentsIds,
56
47
  controlIndex,
57
48
  this.changeService,
58
49
  configPropertyIdMap
@@ -66,16 +57,6 @@ export class OutlineService extends EventTarget {
66
57
 
67
58
  this.dispatchEvent(event);
68
59
  sendAction(outlineChanged(outlineNodes));
69
- if (reuseComponentsIds.size > 0 && scenario === SCENARIO.AdaptationProject && !hasSentWarning && isCloud) {
70
- sendAction(
71
- showInfoCenterMessage({
72
- type: MessageBarType.warning,
73
- title: title,
74
- description: description
75
- })
76
- );
77
- hasSentWarning = true;
78
- }
79
60
  await this.changeService.updateConfigurationProps(configPropertyIdMap);
80
61
  } catch (error) {
81
62
  Log.error('Outline sync failed!', getError(error));
@@ -36,6 +36,7 @@ export type ActionHandler = (action: ExternalAction) => void | Promise<void>;
36
36
  export type ActionSenderFunction = (action: ExternalAction) => void;
37
37
  export type SubscribeFunction = (handler: ActionHandler) => void;
38
38
  export type UnSubscribeFunction = (handler: ActionHandler) => void;
39
+ export type IsReuseComponentApi = (controlId: string) => boolean;
39
40
 
40
41
  export interface Service {
41
42
  init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void | Promise<void>;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/core", "../utils/version", "sap/ui/dt/OverlayRegistry", "sap/ui/dt/OverlayUtil"], function (XMLView, UIComponent, ___utils_core, ___utils_version, OverlayRegistry, OverlayUtil) {
3
+ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/core", "sap/ui/dt/OverlayRegistry", "sap/ui/dt/OverlayUtil"], function (XMLView, UIComponent, ___utils_core, OverlayRegistry, OverlayUtil) {
4
4
  "use strict";
5
5
 
6
6
  const getComponent = ___utils_core["getComponent"];
7
- const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
8
7
  /**
9
8
  * Get runtime control.
10
9
  *
@@ -43,31 +42,6 @@ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/c
43
42
  });
44
43
  }
45
44
 
46
- /**
47
- * Function that checks if control is reuse component
48
- *
49
- * @param controlId id control
50
- * @param ui5VersionInfo UI5 version information
51
- * @returns boolean if control is from reused component view
52
- */
53
- function isReuseComponent(controlId, ui5VersionInfo) {
54
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
55
- major: 1,
56
- minor: 115
57
- })) {
58
- return false;
59
- }
60
- const component = getComponent(controlId);
61
- if (!component) {
62
- return false;
63
- }
64
- const manifest = component.getManifest();
65
- if (!manifest) {
66
- return false;
67
- }
68
- return manifest['sap.app']?.type === 'component';
69
- }
70
-
71
45
  /**
72
46
  * Gets the root view of component for the provided ComponentContainer control.
73
47
  *
@@ -131,7 +105,6 @@ sap.ui.define(["sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/c
131
105
  };
132
106
  __exports.getRuntimeControl = getRuntimeControl;
133
107
  __exports.getLibrary = getLibrary;
134
- __exports.isReuseComponent = isReuseComponent;
135
108
  __exports.getRootControlFromComponentContainer = getRootControlFromComponentContainer;
136
109
  __exports.getManifestProperties = getManifestProperties;
137
110
  __exports.getOverlay = getOverlay;
@@ -2,19 +2,18 @@ import type ManagedObject from 'sap/ui/base/ManagedObject';
2
2
  import type Control from 'sap/ui/core/Control';
3
3
  import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
4
4
  import DataType from 'sap/ui/base/DataType';
5
- import type { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
6
5
  import ComponentContainer from 'sap/ui/core/ComponentContainer';
7
6
  import XMLView from 'sap/ui/core/mvc/XMLView';
8
7
  import UIComponent from 'sap/ui/core/UIComponent';
9
8
 
10
9
  import { getComponent } from '../utils/core';
11
- import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../utils/version';
12
10
  import { DesigntimeSetting } from 'sap/ui/dt/DesignTimeMetadata';
13
11
  import { ChangeService } from './changes';
14
12
  import UI5Element from 'sap/ui/core/Element';
15
13
  import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
16
14
  import OverlayUtil from 'sap/ui/dt/OverlayUtil';
17
15
 
16
+
18
17
  export interface PropertiesInfo {
19
18
  defaultValue: string;
20
19
  description: string;
@@ -83,31 +82,6 @@ export async function getLibrary(controlName: string): Promise<string> {
83
82
  });
84
83
  }
85
84
 
86
- /**
87
- * Function that checks if control is reuse component
88
- *
89
- * @param controlId id control
90
- * @param ui5VersionInfo UI5 version information
91
- * @returns boolean if control is from reused component view
92
- */
93
- export function isReuseComponent(controlId: string, ui5VersionInfo: Ui5VersionInfo): boolean {
94
- if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 115 })) {
95
- return false;
96
- }
97
-
98
- const component = getComponent(controlId);
99
- if (!component) {
100
- return false;
101
- }
102
-
103
- const manifest = component.getManifest() as Manifest;
104
- if (!manifest) {
105
- return false;
106
- }
107
-
108
- return manifest['sap.app']?.type === 'component';
109
- }
110
-
111
85
  /**
112
86
  * Gets the root view of component for the provided ComponentContainer control.
113
87
  *
@@ -44,7 +44,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/core/Control", "sap/ui/core/UIComp
44
44
  /**
45
45
  * Checks if the given root control is an instance of Control or UIComponent.
46
46
  *
47
- * @param {Control | UIComponent} rootControl - The root control to be checked.
47
+ * @param {Component} rootControl - The root control to be checked.
48
48
  * @throws {Error} Throws an error if the root control is not an instance of Control or UIComponent.
49
49
  */
50
50
  function checkRootControl(rootControl) {
@@ -57,7 +57,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/core/Control", "sap/ui/core/UIComp
57
57
  * Checks if key user adaptation is enabled for the specified component.
58
58
  * Fiori tools mode is considered a developer scenario where the `flexEnabled` flag should not be evaluated.
59
59
  *
60
- * @param {Control} component - The UI5 control component to check for flex (key user adaptation) enabled status.
60
+ * @param {Component} component - The UI5 control component to check for flex (key user adaptation) enabled status.
61
61
  * @throws {Error} Throws an error if key user adaptation is explicitly disabled in the component's manifest.
62
62
  */
63
63
  function checkFlexEnabled(component) {
@@ -3,6 +3,7 @@ import Button from 'sap/m/Button';
3
3
  import merge from 'sap/base/util/merge';
4
4
 
5
5
  import Control from 'sap/ui/core/Control';
6
+ import Component from 'sap/ui/core/Component';
6
7
  import UIComponent from 'sap/ui/core/UIComponent';
7
8
 
8
9
  import Utils from 'sap/ui/fl/Utils';
@@ -53,10 +54,10 @@ export function checkLayer(layer: string): void {
53
54
  /**
54
55
  * Checks if the given root control is an instance of Control or UIComponent.
55
56
  *
56
- * @param {Control | UIComponent} rootControl - The root control to be checked.
57
+ * @param {Component} rootControl - The root control to be checked.
57
58
  * @throws {Error} Throws an error if the root control is not an instance of Control or UIComponent.
58
59
  */
59
- export function checkRootControl(rootControl: Control | UIComponent): void {
60
+ export function checkRootControl(rootControl: Component): void {
60
61
  if (!(rootControl instanceof Control) && !(rootControl instanceof UIComponent)) {
61
62
  throw new Error('An invalid root control was passed');
62
63
  }
@@ -66,14 +67,14 @@ export function checkRootControl(rootControl: Control | UIComponent): void {
66
67
  * Checks if key user adaptation is enabled for the specified component.
67
68
  * Fiori tools mode is considered a developer scenario where the `flexEnabled` flag should not be evaluated.
68
69
  *
69
- * @param {Control} component - The UI5 control component to check for flex (key user adaptation) enabled status.
70
+ * @param {Component} component - The UI5 control component to check for flex (key user adaptation) enabled status.
70
71
  * @throws {Error} Throws an error if key user adaptation is explicitly disabled in the component's manifest.
71
72
  */
72
- export function checkFlexEnabled(component: Control): void {
73
+ export function checkFlexEnabled(component: Component): void {
73
74
  // fiori tools is always a developer scenario where the flexEnabled flag should not be evaluated
74
75
  const fioriToolsMode = new URLSearchParams(window.location.search).get('fiori-tools-rta-mode');
75
76
  if (!fioriToolsMode || fioriToolsMode === 'false') {
76
- const manifest = (component as Control & { getManifest: () => Manifest }).getManifest() || {};
77
+ const manifest = ((component as Component& { getManifest: () => Manifest }).getManifest() || {}) as Manifest;
77
78
  const flexEnabled = manifest['sap.ui5']?.flexEnabled;
78
79
 
79
80
  if (flexEnabled === false) {
@@ -114,7 +115,7 @@ export async function checkKeyUser(layer: string): Promise<void> {
114
115
  * @returns {Promise<void>} A promise that resolves when all checks pass without errors.
115
116
  * @throws {Error} Throws an error if any of the checks fail.
116
117
  */
117
- async function checkLayerAndControl(rootControl: Control, layer: string): Promise<void> {
118
+ async function checkLayerAndControl(rootControl: Component, layer: string): Promise<void> {
118
119
  checkLayer(layer);
119
120
 
120
121
  checkRootControl(rootControl);
@@ -39,12 +39,15 @@ ADP_ADD_FRAGMENT_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be cr
39
39
  ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION = Note: The "{0}.fragment.xml" fragment will be created once you save the changes.
40
40
  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.
41
41
  ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Controller extensions are not supported for such views and will be disabled.
42
- ADP_REUSE_COMPONENTS_MESSAGE_TITLE = Reuse components detected
43
- ADP_REUSE_COMPONENTS_MESSAGE_DESCRIPTION = 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.
44
- ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open
42
+ ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open.
43
+ ADP_ADD_FRAGMENT_MENU_ITEM = Add: Fragment
44
+ ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (This action is disabled because the control is a reuse component)
45
+ ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (This action is disabled because the control or parent control has an unstable ID)
46
+ ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend with Controller
47
+ ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend with Controller (This action is disabled because the control is a reuse component)
45
48
  CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.
46
49
 
47
- TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to create new custom column. Make sure the table data is loaded and try again.
50
+ TABLE_ROWS_NEEDED_TO_CREATE_CUSTOM_COLUMN=At least one table row is required to create a new custom column. Make sure the table data is loaded and try again.
48
51
 
49
52
  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.
50
53
 
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.19.8",
12
+ "version": "0.19.10",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/adp-tooling": "0.13.22",
29
29
  "@sap-ux/btp-utils": "1.0.2",
30
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.1",
30
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.2",
31
31
  "@sap-ux/feature-toggle": "0.2.3",
32
32
  "@sap-ux/logger": "0.6.0",
33
33
  "@sap-ux/project-access": "1.29.18",
@@ -49,7 +49,7 @@
49
49
  "nock": "13.4.0",
50
50
  "npm-run-all2": "6.2.0",
51
51
  "supertest": "6.3.3",
52
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.10",
52
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.12",
53
53
  "@sap-ux/axios-extension": "1.19.2",
54
54
  "@sap-ux/i18n": "0.2.3",
55
55
  "@sap-ux/store": "1.0.0",