Skip to content

Commit

Permalink
CB-4358 omit patch version (#2548)
Browse files Browse the repository at this point in the history
Co-authored-by: kseniaguzeeva <[email protected]>
  • Loading branch information
devnaumov and kseniaguzeeva authored Apr 15, 2024
1 parent 8f29b67 commit e45267c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
4 changes: 1 addition & 3 deletions webapp/packages/core-version-update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
"@cloudbeaver/core-di": "~0.1.0",
"@cloudbeaver/core-localization": "~0.1.0",
"@cloudbeaver/core-version": "~0.1.0",
"mobx": "^6.12.0",
"semver": "^7.6.0"
"mobx": "^6.12.0"
},
"peerDependencies": {},
"devDependencies": {
"@types/semver": "~7.5.8",
"typescript": "^5.3.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* you may not use this file except in compliance with the License.
*/
import { computed, makeObservable } from 'mobx';
import { compare } from 'semver';

import { injectable } from '@cloudbeaver/core-di';
import { IVersion, VersionResource, VersionService } from '@cloudbeaver/core-version';
Expand All @@ -29,10 +28,13 @@ export class VersionUpdateService {
return false;
}

return compare(this.versionResource.latest.number, this.versionService.current) === 1;
return this.versionService.compareVersions(this.versionResource.latest.number, this.versionService.current) === 1;
}

constructor(private readonly versionService: VersionService, private readonly versionResource: VersionResource) {
constructor(
private readonly versionService: VersionService,
private readonly versionResource: VersionResource,
) {
this.versionInstructionGetter = null;

makeObservable(this, {
Expand Down
4 changes: 3 additions & 1 deletion webapp/packages/core-version/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
"@cloudbeaver/core-root": "~0.1.0",
"@cloudbeaver/core-utils": "~0.1.0",
"mobx": "^6.12.0",
"react": "^18.2.0"
"react": "^18.2.0",
"semver": "^7.6.0"
},
"peerDependencies": {},
"devDependencies": {
"@types/react": "^18.2.63",
"@types/semver": "^7.5.8",
"typescript": "^5.3.3"
}
}
13 changes: 13 additions & 0 deletions webapp/packages/core-version/src/VersionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* you may not use this file except in compliance with the License.
*/
import { computed, makeObservable } from 'mobx';
import { compare, gte, parse } from 'semver';

import { injectable } from '@cloudbeaver/core-di';
import { ServerConfigResource } from '@cloudbeaver/core-root';
Expand Down Expand Up @@ -44,4 +45,16 @@ export class VersionService {
backendVersion,
};
}

greaterOrEqual(v1: string, v2: string) {
return gte(v1, v2);
}

parseVersion(version: string) {
return parse(version);
}

compareVersions(v1: string, v2: string): number {
return compare(v1, v2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"@cloudbeaver/core-version-update": "~0.1.0",
"mobx-react-lite": "^4.0.5",
"react": "^18.2.0",
"react-markdown": "^9.0.1",
"semver": "^7.6.0"
"react-markdown": "^9.0.1"
},
"peerDependencies": {},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* you may not use this file except in compliance with the License.
*/
import { observer } from 'mobx-react-lite';
import { gte } from 'semver';

import type { AdministrationItemContentComponent } from '@cloudbeaver/core-administration';
import { ColoredContainer, s, useResource, useS, useStyles } from '@cloudbeaver/core-blocks';
import { ColoredContainer, s, useResource, useS } from '@cloudbeaver/core-blocks';
import { useService } from '@cloudbeaver/core-di';
import { CachedMapAllKey } from '@cloudbeaver/core-resource';
import { VersionResource, VersionService } from '@cloudbeaver/core-version';
Expand All @@ -28,7 +27,7 @@ export const VersionUpdate: AdministrationItemContentComponent = observer(functi
});

const GeneralInstructions = versionUpdateService.generalInstructionsGetter?.();
const versions = versionResource.resource.values.filter(v => gte(v.number, versionService.current));
const versions = versionResource.resource.values.filter(v => versionService.greaterOrEqual(v.number, versionService.current));

return (
<ColoredContainer className={s(style, { coloredContainer: true })} wrap gap overflow parent>
Expand Down
2 changes: 1 addition & 1 deletion webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4941,7 +4941,7 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff"
integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==

"@types/semver@^7.3.12", "@types/semver@^7.5.0", "@types/semver@~7.5.8":
"@types/semver@^7.3.12", "@types/semver@^7.5.0", "@types/semver@^7.5.8":
version "7.5.8"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==
Expand Down

0 comments on commit e45267c

Please sign in to comment.