@sap-ux/preview-middleware 0.13.47 → 0.13.49

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.
@@ -112,6 +112,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "../api-hand
112
112
  * @param key Selected extension point key
113
113
  * @param list All of the extension points that are under a view
114
114
  * @param enabled Enables the select control
115
+ * @param hasDefaultContent Whether there is default content associated with the extension name
115
116
  */
116
117
  updateModel: function _updateModel(name, key, list, enabled, hasDefaultContent) {
117
118
  this.model.setProperty('/extensionPointName', name);
@@ -144,6 +144,7 @@ export default class ExtensionPoint extends BaseDialog {
144
144
  * @param key Selected extension point key
145
145
  * @param list All of the extension points that are under a view
146
146
  * @param enabled Enables the select control
147
+ * @param hasDefaultContent Whether there is default content associated with the extension name
147
148
  */
148
149
  private updateModel(
149
150
  name: string,
@@ -59,7 +59,9 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
59
59
  * @returns {boolean} True if the fragment command is enabled, false otherwise.
60
60
  */
61
61
  const isFragmentCommandEnabled = overlays => {
62
- if (overlays.length === 0) return false;
62
+ if (overlays.length === 0) {
63
+ return false;
64
+ }
63
65
  const control = overlays[0].getElement();
64
66
  const hasStableId = FlUtils.checkControlId(control);
65
67
  return hasStableId && overlays.length <= 1;
@@ -74,7 +74,7 @@ export const isControllerExtensionEnabled = (overlays: ElementOverlay[], syncVie
74
74
  * @returns {boolean} True if the fragment command is enabled, false otherwise.
75
75
  */
76
76
  export const isFragmentCommandEnabled = (overlays: ElementOverlay[]): boolean => {
77
- if (overlays.length === 0) return false;
77
+ if (overlays.length === 0) {return false;}
78
78
 
79
79
  const control = overlays[0].getElement();
80
80
  const hasStableId = FlUtils.checkControlId(control);
@@ -2,8 +2,9 @@
2
2
  sap.ui.define([
3
3
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
4
4
  './flex-change',
5
- 'sap/base/Log'
6
- ], function (___sap_ux_private_control_property_editor_common, ___flex_change, Log) {
5
+ 'sap/base/Log',
6
+ '../rta-service'
7
+ ], function (___sap_ux_private_control_property_editor_common, ___flex_change, Log, ___rta_service) {
7
8
  'use strict';
8
9
  const changeProperty = ___sap_ux_private_control_property_editor_common['changeProperty'];
9
10
  const changeStackModified = ___sap_ux_private_control_property_editor_common['changeStackModified'];
@@ -12,6 +13,7 @@ sap.ui.define([
12
13
  const FlexChangesEndPoints = ___sap_ux_private_control_property_editor_common['FlexChangesEndPoints'];
13
14
  const reloadApplication = ___sap_ux_private_control_property_editor_common['reloadApplication'];
14
15
  const applyChange = ___flex_change['applyChange'];
16
+ const modeAndStackChangeHandler = ___rta_service['modeAndStackChangeHandler'];
15
17
  function assertProperties(properties, target) {
16
18
  for (const property of properties) {
17
19
  const value = target[property];
@@ -137,6 +139,7 @@ sap.ui.define([
137
139
  this.updateStack();
138
140
  }
139
141
  createOnStackChangeHandler() {
142
+ const handleStackChange = modeAndStackChangeHandler(this.sendAction, this.options.rta);
140
143
  return async () => {
141
144
  const stack = this.options.rta.getCommandStack();
142
145
  const allCommands = stack.getCommands();
@@ -168,6 +171,7 @@ sap.ui.define([
168
171
  await this.fetchSavedChanges();
169
172
  }
170
173
  this.updateStack(activeChanges);
174
+ handleStackChange();
171
175
  };
172
176
  }
173
177
  prepareChangeType(command, inactiveCommandCount, index) {
@@ -19,6 +19,7 @@ import type { ActionSenderFunction, SubscribeFunction, UI5AdaptationOptions } fr
19
19
  import type Event from 'sap/ui/base/Event';
20
20
  import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
21
21
  import Log from 'sap/base/Log';
22
+ import { modeAndStackChangeHandler } from '../rta-service';
22
23
 
23
24
  interface ChangeContent {
24
25
  property: string;
@@ -248,6 +249,7 @@ export class ChangeService {
248
249
  * @returns (event: sap.ui.base.Event) => Promise<void>
249
250
  */
250
251
  private createOnStackChangeHandler(): (event: Event) => Promise<void> {
252
+ const handleStackChange = modeAndStackChangeHandler(this.sendAction, this.options.rta);
251
253
  return async (): Promise<void> => {
252
254
  const stack = this.options.rta.getCommandStack();
253
255
  const allCommands = stack.getCommands();
@@ -282,6 +284,7 @@ export class ChangeService {
282
284
  }
283
285
 
284
286
  this.updateStack(activeChanges);
287
+ handleStackChange();
285
288
  };
286
289
  }
287
290
 
@@ -8,12 +8,14 @@ sap.ui.define([
8
8
  'sap/base/Log',
9
9
  './logger',
10
10
  './ui5-utils',
11
- './connector-service'
12
- ], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils, ___connector_service) {
11
+ './connector-service',
12
+ './rta-service'
13
+ ], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils, ___connector_service, ___rta_service) {
13
14
  'use strict';
14
15
  const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
15
16
  const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
16
17
  const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
18
+ const appLoaded = ___sap_ux_private_control_property_editor_common['appLoaded'];
17
19
  const initOutline = ___outline_index['initOutline'];
18
20
  const SelectionService = ___selection['SelectionService'];
19
21
  const ChangeService = ___changes_service['ChangeService'];
@@ -21,6 +23,7 @@ sap.ui.define([
21
23
  const logger = ___logger['logger'];
22
24
  const getIcons = ___ui5_utils['getIcons'];
23
25
  const WorkspaceConnectorService = ___connector_service['WorkspaceConnectorService'];
26
+ const RtaService = ___rta_service['RtaService'];
24
27
  function init(rta) {
25
28
  Log.info('Initializing Control Property Editor');
26
29
  const flexSettings = rta.getFlexSettings();
@@ -34,10 +37,12 @@ sap.ui.define([
34
37
  const selectionService = new SelectionService(rta);
35
38
  const changesService = new ChangeService({ rta }, selectionService);
36
39
  const connectorService = new WorkspaceConnectorService();
40
+ const rtaService = new RtaService(rta);
37
41
  const services = [
38
42
  selectionService,
39
43
  changesService,
40
- connectorService
44
+ connectorService,
45
+ rtaService
41
46
  ];
42
47
  try {
43
48
  loadDefaultLibraries();
@@ -56,6 +61,7 @@ sap.ui.define([
56
61
  initOutline(rta, sendAction).catch(error => Log.error('Error during initialization of Control Property Editor', error));
57
62
  const icons = getIcons();
58
63
  sendAction(iconsLoaded(icons));
64
+ sendAction(appLoaded());
59
65
  } catch (error) {
60
66
  Log.error('Error during initialization of Control Property Editor', error);
61
67
  }
@@ -2,7 +2,8 @@ import type { ExternalAction } from '@sap-ux-private/control-property-editor-com
2
2
  import {
3
3
  startPostMessageCommunication,
4
4
  iconsLoaded,
5
- enableTelemetry
5
+ enableTelemetry,
6
+ appLoaded
6
7
  } from '@sap-ux-private/control-property-editor-common';
7
8
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
8
9
 
@@ -15,6 +16,7 @@ import Log from 'sap/base/Log';
15
16
  import { logger } from './logger';
16
17
  import { getIcons } from './ui5-utils';
17
18
  import { WorkspaceConnectorService } from './connector-service';
19
+ import { RtaService } from './rta-service';
18
20
 
19
21
  export default function init(rta: RuntimeAuthoring): Promise<void> {
20
22
  Log.info('Initializing Control Property Editor');
@@ -38,8 +40,8 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
38
40
 
39
41
  const changesService = new ChangeService({ rta }, selectionService);
40
42
  const connectorService = new WorkspaceConnectorService();
41
-
42
- const services: Service[] = [selectionService, changesService, connectorService];
43
+ const rtaService = new RtaService(rta);
44
+ const services: Service[] = [selectionService, changesService, connectorService, rtaService];
43
45
  try {
44
46
  loadDefaultLibraries();
45
47
  const { sendAction } = startPostMessageCommunication<ExternalAction>(
@@ -67,6 +69,7 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
67
69
  const icons = getIcons();
68
70
 
69
71
  sendAction(iconsLoaded(icons));
72
+ sendAction(appLoaded());
70
73
  } catch (error) {
71
74
  Log.error('Error during initialization of Control Property Editor', error);
72
75
  }
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+ sap.ui.define(['open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common'], function (___sap_ux_private_control_property_editor_common) {
3
+ 'use strict';
4
+ const setAppMode = ___sap_ux_private_control_property_editor_common['setAppMode'];
5
+ const setUndoRedoEnablement = ___sap_ux_private_control_property_editor_common['setUndoRedoEnablement'];
6
+ const setSaveEnablement = ___sap_ux_private_control_property_editor_common['setSaveEnablement'];
7
+ const undo = ___sap_ux_private_control_property_editor_common['undo'];
8
+ const redo = ___sap_ux_private_control_property_editor_common['redo'];
9
+ const save = ___sap_ux_private_control_property_editor_common['save'];
10
+ class RtaService {
11
+ constructor(rta) {
12
+ this.rta = rta;
13
+ }
14
+ init(sendAction, subscribe) {
15
+ subscribe(async action => {
16
+ if (setAppMode.match(action)) {
17
+ this.rta.setMode(action.payload);
18
+ }
19
+ if (undo.match(action)) {
20
+ this.rta.undo();
21
+ }
22
+ if (redo.match(action)) {
23
+ this.rta.redo();
24
+ }
25
+ if (save.match(action)) {
26
+ if (this.rta.save) {
27
+ this.rta.save();
28
+ } else {
29
+ this.rta?._serializeToLrep();
30
+ }
31
+ }
32
+ return Promise.resolve();
33
+ });
34
+ this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
35
+ }
36
+ }
37
+ function modeAndStackChangeHandler(sendAction, rta) {
38
+ return () => {
39
+ const canUndo = rta.canUndo();
40
+ const canRedo = rta.canRedo();
41
+ const saveAllowed = rta?.canSave ? rta?.canSave() : canUndo;
42
+ sendAction(setUndoRedoEnablement({
43
+ canUndo,
44
+ canRedo
45
+ }));
46
+ sendAction(setSaveEnablement(saveAllowed));
47
+ };
48
+ }
49
+ var __exports = { __esModule: true };
50
+ __exports.RtaService = RtaService;
51
+ __exports.modeAndStackChangeHandler = modeAndStackChangeHandler;
52
+ return __exports;
53
+ });
@@ -0,0 +1,63 @@
1
+ import {
2
+ setAppMode,
3
+ setUndoRedoEnablement,
4
+ setSaveEnablement,
5
+ undo,
6
+ redo,
7
+ save,
8
+ ExternalAction
9
+ } from '@sap-ux-private/control-property-editor-common';
10
+ import { ActionSenderFunction, SubscribeFunction } from './types';
11
+ import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
12
+ /**
13
+ * A Class of RtaService
14
+ */
15
+ export class RtaService {
16
+ /**
17
+ *
18
+ * @param options ui5 adaptation options.
19
+ */
20
+ constructor(private readonly rta: RuntimeAuthoring) {}
21
+
22
+ /**
23
+ * Initializes rta service.
24
+ *
25
+ * @param sendAction action sender function
26
+ * @param subscribe subscriber function
27
+ */
28
+ public init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void {
29
+ subscribe(async (action): Promise<void> => {
30
+ if (setAppMode.match(action)) {
31
+ this.rta.setMode(action.payload);
32
+ }
33
+ if (undo.match(action)) {
34
+ this.rta.undo();
35
+ }
36
+ if (redo.match(action)) {
37
+ this.rta.redo();
38
+ }
39
+
40
+ if (save.match(action)) {
41
+ if (this.rta.save) {
42
+ // v1.107.x and above
43
+ this.rta.save();
44
+ } else {
45
+ // v1.71.x and above
46
+ this.rta?._serializeToLrep();
47
+ }
48
+ }
49
+ return Promise.resolve();
50
+ });
51
+ this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
52
+ }
53
+ }
54
+
55
+ export function modeAndStackChangeHandler(sendAction: (action: ExternalAction) => void, rta: RuntimeAuthoring) {
56
+ return () => {
57
+ const canUndo = rta.canUndo();
58
+ const canRedo = rta.canRedo();
59
+ const saveAllowed = rta?.canSave ? rta?.canSave() : canUndo; /* canSave v1.112.x and above only*/
60
+ sendAction(setUndoRedoEnablement({ canUndo, canRedo }));
61
+ sendAction(setSaveEnablement(saveAllowed));
62
+ };
63
+ }
@@ -8,7 +8,7 @@ sap.ui.define((function () { 'use strict';
8
8
 
9
9
  (function (exports) {
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- 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.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.save = exports.redo = exports.undo = exports.appLoaded = exports.setSaveEnablement = exports.setUndoRedoEnablement = 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.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
12
  exports.BOOLEAN_VALUE_TYPE = 'boolean';
13
13
  exports.INTEGER_VALUE_TYPE = 'integer';
14
14
  exports.FLOAT_VALUE_TYPE = 'float';
@@ -74,6 +74,13 @@ sap.ui.define((function () { 'use strict';
74
74
  exports.showMessage = createExternalAction('show-dialog-message');
75
75
  exports.reloadApplication = createExternalAction('reload-application');
76
76
  exports.storageFileChanged = createExternalAction('storage-file-changed');
77
+ exports.setAppMode = createExternalAction('set-app-mode');
78
+ exports.setUndoRedoEnablement = createExternalAction('set-undo-redo-enablement');
79
+ exports.setSaveEnablement = createExternalAction('set-save-enablement');
80
+ exports.appLoaded = createExternalAction('app-loaded');
81
+ exports.undo = createExternalAction('undo');
82
+ exports.redo = createExternalAction('redo');
83
+ exports.save = createExternalAction('save');
77
84
 
78
85
  } (api));
79
86
 
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.13.47",
12
+ "version": "0.13.49",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -27,8 +27,8 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/logger": "0.5.1",
29
29
  "@sap-ux/btp-utils": "0.14.4",
30
- "@sap-ux/adp-tooling": "0.10.10",
31
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.22",
30
+ "@sap-ux/adp-tooling": "0.10.11",
31
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.23",
32
32
  "@sap-ux/project-access": "1.20.1"
33
33
  },
34
34
  "devDependencies": {
@@ -45,8 +45,8 @@
45
45
  "supertest": "6.3.3",
46
46
  "@sap-ux-private/playwright": "0.0.3",
47
47
  "dotenv": "16.3.1",
48
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.13",
49
- "@sap-ux/axios-extension": "1.12.4",
48
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.9.14",
49
+ "@sap-ux/axios-extension": "1.12.5",
50
50
  "@sap-ux/store": "0.5.0",
51
51
  "@sap-ux/ui5-info": "0.5.0",
52
52
  "@sap-ux/i18n": "0.0.6"
@@ -65,13 +65,18 @@
65
65
  (() => sap.ui.require(['open/ux/preview/client/flp/initConnectors']))()
66
66
  </script>
67
67
 
68
- <% if (locals.flex && flex?.scenario === 'ADAPTATION_PROJECT') { %>
69
- <!-- Temporary fix until RTA provides api for enable/disable buttons in main RTA navigation menu -->
68
+ <% if (locals.flex && ['ADAPTATION_PROJECT', 'FE_FROM_SCRATCH'].includes(flex?.scenario)) { %>
69
+ <!-- Hides Rta native toolbar -->
70
70
  <style>
71
- .sapUiRtaToolbarActionsSection button[aria-label="Exit"],
72
- .sapUiRtaToolbarActionsSection button[id$="fragment--sapUiRta_feedback"],
73
- .sapUiRtaToolbarActionsSection button[id$="fragment--sapUiRta_actionsToolbar-overflowButton"] {
74
- display:none;
71
+ #shell-header, .sapUiRtaToolbar {
72
+ visibility: hidden;
73
+ height: 1px;
74
+ }
75
+ .sapUshellShellCanvas {
76
+ top: 0 !important;
77
+ }
78
+ .sapUiRtaMode .sapUiShellBackgroundImage.sapUiGlobalBackgroundImageForce.sapUshellShellBG {
79
+ background-color: transparent !important;
75
80
  }
76
81
  </style><% } %>
77
82
  </head>