@sap-ux/preview-middleware 0.17.17 → 0.17.18
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/cpe/context-menu-service.js +56 -0
- package/dist/client/cpe/context-menu-service.ts +59 -0
- package/dist/client/cpe/init.js +6 -2
- package/dist/client/cpe/init.ts +3 -1
- package/dist/client/cpe/outline/nodes.ts +0 -1
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +73 -1
- package/package.json +4 -4
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
sap.ui.define([
|
|
3
|
+
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
4
|
+
'../adp/dialog-factory',
|
|
5
|
+
'../i18n'
|
|
6
|
+
], function (___sap_ux_private_control_property_editor_common, ___adp_dialog_factory, ___i18n) {
|
|
7
|
+
'use strict';
|
|
8
|
+
const executeContextMenuAction = ___sap_ux_private_control_property_editor_common['executeContextMenuAction'];
|
|
9
|
+
const requestControlContextMenu = ___sap_ux_private_control_property_editor_common['requestControlContextMenu'];
|
|
10
|
+
const DialogFactory = ___adp_dialog_factory['DialogFactory'];
|
|
11
|
+
const getTextBundle = ___i18n['getTextBundle'];
|
|
12
|
+
class ContextMenuService {
|
|
13
|
+
sendAction = () => {
|
|
14
|
+
};
|
|
15
|
+
constructor(rta) {
|
|
16
|
+
this.rta = rta;
|
|
17
|
+
}
|
|
18
|
+
async init(sendAction, subscribe) {
|
|
19
|
+
this.sendAction = sendAction;
|
|
20
|
+
this.actionService = await this.rta.getService('action');
|
|
21
|
+
const resourceBundle = await getTextBundle();
|
|
22
|
+
subscribe(async action => {
|
|
23
|
+
if (executeContextMenuAction.match(action)) {
|
|
24
|
+
const {actionName, controlId} = action.payload;
|
|
25
|
+
await this.actionService.execute(controlId, actionName);
|
|
26
|
+
}
|
|
27
|
+
if (requestControlContextMenu.pending.match(action)) {
|
|
28
|
+
const controlId = action.payload;
|
|
29
|
+
const actions = await this.actionService.get(controlId);
|
|
30
|
+
const responsePayload = {
|
|
31
|
+
controlId: controlId,
|
|
32
|
+
contextMenuItems: (actions ?? []).map(val => {
|
|
33
|
+
let enabled = val.enabled;
|
|
34
|
+
let tooltip;
|
|
35
|
+
if (!DialogFactory.canOpenDialog) {
|
|
36
|
+
enabled = false;
|
|
37
|
+
tooltip = resourceBundle.getText('ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
id: val.id,
|
|
41
|
+
title: val.text,
|
|
42
|
+
enabled,
|
|
43
|
+
tooltip
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
const requestControlActions = requestControlContextMenu.fulfilled(responsePayload);
|
|
48
|
+
this.sendAction(requestControlActions);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
var __exports = { __esModule: true };
|
|
54
|
+
__exports.ContextMenuService = ContextMenuService;
|
|
55
|
+
return __exports;
|
|
56
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeContextMenuAction,
|
|
3
|
+
ExternalAction,
|
|
4
|
+
requestControlContextMenu
|
|
5
|
+
} from '@sap-ux-private/control-property-editor-common';
|
|
6
|
+
import { ActionSenderFunction, SubscribeFunction } from './types';
|
|
7
|
+
import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
8
|
+
import { ActionService } from 'sap/ui/rta/service/Action';
|
|
9
|
+
import { DialogFactory } from '../adp/dialog-factory';
|
|
10
|
+
import { getTextBundle } from '../i18n';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Class of ContextMenuService
|
|
14
|
+
*/
|
|
15
|
+
export class ContextMenuService {
|
|
16
|
+
private sendAction: ActionSenderFunction = () => {};
|
|
17
|
+
private actionService: ActionService;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param rta Runtime Authoring instance.
|
|
21
|
+
*/
|
|
22
|
+
constructor(private readonly rta: RuntimeAuthoring) {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initializes rta service.
|
|
26
|
+
*
|
|
27
|
+
* @param sendAction action sender function
|
|
28
|
+
* @param subscribe subscriber function
|
|
29
|
+
*/
|
|
30
|
+
public async init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): Promise<void> {
|
|
31
|
+
this.sendAction = sendAction;
|
|
32
|
+
this.actionService = await this.rta.getService('action');
|
|
33
|
+
const resourceBundle = await getTextBundle();
|
|
34
|
+
subscribe(async (action: ExternalAction): Promise<void> => {
|
|
35
|
+
if (executeContextMenuAction.match(action)) {
|
|
36
|
+
const { actionName, controlId } = action.payload;
|
|
37
|
+
await this.actionService.execute(controlId, actionName);
|
|
38
|
+
}
|
|
39
|
+
if (requestControlContextMenu.pending.match(action)) {
|
|
40
|
+
const controlId = action.payload;
|
|
41
|
+
const actions = await this.actionService.get(controlId);
|
|
42
|
+
const responsePayload = {
|
|
43
|
+
controlId: controlId,
|
|
44
|
+
contextMenuItems: (actions ?? []).map((val) => {
|
|
45
|
+
let enabled = val.enabled;
|
|
46
|
+
let tooltip;
|
|
47
|
+
if (!DialogFactory.canOpenDialog) {
|
|
48
|
+
enabled = false;
|
|
49
|
+
tooltip = resourceBundle.getText('ADP_QUICK_ACTION_DIALOG_OPEN_MESSAGE');
|
|
50
|
+
}
|
|
51
|
+
return { id: val.id, title: val.text, enabled, tooltip };
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
const requestControlActions = requestControlContextMenu.fulfilled(responsePayload);
|
|
55
|
+
this.sendAction(requestControlActions);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
package/dist/client/cpe/init.js
CHANGED
|
@@ -11,8 +11,9 @@ sap.ui.define([
|
|
|
11
11
|
'./rta-service',
|
|
12
12
|
'../utils/error',
|
|
13
13
|
'./quick-actions/quick-action-service',
|
|
14
|
-
'./communication-service'
|
|
15
|
-
|
|
14
|
+
'./communication-service',
|
|
15
|
+
'./context-menu-service'
|
|
16
|
+
], function (Log, ___sap_ux_private_control_property_editor_common, ___outline_service, ___selection, ___changes_service, ___documentation, ___ui5_utils, ___connector_service, ___rta_service, ___utils_error, ___quick_actions_quick_action_service, ___communication_service, ___context_menu_service) {
|
|
16
17
|
'use strict';
|
|
17
18
|
const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
|
|
18
19
|
const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
|
|
@@ -27,6 +28,7 @@ sap.ui.define([
|
|
|
27
28
|
const getError = ___utils_error['getError'];
|
|
28
29
|
const QuickActionService = ___quick_actions_quick_action_service['QuickActionService'];
|
|
29
30
|
const CommunicationService = ___communication_service['CommunicationService'];
|
|
31
|
+
const ContextMenuService = ___context_menu_service['ContextMenuService'];
|
|
30
32
|
function init(rta) {
|
|
31
33
|
let registries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
32
34
|
Log.info('Initializing Control Property Editor');
|
|
@@ -41,12 +43,14 @@ sap.ui.define([
|
|
|
41
43
|
const changesService = new ChangeService({ rta });
|
|
42
44
|
const selectionService = new SelectionService(rta, changesService);
|
|
43
45
|
const connectorService = new WorkspaceConnectorService();
|
|
46
|
+
const contextMenuService = new ContextMenuService(rta);
|
|
44
47
|
const outlineService = new OutlineService(rta, changesService);
|
|
45
48
|
const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
|
|
46
49
|
const services = [
|
|
47
50
|
connectorService,
|
|
48
51
|
selectionService,
|
|
49
52
|
changesService,
|
|
53
|
+
contextMenuService,
|
|
50
54
|
outlineService,
|
|
51
55
|
rtaService,
|
|
52
56
|
quickActionService
|
package/dist/client/cpe/init.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { getError } from '../utils/error';
|
|
|
15
15
|
import { QuickActionService } from './quick-actions/quick-action-service';
|
|
16
16
|
import type { QuickActionDefinitionRegistry } from './quick-actions/registry';
|
|
17
17
|
import { CommunicationService } from './communication-service';
|
|
18
|
+
import { ContextMenuService } from './context-menu-service';
|
|
18
19
|
|
|
19
20
|
export default function init(
|
|
20
21
|
rta: RuntimeAuthoring,
|
|
@@ -40,14 +41,15 @@ export default function init(
|
|
|
40
41
|
|
|
41
42
|
const changesService = new ChangeService({ rta });
|
|
42
43
|
const selectionService = new SelectionService(rta, changesService);
|
|
43
|
-
|
|
44
44
|
const connectorService = new WorkspaceConnectorService();
|
|
45
|
+
const contextMenuService = new ContextMenuService(rta);
|
|
45
46
|
const outlineService = new OutlineService(rta, changesService);
|
|
46
47
|
const quickActionService = new QuickActionService(rta, outlineService, registries, changesService);
|
|
47
48
|
const services: Service[] = [
|
|
48
49
|
connectorService,
|
|
49
50
|
selectionService,
|
|
50
51
|
changesService,
|
|
52
|
+
contextMenuService,
|
|
51
53
|
outlineService,
|
|
52
54
|
rtaService,
|
|
53
55
|
quickActionService
|
|
@@ -8,7 +8,8 @@ sap.ui.define((function () { 'use strict';
|
|
|
8
8
|
|
|
9
9
|
(function (exports) {
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.externalFileChange = exports.setApplicationRequiresReload = exports.executeQuickAction = exports.updateQuickAction = exports.quickActionListChanged = exports.save = exports.redo = exports.undo = exports.appLoaded = exports.setSaveEnablement = exports.setUndoRedoEnablement = exports.applicationModeChanged = exports.setAppMode = exports.storageFileChanged = exports.reloadApplication = exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.NESTED_QUICK_ACTION_KIND = exports.SIMPLE_QUICK_ACTION_KIND = exports.CONTROL_CHANGE_KIND = exports.UNKNOWN_CHANGE_KIND = exports.CONFIGURATION_CHANGE_KIND = exports.PROPERTY_CHANGE_KIND = exports.SAVED_CHANGE_TYPE = exports.PENDING_CHANGE_TYPE = exports.PropertyType = exports.SCENARIO = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
|
|
11
|
+
exports.requestControlContextMenu = exports.externalFileChange = exports.setApplicationRequiresReload = exports.executeContextMenuAction = exports.executeQuickAction = exports.updateQuickAction = exports.quickActionListChanged = exports.save = exports.redo = exports.undo = exports.appLoaded = exports.setSaveEnablement = exports.setUndoRedoEnablement = exports.applicationModeChanged = exports.setAppMode = exports.storageFileChanged = exports.reloadApplication = exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.REJECTED_SUFFIX = exports.FULFILLED_SUFFIX = exports.PENDING_SUFFIX = exports.NESTED_QUICK_ACTION_KIND = exports.SIMPLE_QUICK_ACTION_KIND = exports.CONTROL_CHANGE_KIND = exports.UNKNOWN_CHANGE_KIND = exports.CONFIGURATION_CHANGE_KIND = exports.PROPERTY_CHANGE_KIND = exports.SAVED_CHANGE_TYPE = exports.PENDING_CHANGE_TYPE = exports.PropertyType = exports.SCENARIO = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
|
|
12
|
+
exports.createAsyncActionFactory = createAsyncActionFactory;
|
|
12
13
|
exports.BOOLEAN_VALUE_TYPE = 'boolean';
|
|
13
14
|
exports.INTEGER_VALUE_TYPE = 'integer';
|
|
14
15
|
exports.FLOAT_VALUE_TYPE = 'float';
|
|
@@ -72,6 +73,74 @@ sap.ui.define((function () { 'use strict';
|
|
|
72
73
|
return action;
|
|
73
74
|
};
|
|
74
75
|
}
|
|
76
|
+
exports.PENDING_SUFFIX = '<pending>';
|
|
77
|
+
exports.FULFILLED_SUFFIX = '<fulfilled>';
|
|
78
|
+
exports.REJECTED_SUFFIX = '<rejected>';
|
|
79
|
+
/**
|
|
80
|
+
* Factory for creating request response actions.
|
|
81
|
+
*
|
|
82
|
+
* @param prefix action prefix
|
|
83
|
+
* @returns Function
|
|
84
|
+
*/
|
|
85
|
+
function createAsyncActionFactory(prefix) {
|
|
86
|
+
return function createAction(name) {
|
|
87
|
+
const pendingType = [prefix, name, exports.PENDING_SUFFIX].join(' ');
|
|
88
|
+
/**
|
|
89
|
+
* Pending action.
|
|
90
|
+
*
|
|
91
|
+
* @param payload action payload
|
|
92
|
+
* @returns PayloadAction<typeof pendingType, T>
|
|
93
|
+
*/
|
|
94
|
+
function pending(payload) {
|
|
95
|
+
return {
|
|
96
|
+
type: pendingType,
|
|
97
|
+
payload
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
pending.type = pendingType;
|
|
101
|
+
pending.match = createMatcher(pendingType);
|
|
102
|
+
const fulfilledType = [prefix, name, exports.FULFILLED_SUFFIX].join(' ');
|
|
103
|
+
/**
|
|
104
|
+
* Fulfill action.
|
|
105
|
+
*
|
|
106
|
+
* @param payload action payload
|
|
107
|
+
* @returns PayloadAction<typeof fulfilledType, F>
|
|
108
|
+
*/
|
|
109
|
+
function fulfilled(payload) {
|
|
110
|
+
return {
|
|
111
|
+
type: fulfilledType,
|
|
112
|
+
payload
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
fulfilled.type = fulfilledType;
|
|
116
|
+
fulfilled.match = createMatcher(fulfilledType);
|
|
117
|
+
const rejectedType = [prefix, name, exports.REJECTED_SUFFIX].join(' ');
|
|
118
|
+
/**
|
|
119
|
+
* Reject action.
|
|
120
|
+
*
|
|
121
|
+
* @param message error message
|
|
122
|
+
* @param payload R
|
|
123
|
+
* @returns ErrorAction<typeof rejectedType, F>
|
|
124
|
+
*/
|
|
125
|
+
function rejected(message, payload) {
|
|
126
|
+
return {
|
|
127
|
+
type: rejectedType,
|
|
128
|
+
payload,
|
|
129
|
+
error: {
|
|
130
|
+
message
|
|
131
|
+
},
|
|
132
|
+
showMessage: true
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
rejected.type = rejectedType;
|
|
136
|
+
rejected.match = createMatcher(rejectedType);
|
|
137
|
+
return {
|
|
138
|
+
pending,
|
|
139
|
+
fulfilled,
|
|
140
|
+
rejected
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}
|
|
75
144
|
exports.EXTERNAL_ACTION_PREFIX = '[ext]';
|
|
76
145
|
const createExternalAction = createActionFactory(exports.EXTERNAL_ACTION_PREFIX);
|
|
77
146
|
exports.iconsLoaded = createExternalAction('icons-loaded');
|
|
@@ -98,8 +167,11 @@ sap.ui.define((function () { 'use strict';
|
|
|
98
167
|
exports.quickActionListChanged = createExternalAction('quick-action-list-changed');
|
|
99
168
|
exports.updateQuickAction = createExternalAction('update-quick-action');
|
|
100
169
|
exports.executeQuickAction = createExternalAction('execute-quick-action');
|
|
170
|
+
exports.executeContextMenuAction = createExternalAction('execute-context-menu-action');
|
|
101
171
|
exports.setApplicationRequiresReload = createExternalAction('set-application-requires-reload');
|
|
102
172
|
exports.externalFileChange = createExternalAction('external-file-change');
|
|
173
|
+
const createAsyncExternalAction = createAsyncActionFactory(exports.EXTERNAL_ACTION_PREFIX);
|
|
174
|
+
exports.requestControlContextMenu = createAsyncExternalAction('request-control-context-menu');
|
|
103
175
|
|
|
104
176
|
} (api));
|
|
105
177
|
|
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.17.
|
|
12
|
+
"version": "0.17.18",
|
|
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/logger": "0.6.0",
|
|
29
28
|
"@sap-ux/feature-toggle": "0.2.3",
|
|
29
|
+
"@sap-ux/logger": "0.6.0",
|
|
30
30
|
"@sap-ux/btp-utils": "1.0.0",
|
|
31
31
|
"@sap-ux/adp-tooling": "0.12.122",
|
|
32
|
-
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.
|
|
32
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.35",
|
|
33
33
|
"@sap-ux/project-access": "1.29.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"supertest": "6.3.3",
|
|
49
49
|
"@sap-ux-private/playwright": "0.1.0",
|
|
50
50
|
"dotenv": "16.3.1",
|
|
51
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.
|
|
51
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.58",
|
|
52
52
|
"@sap-ux/axios-extension": "1.18.4",
|
|
53
53
|
"@sap-ux/store": "1.0.0",
|
|
54
54
|
"@sap-ux/ui5-info": "0.8.3",
|