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

[BugFix] Chart details are not updated on selecting another chart (#1155)

Signed-off-by: Pavel Ashevskii <pashevskii@mirantis.com>
This commit is contained in:
pashevskii 2020-11-03 19:41:30 +04:00 committed by GitHub
parent e3354f3b75
commit 0497947159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import "./helm-chart-details.scss";
import React, { Component } from "react";
import { HelmChart, helmChartsApi } from "../../api/endpoints/helm-charts.api";
import { t, Trans } from "@lingui/macro";
import { observable, toJS } from "mobx";
import { observable, autorun } from "mobx";
import { observer } from "mobx-react";
import { Drawer, DrawerItem } from "../drawer";
import { autobind, stopPropagation } from "../../utils";
@ -30,23 +30,23 @@ export class HelmChartDetails extends Component<Props> {
private chartPromise: CancelablePromise<{ readme: string; versions: HelmChart[] }>;
async componentDidMount() {
const { chart: { name, repo, version } } = this.props
try {
const { readme, versions } = await (this.chartPromise = helmChartsApi.get(repo, name, version))
this.readme = readme
this.chartVersions = versions
this.selectedChart = versions[0]
} catch (error) {
this.error = error
}
}
componentWillUnmount() {
this.chartPromise?.cancel();
}
chartUpdater = autorun(() => {
this.selectedChart = null
const { chart: { name, repo, version } } = this.props
helmChartsApi.get(repo, name, version).then(result => {
this.readme = result.readme
this.chartVersions = result.versions
this.selectedChart = result.versions[0]
},
error => {
this.error = error;
})
});
@autobind()
async onVersionChange({ value: version }: SelectOption) {
this.selectedChart = this.chartVersions.find(chart => chart.version === version);