@sap-ux/preview-middleware 0.19.23 → 0.19.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/client/adp/api-handler.js +153 -153
  2. package/dist/client/adp/command-executor.js +75 -75
  3. package/dist/client/adp/control-utils.js +44 -44
  4. package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
  5. package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
  6. package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
  7. package/dist/client/adp/dialog-factory.js +135 -135
  8. package/dist/client/adp/init-dialogs.js +138 -138
  9. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
  11. package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
  12. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
  13. package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
  14. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  15. package/dist/client/adp/quick-actions/control-types.js +23 -23
  16. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  17. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  18. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
  19. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
  20. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  21. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
  22. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
  23. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
  24. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  25. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
  26. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
  27. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  28. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
  29. package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
  30. package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
  31. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
  32. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
  33. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
  34. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
  35. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
  36. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
  37. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
  38. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
  39. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
  40. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  41. package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
  42. package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
  43. package/dist/client/adp/quick-actions/load.js +44 -44
  44. package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
  45. package/dist/client/adp/utils.js +218 -218
  46. package/dist/client/cpe/changes/index.js +10 -10
  47. package/dist/client/cpe/changes/validator.js +39 -39
  48. package/dist/client/cpe/documentation.js +164 -164
  49. package/dist/client/cpe/feature-service.js +36 -36
  50. package/dist/client/cpe/logger.js +30 -30
  51. package/dist/client/cpe/outline/editable.js +37 -37
  52. package/dist/client/cpe/outline/nodes.js +203 -203
  53. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  54. package/dist/client/cpe/quick-actions/registry.js +143 -143
  55. package/dist/client/cpe/quick-actions/utils.js +92 -92
  56. package/dist/client/cpe/types.js +4 -4
  57. package/dist/client/cpe/ui5-utils.js +33 -33
  58. package/dist/client/cpe/utils.js +111 -111
  59. package/dist/client/flp/WorkspaceConnector.js +86 -86
  60. package/dist/client/flp/common.js +28 -28
  61. package/dist/client/flp/enableFakeConnector.js +83 -83
  62. package/dist/client/flp/homepage/Component.js +14 -14
  63. package/dist/client/flp/initCdm.js +117 -117
  64. package/dist/client/flp/initConnectors.js +28 -28
  65. package/dist/client/flp/initRta.js +178 -178
  66. package/dist/client/i18n.js +56 -56
  67. package/dist/client/utils/application.js +32 -32
  68. package/dist/client/utils/core.js +84 -84
  69. package/dist/client/utils/error.js +19 -19
  70. package/dist/client/utils/fe-v2.js +56 -56
  71. package/dist/client/utils/fe-v4.js +140 -140
  72. package/dist/client/utils/version.js +104 -104
  73. package/package.json +2 -2
