@sap-ux/preview-middleware 0.16.123 → 0.16.124

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.
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../cpe/feature-service", "../../../cpe/quick-actions/utils", "../../../utils/core", "../simple-quick-action-base"], function (CommandFactory, _____cpe_feature_service, _____cpe_quick_actions_utils, _____utils_core, ___simple_quick_action_base) {
3
+ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../cpe/feature-service", "../../../cpe/quick-actions/utils", "../../../utils/core", "../simple-quick-action-base", "../../../utils/version"], function (CommandFactory, _____cpe_feature_service, _____cpe_quick_actions_utils, _____utils_core, ___simple_quick_action_base, _____utils_version) {
4
4
  "use strict";
5
5
 
6
6
  const FeatureService = _____cpe_feature_service["FeatureService"];
7
7
  const pageHasControlId = _____cpe_quick_actions_utils["pageHasControlId"];
8
8
  const getControlById = _____utils_core["getControlById"];
9
9
  const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
10
+ const getUi5Version = _____utils_version["getUi5Version"];
11
+ const isVersionEqualOrHasNewerPatch = _____utils_version["isVersionEqualOrHasNewerPatch"];
12
+ const isLowerThanMinimalUi5Version = _____utils_version["isLowerThanMinimalUi5Version"];
10
13
  const ENABLE_SEMANTIC_DATE_RANGE_FILTER_BAR = 'enable-semantic-daterange-filterbar';
11
14
  const CONTROL_TYPE = 'sap.ui.comp.smartfilterbar.SmartFilterBar';
12
15
 
