1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix Helm chart version comparison (#174)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-03-30 17:21:10 +03:00 committed by GitHub
parent 96641307dd
commit f0dd4095ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import { autobind } from "../../utils";
import { HelmChart, helmChartsApi } from "../../api/endpoints/helm-charts.api"; import { HelmChart, helmChartsApi } from "../../api/endpoints/helm-charts.api";
import { ItemStore } from "../../item.store"; import { ItemStore } from "../../item.store";
import flatten from "lodash/flatten" import flatten from "lodash/flatten"
import compareVersions from 'compare-versions';
export interface IChartVersion { export interface IChartVersion {
repo: string; repo: string;
@ -23,11 +24,7 @@ export class HelmChartStore extends ItemStore<HelmChart> {
protected sortVersions = (versions: IChartVersion[]) => { protected sortVersions = (versions: IChartVersion[]) => {
return versions.sort((first, second) => { return versions.sort((first, second) => {
const firstVersion = first.version.replace(/[^\d.]/g, "").split(".").map(Number); return compareVersions(second.version, first.version)
const secondVersion = second.version.replace(/[^\d.]/g, "").split(".").map(Number);
return firstVersion.every((version, index) => {
return version > secondVersion[index];
}) ? -1 : 0;
}); });
}; };

View File

@ -107,7 +107,6 @@ export class UpgradeChart extends React.Component<Props> {
value={version} value={version}
options={versions} options={versions}
formatOptionLabel={this.formatVersionLabel} formatOptionLabel={this.formatVersionLabel}
isOptionDisabled={({ value }: SelectOption<IChartVersion>) => value.version === currentVersion}
onChange={({ value }: SelectOption) => this.version = value} onChange={({ value }: SelectOption) => this.version = value}
/> />
</div> </div>

View File

@ -12,6 +12,7 @@
"dependencies": { "dependencies": {
"axios": "^0.19.0", "axios": "^0.19.0",
"chalk": "^2.4.2", "chalk": "^2.4.2",
"compare-versions": "^3.6.0",
"compression": "^1.7.4", "compression": "^1.7.4",
"cookie-session": "^1.3.3", "cookie-session": "^1.3.3",
"cors": "^2.8.5", "cors": "^2.8.5",

View File

@ -3245,6 +3245,11 @@ commondir@^1.0.1:
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=
compare-versions@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62"
integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==
component-emitter@^1.2.1: component-emitter@^1.2.1:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"