@sap-ux/preview-middleware 0.16.50 → 0.16.52
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/api-handler.js +2 -2
- package/dist/client/adp/api-handler.ts +1 -1
- package/dist/client/adp/command-executor.js +2 -2
- package/dist/client/adp/command-executor.ts +1 -1
- package/dist/client/adp/controllers/BaseDialog.controller.js +2 -2
- package/dist/client/adp/controllers/BaseDialog.controller.ts +1 -1
- package/dist/client/adp/init-dialogs.js +10 -10
- package/dist/client/adp/init-dialogs.ts +11 -10
- package/dist/client/adp/init.js +19 -16
- package/dist/client/adp/init.ts +16 -16
- package/dist/client/cpe/changes/service.js +3 -3
- package/dist/client/cpe/changes/service.ts +1 -1
- package/dist/client/cpe/connector-service.js +8 -7
- package/dist/client/cpe/connector-service.ts +5 -8
- package/dist/client/cpe/init.js +3 -3
- package/dist/client/cpe/init.ts +1 -1
- package/dist/client/cpe/outline/index.js +3 -3
- package/dist/client/cpe/outline/index.ts +3 -3
- package/dist/client/cpe/outline/nodes.js +5 -7
- package/dist/client/cpe/outline/nodes.ts +6 -8
- package/dist/client/cpe/outline/utils.js +8 -4
- package/dist/client/cpe/outline/utils.ts +5 -4
- package/dist/client/cpe/selection.js +3 -3
- package/dist/client/cpe/selection.ts +1 -1
- package/dist/client/flp/WorkspaceConnector.js +5 -3
- package/dist/client/flp/WorkspaceConnector.ts +5 -4
- package/dist/client/flp/bootstrap.js +3 -4
- package/dist/client/flp/init.js +12 -10
- package/dist/client/flp/init.ts +8 -9
- package/dist/client/flp/initConnectors.js +7 -8
- package/dist/client/flp/initConnectors.ts +2 -8
- package/dist/client/{cpe/error-utils.js → utils/error.js} +1 -1
- package/dist/client/utils/version.js +46 -1
- package/dist/client/utils/version.ts +63 -3
- package/package.json +4 -4
- package/dist/client/adp/ui5-version-utils.js +0 -65
- package/dist/client/adp/ui5-version-utils.ts +0 -52
- /package/dist/client/{cpe/error-utils.ts → utils/error.ts} +0 -0
|
@@ -5,6 +5,7 @@ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
|
5
5
|
import { getComponent } from '../ui5-utils';
|
|
6
6
|
import Component from 'sap/ui/core/Component';
|
|
7
7
|
import { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
|
|
8
|
+
import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../../utils/version';
|
|
8
9
|
|
|
9
10
|
export const isEditable = (id = ''): boolean => {
|
|
10
11
|
let editable = false;
|
|
@@ -34,11 +35,11 @@ export const isEditable = (id = ''): boolean => {
|
|
|
34
35
|
* Function that checks if control is reuse component
|
|
35
36
|
*
|
|
36
37
|
* @param controlId id control
|
|
37
|
-
* @param
|
|
38
|
+
* @param ui5VersionInfo UI5 version information
|
|
38
39
|
* @returns boolean if control is from reused component view
|
|
39
40
|
*/
|
|
40
|
-
export const isReuseComponent = (controlId: string,
|
|
41
|
-
if(
|
|
41
|
+
export const isReuseComponent = (controlId: string, ui5VersionInfo: Ui5VersionInfo): boolean => {
|
|
42
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 115 })) {
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -48,7 +49,7 @@ export const isReuseComponent = (controlId: string, minorUI5Version: number): bo
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const manifest = component.getManifest() as Manifest;
|
|
51
|
-
if(!manifest) {
|
|
52
|
+
if (!manifest) {
|
|
52
53
|
return false;
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -8,8 +8,8 @@ sap.ui.define([
|
|
|
8
8
|
'sap/ui/dt/OverlayRegistry',
|
|
9
9
|
'sap/ui/dt/OverlayUtil',
|
|
10
10
|
'./ui5-utils',
|
|
11
|
-
'
|
|
12
|
-
], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, ___documentation, OverlayRegistry, OverlayUtil, ___ui5_utils,
|
|
11
|
+
'../utils/error'
|
|
12
|
+
], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, ___documentation, OverlayRegistry, OverlayUtil, ___ui5_utils, ___utils_error) {
|
|
13
13
|
'use strict';
|
|
14
14
|
const controlSelected = ___sap_ux_private_control_property_editor_common['controlSelected'];
|
|
15
15
|
const propertyChanged = ___sap_ux_private_control_property_editor_common['propertyChanged'];
|
|
@@ -19,7 +19,7 @@ sap.ui.define([
|
|
|
19
19
|
const getRuntimeControl = ___utils['getRuntimeControl'];
|
|
20
20
|
const getDocumentation = ___documentation['getDocumentation'];
|
|
21
21
|
const getComponent = ___ui5_utils['getComponent'];
|
|
22
|
-
const getError =
|
|
22
|
+
const getError = ___utils_error['getError'];
|
|
23
23
|
function propertyChangeId(controlId, propertyName) {
|
|
24
24
|
return [
|
|
25
25
|
controlId,
|
|
@@ -20,7 +20,7 @@ import { getDocumentation } from './documentation';
|
|
|
20
20
|
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
21
21
|
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
|
|
22
22
|
import { getComponent } from './ui5-utils';
|
|
23
|
-
import { getError } from '
|
|
23
|
+
import { getError } from '../utils/error';
|
|
24
24
|
|
|
25
25
|
export interface PropertyChangeParams {
|
|
26
26
|
name: string;
|
|
@@ -6,6 +6,7 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
|
|
|
6
6
|
const CHANGES_API_PATH = ___common["CHANGES_API_PATH"];
|
|
7
7
|
const getFlexSettings = ___common["getFlexSettings"];
|
|
8
8
|
const getUi5Version = ___utils_version["getUi5Version"];
|
|
9
|
+
const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
|
|
9
10
|
const connector = merge({}, ObjectStorageConnector, {
|
|
10
11
|
layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
|
|
11
12
|
storage: {
|
|
@@ -69,9 +70,10 @@ sap.ui.define(["sap/base/util/merge", "sap/ui/fl/write/api/connectors/ObjectStor
|
|
|
69
70
|
},
|
|
70
71
|
loadFeatures: async function () {
|
|
71
72
|
const features = await ObjectStorageConnector.loadFeatures();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
features.isVariantAdaptationEnabled = !isLowerThanMinimalUi5Version(await getUi5Version(), {
|
|
74
|
+
major: 1,
|
|
75
|
+
minor: 90
|
|
76
|
+
});
|
|
75
77
|
const settings = getFlexSettings();
|
|
76
78
|
if (settings?.developerMode) {
|
|
77
79
|
features.isVariantAdaptationEnabled = false;
|
|
@@ -2,7 +2,7 @@ import merge from 'sap/base/util/merge';
|
|
|
2
2
|
import ObjectStorageConnector from 'sap/ui/fl/write/api/connectors/ObjectStorageConnector';
|
|
3
3
|
import Layer from 'sap/ui/fl/Layer';
|
|
4
4
|
import { CHANGES_API_PATH, FlexChange, getFlexSettings } from './common';
|
|
5
|
-
import { getUi5Version } from '../utils/version';
|
|
5
|
+
import { getUi5Version, isLowerThanMinimalUi5Version } from '../utils/version';
|
|
6
6
|
|
|
7
7
|
const connector = merge({}, ObjectStorageConnector, {
|
|
8
8
|
layers: [Layer.VENDOR, Layer.CUSTOMER_BASE],
|
|
@@ -68,9 +68,10 @@ const connector = merge({}, ObjectStorageConnector, {
|
|
|
68
68
|
} as typeof ObjectStorageConnector.storage,
|
|
69
69
|
loadFeatures: async function () {
|
|
70
70
|
const features = await ObjectStorageConnector.loadFeatures();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
features.isVariantAdaptationEnabled = !isLowerThanMinimalUi5Version(await getUi5Version(), {
|
|
72
|
+
major: 1,
|
|
73
|
+
minor: 90
|
|
74
|
+
});
|
|
74
75
|
const settings = getFlexSettings();
|
|
75
76
|
if (settings?.developerMode) {
|
|
76
77
|
features.isVariantAdaptationEnabled = false;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment,
|
|
2
2
|
@typescript-eslint/no-unsafe-member-access,
|
|
3
|
-
@typescript-eslint/no-unsafe-assignment,
|
|
4
3
|
@typescript-eslint/no-unsafe-argument,
|
|
5
4
|
no-console */
|
|
6
5
|
|
|
@@ -15,9 +14,9 @@ async function ushellBootstrap(fnCallback) {
|
|
|
15
14
|
try {
|
|
16
15
|
const response = await fetch(`${basePath}/resources/sap-ui-version.json`);
|
|
17
16
|
const json = await response.json();
|
|
18
|
-
const version = json?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version;
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
17
|
+
const version = json?.libraries?.find((lib) => lib.name === 'sap.ui.core')?.version ?? '1.121.0';
|
|
18
|
+
const majorUi5Version = parseInt(version.split('.')[0], 10);
|
|
19
|
+
if (majorUi5Version >= 2) {
|
|
21
20
|
src = `${basePath}/resources/sap/ushell/bootstrap/sandbox2.js`;
|
|
22
21
|
}
|
|
23
22
|
} catch (error) {
|
package/dist/client/flp/init.js
CHANGED
|
@@ -5,19 +5,20 @@ sap.ui.define([
|
|
|
5
5
|
'sap/ui/core/IconPool',
|
|
6
6
|
'sap/base/i18n/ResourceBundle',
|
|
7
7
|
'../adp/api-handler',
|
|
8
|
-
'../
|
|
8
|
+
'../utils/error',
|
|
9
9
|
'./initConnectors',
|
|
10
10
|
'../utils/version'
|
|
11
|
-
], function (Log, ___sap_ux_private_control_property_editor_common, IconPool, ResourceBundle, ___adp_api_handler,
|
|
11
|
+
], function (Log, ___sap_ux_private_control_property_editor_common, IconPool, ResourceBundle, ___adp_api_handler, ___utils_error, __initConnectors, ___utils_version) {
|
|
12
12
|
'use strict';
|
|
13
13
|
function _interopRequireDefault(obj) {
|
|
14
14
|
return obj && obj.__esModule && typeof obj.default !== 'undefined' ? obj.default : obj;
|
|
15
15
|
}
|
|
16
16
|
const SCENARIO = ___sap_ux_private_control_property_editor_common['SCENARIO'];
|
|
17
17
|
const getManifestAppdescr = ___adp_api_handler['getManifestAppdescr'];
|
|
18
|
-
const getError =
|
|
18
|
+
const getError = ___utils_error['getError'];
|
|
19
19
|
const initConnectors = _interopRequireDefault(__initConnectors);
|
|
20
20
|
const getUi5Version = ___utils_version['getUi5Version'];
|
|
21
|
+
const isLowerThanMinimalUi5Version = ___utils_version['isLowerThanMinimalUi5Version'];
|
|
21
22
|
const UI5_LIBS = [
|
|
22
23
|
'sap.apf',
|
|
23
24
|
'sap.base',
|
|
@@ -160,22 +161,24 @@ sap.ui.define([
|
|
|
160
161
|
const urlParams = new URLSearchParams(window.location.search);
|
|
161
162
|
const container = sap?.ushell?.Container ?? sap.ui.require('sap/ushell/Container');
|
|
162
163
|
let scenario = '';
|
|
163
|
-
const
|
|
164
|
+
const ui5VersionInfo = await getUi5Version();
|
|
164
165
|
if (flex) {
|
|
165
166
|
const flexSettings = JSON.parse(flex);
|
|
166
167
|
scenario = flexSettings.scenario;
|
|
167
168
|
container.attachRendererCreatedEvent(async function () {
|
|
168
169
|
const lifecycleService = await container.getServiceAsync('AppLifeCycle');
|
|
169
170
|
lifecycleService.attachAppLoaded(event => {
|
|
170
|
-
const minor = parseInt(version.split('.')[1], 10);
|
|
171
171
|
const view = event.getParameter('componentInstance');
|
|
172
172
|
const flexSettings = JSON.parse(flex);
|
|
173
173
|
const pluginScript = flexSettings.pluginScript ?? '';
|
|
174
174
|
let libs = [];
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
176
|
+
major: 1,
|
|
177
|
+
minor: 72
|
|
178
|
+
})) {
|
|
178
179
|
libs.push('open/ux/preview/client/flp/initRta');
|
|
180
|
+
} else {
|
|
181
|
+
libs.push('sap/ui/rta/api/startAdaptation');
|
|
179
182
|
}
|
|
180
183
|
if (flexSettings.pluginScript) {
|
|
181
184
|
libs.push(pluginScript);
|
|
@@ -205,8 +208,7 @@ sap.ui.define([
|
|
|
205
208
|
const resourceBundle = await loadI18nResourceBundle(scenario);
|
|
206
209
|
setI18nTitle(resourceBundle);
|
|
207
210
|
registerSAPFonts();
|
|
208
|
-
const
|
|
209
|
-
const renderer = major < 2 ? await container.createRenderer(undefined, true) : await container.createRendererInternal(undefined, true);
|
|
211
|
+
const renderer = ui5VersionInfo.major < 2 ? await container.createRenderer(undefined, true) : await container.createRendererInternal(undefined, true);
|
|
210
212
|
renderer.placeAt('content');
|
|
211
213
|
}
|
|
212
214
|
const bootstrapConfig = document.getElementById('sap-ui-bootstrap');
|
package/dist/client/flp/init.ts
CHANGED
|
@@ -7,9 +7,9 @@ import IconPool from 'sap/ui/core/IconPool';
|
|
|
7
7
|
import ResourceBundle from 'sap/base/i18n/ResourceBundle';
|
|
8
8
|
import AppState from 'sap/ushell/services/AppState';
|
|
9
9
|
import { getManifestAppdescr } from '../adp/api-handler';
|
|
10
|
-
import { getError } from '../
|
|
10
|
+
import { getError } from '../utils/error';
|
|
11
11
|
import initConnectors from './initConnectors';
|
|
12
|
-
import { getUi5Version } from '../utils/version';
|
|
12
|
+
import { getUi5Version, isLowerThanMinimalUi5Version } from '../utils/version';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
|
|
@@ -269,7 +269,7 @@ export async function init({
|
|
|
269
269
|
const urlParams = new URLSearchParams(window.location.search);
|
|
270
270
|
const container = sap?.ushell?.Container ?? sap.ui.require('sap/ushell/Container');
|
|
271
271
|
let scenario: string = '';
|
|
272
|
-
const
|
|
272
|
+
const ui5VersionInfo = await getUi5Version();
|
|
273
273
|
// Register RTA if configured
|
|
274
274
|
if (flex) {
|
|
275
275
|
const flexSettings = JSON.parse(flex) as FlexSettings;
|
|
@@ -277,16 +277,16 @@ export async function init({
|
|
|
277
277
|
container.attachRendererCreatedEvent(async function () {
|
|
278
278
|
const lifecycleService = await container.getServiceAsync<AppLifeCycle>('AppLifeCycle');
|
|
279
279
|
lifecycleService.attachAppLoaded((event) => {
|
|
280
|
-
const minor = parseInt(version.split('.')[1], 10);
|
|
281
280
|
const view = event.getParameter('componentInstance');
|
|
282
281
|
const flexSettings = JSON.parse(flex) as FlexSettings;
|
|
283
282
|
const pluginScript = flexSettings.pluginScript ?? '';
|
|
284
283
|
|
|
285
284
|
let libs: string[] = [];
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else {
|
|
285
|
+
|
|
286
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 72 })) {
|
|
289
287
|
libs.push('open/ux/preview/client/flp/initRta');
|
|
288
|
+
} else {
|
|
289
|
+
libs.push('sap/ui/rta/api/startAdaptation');
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
if (flexSettings.pluginScript) {
|
|
@@ -332,10 +332,9 @@ export async function init({
|
|
|
332
332
|
const resourceBundle = await loadI18nResourceBundle(scenario as Scenario);
|
|
333
333
|
setI18nTitle(resourceBundle);
|
|
334
334
|
registerSAPFonts();
|
|
335
|
-
const major = version ? parseInt(version.split('.')[0], 10) : 2;
|
|
336
335
|
|
|
337
336
|
const renderer =
|
|
338
|
-
major < 2
|
|
337
|
+
ui5VersionInfo.major < 2
|
|
339
338
|
? await container.createRenderer(undefined, true)
|
|
340
339
|
: await container.createRendererInternal(undefined, true);
|
|
341
340
|
renderer.placeAt('content');
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["
|
|
3
|
+
sap.ui.define(["../utils/version"], function (___utils_version) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
const getUi5Version = ___utils_version["getUi5Version"];
|
|
7
|
+
const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
|
|
6
8
|
/**
|
|
7
9
|
* Initializes UI5 connectors based on the current UI5 version.
|
|
8
10
|
*
|
|
@@ -14,13 +16,10 @@ sap.ui.define(["sap/ui/VersionInfo"], function (VersionInfo) {
|
|
|
14
16
|
* intiConnectors(); // Simply call the function without any arguments.
|
|
15
17
|
*/
|
|
16
18
|
async function initConnectors() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const minor = parseInt(versionArray[1], 10);
|
|
22
|
-
const major = parseInt(versionArray[0], 10);
|
|
23
|
-
if (major === 1 && minor < 72) {
|
|
19
|
+
if (isLowerThanMinimalUi5Version(await getUi5Version(), {
|
|
20
|
+
major: 1,
|
|
21
|
+
minor: 72
|
|
22
|
+
})) {
|
|
24
23
|
sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector) {
|
|
25
24
|
enableFakeConnector();
|
|
26
25
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {SingleVersionInfo} from '../../types/global';
|
|
1
|
+
import { getUi5Version, isLowerThanMinimalUi5Version } from '../utils/version';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Initializes UI5 connectors based on the current UI5 version.
|
|
@@ -12,12 +11,7 @@ import type {SingleVersionInfo} from '../../types/global';
|
|
|
12
11
|
* intiConnectors(); // Simply call the function without any arguments.
|
|
13
12
|
*/
|
|
14
13
|
export default async function initConnectors(): Promise<void> {
|
|
15
|
-
|
|
16
|
-
const versionArray = version ? version.split('.') : ['2', '99'];
|
|
17
|
-
const minor = parseInt(versionArray[1], 10);
|
|
18
|
-
const major = parseInt(versionArray[0], 10);
|
|
19
|
-
|
|
20
|
-
if (major === 1 && minor < 72) {
|
|
14
|
+
if (isLowerThanMinimalUi5Version(await getUi5Version(), { major: 1, minor: 72 })) {
|
|
21
15
|
sap.ui.require(['open/ux/preview/client/flp/enableFakeConnector'], function (enableFakeConnector: () => void) {
|
|
22
16
|
enableFakeConnector();
|
|
23
17
|
});
|
|
@@ -3,8 +3,18 @@
|
|
|
3
3
|
sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Default minimal supported UI5 version
|
|
8
|
+
*/
|
|
9
|
+
const minVersionInfo = {
|
|
10
|
+
major: 1,
|
|
11
|
+
minor: 71
|
|
12
|
+
};
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* Retrieve the UI5 version from sap.ui.core library
|
|
16
|
+
*
|
|
17
|
+
* @returns Ui5VersionInfo
|
|
8
18
|
*/
|
|
9
19
|
async function getUi5Version() {
|
|
10
20
|
let version = (await VersionInfo.load({
|
|
@@ -14,12 +24,47 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
|
|
|
14
24
|
Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
|
|
15
25
|
version = '1.121.0';
|
|
16
26
|
}
|
|
17
|
-
|
|
27
|
+
const [major, minor] = version.split('.').map(versionPart => parseInt(versionPart, 10));
|
|
28
|
+
return {
|
|
29
|
+
major: major,
|
|
30
|
+
minor: minor
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the given version is lower than the required minimal version.
|
|
36
|
+
* @param ui5VersionInfo to check
|
|
37
|
+
* @param minUi5VersionInfo to check against (default is 1.71)
|
|
38
|
+
*
|
|
39
|
+
* @returns boolean
|
|
40
|
+
*/
|
|
41
|
+
function isLowerThanMinimalUi5Version(ui5VersionInfo) {
|
|
42
|
+
let minUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
|
|
43
|
+
if (!isNaN(ui5VersionInfo.major) && !isNaN(ui5VersionInfo.minor)) {
|
|
44
|
+
if (ui5VersionInfo.major < minUi5VersionInfo.major) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Get UI5 version validation message.
|
|
56
|
+
* @param ui5VersionInfo to be mentioned in the message
|
|
57
|
+
* @returns string with validation message.
|
|
58
|
+
*/
|
|
59
|
+
function getUI5VersionValidationMessage(ui5VersionInfo) {
|
|
60
|
+
return `The current SAPUI5 version set for this Adaptation project is ${ui5VersionInfo.major}.${ui5VersionInfo.minor}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is ${minVersionInfo.major}.${minVersionInfo.minor}`;
|
|
18
61
|
}
|
|
19
62
|
var __exports = {
|
|
20
63
|
__esModule: true
|
|
21
64
|
};
|
|
22
65
|
__exports.getUi5Version = getUi5Version;
|
|
66
|
+
__exports.isLowerThanMinimalUi5Version = isLowerThanMinimalUi5Version;
|
|
67
|
+
__exports.getUI5VersionValidationMessage = getUI5VersionValidationMessage;
|
|
23
68
|
return __exports;
|
|
24
69
|
});
|
|
25
70
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,15 +1,75 @@
|
|
|
1
|
-
import type { SingleVersionInfo } from '../../types/global';
|
|
2
1
|
import VersionInfo from 'sap/ui/VersionInfo';
|
|
3
2
|
import Log from 'sap/base/Log';
|
|
4
3
|
|
|
4
|
+
type SingleVersionInfo =
|
|
5
|
+
| {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
}
|
|
9
|
+
| undefined;
|
|
10
|
+
|
|
11
|
+
export type Ui5VersionInfo = {
|
|
12
|
+
major: number;
|
|
13
|
+
minor: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Default minimal supported UI5 version
|
|
18
|
+
*/
|
|
19
|
+
const minVersionInfo = {
|
|
20
|
+
major: 1,
|
|
21
|
+
minor: 71
|
|
22
|
+
} as Readonly<Ui5VersionInfo>;
|
|
23
|
+
|
|
5
24
|
/**
|
|
6
25
|
* Retrieve the UI5 version from sap.ui.core library
|
|
26
|
+
*
|
|
27
|
+
* @returns Ui5VersionInfo
|
|
7
28
|
*/
|
|
8
|
-
export async function getUi5Version() {
|
|
29
|
+
export async function getUi5Version(): Promise<Ui5VersionInfo> {
|
|
9
30
|
let version = ((await VersionInfo.load({ library: 'sap.ui.core' })) as SingleVersionInfo)?.version;
|
|
10
31
|
if (!version) {
|
|
11
32
|
Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
|
|
12
33
|
version = '1.121.0';
|
|
13
34
|
}
|
|
14
|
-
|
|
35
|
+
const [major, minor] = version.split('.').map(versionPart => parseInt(versionPart, 10));
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
major: major,
|
|
39
|
+
minor: minor
|
|
40
|
+
} satisfies Ui5VersionInfo;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the given version is lower than the required minimal version.
|
|
45
|
+
* @param ui5VersionInfo to check
|
|
46
|
+
* @param minUi5VersionInfo to check against (default is 1.71)
|
|
47
|
+
*
|
|
48
|
+
* @returns boolean
|
|
49
|
+
*/
|
|
50
|
+
export function isLowerThanMinimalUi5Version(
|
|
51
|
+
ui5VersionInfo: Ui5VersionInfo,
|
|
52
|
+
minUi5VersionInfo: Ui5VersionInfo = minVersionInfo
|
|
53
|
+
): boolean {
|
|
54
|
+
if (!isNaN(ui5VersionInfo.major) && !isNaN(ui5VersionInfo.minor)) {
|
|
55
|
+
if (ui5VersionInfo.major < minUi5VersionInfo.major) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (
|
|
59
|
+
ui5VersionInfo.major === minUi5VersionInfo.major &&
|
|
60
|
+
ui5VersionInfo.minor < minUi5VersionInfo.minor
|
|
61
|
+
) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get UI5 version validation message.
|
|
70
|
+
* @param ui5VersionInfo to be mentioned in the message
|
|
71
|
+
* @returns string with validation message.
|
|
72
|
+
*/
|
|
73
|
+
export function getUI5VersionValidationMessage(ui5VersionInfo: Ui5VersionInfo): string {
|
|
74
|
+
return `The current SAPUI5 version set for this Adaptation project is ${ui5VersionInfo.major}.${ui5VersionInfo.minor}. The minimum version to use for SAPUI5 Adaptation Project and its SAPUI5 Visual Editor is ${minVersionInfo.major}.${minVersionInfo.minor}`;
|
|
15
75
|
}
|
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.16.
|
|
12
|
+
"version": "0.16.52",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"@sap-ux/logger": "0.6.0",
|
|
29
29
|
"@sap-ux/btp-utils": "0.15.1",
|
|
30
|
-
"@sap-ux/adp-tooling": "0.12.
|
|
30
|
+
"@sap-ux/adp-tooling": "0.12.40",
|
|
31
31
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.27",
|
|
32
|
-
"@sap-ux/project-access": "1.26.
|
|
32
|
+
"@sap-ux/project-access": "1.26.8"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/ejs": "3.1.2",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"supertest": "6.3.3",
|
|
46
46
|
"@sap-ux-private/playwright": "0.1.0",
|
|
47
47
|
"dotenv": "16.3.1",
|
|
48
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.
|
|
48
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.9",
|
|
49
49
|
"@sap-ux/axios-extension": "1.16.4",
|
|
50
50
|
"@sap-ux/store": "0.9.1",
|
|
51
51
|
"@sap-ux/ui5-info": "0.8.1",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define([], function () {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Parses the UI5 version
|
|
8
|
-
* Returns NaN for snapshot or snapshot-untested
|
|
9
|
-
* Returns x.xx for snapshot-x.xx
|
|
10
|
-
*
|
|
11
|
-
* @param version the UI5 version to parse
|
|
12
|
-
* @returns The major and the minor version, e.g. 1.86
|
|
13
|
-
*/
|
|
14
|
-
function parseUI5Version(version) {
|
|
15
|
-
const versionParts = version.replace(/snapshot-untested|snapshot-|snapshot/, '').split('.');
|
|
16
|
-
const major = parseInt(versionParts[0], 10);
|
|
17
|
-
const minor = parseInt(versionParts[1], 10);
|
|
18
|
-
return {
|
|
19
|
-
major,
|
|
20
|
-
minor
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Checks if the given version is lower than the required minimal version.
|
|
26
|
-
* @param version to check
|
|
27
|
-
* @param minVersion to check
|
|
28
|
-
*
|
|
29
|
-
* @returns boolean
|
|
30
|
-
*/
|
|
31
|
-
function isLowerThanMinimalUi5Version(version, minVersion) {
|
|
32
|
-
if (version && minVersion) {
|
|
33
|
-
const minVersionParsed = parseUI5Version(minVersion);
|
|
34
|
-
const ui5VersionParsed = parseUI5Version(version);
|
|
35
|
-
if (!isNaN(ui5VersionParsed.major) && !isNaN(ui5VersionParsed.minor)) {
|
|
36
|
-
if (ui5VersionParsed.major < minVersionParsed.major) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
if (ui5VersionParsed.major === minVersionParsed.major && ui5VersionParsed.minor < minVersionParsed.minor) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get UI5 version validation message based on conditions.
|
|
49
|
-
* @param ui5Version to validate
|
|
50
|
-
* @returns string with validation message or undefined if non condition is met.
|
|
51
|
-
*/
|
|
52
|
-
function getUI5VersionValidationMessage(ui5Version) {
|
|
53
|
-
if (isLowerThanMinimalUi5Version(ui5Version, '1.71')) {
|
|
54
|
-
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`;
|
|
55
|
-
}
|
|
56
|
-
return undefined;
|
|
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
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses the UI5 version
|
|
3
|
-
* Returns NaN for snapshot or snapshot-untested
|
|
4
|
-
* Returns x.xx for snapshot-x.xx
|
|
5
|
-
*
|
|
6
|
-
* @param version the UI5 version to parse
|
|
7
|
-
* @returns The major and the minor version, e.g. 1.86
|
|
8
|
-
*/
|
|
9
|
-
function parseUI5Version(version: string): { major: number; minor: number } {
|
|
10
|
-
const versionParts = version.replace(/snapshot-untested|snapshot-|snapshot/, '').split('.');
|
|
11
|
-
const major = parseInt(versionParts[0], 10);
|
|
12
|
-
const minor = parseInt(versionParts[1], 10);
|
|
13
|
-
|
|
14
|
-
return { major, minor };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Checks if the given version is lower than the required minimal version.
|
|
19
|
-
* @param version to check
|
|
20
|
-
* @param minVersion to check
|
|
21
|
-
*
|
|
22
|
-
* @returns boolean
|
|
23
|
-
*/
|
|
24
|
-
export function isLowerThanMinimalUi5Version(version: string, minVersion: string): boolean {
|
|
25
|
-
if (version && minVersion) {
|
|
26
|
-
const minVersionParsed = parseUI5Version(minVersion);
|
|
27
|
-
const ui5VersionParsed = parseUI5Version(version);
|
|
28
|
-
if (!isNaN(ui5VersionParsed.major) && !isNaN(ui5VersionParsed.minor)) {
|
|
29
|
-
if (ui5VersionParsed.major < minVersionParsed.major) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
if (ui5VersionParsed.major === minVersionParsed.major && ui5VersionParsed.minor < minVersionParsed.minor) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get UI5 version validation message based on conditions.
|
|
42
|
-
* @param ui5Version to validate
|
|
43
|
-
* @returns string with validation message or undefined if non condition is met.
|
|
44
|
-
*/
|
|
45
|
-
export function getUI5VersionValidationMessage(ui5Version: string): string | undefined {
|
|
46
|
-
if (isLowerThanMinimalUi5Version(ui5Version, '1.71')) {
|
|
47
|
-
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`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
File without changes
|