Skip to content

Commit a5d0709

Browse files
authored
License: Small fixes from testing (#33373)
1 parent d6d7580 commit a5d0709

4 files changed

Lines changed: 29 additions & 15 deletions

File tree

packages/devextreme/js/__internal/core/license/license_validation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ describe('license check', () => {
378378
{ token: TOKEN_23_2, version: '42.4.5' },
379379
{ token: TOKEN_23_1, version: '23.3.0' },
380380
{ token: TOKEN_23_2, version: '42.4.0' },
381-
])('Trial panel should be displayed if license is outdated (>=1 major for RTM, >=2 major for preview)', ({ token, version }) => {
381+
])('Trial panel should be displayed if license is outdated', ({ token, version }) => {
382382
validateLicense(token, version);
383383
expect(trialPanelSpy).toHaveBeenCalledTimes(1);
384384
});

packages/devextreme/js/__internal/core/license/license_validation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { fullVersion } from '@js/core/version';
55
import type { Version } from '../../utils/version';
66
import {
77
assertedVersionsCompatible,
8-
getPreviousMajorVersion,
98
parseVersion,
109
} from '../../utils/version';
1110
import {
@@ -64,7 +63,7 @@ function getLicenseCheckParams({
6463
try {
6564
preview = isPreview(version.patch);
6665

67-
const { major, minor } = preview ? getPreviousMajorVersion(version) : version;
66+
const { major, minor } = version;
6867

6968
if (!licenseKey || licenseKey === LICENSE_KEY_PLACEHOLDER) {
7069
return { preview, error: 'W0019', warningType: 'no-key' };

packages/devextreme/js/__internal/core/license/license_warnings.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,40 @@ export function logLicenseWarning(
7070

7171
const warnings: string[][] = [[purchaseLine]];
7272

73+
const pushToLastGroup = (...items: string[]): void => {
74+
const lastGroup = warnings[warnings.length - 1];
75+
if (lastGroup.length === 1) {
76+
lastGroup.push('', ...items);
77+
} else {
78+
lastGroup.push(...items);
79+
}
80+
};
81+
7382
switch (warningType) {
7483
case 'no-key':
75-
warnings[warnings.length - 1].push(T.keyNotFound);
84+
pushToLastGroup(T.keyNotFound);
7685
warnings.push([installLine]);
7786
break;
7887

7988
case 'invalid-key':
80-
warnings[warnings.length - 1].push(T.keyVerificationFailed());
89+
pushToLastGroup(T.keyVerificationFailed());
8190
warnings.push([installLine]);
8291
break;
8392

8493
case 'lcx-used':
8594
// eslint-disable-next-line spellcheck/spell-checker
86-
warnings[warnings.length - 1].push(T.keyVerificationFailed(), T.lcxUsedInsteadOfLcp);
95+
pushToLastGroup(T.keyVerificationFailed(), T.lcxUsedInsteadOfLcp);
8796
warnings.push([installLine]);
8897
break;
8998

9099
case 'old-devextreme-key':
91-
warnings[warnings.length - 1].push(T.keyVerificationFailed(), T.oldDevExtremeKey);
100+
pushToLastGroup(T.keyVerificationFailed(), T.oldDevExtremeKey);
92101
warnings.push([installLine]);
93102
break;
94103

95104
case 'version-mismatch': {
96105
const incompatibleLine = `${T.warningPrefix('W0020')} ${T.keyVerificationFailed('incompatibleVersion', versionInfo?.keyVersion, versionInfo?.requiredVersion)}`;
97-
warnings[warnings.length - 1].push(T.keyVerificationFailed());
106+
pushToLastGroup(T.keyVerificationFailed());
98107
warnings.push([incompatibleLine]);
99108
break;
100109
}

packages/devextreme/license/devextreme-license.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,20 @@ function main() {
212212
if(warning.type !== 'trial') {
213213
const code = TEMPLATES.warningCodeByType(warning.type);
214214

215-
lines.push(
216-
TEMPLATES.keyVerificationFailed(warning.type, warning.keyVersion, warning.currentVersion),
217-
);
218-
219-
if(warning.type === 'trialExpired') {
220-
lines.push(prefixed(`${TEMPLATES.warningPrefix(code)} ${TEMPLATES.purchaseLicense}`));
215+
if(warning.type === 'incompatibleVersion') {
216+
lines.push(
217+
prefixed(`${TEMPLATES.warningPrefix(code)} ${TEMPLATES.keyVerificationFailed(warning.type, warning.keyVersion, warning.currentVersion)}`),
218+
);
221219
} else {
222-
lines.push(prefixed(`${TEMPLATES.warningPrefix(code)} ${TEMPLATES.installationInstructions}`));
220+
lines.push(
221+
TEMPLATES.keyVerificationFailed(warning.type, warning.keyVersion, warning.currentVersion),
222+
);
223+
224+
if(warning.type === 'trialExpired') {
225+
lines.push(prefixed(`${TEMPLATES.warningPrefix(code)} ${TEMPLATES.purchaseLicense}`));
226+
} else {
227+
lines.push(prefixed(`${TEMPLATES.warningPrefix(code)} ${TEMPLATES.installationInstructions}`));
228+
}
223229
}
224230
}
225231

0 commit comments

Comments
 (0)