@sap-ux/preview-middleware 0.11.6 → 0.11.8

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/base/flp.js CHANGED
@@ -165,11 +165,15 @@ class FlpSandbox {
165
165
  previewUrl = `${previewUrl}.inner.html`;
166
166
  (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/cpe/init');
167
167
  this.router.get(editor.path, (_req, res) => {
168
- var _a, _b;
168
+ var _a, _b, _c;
169
+ let templatePreviewUrl = `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.config.intent.object}-${this.config.intent.action}`;
170
+ if (((_a = rta.options) === null || _a === void 0 ? void 0 : _a.scenario) === 'ADAPTATION_PROJECT') {
171
+ templatePreviewUrl = templatePreviewUrl.replace('?', `?sap-ui-layer=${rta.layer}&`);
172
+ }
169
173
  const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/editor.html'), 'utf-8');
170
174
  const html = (0, ejs_1.render)(template, {
171
- previewUrl: `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.config.intent.object}-${this.config.intent.action}`,
172
- telemetry: (_b = (_a = rta.options) === null || _a === void 0 ? void 0 : _a.telemetry) !== null && _b !== void 0 ? _b : false
175
+ previewUrl: templatePreviewUrl,
176
+ telemetry: (_c = (_b = rta.options) === null || _b === void 0 ? void 0 : _b.telemetry) !== null && _c !== void 0 ? _c : false
173
177
  });
174
178
  res.status(200).contentType('html').send(html);
175
179
  });
@@ -4,23 +4,27 @@ sap.ui.define([
4
4
  '../cpe/init',
5
5
  './init-dialogs',
6
6
  'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
7
- './extension-point'
8
- ], function (log, __init, ___init_dialogs, ___sap_ux_private_control_property_editor_common, __ExtensionPointService) {
7
+ './extension-point',
8
+ 'sap/ui/VersionInfo',
9
+ './ui5-version-utils'
10
+ ], function (log, __init, ___init_dialogs, ___sap_ux_private_control_property_editor_common, __ExtensionPointService, VersionInfo, ___ui5_version_utils) {
9
11
  'use strict';
10
12
  function _interopRequireDefault(obj) {
11
13
  return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
12
14
  }
13
15
  const init = _interopRequireDefault(__init);
14
16
  const initDialogs = ___init_dialogs['initDialogs'];
17
+ const showMessage = ___sap_ux_private_control_property_editor_common['showMessage'];
15
18
  const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
16
19
  const ExtensionPointService = _interopRequireDefault(__ExtensionPointService);
17
- var __exports = function (rta) {
20
+ const getUI5VersionValidationMessage = ___ui5_version_utils['getUI5VersionValidationMessage'];
21
+ var __exports = async function (rta) {
18
22
  const extPointService = new ExtensionPointService(rta);
19
23
  const actionHandlers = [];
20
24
  function subscribe(handler) {
21
25
  actionHandlers.push(handler);
22
26
  }
23
- startPostMessageCommunication(window.parent, async function onAction(action) {
27
+ const {sendAction} = startPostMessageCommunication(window.parent, async function onAction(action) {
24
28
  for (const handler of actionHandlers) {
25
29
  try {
26
30
  await handler(action);
@@ -32,6 +36,11 @@ sap.ui.define([
32
36
  initDialogs(rta);
33
37
  extPointService.init(subscribe);
34
38
  init(rta);
39
+ const ui5Version = await VersionInfo.load();
40
+ const ui5VersionValidationMsg = getUI5VersionValidationMessage(ui5Version.version);
41
+ if (ui5VersionValidationMsg) {
42
+ sendAction(showMessage(ui5VersionValidationMsg));
43
+ }
35
44
  log.debug('ADP init executed.');
36
45
  };
37
46
  return __exports;
@@ -3,11 +3,17 @@ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
3
3
 
4
4
  import init from '../cpe/init';
5
5
  import { initDialogs } from './init-dialogs';
6
- import { ExternalAction, startPostMessageCommunication } from '@sap-ux-private/control-property-editor-common';
6
+ import {
7
+ ExternalAction,
8
+ showMessage,
9
+ startPostMessageCommunication
10
+ } from '@sap-ux-private/control-property-editor-common';
7
11
  import { ActionHandler } from '../cpe/types';
8
12
  import ExtensionPointService from './extension-point';
13
+ import VersionInfo from 'sap/ui/VersionInfo';
14
+ import { getUI5VersionValidationMessage } from './ui5-version-utils';
9
15
 
10
- export default function (rta: RuntimeAuthoring) {
16
+ export default async function (rta: RuntimeAuthoring) {
11
17
  const extPointService = new ExtensionPointService(rta);
12
18
  const actionHandlers: ActionHandler[] = [];
13
19
  /**
@@ -18,20 +24,31 @@ export default function (rta: RuntimeAuthoring) {
18
24
  actionHandlers.push(handler);
19
25
  }
20
26
 
21
- startPostMessageCommunication<ExternalAction>(window.parent, async function onAction(action) {
22
- for (const handler of actionHandlers) {
23
- try {
24
- await handler(action);
25
- } catch (error) {
26
- log.error('Handler Failed: ', error);
27
+ const { sendAction } = startPostMessageCommunication<ExternalAction>(
28
+ window.parent,
29
+ async function onAction(action) {
30
+ for (const handler of actionHandlers) {
31
+ try {
32
+ await handler(action);
33
+ } catch (error) {
34
+ log.error('Handler Failed: ', error);
35
+ }
27
36
  }
28
37
  }
29
- });
38
+ );
39
+
30
40
  // initialize fragment content menu entry
31
41
  initDialogs(rta);
32
42
  // initialize extension point service
33
43
  extPointService.init(subscribe);
34
44
  // also initialize the editor
35
45
  init(rta);
46
+
47
+ const ui5Version = (await VersionInfo.load()) as { version: string };
48
+ const ui5VersionValidationMsg = getUI5VersionValidationMessage(ui5Version.version);
49
+
50
+ if (ui5VersionValidationMsg) {
51
+ sendAction(showMessage(ui5VersionValidationMsg));
52
+ }
36
53
  log.debug('ADP init executed.');
37
54
  }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Checks if the given version is lower than the required minimal version.
8
+ * @param version to check
9
+ * @param minVersion to check
10
+ *
11
+ * @returns boolean
12
+ */
13
+ function isLowerThanMinimalUi5Version(version, minVersion) {
14
+ if (version && minVersion) {
15
+ const minVersionParsed = parseUI5Version(minVersion);
16
+ const ui5VersionParsed = parseUI5Version(version);
17
+ if (!isNaN(ui5VersionParsed.major) && !isNaN(ui5VersionParsed.minor)) {
18
+ if (ui5VersionParsed.major < minVersionParsed.major) {
19
+ return true;
20
+ }
21
+ if (ui5VersionParsed.major === minVersionParsed.major && ui5VersionParsed.minor < minVersionParsed.minor) {
22
+ return true;
23
+ }
24
+ }
25
+ }
26
+ return false;
27
+ }
28
+
29
+ /**
30
+ * Get UI5 version validation message based on conditions.
31
+ * @param ui5Version to validate
32
+ * @returns string with validation message or undefined if non condition is met.
33
+ */
34
+ function getUI5VersionValidationMessage(ui5Version) {
35
+ if (isLowerThanMinimalUi5Version(ui5Version, '1.71')) {
36
+ return `The current SAPUI5 version set for this Adaptation project is ${ui5Version}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is 1.71`;
37
+ }
38
+ return undefined;
39
+ }
40
+
41
+ /**
42
+ * Parses the UI5 version
43
+ * Returns NaN for snapshot or snapshot-untested
44
+ * Returns x.xx for snapshot-x.xx
45
+ *
46
+ * @param version the UI5 version to parse
47
+ * @returns The major and the minor version, e.g. 1.86
48
+ */
49
+ function parseUI5Version(version) {
50
+ const versionParts = version.replace(/snapshot-untested|snapshot-|snapshot/, '').split('.');
51
+ const major = parseInt(versionParts[0], 10);
52
+ const minor = parseInt(versionParts[1], 10);
53
+ return {
54
+ major,
55
+ minor
56
+ };
57
+ }
58
+ var __exports = {
59
+ __esModule: true
60
+ };
61
+ __exports.isLowerThanMinimalUi5Version = isLowerThanMinimalUi5Version;
62
+ __exports.getUI5VersionValidationMessage = getUI5VersionValidationMessage;
63
+ return __exports;
64
+ });
65
+ //# sourceMappingURL=ui5-version-utils.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Checks if the given version is lower than the required minimal version.
3
+ * @param version to check
4
+ * @param minVersion to check
5
+ *
6
+ * @returns boolean
7
+ */
8
+ export function isLowerThanMinimalUi5Version(version: string, minVersion: string): boolean {
9
+ if (version && minVersion) {
10
+ const minVersionParsed = parseUI5Version(minVersion);
11
+ const ui5VersionParsed = parseUI5Version(version);
12
+ if (!isNaN(ui5VersionParsed.major) && !isNaN(ui5VersionParsed.minor)) {
13
+ if (ui5VersionParsed.major < minVersionParsed.major) {
14
+ return true;
15
+ }
16
+ if (ui5VersionParsed.major === minVersionParsed.major && ui5VersionParsed.minor < minVersionParsed.minor) {
17
+ return true;
18
+ }
19
+ }
20
+ }
21
+ return false;
22
+ }
23
+
24
+ /**
25
+ * Get UI5 version validation message based on conditions.
26
+ * @param ui5Version to validate
27
+ * @returns string with validation message or undefined if non condition is met.
28
+ */
29
+ export function getUI5VersionValidationMessage(ui5Version: string): string | undefined {
30
+ if (isLowerThanMinimalUi5Version(ui5Version, '1.71')) {
31
+ return `The current SAPUI5 version set for this Adaptation project is ${ui5Version}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is 1.71`;
32
+ }
33
+
34
+ return undefined;
35
+ }
36
+
37
+ /**
38
+ * Parses the UI5 version
39
+ * Returns NaN for snapshot or snapshot-untested
40
+ * Returns x.xx for snapshot-x.xx
41
+ *
42
+ * @param version the UI5 version to parse
43
+ * @returns The major and the minor version, e.g. 1.86
44
+ */
45
+ function parseUI5Version(version: string): { major: number; minor: number } {
46
+ const versionParts = version.replace(/snapshot-untested|snapshot-|snapshot/, '').split('.');
47
+ const major = parseInt(versionParts[0], 10);
48
+ const minor = parseInt(versionParts[1], 10);
49
+
50
+ return { major, minor };
51
+ }
@@ -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.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.scenarioLoaded = 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.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.scenarioLoaded = 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';
@@ -72,6 +72,7 @@ sap.ui.define((function () { 'use strict';
72
72
  exports.propertyChanged = createExternalAction('property-changed');
73
73
  exports.propertyChangeFailed = createExternalAction('change-property-failed');
74
74
  exports.changeStackModified = createExternalAction('change-stack-modified');
75
+ exports.showMessage = createExternalAction('show-dialog-message');
75
76
 
76
77
  } (api));
77
78
 
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.11.6",
12
+ "version": "0.11.8",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "dependencies": {
25
25
  "ejs": "3.1.9",
26
26
  "@sap-ux/logger": "0.4.0",
27
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.4",
28
- "@sap-ux/adp-tooling": "0.7.1"
27
+ "@sap-ux/adp-tooling": "0.7.1",
28
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/ejs": "3.1.2",
@@ -36,9 +36,9 @@
36
36
  "npm-run-all": "4.1.5",
37
37
  "nock": "13.2.1",
38
38
  "supertest": "6.3.3",
39
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.8.3",
40
- "@sap-ux/project-access": "1.15.5",
41
- "@sap-ux/store": "0.4.0"
39
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.8.4",
40
+ "@sap-ux/store": "0.4.0",
41
+ "@sap-ux/project-access": "1.16.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "express": "4"