@@ -1,119 +1,119 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Initializes the CDM (Common Data Model) configuration for the SAP Fiori Launchpad.
8
- *
9
- * @param {sap.ushell.Container} container - The SAP Fiori Launchpad container.
10
- * @returns {Promise<void>} A promise that resolves when the initialization is complete.
11
- */
12
- async function initCdm(container) {
13
- window['sap-ushell-config'] = {
14
- defaultRenderer: 'fiori2',
15
- renderers: {
16
- fiori2: {
17
- componentData: {
18
- config: {
19
- enableSearch: false,
20
- enableRecentActivity: true,
21
- rootIntent: 'Shell-home'
22
- }
23
- }
24
- }
25
- },
26
- ushell: {
27
- customPreload: {
28
- enabled: false
29
- },
30
- spaces: {
31
- enabled: true,
32
- myHome: {
33
- enabled: true
34
- }
35
- },
36
- homeApp: {
37
- component: {
38
- name: 'open.ux.preview.client.flp.homepage',
39
- url: '/preview/client/flp/homepage'
40
- }
41
- }
42
- },
43
- services: {
44
- Container: {
45
- adapter: {
46
- config: {
47
- userProfile: {
48
- metadata: {
49
- editablePropterties: ['accessibility', 'contentDensity', 'theme']
50
- },
51
- defaults: {
52
- email: 'john.doe@sap.com',
53
- firstName: 'John',
54
- lastName: 'Doe',
55
- fullName: 'John Doe',
56
- id: 'DOEJ'
57
- }
58
- }
59
- }
60
- }
61
- },
62
- CommonDataModel: {
63
- adapter: {
64
- config: {
65
- ignoreSiteDataPersonalization: true,
66
- siteDataUrl: '/cdm.json'
67
- }
68
- }
69
- },
70
- Personalization: {
71
- adapter: {
72
- module: 'sap.ushell.adapters.local.PersonalizationAdapter',
73
- config: {
74
- storageType: 'MEMORY'
75
- }
76
- }
77
- },
78
- PersonalizationV2: {
79
- adapter: {
80
- module: 'sap.ushell.adapters.local.PersonalizationAdapter',
81
- config: {
82
- storageType: 'MEMORY'
83
- }
84
- }
85
- },
86
- AppState: {
87
- adapter: {
88
- module: 'sap.ushell.adapters.local.AppStateAdapter'
89
- },
90
- config: {
91
- transient: true
92
- }
93
- },
94
- NavTargetResolutionInternal: {
95
- config: {
96
- allowTestUrlComponentConfig: false,
97
- enableClientSideTargetResolution: true
98
- },
99
- adapter: {
100
- module: 'sap.ushell.adapters.local.NavTargetResolutionInternalAdapter'
101
- }
102
- },
103
- UserInfo: {
104
- adapter: {
105
- module: 'sap.ushell.adapters.local.UserInfoAdapter'
106
- }
107
- },
108
- FlpLaunchPage: {
109
- adapter: {
110
- module: 'sap.ushell.adapters.cdm.v3.FlpLaunchPageAdapter'
111
- }
112
- }
113
- }
114
- };
115
- await container.init('cdm');
116
- }
117
- return initCdm;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Initializes the CDM (Common Data Model) configuration for the SAP Fiori Launchpad.
8
+ *
9
+ * @param {sap.ushell.Container} container - The SAP Fiori Launchpad container.
10
+ * @returns {Promise<void>} A promise that resolves when the initialization is complete.
11
+ */
12
+ async function initCdm(container) {
13
+ window['sap-ushell-config'] = {
14
+ defaultRenderer: 'fiori2',
15
+ renderers: {
16
+ fiori2: {
17
+ componentData: {
18
+ config: {
19
+ enableSearch: false,
20
+ enableRecentActivity: true,
21
+ rootIntent: 'Shell-home'
22
+ }
23
+ }
24
+ }
25
+ },
26
+ ushell: {
27
+ customPreload: {
28
+ enabled: false
29
+ },
30
+ spaces: {
31
+ enabled: true,
32
+ myHome: {
33
+ enabled: true
34
+ }
35
+ },
36
+ homeApp: {
37
+ component: {
38
+ name: 'open.ux.preview.client.flp.homepage',
39
+ url: '/preview/client/flp/homepage'
40
+ }
41
+ }
42
+ },
43
+ services: {
44
+ Container: {
45
+ adapter: {
46
+ config: {
47
+ userProfile: {
48
+ metadata: {
49
+ editablePropterties: ['accessibility', 'contentDensity', 'theme']
50
+ },
51
+ defaults: {
52
+ email: 'john.doe@sap.com',
53
+ firstName: 'John',
54
+ lastName: 'Doe',
55
+ fullName: 'John Doe',
56
+ id: 'DOEJ'
57
+ }
58
+ }
59
+ }
60
+ }
61
+ },
62
+ CommonDataModel: {
63
+ adapter: {
64
+ config: {
65
+ ignoreSiteDataPersonalization: true,
66
+ siteDataUrl: '/cdm.json'
67
+ }
68
+ }
69
+ },
70
+ Personalization: {
71
+ adapter: {
72
+ module: 'sap.ushell.adapters.local.PersonalizationAdapter',
73
+ config: {
74
+ storageType: 'MEMORY'
75
+ }
76
+ }
77
+ },
78
+ PersonalizationV2: {
79
+ adapter: {
80
+ module: 'sap.ushell.adapters.local.PersonalizationAdapter',
81
+ config: {
82
+ storageType: 'MEMORY'
83
+ }
84
+ }
85
+ },
86
+ AppState: {
87
+ adapter: {
88
+ module: 'sap.ushell.adapters.local.AppStateAdapter'
89
+ },
90
+ config: {
91
+ transient: true
92
+ }
93
+ },
94
+ NavTargetResolutionInternal: {
95
+ config: {
96
+ allowTestUrlComponentConfig: false,
97
+ enableClientSideTargetResolution: true
98
+ },
99
+ adapter: {
100
+ module: 'sap.ushell.adapters.local.NavTargetResolutionInternalAdapter'
101
+ }
102
+ },
103
+ UserInfo: {
104
+ adapter: {
105
+ module: 'sap.ushell.adapters.local.UserInfoAdapter'
106
+ }
107
+ },
108
+ FlpLaunchPage: {
109
+ adapter: {
110
+ module: 'sap.ushell.adapters.cdm.v3.FlpLaunchPageAdapter'
111
+ }
112
+ }
113
+ }
114
+ };
115
+ await container.init('cdm');
116
+ }
117
+ return initCdm;
118
118
  });
