@sap-ux/preview-middleware 0.25.41 → 0.25.42

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.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/Component", "sap/ui/dt/OverlayRegistry", "../../cpe/quick-actions/utils", "../../utils/core", "../dialog-factory", "../../i18n", "./simple-quick-action-base", "./dialog-enablement-validator"], function (Component, OverlayRegistry, ____cpe_quick_actions_utils, ____utils_core, ___dialog_factory, ____i18n, ___simple_quick_action_base, ___dialog_enablement_validator) {
4
+ "use strict";
5
+
6
+ const pageHasControlId = ____cpe_quick_actions_utils["pageHasControlId"];
7
+ const getControlById = ____utils_core["getControlById"];
8
+ const DialogFactory = ___dialog_factory["DialogFactory"];
9
+ const DialogNames = ___dialog_factory["DialogNames"];
10
+ const getTextBundle = ____i18n["getTextBundle"];
11
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
12
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
13
+ const ADD_NEW_OBJECT_PAGE_ACTION = 'add-new-subpage';
14
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
15
+ /**
16
+ * Base Quick Action class for adding a custom page action.
17
+ */
18
+ class AddNewSubpageBase extends SimpleQuickActionDefinitionBase {
19
+ constructor(context) {
20
+ super(ADD_NEW_OBJECT_PAGE_ACTION, [], 'QUICK_ACTION_ADD_NEW_SUB_PAGE', context, [{
21
+ run: async () => {
22
+ const i18n = await getTextBundle();
23
+ if (this.navProperties.length === 0) {
24
+ return {
25
+ type: 'error',
26
+ message: i18n.getText('NO_SUB_PAGES_TO_ADD')
27
+ };
28
+ }
29
+ return undefined;
30
+ }
31
+ }, DIALOG_ENABLEMENT_VALIDATOR]);
32
+ this.appReference = context.flexSettings.projectId ?? '';
33
+ this.existingPages = this.getApplicationPages();
34
+ }
35
+ async addNavigationOptionIfAvailable(metaModel, targetEntitySet, navProperty) {
36
+ if (!targetEntitySet) {
37
+ return;
38
+ }
39
+ const pageExists = await this.isPageExists(targetEntitySet, metaModel);
40
+ if (!pageExists) {
41
+ this.navProperties.push({
42
+ entitySet: targetEntitySet,
43
+ navProperty: navProperty ?? targetEntitySet
44
+ });
45
+ }
46
+ }
47
+ async initialize() {
48
+ if (!this.appReference) {
49
+ throw new Error('App reference not defined');
50
+ }
51
+ const allControls = CONTROL_TYPES.flatMap(item => this.context.controlIndex[item] ?? []);
52
+ const control = allControls.find(c => pageHasControlId(this.context.view, c.controlId));
53
+ this.pageType = this.context.view.getViewName().split('.view.')[0];
54
+ const metaModel = this.getODataMetaModel();
55
+ if (!metaModel || !control) {
56
+ return;
57
+ }
58
+ const modifiedControl = getControlById(control.controlId);
59
+ if (!modifiedControl) {
60
+ return;
61
+ }
62
+ const component = Component.getOwnerComponentFor(modifiedControl);
63
+ const entitySetName = await this.getEntitySetNameFromPageComponent(component, metaModel);
64
+ if (!entitySetName) {
65
+ return;
66
+ }
67
+ this.entitySet = entitySetName;
68
+ this.navProperties = [];
69
+ if (!this.isCurrentObjectPage()) {
70
+ await this.addNavigationOptionIfAvailable(metaModel, this.entitySet);
71
+ } else {
72
+ await this.prepareNavigationData(metaModel);
73
+ }
74
+ this.control = modifiedControl;
75
+ }
76
+ async execute() {
77
+ const overlay = OverlayRegistry.getOverlay(this.control);
78
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_SUBPAGE, undefined, {
79
+ appReference: this.appReference,
80
+ navProperties: this.navProperties,
81
+ title: 'ADD_SUB_PAGE_DIALOG_TITLE',
82
+ pageDescriptor: this.currentPageDescriptor
83
+ }, {
84
+ actionName: this.type,
85
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
86
+ });
87
+ return [];
88
+ }
89
+ }
90
+ var __exports = {
91
+ __esModule: true
92
+ };
93
+ __exports.ADD_NEW_OBJECT_PAGE_ACTION = ADD_NEW_OBJECT_PAGE_ACTION;
94
+ __exports.AddNewSubpageBase = AddNewSubpageBase;
95
+ return __exports;
96
+ });
97
+ //# sourceMappingURL=add-new-subpage-quick-action-base.js.map
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../../utils/version", "../../utils", "../../../cpe/quick-actions/utils", "../../../i18n", "../../api-handler", "../../dialog-factory", "../../init-dialogs", "../dialog-enablement-validator", "../simple-quick-action-base"], function (OverlayRegistry, _____utils_version, ____utils, _____cpe_quick_actions_utils, _____i18n, ____api_handler, ____dialog_factory, ____init_dialogs, ___dialog_enablement_validator, ___simple_quick_action_base) {
4
+ "use strict";
5
+
6
+ const getUi5Version = _____utils_version["getUi5Version"];
7
+ const getControllerInfoForControl = ____utils["getControllerInfoForControl"];
8
+ const getReuseComponentChecker = ____utils["getReuseComponentChecker"];
9
+ const checkForExistingChange = ____utils["checkForExistingChange"];
10
+ const getRelevantControlFromActivePage = _____cpe_quick_actions_utils["getRelevantControlFromActivePage"];
11
+ const getTextBundle = _____i18n["getTextBundle"];
12
+ const getExistingController = ____api_handler["getExistingController"];
13
+ const DialogFactory = ____dialog_factory["DialogFactory"];
14
+ const DialogNames = ____dialog_factory["DialogNames"];
15
+ const isControllerExtensionEnabledForControl = ____init_dialogs["isControllerExtensionEnabledForControl"];
16
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
17
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
18
+ const ADD_CONTROLLER_TO_PAGE_TYPE = 'add-controller-to-page';
19
+ const CONTROL_TYPES = ['sap.f.DynamicPage', 'sap.uxap.ObjectPageLayout'];
20
+
21
+ /**
22
+ * Quick Action for adding controller to a page.
23
+ */
24
+ class AddControllerToPageQuickAction extends SimpleQuickActionDefinitionBase {
25
+ constructor(context) {
26
+ super(ADD_CONTROLLER_TO_PAGE_TYPE, CONTROL_TYPES, '', context, [DIALOG_ENABLEMENT_VALIDATOR, {
27
+ run: async () => {
28
+ const controllerName = getControllerInfoForControl(this.context.view).controllerName;
29
+ const i18n = await getTextBundle();
30
+ if (checkForExistingChange(this.context.rta, 'codeExt', 'selector.controllerName', controllerName)) {
31
+ return {
32
+ type: 'error',
33
+ message: i18n.getText('ADP_QUICK_ACTION_CONTROLLER_PENDING_CHANGE_EXISTS')
34
+ };
35
+ }
36
+ }
37
+ }]);
38
+ }
39
+ controllerExists = false;
40
+ forceRefreshAfterExecution = true;
41
+ async initialize() {
42
+ const version = await getUi5Version();
43
+ const isReuseComponent = await getReuseComponentChecker(version);
44
+ const control = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)[0];
45
+ if (control) {
46
+ const controlInfo = getControllerInfoForControl(control);
47
+ const data = await getExistingController(controlInfo.controllerName);
48
+ this.controllerExists = data?.controllerExists;
49
+ const isActiveAction = isControllerExtensionEnabledForControl(control, isReuseComponent, this.context.flexSettings.isCloud);
50
+ this.control = isActiveAction ? control : undefined;
51
+ }
52
+ }
53
+ get textKey() {
54
+ return this.controllerExists ? 'QUICK_ACTION_SHOW_PAGE_CONTROLLER' : 'QUICK_ACTION_ADD_PAGE_CONTROLLER';
55
+ }
56
+ async execute() {
57
+ if (this.control) {
58
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
59
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.CONTROLLER_EXTENSION, undefined, {}, {
60
+ actionName: this.type,
61
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
62
+ });
63
+ }
64
+ return [];
65
+ }
66
+ }
67
+ var __exports = {
68
+ __esModule: true
69
+ };
70
+ __exports.ADD_CONTROLLER_TO_PAGE_TYPE = ADD_CONTROLLER_TO_PAGE_TYPE;
71
+ __exports.AddControllerToPageQuickAction = AddControllerToPageQuickAction;
72
+ return __exports;
73
+ });
74
+ //# sourceMappingURL=add-controller-to-page.js.map
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "sap/ui/dt/OverlayRegistry", "sap/ui/rta/command/CommandFactory", "../../../utils/application", "../../../utils/fe-v4", "../../../utils/version", "../../api-handler", "../../dialog-factory", "../dialog-enablement-validator", "../fe-v2/utils", "../quick-action-base"], function (___sap_ux_private_control_property_editor_common, OverlayRegistry, CommandFactory, _____utils_application, _____utils_fe_v4, _____utils_version, ____api_handler, ____dialog_factory, ___dialog_enablement_validator, ___fe_v2_utils, ___quick_action_base) {
4
+ "use strict";
5
+
6
+ const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common["NESTED_QUICK_ACTION_KIND"];
7
+ const getApplicationType = _____utils_application["getApplicationType"];
8
+ const getV4AppComponent = _____utils_fe_v4["getV4AppComponent"];
9
+ const getUi5Version = _____utils_version["getUi5Version"];
10
+ const isLowerThanMinimalUi5Version = _____utils_version["isLowerThanMinimalUi5Version"];
11
+ const getDataSourceAnnotationFileMap = ____api_handler["getDataSourceAnnotationFileMap"];
12
+ const DialogFactory = ____dialog_factory["DialogFactory"];
13
+ const DialogNames = ____dialog_factory["DialogNames"];
14
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
15
+ const getV2AppComponent = ___fe_v2_utils["getV2AppComponent"];
16
+ const QuickActionDefinitionBase = ___quick_action_base["QuickActionDefinitionBase"];
17
+ const ADD_NEW_ANNOTATION_FILE = 'add-new-annotation-file';
18
+ const ADD_NEW_ANNOTATION_FILE_TITLE = 'QUICK_ACTION_ADD_NEW_ANNOTATION_FILE';
19
+
20
+ /**
21
+ * Add New Annotation File.
22
+ */
23
+ class AddNewAnnotationFile extends QuickActionDefinitionBase {
24
+ children = [];
25
+ get quickActionSteps() {
26
+ return 1;
27
+ }
28
+ kind = NESTED_QUICK_ACTION_KIND;
29
+ type = ADD_NEW_ANNOTATION_FILE;
30
+ forceRefreshAfterExecution = true;
31
+ isApplicable = true;
32
+ get id() {
33
+ return `${this.context.key}-${this.type}`;
34
+ }
35
+ constructor(context) {
36
+ super(ADD_NEW_ANNOTATION_FILE, NESTED_QUICK_ACTION_KIND, '', context, [DIALOG_ENABLEMENT_VALIDATOR]);
37
+ this.context = context;
38
+ }
39
+ async initialize() {
40
+ const version = await getUi5Version();
41
+ if (isLowerThanMinimalUi5Version(version, {
42
+ major: 1,
43
+ minor: 108,
44
+ patch: 27
45
+ })) {
46
+ this.isApplicable = false;
47
+ return;
48
+ }
49
+ this.annotationDataSourceData = await getDataSourceAnnotationFileMap();
50
+ const {
51
+ annotationDataSourceMap
52
+ } = this.annotationDataSourceData;
53
+ if (!Object.keys(this.annotationDataSourceData.annotationDataSourceMap).length) {
54
+ throw new Error('No data sources found in the manifest');
55
+ }
56
+ for (const key in annotationDataSourceMap) {
57
+ if (Object.prototype.hasOwnProperty.call(annotationDataSourceMap, key)) {
58
+ const source = annotationDataSourceMap[key];
59
+ const {
60
+ annotationExistsInWS
61
+ } = source.annotationDetails;
62
+ if (source.metadataReadErrorMsg) {
63
+ this.children.push({
64
+ path: this.children.length.toString(),
65
+ enabled: false,
66
+ tooltip: source.metadataReadErrorMsg,
67
+ label: this.context.resourceBundle.getText('ADD_ANNOTATION_FILE', [key]),
68
+ children: []
69
+ });
70
+ } else {
71
+ this.children.push({
72
+ path: this.children.length.toString(),
73
+ enabled: true,
74
+ label: annotationExistsInWS ? this.context.resourceBundle.getText('SHOW_ANNOTATION_FILE', [key]) : this.context.resourceBundle.getText('ADD_ANNOTATION_FILE', [key]),
75
+ children: []
76
+ });
77
+ }
78
+ }
79
+ }
80
+ }
81
+ get textKey() {
82
+ let result = ADD_NEW_ANNOTATION_FILE_TITLE;
83
+ const dataSourceIds = Object.keys(this.annotationDataSourceData.annotationDataSourceMap);
84
+ if (dataSourceIds.length === 1) {
85
+ const details = this.annotationDataSourceData.annotationDataSourceMap[dataSourceIds[0]];
86
+ if (details.annotationDetails.annotationExistsInWS) {
87
+ result = 'QUICK_ACTION_SHOW_ANNOTATION_FILE';
88
+ }
89
+ }
90
+ return result;
91
+ }
92
+ async execute(path) {
93
+ const {
94
+ annotationDataSourceMap,
95
+ isRunningInBAS
96
+ } = this.annotationDataSourceData;
97
+ const appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
98
+ const index = Number(path);
99
+ if (index >= 0) {
100
+ const dataSourceId = Object.keys(annotationDataSourceMap)[index];
101
+ const dataSource = annotationDataSourceMap[dataSourceId];
102
+ if (dataSource?.annotationDetails.annotationExistsInWS) {
103
+ const annotationFileDetails = dataSource.annotationDetails;
104
+ const {
105
+ annotationPath,
106
+ annotationPathFromRoot
107
+ } = annotationFileDetails;
108
+ await DialogFactory.createDialog(OverlayRegistry.getOverlay(this.context.view),
109
+ // this passed only because, for method param is required.
110
+ this.context.rta,
111
+ // same as above
112
+ DialogNames.FILE_EXISTS, undefined, {
113
+ fileName: annotationPathFromRoot,
114
+ filePath: annotationPath,
115
+ isRunningInBAS: isRunningInBAS
116
+ });
117
+ }
118
+ // Create annotation file only, if no file exists already for datasource id or if the change file exist and but no annotation file exists in file system.
119
+ else if (dataSource) {
120
+ const timestamp = Date.now();
121
+ const annotationFileNameWithoutExtension = `annotation_${timestamp}`;
122
+ const annotationFileName = `${annotationFileNameWithoutExtension}.xml`;
123
+ const annotationNameSpace = this.context.flexSettings.layer === 'CUSTOMER_BASE' ? `customer.annotation.${annotationFileNameWithoutExtension}` : `annotation.${annotationFileNameWithoutExtension}`;
124
+ const parameters = {
125
+ dataSourceId: dataSourceId,
126
+ annotations: [annotationNameSpace],
127
+ annotationsInsertPosition: 'END',
128
+ dataSource: {
129
+ [annotationNameSpace]: {
130
+ uri: `annotations/${annotationFileName}`,
131
+ type: 'ODataAnnotation'
132
+ }
133
+ }
134
+ };
135
+ const modifiedValue = {
136
+ changeType: 'appdescr_app_addAnnotationsToOData',
137
+ appComponent: appType === 'fe-v4' ? getV4AppComponent(this.context.view) : getV2AppComponent(this.context.view),
138
+ generator: this.context.flexSettings.generator,
139
+ reference: this.context.flexSettings.projectId,
140
+ parameters,
141
+ serviceUrl: dataSource.serviceUrl
142
+ };
143
+ const command = await CommandFactory.getCommandFor(this.context.view, 'appDescriptor', modifiedValue, null, this.context.flexSettings);
144
+ return [command];
145
+ }
146
+ }
147
+ return [];
148
+ }
149
+
150
+ /**
151
+ * Prepares nested quick action object
152
+ * @returns action instance
153
+ */
154
+ getActionObject() {
155
+ return {
156
+ kind: NESTED_QUICK_ACTION_KIND,
157
+ id: this.id,
158
+ enabled: this.isApplicable,
159
+ title: this.context.resourceBundle.getText(this.textKey),
160
+ children: this.children
161
+ };
162
+ }
163
+ }
164
+ var __exports = {
165
+ __esModule: true
166
+ };
167
+ __exports.ADD_NEW_ANNOTATION_FILE = ADD_NEW_ANNOTATION_FILE;
168
+ __exports.AddNewAnnotationFile = AddNewAnnotationFile;
169
+ return __exports;
170
+ });
171
+ //# sourceMappingURL=add-new-annotation-file.js.map
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../simple-quick-action-base", "../../../utils/application", "../../../utils/version", "../dialog-enablement-validator"], function (OverlayRegistry, ____dialog_factory, ___simple_quick_action_base, _____utils_application, _____utils_version, ___dialog_enablement_validator) {
4
+ "use strict";
5
+
6
+ const DialogFactory = ____dialog_factory["DialogFactory"];
7
+ const DialogNames = ____dialog_factory["DialogNames"];
8
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
9
+ const getApplicationType = _____utils_application["getApplicationType"];
10
+ const getUi5Version = _____utils_version["getUi5Version"];
11
+ const isLowerThanMinimalUi5Version = _____utils_version["isLowerThanMinimalUi5Version"];
12
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
13
+ const ADD_PAGE_ACTION = 'add-page-action';
14
+ const CONTROL_TYPES = ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'];
15
+
16
+ /**
17
+ * Quick Action for adding a custom page action.
18
+ */
19
+ class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase {
20
+ constructor(context) {
21
+ super(ADD_PAGE_ACTION, CONTROL_TYPES, 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION', context, [DIALOG_ENABLEMENT_VALIDATOR]);
22
+ this.appType = getApplicationType(this.context.rta.getRootControlInstance().getManifest());
23
+ }
24
+ async initialize() {
25
+ const version = await getUi5Version();
26
+ if (this.appType === 'fe-v4' && isLowerThanMinimalUi5Version(version, {
27
+ major: 1,
28
+ minor: 130
29
+ })) {
30
+ return;
31
+ }
32
+ await super.initialize();
33
+ }
34
+ async execute() {
35
+ if (this.control) {
36
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
37
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
38
+ aggregation: 'actions',
39
+ title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
40
+ defaultAggregationArrayIndex: 1
41
+ }, {
42
+ actionName: this.type,
43
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
44
+ });
45
+ }
46
+ return [];
47
+ }
48
+ }
49
+ var __exports = {
50
+ __esModule: true
51
+ };
52
+ __exports.ADD_PAGE_ACTION = ADD_PAGE_ACTION;
53
+ __exports.AddPageActionQuickAction = AddPageActionQuickAction;
54
+ return __exports;
55
+ });
56
+ //# sourceMappingURL=create-page-action.js.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../../../cpe/quick-actions/utils", "../simple-quick-action-base", "../dialog-enablement-validator"], function (OverlayRegistry, ____dialog_factory, _____cpe_quick_actions_utils, ___simple_quick_action_base, ___dialog_enablement_validator) {
4
+ "use strict";
5
+
6
+ const DialogFactory = ____dialog_factory["DialogFactory"];
7
+ const DialogNames = ____dialog_factory["DialogNames"];
8
+ const getRelevantControlFromActivePage = _____cpe_quick_actions_utils["getRelevantControlFromActivePage"];
9
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
10
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
11
+ const OP_ADD_CUSTOM_SECTION = 'op-add-custom-section';
12
+ const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
13
+
14
+ /**
15
+ * Quick Action for adding a Header Field to an Object Page.
16
+ */
17
+ class AddCustomSectionQuickAction extends SimpleQuickActionDefinitionBase {
18
+ constructor(context) {
19
+ super(OP_ADD_CUSTOM_SECTION, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_CUSTOM_SECTION', context, [DIALOG_ENABLEMENT_VALIDATOR]);
20
+ }
21
+ async execute() {
22
+ const objectPageLayout = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)[0];
23
+ const overlay = OverlayRegistry.getOverlay(objectPageLayout) || [];
24
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
25
+ aggregation: 'sections',
26
+ title: 'QUICK_ACTION_OP_ADD_CUSTOM_SECTION'
27
+ }, {
28
+ actionName: this.type,
29
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
30
+ });
31
+ return [];
32
+ }
33
+ }
34
+ var __exports = {
35
+ __esModule: true
36
+ };
37
+ __exports.OP_ADD_CUSTOM_SECTION = OP_ADD_CUSTOM_SECTION;
38
+ __exports.AddCustomSectionQuickAction = AddCustomSectionQuickAction;
39
+ return __exports;
40
+ });
41
+ //# sourceMappingURL=op-add-custom-section.js.map
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../../../utils/core", "../simple-quick-action-base", "../dialog-enablement-validator", "../../../i18n"], function (OverlayRegistry, ____dialog_factory, _____utils_core, ___simple_quick_action_base, ___dialog_enablement_validator, _____i18n) {
4
+ "use strict";
5
+
6
+ const DialogFactory = ____dialog_factory["DialogFactory"];
7
+ const DialogNames = ____dialog_factory["DialogNames"];
8
+ const isA = _____utils_core["isA"];
9
+ const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
10
+ const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
11
+ const getTextBundle = _____i18n["getTextBundle"];
12
+ const OP_ADD_HEADER_FIELD_TYPE = 'op-add-header-field';
13
+ const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
14
+
15
+ /**
16
+ * Quick Action for adding a Header Field to an Object Page.
17
+ */
18
+ class AddHeaderFieldQuickAction extends SimpleQuickActionDefinitionBase {
19
+ constructor(context) {
20
+ super(OP_ADD_HEADER_FIELD_TYPE, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_HEADER_FIELD', context, [DIALOG_ENABLEMENT_VALIDATOR, {
21
+ run: async () => {
22
+ const i18n = await getTextBundle();
23
+ if (!this.control?.getShowHeaderContent()) {
24
+ return {
25
+ type: 'error',
26
+ message: i18n.getText('DISABLE_SHOW_HEADER_CONTENT')
27
+ };
28
+ }
29
+ return undefined;
30
+ }
31
+ }]);
32
+ }
33
+ async execute() {
34
+ if (!this.control) {
35
+ return [];
36
+ }
37
+ const headerContent = this.control.getHeaderContent();
38
+
39
+ // check if only flex box exist in the headerContent.
40
+ if (headerContent.length === 1 && isA('sap.m.FlexBox', headerContent[0])) {
41
+ const overlay = OverlayRegistry.getOverlay(headerContent[0]) || [];
42
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
43
+ aggregation: 'items',
44
+ title: 'QUICK_ACTION_OP_ADD_HEADER_FIELD'
45
+ }, {
46
+ actionName: this.type,
47
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
48
+ });
49
+ } else if (this.control) {
50
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
51
+ await DialogFactory.createDialog(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, {
52
+ aggregation: 'headerContent',
53
+ title: 'QUICK_ACTION_OP_ADD_HEADER_FIELD'
54
+ }, {
55
+ actionName: this.type,
56
+ telemetryEventIdentifier: this.getTelemetryIdentifier()
57
+ });
58
+ }
59
+ return [];
60
+ }
61
+ }
62
+ var __exports = {
63
+ __esModule: true
64
+ };
65
+ __exports.OP_ADD_HEADER_FIELD_TYPE = OP_ADD_HEADER_FIELD_TYPE;
66
+ __exports.AddHeaderFieldQuickAction = AddHeaderFieldQuickAction;
67
+ return __exports;
68
+ });
69
+ //# sourceMappingURL=op-add-header-field.js.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
7
+ const M_TABLE_TYPE = 'sap.m.Table';
8
+ const MDC_TABLE_TYPE = 'sap.ui.mdc.Table';
9
+ const TREE_TABLE_TYPE = 'sap.ui.table.TreeTable';
10
+ const GRID_TABLE_TYPE = 'sap.ui.table.Table';
11
+ const ANALYTICAL_TABLE_TYPE = 'sap.ui.table.AnalyticalTable';
12
+ const MDC_ACTION_TOOLBAR_TYPE = 'sap.ui.mdc.ActionToolbar';
13
+ var __exports = {
14
+ __esModule: true
15
+ };
16
+ __exports.SMART_TABLE_TYPE = SMART_TABLE_TYPE;
17
+ __exports.M_TABLE_TYPE = M_TABLE_TYPE;
18
+ __exports.MDC_TABLE_TYPE = MDC_TABLE_TYPE;
19
+ __exports.TREE_TABLE_TYPE = TREE_TABLE_TYPE;
20
+ __exports.GRID_TABLE_TYPE = GRID_TABLE_TYPE;
21
+ __exports.ANALYTICAL_TABLE_TYPE = ANALYTICAL_TABLE_TYPE;
22
+ __exports.MDC_ACTION_TOOLBAR_TYPE = MDC_ACTION_TOOLBAR_TYPE;
23
+ return __exports;
24
+ });
25
+ //# sourceMappingURL=control-types.js.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../i18n", "../dialog-factory"], function (____i18n, ___dialog_factory) {
4
+ "use strict";
5
+
6
+ const getTextBundle = ____i18n["getTextBundle"];
7
+ const DialogFactory = ___dialog_factory["DialogFactory"];
8
+ const DIALOG_ENABLEMENT_VALIDATOR = {
9
+ run: async () => {
10
+ const i18n = await getTextBundle();
11
+ if (!DialogFactory.canOpenDialog) {
12
+ return {
13
+ type: 'error',
14
+ message: i18n.getText('ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE')
15
+ };
16
+ }
17
+ return undefined;
18
+ }
19
+ };
20
+ var __exports = {
21
+ __esModule: true
22
+ };
23
+ __exports.DIALOG_ENABLEMENT_VALIDATOR = DIALOG_ENABLEMENT_VALIDATOR;
24
+ return __exports;
25
+ });
26
+ //# sourceMappingURL=dialog-enablement-validator.js.map
@@ -35,6 +35,7 @@ sap.ui.define(["sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-privat
35
35
  * SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
36
36
  */
37
37
  const UI5_LIBS = ['sap.apf', 'sap.base', 'sap.chart', 'sap.collaboration', 'sap.f', 'sap.fe', 'sap.fileviewer', 'sap.gantt', 'sap.landvisz', 'sap.m', 'sap.ndc', 'sap.ovp', 'sap.rules', 'sap.suite', 'sap.tnt', 'sap.ui', 'sap.uiext', 'sap.ushell', 'sap.uxap', 'sap.viz', 'sap.webanalytics', 'sap.zen'];
38
+ const CONTROLLER_EXTENSION_PATH_REGEX = /\/changes\/coding\/.+\.(js|ts)/;
38
39
  /**
39
40
  * Check whether a specific dependency is a custom library, and if yes, add it to the map.
40
41
  *
@@ -243,6 +244,55 @@ sap.ui.define(["sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-privat
243
244
  });
244
245
  }
245
246
 
247
+ /**
248
+ * Extracts an Error object from a global error event.
249
+ * Handles both synchronous errors (ErrorEvent) and unhandled promise rejections (PromiseRejectionEvent).
250
+ *
251
+ * @param {GlobalErrorEvent} event - The global error or unhandled rejection event.
252
+ * @returns {Error | undefined} The extracted Error instance, or undefined if no Error could be extracted.
253
+ */
254
+ function extractError(event) {
255
+ if ('error' in event && event.error instanceof Error) {
256
+ return event.error;
257
+ }
258
+ if ('reason' in event && event.reason instanceof Error) {
259
+ return event.reason;
260
+ }
261
+ return undefined;
262
+ }
263
+
264
+ /**
265
+ * Reports controller extension errors to the Info Center.
266
+ * Filters events by checking if the stack trace contains 'ControllerExtension',
267
+ * and sends matching errors as error-level messages to the Info Center panel.
268
+ *
269
+ * @param {GlobalErrorEvent} event - The global error or unhandled rejection event.
270
+ */
271
+ const reportControllerExtensionErrorToInfoCenter = event => {
272
+ const error = extractError(event);
273
+ const stackTrace = error?.stack ?? '';
274
+ if (!CONTROLLER_EXTENSION_PATH_REGEX.test(stackTrace)) {
275
+ return;
276
+ }
277
+ void sendInfoCenterMessage({
278
+ title: {
279
+ key: 'CONTROLLER_EXTENSION_UNHANDLED_ERROR_TITLE'
280
+ },
281
+ description: error?.message ?? '',
282
+ type: MessageBarType.error,
283
+ details: stackTrace
284
+ });
285
+ };
286
+
287
+ /**
288
+ * Registers global event listeners for uncaught errors and unhandled promise rejections
289
+ * to detect and report controller extension errors to the Info Center.
290
+ */
291
+ function registerForControllerExtensionErrors() {
292
+ globalThis.addEventListener('error', reportControllerExtensionErrorToInfoCenter);
293
+ globalThis.addEventListener('unhandledrejection', reportControllerExtensionErrorToInfoCenter);
294
+ }
295
+
246
296
  /**
247
297
  * Apply additional configuration and initialize sandbox.
248
298
  *
@@ -266,6 +316,7 @@ sap.ui.define(["sap/base/Log", "open/ux/preview/client/thirdparty/@sap-ux-privat
266
316
  const ui5VersionInfo = await getUi5Version();
267
317
  // Register RTA if configured
268
318
  if (flex) {
319
+ registerForControllerExtensionErrors();
269
320
  const flexSettings = JSON.parse(flex);
270
321
  scenario = flexSettings.scenario;
271
322
  container.attachRendererCreatedEvent(async function () {
@@ -43,6 +43,10 @@ const UI5_LIBS = [
43
43
  'sap.zen'
44
44
  ];
45
45
 
46
+ const CONTROLLER_EXTENSION_PATH_REGEX = /\/changes\/coding\/.+\.(js|ts)/;
47
+
48
+ type GlobalErrorEvent = ErrorEvent | PromiseRejectionEvent;
49
+
46
50
  interface Manifest {
47
51
  ['sap.ui5']?: {
48
52
  dependencies?: {
@@ -278,6 +282,55 @@ function addCardGenerationUserAction(componentInstance: Component, container: ty
278
282
  });
279
283
  }
280
284
 
285
+ /**
286
+ * Extracts an Error object from a global error event.
287
+ * Handles both synchronous errors (ErrorEvent) and unhandled promise rejections (PromiseRejectionEvent).
288
+ *
289
+ * @param {GlobalErrorEvent} event - The global error or unhandled rejection event.
290
+ * @returns {Error | undefined} The extracted Error instance, or undefined if no Error could be extracted.
291
+ */
292
+ function extractError(event: GlobalErrorEvent): Error | undefined {
293
+ if ('error' in event && event.error instanceof Error) {
294
+ return event.error;
295
+ }
296
+
297
+ if ('reason' in event && event.reason instanceof Error) {
298
+ return event.reason;
299
+ }
300
+
301
+ return undefined;
302
+ }
303
+
304
+ /**
305
+ * Reports controller extension errors to the Info Center.
306
+ * Filters events by checking if the stack trace contains 'ControllerExtension',
307
+ * and sends matching errors as error-level messages to the Info Center panel.
308
+ *
309
+ * @param {GlobalErrorEvent} event - The global error or unhandled rejection event.
310
+ */
311
+ const reportControllerExtensionErrorToInfoCenter: (event: GlobalErrorEvent) => void = (event) => {
312
+ const error = extractError(event);
313
+ const stackTrace = error?.stack ?? '';
314
+ if (!CONTROLLER_EXTENSION_PATH_REGEX.test(stackTrace)) {
315
+ return;
316
+ }
317
+ void sendInfoCenterMessage({
318
+ title: { key: 'CONTROLLER_EXTENSION_UNHANDLED_ERROR_TITLE' },
319
+ description: error?.message ?? '',
320
+ type: MessageBarType.error,
321
+ details: stackTrace
322
+ });
323
+ };
324
+
325
+ /**
326
+ * Registers global event listeners for uncaught errors and unhandled promise rejections
327
+ * to detect and report controller extension errors to the Info Center.
328
+ */
329
+ function registerForControllerExtensionErrors(): void {
330
+ globalThis.addEventListener('error', reportControllerExtensionErrorToInfoCenter);
331
+ globalThis.addEventListener('unhandledrejection', reportControllerExtensionErrorToInfoCenter);
332
+ }
333
+
281
334
  /**
282
335
  * Apply additional configuration and initialize sandbox.
283
336
  *
@@ -309,6 +362,7 @@ export async function init({
309
362
  const ui5VersionInfo = await getUi5Version();
310
363
  // Register RTA if configured
311
364
  if (flex) {
365
+ registerForControllerExtensionErrors();
312
366
  const flexSettings = JSON.parse(flex) as FlexSettings;
313
367
  scenario = flexSettings.scenario;
314
368
  container.attachRendererCreatedEvent(async function () {
@@ -83,6 +83,7 @@ FLP_UI_INVALID_UI5_VERSION_DESCRIPTION = Invalid version info
83
83
  FLP_UI_VERSION_RETRIEVAL_FAILURE_DESCRIPTION = Could not get the SAPUI5 version of the application. Using {0} as fallback.
84
84
  FLP_UI5_VERSION_WARNING_TITLE = SAPUI5 Version Warning
85
85
  FLP_UI5_VERSION_WARNING_DESCRIPTION = The current SAPUI5 version set for this adaptation project is {0}. The minimum version for SAPUI5 Adaptation Project and its SAPUI5 Adaptation Editor is {1}. Install version {1} or higher.
86
+ CONTROLLER_EXTENSION_UNHANDLED_ERROR_TITLE = Controller Extension Unhandled Error
86
87
 
87
88
  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.
88
89
 
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.25.41",
12
+ "version": "0.25.42",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,13 +27,13 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "qrcode": "1.5.4",
29
29
  "@sap/bas-sdk": "3.13.6",
30
- "@sap-ux/adp-tooling": "0.18.129",
31
30
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.25",
32
- "@sap-ux/btp-utils": "1.1.15",
31
+ "@sap-ux/adp-tooling": "0.18.129",
33
32
  "@sap-ux/feature-toggle": "0.3.8",
34
33
  "@sap-ux/logger": "0.8.5",
35
- "@sap-ux/system-access": "0.7.11",
34
+ "@sap-ux/btp-utils": "1.1.15",
36
35
  "@sap-ux/project-access": "1.36.3",
36
+ "@sap-ux/system-access": "0.7.11",
37
37
  "@sap-ux/i18n": "0.3.11"
38
38
  },
39
39
  "devDependencies": {
@@ -53,10 +53,10 @@
53
53
  "nock": "14.0.11",
54
54
  "npm-run-all2": "8.0.4",
55
55
  "supertest": "7.2.2",
56
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.25.41",
56
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.25.42",
57
+ "@sap-ux/axios-extension": "1.25.35",
57
58
  "@sap-ux/store": "1.5.13",
58
- "@sap-ux/ui5-info": "0.13.21",
59
- "@sap-ux/axios-extension": "1.25.35"
59
+ "@sap-ux/ui5-info": "0.13.21"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "express": "4"