@sap-ux/preview-middleware 0.20.1 → 0.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/adp/command-executor.js +2 -2
- package/dist/client/adp/command-executor.ts +4 -4
- package/dist/client/adp/controllers/AddFragment.controller.js +1 -1
- package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +1 -1
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +2 -2
- package/dist/client/adp/controllers/BaseDialog.controller.js +2 -13
- package/dist/client/adp/controllers/BaseDialog.controller.ts +7 -25
- package/dist/client/adp/controllers/ControllerExtension.controller.js +73 -15
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +110 -22
- package/dist/client/adp/dialog-factory.js +1 -1
- package/dist/client/adp/dialog-factory.ts +3 -1
- package/dist/client/adp/extend-controller.js +48 -0
- package/dist/client/adp/extend-controller.ts +49 -0
- package/dist/client/adp/init-dialogs.js +15 -35
- package/dist/client/adp/init-dialogs.ts +42 -20
- package/dist/client/adp/init.js +9 -1
- package/dist/client/adp/init.ts +6 -1
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +16 -2
- package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +25 -3
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +1 -1
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.ts +1 -1
- package/dist/client/adp/ui/ControllerExtension.fragment.xml +14 -3
- package/dist/client/adp/utils.js +49 -8
- package/dist/client/adp/utils.ts +55 -7
- package/dist/client/cpe/connector-service.ts +1 -0
- package/dist/client/cpe/context-menu-service.js +6 -3
- package/dist/client/cpe/context-menu-service.ts +3 -1
- package/dist/client/cpe/quick-actions/quick-action-service.js +10 -3
- package/dist/client/cpe/quick-actions/quick-action-service.ts +7 -1
- package/dist/client/messagebundle.properties +5 -0
- package/package.json +6 -6
package/dist/client/adp/utils.ts
CHANGED
|
@@ -9,6 +9,7 @@ import FlexUtils from 'sap/ui/fl/Utils';
|
|
|
9
9
|
import IsReuseComponentApi from 'sap/ui/rta/util/isReuseComponent';
|
|
10
10
|
import { getControlById } from '../utils/core';
|
|
11
11
|
import type { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
|
|
12
|
+
import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
12
13
|
|
|
13
14
|
import { getError } from '../utils/error';
|
|
14
15
|
import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../utils/version';
|
|
@@ -60,19 +61,66 @@ export function createDeferred<T>(): Deferred<T> {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
|
-
* Checks
|
|
64
|
+
* Checks for the existence of a change associated with a specific fragment name in the RTA command stack.
|
|
65
|
+
*
|
|
66
|
+
* @param {RuntimeAuthoring} rta - The RuntimeAuthoring instance to check for existing changes.
|
|
67
|
+
* @param {string} commandName - The name of the fragment to check for existing changes.
|
|
68
|
+
* @param {string} propertyPath - The path to the property as string separated by dot in the change definition to check.
|
|
69
|
+
* @param {string} propertyValue - The value to match against the specified property.
|
|
70
|
+
* @returns {Promise<boolean>} A promise that resolves to `true` if a matching change is found, otherwise `false`.
|
|
71
|
+
*/
|
|
72
|
+
export function checkForExistingChange(
|
|
73
|
+
rta: RuntimeAuthoring,
|
|
74
|
+
commandName: string,
|
|
75
|
+
propertyPath: string,
|
|
76
|
+
propertyValue: string
|
|
77
|
+
): boolean {
|
|
78
|
+
const allCommands = rta.getCommandStack().getCommands();
|
|
79
|
+
|
|
80
|
+
return allCommands.some((command: FlexCommand) => {
|
|
81
|
+
if (typeof command.getCommands === 'function') {
|
|
82
|
+
const subCommand = command.getCommands().find((c: FlexCommand) => c?.getProperty('name') === commandName);
|
|
83
|
+
|
|
84
|
+
return subCommand && matchesChangeProperty(subCommand, propertyPath, propertyValue);
|
|
85
|
+
} else {
|
|
86
|
+
return matchesChangeProperty(command, propertyPath, propertyValue);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Retrieves the value of a nested property from an object based on a dot-separated path.
|
|
93
|
+
*
|
|
94
|
+
* @param obj - The object from which to retrieve the nested property.
|
|
95
|
+
* @param path - A dot-separated string representing the path to the desired property.
|
|
96
|
+
* For example, "a.b.c" will attempt to access `obj.a.b.c`.
|
|
97
|
+
* @returns The value of the nested property if it exists, or `undefined` if any part of the path is invalid.
|
|
98
|
+
*/
|
|
99
|
+
export function getNestedProperty(obj: object, path: string): unknown {
|
|
100
|
+
return path.split('.').reduce((acc: unknown, key) => {
|
|
101
|
+
return (acc as Record<string, unknown>)?.[key];
|
|
102
|
+
}, obj);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Checks if a specific property in the command's change matches the given value.
|
|
64
107
|
*
|
|
65
108
|
* @param {FlexCommand} command - The command object containing the prepared change to be examined.
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @
|
|
68
|
-
*
|
|
109
|
+
* @param {string} propertyPath - The path to the property in the change definition to check.
|
|
110
|
+
* @param {string} propertyValue - The value to match against the specified property.
|
|
111
|
+
* @returns {boolean} Returns true if the command's change contains the specified property with the matching value; otherwise, returns false.
|
|
69
112
|
*/
|
|
70
|
-
export function
|
|
113
|
+
export function matchesChangeProperty(command: FlexCommand, propertyPath: string, propertyValue: string): boolean {
|
|
71
114
|
if (typeof command.getPreparedChange !== 'function') {
|
|
72
115
|
return false;
|
|
73
116
|
}
|
|
74
|
-
const change = command.getPreparedChange()
|
|
75
|
-
|
|
117
|
+
const change = command.getPreparedChange()?.getDefinition?.();
|
|
118
|
+
if (!change) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const nestedProperty = getNestedProperty(change, propertyPath);
|
|
123
|
+
return typeof nestedProperty === 'string' ? nestedProperty.includes(propertyValue) : false;
|
|
76
124
|
}
|
|
77
125
|
|
|
78
126
|
/**
|
|
@@ -5,8 +5,9 @@ sap.ui.define([
|
|
|
5
5
|
'../i18n',
|
|
6
6
|
'sap/base/Log',
|
|
7
7
|
'../utils/core',
|
|
8
|
-
'../utils/version'
|
|
9
|
-
|
|
8
|
+
'../utils/version',
|
|
9
|
+
'../utils/application'
|
|
10
|
+
], function (___sap_ux_private_control_property_editor_common, ___adp_dialog_factory, ___i18n, Log, ___utils_core, ___utils_version, ___utils_application) {
|
|
10
11
|
'use strict';
|
|
11
12
|
const executeContextMenuAction = ___sap_ux_private_control_property_editor_common['executeContextMenuAction'];
|
|
12
13
|
const reportTelemetry = ___sap_ux_private_control_property_editor_common['reportTelemetry'];
|
|
@@ -15,6 +16,7 @@ sap.ui.define([
|
|
|
15
16
|
const getTextBundle = ___i18n['getTextBundle'];
|
|
16
17
|
const getControlById = ___utils_core['getControlById'];
|
|
17
18
|
const getUi5Version = ___utils_version['getUi5Version'];
|
|
19
|
+
const getApplicationType = ___utils_application['getApplicationType'];
|
|
18
20
|
class ContextMenuService {
|
|
19
21
|
sendAction = () => {
|
|
20
22
|
};
|
|
@@ -36,7 +38,8 @@ sap.ui.define([
|
|
|
36
38
|
category: 'OutlineContextMenu',
|
|
37
39
|
actionName,
|
|
38
40
|
controlName,
|
|
39
|
-
ui5Version: `${ versionInfo.major }.${ versionInfo.minor }.${ versionInfo.patch }
|
|
41
|
+
ui5Version: `${ versionInfo.major }.${ versionInfo.minor }.${ versionInfo.patch }`,
|
|
42
|
+
appType: getApplicationType(this.rta.getRootControlInstance().getManifest())
|
|
40
43
|
});
|
|
41
44
|
} catch (err) {
|
|
42
45
|
Log.error('Error in reporting Telemetry:', err);
|
|
@@ -12,6 +12,7 @@ import { getTextBundle } from '../i18n';
|
|
|
12
12
|
import Log from 'sap/base/Log';
|
|
13
13
|
import { getControlById } from '../utils/core';
|
|
14
14
|
import { getUi5Version } from '../utils/version';
|
|
15
|
+
import { getApplicationType } from '../utils/application';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* A Class of ContextMenuService
|
|
@@ -46,7 +47,8 @@ export class ContextMenuService {
|
|
|
46
47
|
category: 'OutlineContextMenu',
|
|
47
48
|
actionName,
|
|
48
49
|
controlName,
|
|
49
|
-
ui5Version: `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}
|
|
50
|
+
ui5Version: `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}`,
|
|
51
|
+
appType: getApplicationType(this.rta.getRootControlInstance().getManifest())
|
|
50
52
|
});
|
|
51
53
|
} catch (err) {
|
|
52
54
|
Log.error('Error in reporting Telemetry:', err);
|
|
@@ -3,8 +3,10 @@ sap.ui.define([
|
|
|
3
3
|
'sap/base/Log',
|
|
4
4
|
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
5
5
|
'../../i18n',
|
|
6
|
-
'../../adp/dialog-factory'
|
|
7
|
-
|
|
6
|
+
'../../adp/dialog-factory',
|
|
7
|
+
'../../utils/application',
|
|
8
|
+
'../../utils/version'
|
|
9
|
+
], function (Log, ___sap_ux_private_control_property_editor_common, ____i18n, ____adp_dialog_factory, ____utils_application, ____utils_version) {
|
|
8
10
|
'use strict';
|
|
9
11
|
const executeQuickAction = ___sap_ux_private_control_property_editor_common['executeQuickAction'];
|
|
10
12
|
const quickActionListChanged = ___sap_ux_private_control_property_editor_common['quickActionListChanged'];
|
|
@@ -15,6 +17,8 @@ sap.ui.define([
|
|
|
15
17
|
const reportTelemetry = ___sap_ux_private_control_property_editor_common['reportTelemetry'];
|
|
16
18
|
const getTextBundle = ____i18n['getTextBundle'];
|
|
17
19
|
const DialogFactory = ____adp_dialog_factory['DialogFactory'];
|
|
20
|
+
const getApplicationType = ____utils_application['getApplicationType'];
|
|
21
|
+
const getUi5Version = ____utils_version['getUi5Version'];
|
|
18
22
|
class QuickActionService {
|
|
19
23
|
sendAction = () => {
|
|
20
24
|
};
|
|
@@ -104,11 +108,14 @@ sap.ui.define([
|
|
|
104
108
|
}
|
|
105
109
|
async executeAction(actionInstance, payload) {
|
|
106
110
|
try {
|
|
111
|
+
const versionInfo = await getUi5Version();
|
|
107
112
|
await reportTelemetry({
|
|
108
113
|
category: 'QuickAction',
|
|
109
114
|
actionName: actionInstance.type,
|
|
110
115
|
telemetryEventIdentifier: actionInstance.getTelemetryIdentifier(true),
|
|
111
|
-
quickActionSteps: actionInstance.quickActionSteps
|
|
116
|
+
quickActionSteps: actionInstance.quickActionSteps,
|
|
117
|
+
appType: getApplicationType(this.rta.getRootControlInstance().getManifest()),
|
|
118
|
+
ui5Version: `${ versionInfo.major }.${ versionInfo.minor }.${ versionInfo.patch }`
|
|
112
119
|
});
|
|
113
120
|
} catch (error) {
|
|
114
121
|
Log.error('Error in reporting Telemetry:', error);
|
|
@@ -23,6 +23,9 @@ import { OutlineService } from '../outline/service';
|
|
|
23
23
|
import { getTextBundle, TextBundle } from '../../i18n';
|
|
24
24
|
import { ChangeService } from '../changes';
|
|
25
25
|
import { DialogFactory } from '../../adp/dialog-factory';
|
|
26
|
+
import { getApplicationType } from '../../utils/application';
|
|
27
|
+
import { getUi5Version } from '../../utils/version';
|
|
28
|
+
|
|
26
29
|
|
|
27
30
|
/**
|
|
28
31
|
* Service providing Quick Actions.
|
|
@@ -152,11 +155,14 @@ export class QuickActionService implements Service {
|
|
|
152
155
|
|
|
153
156
|
private async executeAction(actionInstance: QuickActionDefinition, payload: QuickActionExecutionPayload) {
|
|
154
157
|
try {
|
|
158
|
+
const versionInfo = await getUi5Version();
|
|
155
159
|
await reportTelemetry({
|
|
156
160
|
category: 'QuickAction',
|
|
157
161
|
actionName: actionInstance.type,
|
|
158
162
|
telemetryEventIdentifier: actionInstance.getTelemetryIdentifier(true),
|
|
159
|
-
quickActionSteps: actionInstance.quickActionSteps
|
|
163
|
+
quickActionSteps: actionInstance.quickActionSteps,
|
|
164
|
+
appType: getApplicationType(this.rta.getRootControlInstance().getManifest()),
|
|
165
|
+
ui5Version: `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}`
|
|
160
166
|
});
|
|
161
167
|
} catch (error) {
|
|
162
168
|
Log.error('Error in reporting Telemetry:', error);
|
|
@@ -39,14 +39,19 @@ ADP_ADD_SUB_PAGE_DIALOG_PAGE_TYPE_LABEL = Page Type
|
|
|
39
39
|
ADP_ADD_SUB_PAGE_DIALOG_NAVIGATION_LABEL = Navigation
|
|
40
40
|
ADP_ADD_FRAGMENT_NOTIFICATION = Note: The `{0}.fragment.xml` fragment will be created once you save the change.
|
|
41
41
|
ADP_ADD_FRAGMENT_WITH_TEMPLATE_NOTIFICATION = Note: The `{0}.fragment.xml` fragment will be created once you save the changes.
|
|
42
|
+
ADP_CONTROLLER_EXTENSION_EXISTS = An existing controller extension has been found. Please use the previously created extension controller.
|
|
43
|
+
ADP_CONTROLLER_PENDING_CHANGE_EXISTS = A pending change for controller extension has been found. Please use the previously created extension controller after saving the change or delete the pending change.
|
|
44
|
+
ADP_CREATE_CONTROLLER_EXTENSION = Note: The `{0}` controller extension will be created once you save the change.
|
|
42
45
|
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.
|
|
43
46
|
ADP_SYNC_VIEWS_MESSAGE = Synchronous views are detected for this application. Controller extensions are not supported for such views and will be disabled.
|
|
44
47
|
ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE = This action is disabled because a dialog is already open.
|
|
48
|
+
ADP_QUICK_ACTION_CONTROLLER_PENDING_CHANGE_EXISTS =This action is disabled because a pending change for a controller extension has been found.
|
|
45
49
|
ADP_ADD_FRAGMENT_MENU_ITEM = Add: Fragment
|
|
46
50
|
ADP_ADD_FRAGMENT_MENU_ITEM_REUSE_COMPONENT = Add: Fragment (This action is disabled because the control is a reuse component)
|
|
47
51
|
ADP_ADD_FRAGMENT_MENU_ITEM_UNSTABLE_ID = Add: Fragment (This action is disabled because the control or parent control has an unstable ID)
|
|
48
52
|
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM = Extend with Controller
|
|
49
53
|
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_REUSE_COMPONENT = Extend with Controller (This action is disabled because the control is a reuse component)
|
|
54
|
+
ADP_ADD_CONTROLLER_EXTENSION_MENU_ITEM_SYNC_VIEW = Extend with Controller (This action is disabled because the controls are part of a synchronous view)
|
|
50
55
|
CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.
|
|
51
56
|
|
|
52
57
|
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.
|
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.20.
|
|
12
|
+
"version": "0.20.3",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"ejs": "3.1.10",
|
|
26
26
|
"mem-fs": "2.1.0",
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
|
-
"@sap-ux/adp-tooling": "0.14.1",
|
|
29
28
|
"@sap-ux/btp-utils": "1.1.0",
|
|
30
29
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.5",
|
|
31
|
-
"@sap-ux/
|
|
30
|
+
"@sap-ux/adp-tooling": "0.14.2",
|
|
32
31
|
"@sap-ux/logger": "0.7.0",
|
|
32
|
+
"@sap-ux/feature-toggle": "0.3.0",
|
|
33
33
|
"@sap-ux/project-access": "1.30.1",
|
|
34
34
|
"@sap-ux/system-access": "0.6.0"
|
|
35
35
|
},
|
|
@@ -49,11 +49,11 @@
|
|
|
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.14.0",
|
|
53
52
|
"@sap-ux/axios-extension": "1.21.0",
|
|
53
|
+
"@sap-ux/i18n": "0.3.0",
|
|
54
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.14.2",
|
|
54
55
|
"@sap-ux/store": "1.1.0",
|
|
55
|
-
"@sap-ux/ui5-info": "0.11.0"
|
|
56
|
-
"@sap-ux/i18n": "0.3.0"
|
|
56
|
+
"@sap-ux/ui5-info": "0.11.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"express": "4"
|