119
119
  //# sourceMappingURL=initCdm.js.map
@@ -1,30 +1,30 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../utils/version"], function (___utils_version) {
4
- "use strict";
5
-
6
- const getUi5Version = ___utils_version["getUi5Version"];
7
- const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
8
- /**
9
- * Initializes UI5 connectors based on the current UI5 version.
10
- *
11
- * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
12
- * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
13
- * This setup allows for flexibility in using different connectors based on the UI5 version.
14
- *
15
- * @example
16
- * intiConnectors(); // Simply call the function without any arguments.
17
- */
18
- async function initConnectors() {
19
- if (isLowerThanMinimalUi5Version(await getUi5Version(), {
20
- major: 1,
21
- minor: 72
22
- })) {
23
- sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
24
- enableFakeConnector();
25
- });
26
- }
27
- }
28
- return initConnectors;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../utils/version"], function (___utils_version) {
4
+ "use strict";
5
+
6
+ const getUi5Version = ___utils_version["getUi5Version"];
7
+ const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
8
+ /**
9
+ * Initializes UI5 connectors based on the current UI5 version.
10
+ *
11
+ * For UI5 versions below 1.72, this function dynamically requires and executes a FakeLrepConnector.
12
+ * For UI5 versions 1.72 and above, it defines a local connector that reuses the WorkspaceConnector.
13
+ * This setup allows for flexibility in using different connectors based on the UI5 version.
14
+ *
15
+ * @example
16
+ * intiConnectors(); // Simply call the function without any arguments.
17
+ */
18
+ async function initConnectors() {
19
+ if (isLowerThanMinimalUi5Version(await getUi5Version(), {
20
+ major: 1,
21
+ minor: 72
22
+ })) {
23
+ sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
24
+ enableFakeConnector();
25
+ });
26
+ }
27
+ }
28
+ return initConnectors;
29
29
  });
30
30
  //# sourceMappingURL=initConnectors.js.map
