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:
parent
e3354f3b75
commit
0497947159
@ -3,7 +3,7 @@ import "./helm-chart-details.scss";
|
|||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { HelmChart, helmChartsApi } from "../../api/endpoints/helm-charts.api";
|
import { HelmChart, helmChartsApi } from "../../api/endpoints/helm-charts.api";
|
||||||
import { t, Trans } from "@lingui/macro";
|
import { t, Trans } from "@lingui/macro";
|
||||||
import { observable, toJS } from "mobx";
|
import { observable, autorun } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { Drawer, DrawerItem } from "../drawer";
|
import { Drawer, DrawerItem } from "../drawer";
|
||||||
import { autobind, stopPropagation } from "../../utils";
|
import { autobind, stopPropagation } from "../../utils";
|
||||||
@ -30,23 +30,23 @@ export class HelmChartDetails extends Component<Props> {
|
|||||||
|
|
||||||
private chartPromise: CancelablePromise<{ readme: string; versions: HelmChart[] }>;
|
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() {
|
componentWillUnmount() {
|
||||||
this.chartPromise?.cancel();
|
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()
|
@autobind()
|
||||||
async onVersionChange({ value: version }: SelectOption) {
|
async onVersionChange({ value: version }: SelectOption) {
|
||||||
this.selectedChart = this.chartVersions.find(chart => chart.version === version);
|
this.selectedChart = this.chartVersions.find(chart => chart.version === version);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user