@@ -19,7 +22,27 @@ sap.ui.define(["sap/ui/rta/command/CommandFactory", "../../../cpe/feature-servic
19
22
  }
20
23
  forceRefreshAfterExecution = true;
21
24
  isUseDateRangeTypeEnabled = false;
22
- initialize() {
25
+ async initialize() {
26
+ const version = await getUi5Version();
27
+ const isUI5VersionNotSupported = isLowerThanMinimalUi5Version(version, {
28
+ major: 1,
29
+ minor: 128
30
+ }) && !(isVersionEqualOrHasNewerPatch(version, {
31
+ major: 1,
32
+ minor: 96,
33
+ patch: 37
34
+ }) || isVersionEqualOrHasNewerPatch(version, {
35
+ major: 1,
36
+ minor: 108,
37
+ patch: 38
38
+ }) || isVersionEqualOrHasNewerPatch(version, {
39
+ major: 1,
40
+ minor: 120,
41
+ patch: 23
42
+ }));
43
+ if (isUI5VersionNotSupported) {
44
+ return;
45
+ }
23
46
  if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
24
47
  return;
25
48
  }
@@ -8,6 +8,7 @@ import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/qu
8
8
  import { pageHasControlId } from '../../../cpe/quick-actions/utils';
9
9
  import { getControlById } from '../../../utils/core';
10
10
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
11
+ import { getUi5Version, isVersionEqualOrHasNewerPatch, isLowerThanMinimalUi5Version } from '../../../utils/version';
11
12
 
12
13
  export const ENABLE_SEMANTIC_DATE_RANGE_FILTER_BAR = 'enable-semantic-daterange-filterbar';
13
14
  const CONTROL_TYPE = 'sap.ui.comp.smartfilterbar.SmartFilterBar';
@@ -25,7 +26,19 @@ export class ToggleSemanticDateRangeFilterBar
25
26
  readonly forceRefreshAfterExecution = true;
26
27
  private isUseDateRangeTypeEnabled = false;
27
28
 
28
- initialize(): void {
29
+ async initialize(): Promise<void> {
30
+ const version = await getUi5Version();
31
+ const isUI5VersionNotSupported =
32
+ isLowerThanMinimalUi5Version(version, { major: 1, minor: 128 }) &&
33
+ !(
34
+ isVersionEqualOrHasNewerPatch(version, { major: 1, minor: 96, patch: 37 }) ||
35
+ isVersionEqualOrHasNewerPatch(version, { major: 1, minor: 108, patch: 38 }) ||
36
+ isVersionEqualOrHasNewerPatch(version, { major: 1, minor: 120, patch: 23 })
37
+ );
38
+
39
+ if (isUI5VersionNotSupported) {
40
+ return;
41
+ }
29
42
  if (FeatureService.isFeatureEnabled('cpe.beta.quick-actions') === false) {
30
43
  return;
31
44
  }
@@ -24,10 +24,11 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
24
24
  Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
25
25
  version = '1.121.0';
26
26
  }
27
- const [major, minor] = version.split('.').map(versionPart => parseInt(versionPart, 10));
27
+ const [major, minor, patch] = version.split('.').map(versionPart => parseInt(versionPart, 10));
28
28
  return {
29
29
  major: major,
30
- minor: minor
30
+ minor: minor,
31
+ patch: patch
31
32
  };
32
33
  }
33
34
 
@@ -51,6 +52,21 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
51
52
  return false;
52
53
  }
53
54
 
55
+ /**
56
+ * Checks if the given version is equal to the specified version.
57
+ * @param ui5VersionInfo to check
58
+ * @param targetUi5VersionInfo to check against (default is 1.71)
59
+ *
60
+ * @returns boolean
61
+ */
62
+ function isVersionEqualOrHasNewerPatch(ui5VersionInfo) {
63
+ let targetUi5VersionInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : minVersionInfo;
64
+ if (!isNaN(ui5VersionInfo.major) && !isNaN(ui5VersionInfo.minor)) {
65
+ return ui5VersionInfo.major === targetUi5VersionInfo.major && ui5VersionInfo.minor === targetUi5VersionInfo.minor && (ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0);
66
+ }
67
+ return false;
68
+ }
69
+
54
70
  /**
55
71
  * Get UI5 version validation message.
56
72
  * @param ui5VersionInfo to be mentioned in the message
@@ -64,6 +80,7 @@ sap.ui.define(["sap/ui/VersionInfo", "sap/base/Log"], function (VersionInfo, Log
64
80
  };
65
81
  __exports.getUi5Version = getUi5Version;
66
82
  __exports.isLowerThanMinimalUi5Version = isLowerThanMinimalUi5Version;
83
+ __exports.isVersionEqualOrHasNewerPatch = isVersionEqualOrHasNewerPatch;
67
84
  __exports.getUI5VersionValidationMessage = getUI5VersionValidationMessage;
68
85
  return __exports;
69
86
  });
@@ -3,14 +3,15 @@ import Log from 'sap/base/Log';
3
3
 
4
4
  type SingleVersionInfo =
5
5
  | {
6
- name: string;
7
- version: string;
8
- }
6
+ name: string;
7
+ version: string;
8
+ }
9
9
  | undefined;
10
10
 
11
11
  export type Ui5VersionInfo = {
12
12
  major: number;
13
13
  minor: number;
14
+ patch?: number;
14
15
  };
15
16
 
16
17
  /**
@@ -32,11 +33,12 @@ export async function getUi5Version(): Promise<Ui5VersionInfo> {
32
33
  Log.error('Could not get UI5 version of application. Using 1.121.0 as fallback.');
33
34
  version = '1.121.0';
34
35
  }
35
- const [major, minor] = version.split('.').map(versionPart => parseInt(versionPart, 10));
36
+ const [major, minor, patch] = version.split('.').map((versionPart) => parseInt(versionPart, 10));
36
37
 
37
38
  return {
38
39
  major: major,
39
- minor: minor
40
+ minor: minor,
41
+ patch: patch
40
42
  } satisfies Ui5VersionInfo;
41
43
  }
42
44
 
@@ -55,16 +57,33 @@ export function isLowerThanMinimalUi5Version(
55
57
  if (ui5VersionInfo.major < minUi5VersionInfo.major) {
56
58
  return true;
57
59
  }
58
- if (
59
- ui5VersionInfo.major === minUi5VersionInfo.major &&
60
- ui5VersionInfo.minor < minUi5VersionInfo.minor
61
- ) {
60
+ if (ui5VersionInfo.major === minUi5VersionInfo.major && ui5VersionInfo.minor < minUi5VersionInfo.minor) {
62
61
  return true;
63
62
  }
64
63
  }
65
64
  return false;
66
65
  }
67
66
 
67
+ /**
68
+ * Checks if the given version is equal to the specified version.
69
+ * @param ui5VersionInfo to check
70
+ * @param targetUi5VersionInfo to check against (default is 1.71)
71
+ *
72
+ * @returns boolean
73
+ */
74
+ export function isVersionEqualOrHasNewerPatch(
75
+ ui5VersionInfo: Ui5VersionInfo,
76
+ targetUi5VersionInfo: Ui5VersionInfo = minVersionInfo
77
+ ): boolean {
78
+ if (!isNaN(ui5VersionInfo.major) && !isNaN(ui5VersionInfo.minor)) {
79
+ return (
80
+ ui5VersionInfo.major === targetUi5VersionInfo.major &&
81
+ ui5VersionInfo.minor === targetUi5VersionInfo.minor &&
82
+ (ui5VersionInfo?.patch ?? 0) >= (targetUi5VersionInfo?.patch ?? 0));
83
+ }
84
+ return false;
85
+ }
86
+
68
87
  /**
69
88
  * Get UI5 version validation message.
70
89
  * @param ui5VersionInfo to be mentioned in the message
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.123",
12
+ "version": "0.16.124",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "@sap-ux/logger": "0.6.0",
29
29
  "@sap-ux/feature-toggle": "0.2.2",
30
30
  "@sap-ux/btp-utils": "0.17.0",
31
- "@sap-ux/adp-tooling": "0.12.81",
32
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.26",
32
+ "@sap-ux/adp-tooling": "0.12.81",
33
33
  "@sap-ux/project-access": "1.28.7"
34
34
  },
35
35
  "devDependencies": {
@@ -46,11 +46,11 @@
46
46
  "supertest": "6.3.3",
47
47
  "@sap-ux-private/playwright": "0.1.0",
48
48
  "dotenv": "16.3.1",
49
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.32",
49
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.33",
50
50
  "@sap-ux/axios-extension": "1.17.4",
51
- "@sap-ux/store": "0.9.3",
52
51
  "@sap-ux/ui5-info": "0.8.3",
53
- "@sap-ux/i18n": "0.2.0"
52
+ "@sap-ux/i18n": "0.2.0",
53
+ "@sap-ux/store": "0.9.3"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "express": "4"