@@ -1,180 +1,180 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/base/util/merge", "sap/ui/core/Control", "sap/ui/core/UIComponent", "sap/ui/fl/Utils", "sap/ui/fl/write/api/FeaturesAPI", "sap/ui/rta/RuntimeAuthoring"], function (merge, Control, UIComponent, Utils, FeaturesAPI, RuntimeAuthoring) {
4
- "use strict";
5
-
6
- const defaultOptions = {
7
- flexSettings: {
8
- developerMode: false,
9
- layer: 'CUSTOMER'
10
- }
11
- };
12
- const layers = {
13
- BASE: 'BASE',
14
- CUSTOMER: 'CUSTOMER',
15
- CUSTOMER_BASE: 'CUSTOMER_BASE',
16
- PARTNER: 'PARTNER',
17
- PUBLIC: 'PUBLIC',
18
- USER: 'USER',
19
- VENDOR: 'VENDOR'
20
- };
21
-
22
- /**
23
- * Checks if the given layer is a valid layer.
24
- *
25
- * @param {string} layer - The layer name to be validated.
26
- * @returns {boolean} Returns true if the layer is valid, otherwise false.
27
- */
28
- function isValidLayer(layer) {
29
- return Object.keys(layers).some(existingLayer => existingLayer === layer);
30
- }
31
-
32
- /**
33
- * Validates a given layer and throws an error if it is invalid.
34
- *
35
- * @param {string} layer - The layer name to be checked.
36
- * @throws {Error} Throws an error if the layer is not valid.
37
- */
38
- function checkLayer(layer) {
39
- if (!isValidLayer(layer)) {
40
- throw new Error('An invalid layer is passed');
41
- }
42
- }
43
-
44
- /**
45
- * Checks if the given root control is an instance of Control or UIComponent.
46
- *
47
- * @param {Component} rootControl - The root control to be checked.
48
- * @throws {Error} Throws an error if the root control is not an instance of Control or UIComponent.
49
- */
50
- function checkRootControl(rootControl) {
51
- if (!(rootControl instanceof Control) && !(rootControl instanceof UIComponent)) {
52
- throw new Error('An invalid root control was passed');
53
- }
54
- }
55
-
56
- /**
57
- * Checks if key user adaptation is enabled for the specified component.
58
- * Fiori tools mode is considered a developer scenario where the `flexEnabled` flag should not be evaluated.
59
- *
60
- * @param {Component} component - The UI5 control component to check for flex (key user adaptation) enabled status.
61
- * @throws {Error} Throws an error if key user adaptation is explicitly disabled in the component's manifest.
62
- */
63
- function checkFlexEnabled(component) {
64
- // fiori tools is always a developer scenario where the flexEnabled flag should not be evaluated
65
- const fioriToolsMode = new URLSearchParams(window.location.search).get('fiori-tools-rta-mode');
66
- if (!fioriToolsMode || fioriToolsMode === 'false') {
67
- const manifest = component.getManifest() || {};
68
- const flexEnabled = manifest['sap.ui5']?.flexEnabled;
69
- if (flexEnabled === false) {
70
- throw new Error('This app is not enabled for key user adaptation');
71
- }
72
- }
73
- }
74
-
75
- /**
76
- * Checks if the current user is a key user for the given layer.
77
- * Specifically, it checks for key user rights if the layer is the CUSTOMER layer.
78
- * If the user is not a key user and the layer is CUSTOMER, an error is thrown.
79
- *
80
- * Note: The function assumes the presence of 'layers.CUSTOMER'. In case of non-CUSTOMER layers,
81
- * it simply resolves the promise without any additional checks.
82
- *
83
- * @param {string} layer - The layer for which to check key user rights.
84
- * @returns {Promise<void>} A promise that resolves if the user is a key user or the layer is not CUSTOMER.
85
- * Rejects with an error if the user is not a key user for the CUSTOMER layer.
86
- * @throws {Error} Throws an error with the message 'No key user rights found' if the user lacks key user rights.
87
- */
88
- async function checkKeyUser(layer) {
89
- if (layers.CUSTOMER === layer) {
90
- const isKeyUser = await FeaturesAPI.isKeyUser();
91
- if (!isKeyUser) {
92
- throw new Error('No key user rights found');
93
- }
94
- }
95
- }
96
-
97
- /**
98
- * Checks the validity of the specified layer and root control.
99
- * It ensures that the layer is valid and the root control is an instance of Control or UIComponent.
100
- * Additionally, it checks key user permissions for the specified layer.
101
- *
102
- * @param {Control} rootControl - The root control to be validated.
103
- * @param {string} layer - The layer name to be validated.
104
- * @returns {Promise<void>} A promise that resolves when all checks pass without errors.
105
- * @throws {Error} Throws an error if any of the checks fail.
106
- */
107
- async function checkLayerAndControl(rootControl, layer) {
108
- checkLayer(layer);
109
- checkRootControl(rootControl);
110
- await checkKeyUser(layer);
111
- }
112
-
113
- /**
114
- * Retrieves the first HTML element with the specified title attribute.
115
- *
116
- * @param {string} title - The title attribute value to search for in the HTML elements.
117
- * @param {Element | null} element - The target element that will be searched.
118
- * @returns {Element | null} The first HTML element that matches the given title attribute value, or null if no such element is found.
119
- */
120
- function getElementByTitle(title, element) {
121
- const selector = `[title="${title}"]`;
122
- return element ? element.querySelector(selector) : document.querySelector(selector);
123
- }
124
-
125
- /**
126
- * Hides a UI5 Button control with the specified ID.
127
- *
128
- * This function attempts to find a UI5 Button control by its ID and then sets its visibility to false.
129
- *
130
- * @param {string | undefined} buttonId - The ID of the Button control to hide. If undefined, no action is taken.
131
- * @returns {void}
132
- */
133
- function hideButtonById(buttonId) {
134
- const button = sap.ui.getCore().byId(buttonId);
135
- button?.setVisible(false);
136
- }
137
-
138
- /**
139
- * Hides specific buttons by ID from the RTA toolbar.
140
- * This function specifically targets buttons 'Reset' and 'Publish'.
141
- */
142
- function removeExtraBtnsFromToolbar() {
143
- const rtaToolbarEl = document.querySelector('.sapUiRtaToolbar');
144
- const resetEl = getElementByTitle('Reset', rtaToolbarEl);
145
- const publishEl = getElementByTitle('Publish', rtaToolbarEl);
146
- hideButtonById(resetEl?.id);
147
- hideButtonById(publishEl?.id);
148
- }
149
-
150
- /**
151
- * Initializes custom RuntimeAuthoring for UI5 Versions < 1.72 and start UI Adaptation.
152
- * Ensures that the passed options are valid.
153
- *
154
- * @param {RTAOptions} options - Options that are passed to RuntimeAuthoring upon initialization.
155
- * @param {RTAPlugin} loadPlugins - Script that needs to be executed after rta is initialized.
156
- * @returns {Promise<void>} A promise that resolves when all the checks have passed and RuntimeAuthoring is started.
157
- */
158
- var __exports = async function (options, loadPlugins) {
159
- options = merge(defaultOptions, options);
160
- const layer = options.flexSettings.layer;
161
- const rootControl = options.rootControl;
162
- await checkLayerAndControl(rootControl, layer);
163
- options.rootControl = Utils.getAppComponentForControl(rootControl);
164
- checkFlexEnabled(options.rootControl);
165
- const rta = new RuntimeAuthoring(options);
166
- rta.attachEvent('stop', () => rta.destroy());
167
- if (loadPlugins) {
168
- await loadPlugins(rta);
169
- }
170
- await rta.start();
171
- removeExtraBtnsFromToolbar();
172
- };
173
- __exports.isValidLayer = isValidLayer;
174
- __exports.checkLayer = checkLayer;
175
- __exports.checkRootControl = checkRootControl;
176
- __exports.checkFlexEnabled = checkFlexEnabled;
177
- __exports.checkKeyUser = checkKeyUser;
178
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/base/util/merge", "sap/ui/core/Control", "sap/ui/core/UIComponent", "sap/ui/fl/Utils", "sap/ui/fl/write/api/FeaturesAPI", "sap/ui/rta/RuntimeAuthoring"], function (merge, Control, UIComponent, Utils, FeaturesAPI, RuntimeAuthoring) {
4
+ "use strict";
5
+
6
+ const defaultOptions = {
7
+ flexSettings: {
8
+ developerMode: false,
9
+ layer: 'CUSTOMER'
10
+ }
11
+ };
12
+ const layers = {
13
+ BASE: 'BASE',
14
+ CUSTOMER: 'CUSTOMER',
15
+ CUSTOMER_BASE: 'CUSTOMER_BASE',
16
+ PARTNER: 'PARTNER',
17
+ PUBLIC: 'PUBLIC',
18
+ USER: 'USER',
19
+ VENDOR: 'VENDOR'
20
+ };
21
+
22
+ /**
23
+ * Checks if the given layer is a valid layer.
24
+ *
25
+ * @param {string} layer - The layer name to be validated.
26
+ * @returns {boolean} Returns true if the layer is valid, otherwise false.
27
+ */
28
+ function isValidLayer(layer) {
29
+ return Object.keys(layers).some(existingLayer => existingLayer === layer);
30
+ }
31
+
32
+ /**
33
+ * Validates a given layer and throws an error if it is invalid.
34
+ *
35
+ * @param {string} layer - The layer name to be checked.
36
+ * @throws {Error} Throws an error if the layer is not valid.
37
+ */
38
+ function checkLayer(layer) {
39
+ if (!isValidLayer(layer)) {
40
+ throw new Error('An invalid layer is passed');
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Checks if the given root control is an instance of Control or UIComponent.
46
+ *
47
+ * @param {Component} rootControl - The root control to be checked.
48
+ * @throws {Error} Throws an error if the root control is not an instance of Control or UIComponent.
49
+ */
50
+ function checkRootControl(rootControl) {
51
+ if (!(rootControl instanceof Control) && !(rootControl instanceof UIComponent)) {
52
+ throw new Error('An invalid root control was passed');
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Checks if key user adaptation is enabled for the specified component.
58
+ * Fiori tools mode is considered a developer scenario where the `flexEnabled` flag should not be evaluated.
59
+ *
60
+ * @param {Component} component - The UI5 control component to check for flex (key user adaptation) enabled status.
61
+ * @throws {Error} Throws an error if key user adaptation is explicitly disabled in the component's manifest.
62
+ */
63
+ function checkFlexEnabled(component) {
64
+ // fiori tools is always a developer scenario where the flexEnabled flag should not be evaluated
65
+ const fioriToolsMode = new URLSearchParams(window.location.search).get('fiori-tools-rta-mode');
66
+ if (!fioriToolsMode || fioriToolsMode === 'false') {
67
+ const manifest = component.getManifest() || {};
68
+ const flexEnabled = manifest['sap.ui5']?.flexEnabled;
69
+ if (flexEnabled === false) {
70
+ throw new Error('This app is not enabled for key user adaptation');
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Checks if the current user is a key user for the given layer.
77
+ * Specifically, it checks for key user rights if the layer is the CUSTOMER layer.
78
+ * If the user is not a key user and the layer is CUSTOMER, an error is thrown.
79
+ *
80
+ * Note: The function assumes the presence of 'layers.CUSTOMER'. In case of non-CUSTOMER layers,
81
+ * it simply resolves the promise without any additional checks.
82
+ *
83
+ * @param {string} layer - The layer for which to check key user rights.
84
+ * @returns {Promise<void>} A promise that resolves if the user is a key user or the layer is not CUSTOMER.
85
+ * Rejects with an error if the user is not a key user for the CUSTOMER layer.
86
+ * @throws {Error} Throws an error with the message 'No key user rights found' if the user lacks key user rights.
87
+ */
88
+ async function checkKeyUser(layer) {
89
+ if (layers.CUSTOMER === layer) {
90
+ const isKeyUser = await FeaturesAPI.isKeyUser();
91
+ if (!isKeyUser) {
92
+ throw new Error('No key user rights found');
93
+ }
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Checks the validity of the specified layer and root control.
99
+ * It ensures that the layer is valid and the root control is an instance of Control or UIComponent.
100
+ * Additionally, it checks key user permissions for the specified layer.
101
+ *
102
+ * @param {Control} rootControl - The root control to be validated.
103
+ * @param {string} layer - The layer name to be validated.
104
+ * @returns {Promise<void>} A promise that resolves when all checks pass without errors.
105
+ * @throws {Error} Throws an error if any of the checks fail.
106
+ */
107
+ async function checkLayerAndControl(rootControl, layer) {
108
+ checkLayer(layer);
109
+ checkRootControl(rootControl);
110
+ await checkKeyUser(layer);
111
+ }
112
+
113
+ /**
114
+ * Retrieves the first HTML element with the specified title attribute.
115
+ *
116
+ * @param {string} title - The title attribute value to search for in the HTML elements.
117
+ * @param {Element | null} element - The target element that will be searched.
118
+ * @returns {Element | null} The first HTML element that matches the given title attribute value, or null if no such element is found.
119
+ */
120
+ function getElementByTitle(title, element) {
121
+ const selector = `[title="${title}"]`;
122
+ return element ? element.querySelector(selector) : document.querySelector(selector);
123
+ }
124
+
125
+ /**
126
+ * Hides a UI5 Button control with the specified ID.
127
+ *
128
+ * This function attempts to find a UI5 Button control by its ID and then sets its visibility to false.
129
+ *
130
+ * @param {string | undefined} buttonId - The ID of the Button control to hide. If undefined, no action is taken.
131
+ * @returns {void}
132
+ */
133
+ function hideButtonById(buttonId) {
134
+ const button = sap.ui.getCore().byId(buttonId);
135
+ button?.setVisible(false);
136
+ }
137
+
138
+ /**
139
+ * Hides specific buttons by ID from the RTA toolbar.
140
+ * This function specifically targets buttons 'Reset' and 'Publish'.
141
+ */
142
+ function removeExtraBtnsFromToolbar() {
143
+ const rtaToolbarEl = document.querySelector('.sapUiRtaToolbar');
144
+ const resetEl = getElementByTitle('Reset', rtaToolbarEl);
145
+ const publishEl = getElementByTitle('Publish', rtaToolbarEl);
146
+ hideButtonById(resetEl?.id);
147
+ hideButtonById(publishEl?.id);
148
+ }
149
+
150
+ /**
151
+ * Initializes custom RuntimeAuthoring for UI5 Versions < 1.72 and start UI Adaptation.
152
+ * Ensures that the passed options are valid.
153
+ *
154
+ * @param {RTAOptions} options - Options that are passed to RuntimeAuthoring upon initialization.
155
+ * @param {RTAPlugin} loadPlugins - Script that needs to be executed after rta is initialized.
156
+ * @returns {Promise<void>} A promise that resolves when all the checks have passed and RuntimeAuthoring is started.
157
+ */
158
+ var __exports = async function (options, loadPlugins) {
159
+ options = merge(defaultOptions, options);
160
+ const layer = options.flexSettings.layer;
161
+ const rootControl = options.rootControl;
162
+ await checkLayerAndControl(rootControl, layer);
163
+ options.rootControl = Utils.getAppComponentForControl(rootControl);
164
+ checkFlexEnabled(options.rootControl);
165
+ const rta = new RuntimeAuthoring(options);
166
+ rta.attachEvent('stop', () => rta.destroy());
167
+ if (loadPlugins) {
168
+ await loadPlugins(rta);
169
+ }
170
+ await rta.start();
171
+ removeExtraBtnsFromToolbar();
172
+ };
173
+ __exports.isValidLayer = isValidLayer;
174
+ __exports.checkLayer = checkLayer;
175
+ __exports.checkRootControl = checkRootControl;
176
+ __exports.checkFlexEnabled = checkFlexEnabled;
177
+ __exports.checkKeyUser = checkKeyUser;
178
+ return __exports;
179
179
  });
180
180
  //# sourceMappingURL=initRta.js.map