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

Fix show details and updating helm releases tests

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-08-11 08:35:58 -04:00
parent 042b679ca6
commit d249c4c679
8 changed files with 231 additions and 334 deletions

View File

@ -2131,7 +2131,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -2212,7 +2212,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -3042,7 +3042,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -3123,7 +3123,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -4014,7 +4014,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -4095,7 +4095,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -4986,7 +4986,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -5067,7 +5067,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -5365,7 +5365,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -5419,7 +5419,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -6210,7 +6212,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -6291,7 +6293,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -6589,7 +6591,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -6643,7 +6645,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -7434,7 +7438,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -7515,7 +7519,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -7813,7 +7817,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -7867,7 +7871,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -8008,7 +8014,7 @@ exports[`showing details for helm release given application is started when navi
</body>
`;
exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when update resolves with failure renders 1`] = `
exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when requestHelmCharts resolves when requestHelmChartVersions resolves when update resolves with failure renders 1`] = `
<body>
<div>
<div
@ -8864,7 +8870,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -8918,7 +8924,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -9059,7 +9067,7 @@ exports[`showing details for helm release given application is started when navi
</body>
`;
exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when update resolves with success renders 1`] = `
exports[`showing details for helm release given application is started when navigating to helm releases when releases resolve when selecting release to see details when call for release resolve with release when configuration resolves when changing the configuration when saving when requestHelmCharts resolves when requestHelmChartVersions resolves when update resolves with success renders 1`] = `
<body>
<div>
<div
@ -9915,7 +9923,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -9969,7 +9977,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -10762,7 +10772,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -10843,7 +10853,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -11141,7 +11151,7 @@ exports[`showing details for helm release given application is started when navi
class="flex gaps align-center"
>
<span>
some-chart
some-chart-1.0.0
</span>
<button
class="Button box right upgrade primary"
@ -11195,7 +11205,9 @@ exports[`showing details for helm release given application is started when navi
<div
class="version flex gaps align-center"
>
<span />
<span>
1.0.0
</span>
</div>
</span>
</div>
@ -11986,7 +11998,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -12067,7 +12079,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -12295,147 +12307,8 @@ exports[`showing details for helm release given application is started when navi
style="flex-basis: 300px;"
>
<div
class="UpgradeChart flex column"
>
<div
class="InfoPanel flex gaps align-center"
>
<div
class="controls"
>
<div
class="upgrade flex gaps align-center"
>
<span>
Release
</span>
<div
class="badge"
>
some-name
</div>
<span>
Namespace
</span>
<div
class="badge"
>
some-namespace
</div>
<span>
Version
</span>
<div
class="badge"
/>
<span>
Upgrade version
</span>
<div
class="Select theme-outlined chart-version css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-char-version-input-live-region"
/>
<span
aria-atomic="false"
aria-live="polite"
aria-relevant="additions text"
class="css-1f43avz-a11yText-A11yText"
/>
<div
class="Select__control css-1s2u09g-control"
>
<div
class="Select__value-container css-319lph-ValueContainer"
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-char-version-input-placeholder"
>
Select...
</div>
<div
class="Select__input-container css-6j8wv5-Input"
data-value=""
>
<input
aria-autocomplete="list"
aria-describedby="react-select-char-version-input-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
autocomplete="off"
autocorrect="off"
class="Select__input"
id="char-version-input"
role="combobox"
spellcheck="false"
style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;"
tabindex="0"
type="text"
value=""
/>
</div>
</div>
<div
class="Select__indicators css-1hb7zxy-IndicatorsContainer"
>
<span
class="Select__indicator-separator css-1okebmr-indicatorSeparator"
/>
<div
aria-hidden="true"
class="Select__indicator Select__dropdown-indicator css-tlfecz-indicatorContainer"
>
<svg
aria-hidden="true"
class="css-tj5bde-Svg"
focusable="false"
height="20"
viewBox="0 0 20 20"
width="20"
>
<path
d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
/>
</svg>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class="flex gaps align-center"
/>
<button
class="Button plain"
type="button"
>
Cancel
</button>
<button
class="Button active outlined"
type="button"
>
Upgrade
</button>
<button
class="Button primary active"
type="button"
>
Upgrade & Close
</button>
</div>
<textarea
data-testid="monaco-editor-for-some-tab-id"
/>
</div>
class="Spinner singleColor center"
/>
</div>
</div>
</div>
@ -13094,7 +12967,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -13175,7 +13048,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -14069,7 +13942,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -14150,7 +14023,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -14980,7 +14853,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -15061,7 +14934,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"
@ -15952,7 +15825,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
1.0.0
</div>
<div
class="TableCell app-version"
@ -16033,7 +15906,7 @@ exports[`showing details for helm release given application is started when navi
<div
class="TableCell version"
>
2.0.0
</div>
<div
class="TableCell app-version"

View File

@ -18,8 +18,8 @@ import requestHelmReleaseConfigurationInjectable from "../../common/k8s-api/endp
import type { RequestHelmReleaseUpdate } from "../../common/k8s-api/endpoints/helm-releases.api/update.injectable";
import requestHelmReleaseUpdateInjectable from "../../common/k8s-api/endpoints/helm-releases.api/update.injectable";
import { useFakeTime } from "../../common/test-utils/use-fake-time";
import type { RequestHelmRelease, DetailedHelmRelease } from "../../renderer/components/+helm-releases/release-details/release-details-model/request-helm-release.injectable";
import requestHelmReleaseInjectable from "../../renderer/components/+helm-releases/release-details/release-details-model/request-helm-release.injectable";
import type { RequestDetailedHelmRelease } from "../../renderer/components/+helm-releases/release-details/release-details-model/request-detailed-helm-release.injectable";
import requestDetailedHelmReleaseInjectable from "../../renderer/components/+helm-releases/release-details/release-details-model/request-detailed-helm-release.injectable";
import showSuccessNotificationInjectable from "../../renderer/components/notifications/show-success-notification.injectable";
import showCheckedErrorInjectable from "../../renderer/components/notifications/show-checked-error.injectable";
import getRandomUpgradeChartTabIdInjectable from "../../renderer/components/dock/upgrade-chart/get-random-upgrade-chart-tab-id.injectable";
@ -31,11 +31,12 @@ import requestHelmChartsInjectable from "../../common/k8s-api/endpoints/helm-cha
import requestHelmChartVersionsInjectable from "../../common/k8s-api/endpoints/helm-charts.api/get-versions.injectable";
import requestHelmChartReadmeInjectable from "../../common/k8s-api/endpoints/helm-charts.api/get-readme.injectable";
import requestHelmChartValuesInjectable from "../../common/k8s-api/endpoints/helm-charts.api/get-values.injectable";
import { HelmChart } from "../../common/k8s-api/endpoints/helm-charts.api";
describe("showing details for helm release", () => {
let builder: ApplicationBuilder;
let requestHelmReleasesMock: AsyncFnMock<RequestHelmReleases>;
let requestHelmReleaseMock: AsyncFnMock<RequestHelmRelease>;
let requestDetailedHelmReleaseMock: AsyncFnMock<RequestDetailedHelmRelease>;
let requestHelmReleaseConfigurationMock: AsyncFnMock<RequestHelmReleaseConfiguration>;
let requestHelmReleaseUpdateMock: AsyncFnMock<RequestHelmReleaseUpdate>;
let requestHelmChartsMock: AsyncFnMock<RequestHelmCharts>;
@ -53,7 +54,7 @@ describe("showing details for helm release", () => {
builder.setEnvironmentToClusterFrame();
requestHelmReleasesMock = asyncFn();
requestHelmReleaseMock = asyncFn();
requestDetailedHelmReleaseMock = asyncFn();
requestHelmReleaseConfigurationMock = asyncFn();
requestHelmReleaseUpdateMock = asyncFn();
requestHelmChartsMock = asyncFn();
@ -69,7 +70,7 @@ describe("showing details for helm release", () => {
windowDi.override(showSuccessNotificationInjectable, () => showSuccessNotificationMock);
windowDi.override(showCheckedErrorInjectable, () => showCheckedErrorNotificationMock);
windowDi.override(requestHelmReleasesInjectable, () => requestHelmReleasesMock);
windowDi.override(requestHelmReleaseInjectable, () => requestHelmReleaseMock);
windowDi.override(requestDetailedHelmReleaseInjectable, () => requestDetailedHelmReleaseMock);
windowDi.override(requestHelmReleaseConfigurationInjectable, () => requestHelmReleaseConfigurationMock);
windowDi.override(requestHelmReleaseUpdateInjectable, () => requestHelmReleaseUpdateMock);
windowDi.override(requestHelmChartsInjectable, () => requestHelmChartsMock);
@ -139,7 +140,7 @@ describe("showing details for helm release", () => {
appVersion: "some-app-version",
name: "some-name",
namespace: "some-namespace",
chart: "some-chart",
chart: "some-chart-1.0.0",
status: "some-status",
updated: "some-updated",
revision: "some-revision",
@ -154,7 +155,7 @@ describe("showing details for helm release", () => {
appVersion: "some-other-app-version",
name: "some-other-name",
namespace: "some-other-namespace",
chart: "some-other-chart",
chart: "some-other-chart-2.0.0",
status: "some-other-status",
updated: "some-other-updated",
revision: "some-other-revision",
@ -193,7 +194,7 @@ describe("showing details for helm release", () => {
});
it("calls for release", () => {
expect(requestHelmReleaseMock).toHaveBeenCalledWith(
expect(requestDetailedHelmReleaseMock).toHaveBeenCalledWith(
"some-name",
"some-namespace",
);
@ -207,7 +208,7 @@ describe("showing details for helm release", () => {
describe("when opening details for second release", () => {
beforeEach(() => {
requestHelmReleaseMock.mockClear();
requestDetailedHelmReleaseMock.mockClear();
const row = rendered.getByTestId(
"helm-release-row-for-some-other-namespace/some-other-name",
@ -221,7 +222,7 @@ describe("showing details for helm release", () => {
});
it("calls for another release", () => {
expect(requestHelmReleaseMock).toHaveBeenCalledWith(
expect(requestDetailedHelmReleaseMock).toHaveBeenCalledWith(
"some-other-name",
"some-other-namespace",
);
@ -261,7 +262,7 @@ describe("showing details for helm release", () => {
describe("when opening details for same release", () => {
beforeEach(() => {
requestHelmReleaseMock.mockClear();
requestDetailedHelmReleaseMock.mockClear();
const row = rendered.getByTestId(
"helm-release-row-for-some-namespace/some-name",
@ -275,15 +276,14 @@ describe("showing details for helm release", () => {
});
it("does not reload", () => {
expect(requestHelmReleaseMock).not.toHaveBeenCalled();
expect(requestDetailedHelmReleaseMock).not.toHaveBeenCalled();
});
});
});
describe("when call for release resolves with error", () => {
beforeEach(async () => {
await requestHelmReleaseMock.resolve({
await requestDetailedHelmReleaseMock.resolve({
callWasSuccessful: false,
error: "some-error",
});
@ -312,9 +312,49 @@ describe("showing details for helm release", () => {
describe("when call for release resolve with release", () => {
beforeEach(async () => {
await requestHelmReleaseMock.resolve({
await requestDetailedHelmReleaseMock.resolve({
callWasSuccessful: true,
response: detailedReleaseFake,
response: {
release: {
appVersion: "some-app-version",
chart: "some-chart-1.0.0",
status: "some-status",
updated: "some-updated",
revision: "some-revision",
name: "some-name",
namespace: "some-namespace",
},
details: {
name: "some-name",
namespace: "some-namespace",
version: "some-version",
config: "some-config",
manifest: "some-manifest",
info: {
deleted: "some-deleted",
description: "some-description",
first_deployed: "some-first-deployed",
last_deployed: "some-last-deployed",
notes: "some-notes",
status: "some-status",
},
resources: [
{
kind: "some-kind",
apiVersion: "some-api-version",
metadata: {
uid: "some-uid",
name: "some-resource",
namespace: "some-namespace",
creationTimestamp: "2015-10-22T07:28:00Z",
},
},
],
},
},
});
});
@ -477,94 +517,115 @@ describe("showing details for helm release", () => {
expect(saveButton).toHaveClass("waiting");
});
it("calls for update", () => {
expect(requestHelmReleaseUpdateMock).toHaveBeenCalledWith(
"some-name",
"some-namespace",
{
chart: "some-chart",
repo: "",
values: "some-new-configuration",
version: "",
},
);
});
describe("when update resolves with success", () => {
describe("when requestHelmCharts resolves", () => {
beforeEach(async () => {
requestHelmReleasesMock.mockClear();
requestHelmReleaseConfigurationMock.mockClear();
await requestHelmReleaseUpdateMock.resolve({
updateWasSuccessful: true,
await requestHelmChartsMock.resolve([HelmChart.create({
apiVersion: "1.2.3",
version: "1.0.0",
created: "at-some-time",
name: "some-chart",
repo: "some-repo",
})]);
});
describe("when requestHelmChartVersions resolves", () => {
beforeEach(async () => {
await requestHelmChartVersionsMock.resolve([HelmChart.create({
apiVersion: "1.2.3",
version: "1.0.0",
created: "at-some-time",
name: "some-chart",
repo: "some-repo",
})]);
});
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("calls for update", () => {
expect(requestHelmReleaseUpdateMock).toHaveBeenCalledWith(
"some-name",
"some-namespace",
it("does not show spinner anymore", () => {
const saveButton = rendered.getByTestId(
"helm-release-configuration-save-button",
);
expect(saveButton).not.toHaveClass("waiting");
});
it("reloads the configuration", () => {
expect(requestHelmReleaseConfigurationMock).toHaveBeenCalledWith(
"some-name",
"some-namespace",
true,
);
});
it("shows success notification", () => {
expect(showSuccessNotificationMock).toHaveBeenCalled();
});
it("does not show error notification", () => {
expect(showCheckedErrorNotificationMock).not.toHaveBeenCalled();
});
});
describe("when update resolves with failure", () => {
beforeEach(async () => {
requestHelmReleasesMock.mockClear();
requestHelmReleaseConfigurationMock.mockClear();
await requestHelmReleaseUpdateMock.resolve({
updateWasSuccessful: false,
error: "some-error",
{
chart: "some-chart",
repo: "some-repo",
values: "some-new-configuration",
version: "1.0.0",
},
);
});
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
describe("when update resolves with success", () => {
beforeEach(async () => {
requestHelmReleasesMock.mockClear();
requestHelmReleaseConfigurationMock.mockClear();
it("does not show spinner anymore", () => {
const saveButton = rendered.getByTestId(
"helm-release-configuration-save-button",
);
await requestHelmReleaseUpdateMock.resolve({
updateWasSuccessful: true,
});
});
expect(saveButton).not.toHaveClass("waiting");
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("does not reload the configuration", () => {
expect(requestHelmReleaseConfigurationMock).not.toHaveBeenCalled();
});
it("does not show spinner anymore", () => {
const saveButton = rendered.getByTestId(
"helm-release-configuration-save-button",
);
it("does not show success notification", () => {
expect(showSuccessNotificationMock).not.toHaveBeenCalled();
});
expect(saveButton).not.toHaveClass("waiting");
});
it("shows error notification", () => {
expect(showCheckedErrorNotificationMock).toHaveBeenCalled();
it("reloads the configuration", () => {
expect(requestHelmReleaseConfigurationMock).toHaveBeenCalledWith(
"some-name",
"some-namespace",
true,
);
});
it("shows success notification", () => {
expect(showSuccessNotificationMock).toHaveBeenCalled();
});
it("does not show error notification", () => {
expect(showCheckedErrorNotificationMock).not.toHaveBeenCalled();
});
});
describe("when update resolves with failure", () => {
beforeEach(async () => {
requestHelmReleasesMock.mockClear();
requestHelmReleaseConfigurationMock.mockClear();
await requestHelmReleaseUpdateMock.resolve({
updateWasSuccessful: false,
error: "some-error",
});
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
it("does not show spinner anymore", () => {
const saveButton = rendered.getByTestId(
"helm-release-configuration-save-button",
);
expect(saveButton).not.toHaveClass("waiting");
});
it("does not reload the configuration", () => {
expect(requestHelmReleaseConfigurationMock).not.toHaveBeenCalled();
});
it("does not show success notification", () => {
expect(showSuccessNotificationMock).not.toHaveBeenCalled();
});
it("shows error notification", () => {
expect(showCheckedErrorNotificationMock).toHaveBeenCalled();
});
});
});
});
});
@ -576,45 +637,3 @@ describe("showing details for helm release", () => {
});
});
});
const detailedReleaseFake: DetailedHelmRelease = {
release: {
appVersion: "some-app-version",
chart: "some-chart",
status: "some-status",
updated: "some-updated",
revision: "some-revision",
name: "some-name",
namespace: "some-namespace",
},
details: {
name: "some-name",
namespace: "some-namespace",
version: "some-version",
config: "some-config",
manifest: "some-manifest",
info: {
deleted: "some-deleted",
description: "some-description",
first_deployed: "some-first-deployed",
last_deployed: "some-last-deployed",
notes: "some-notes",
status: "some-status",
},
resources: [
{
kind: "some-kind",
apiVersion: "some-api-version",
metadata: {
uid: "some-uid",
name: "some-resource",
namespace: "some-namespace",
creationTimestamp: "2015-10-22T07:28:00Z",
},
},
],
},
};

View File

@ -4,6 +4,7 @@
*/
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import { asyncComputed } from "@ogre-tools/injectable-react";
import { when } from "mobx";
import { coerce } from "semver";
import requestHelmChartVersionsInjectable from "../../../../common/k8s-api/endpoints/helm-charts.api/get-versions.injectable";
import type { HelmRelease } from "../../../../common/k8s-api/endpoints/helm-releases.api";
@ -29,6 +30,7 @@ const helmChartVersionsInjectable = getInjectable({
const helmCharts = di.inject(helmChartsInjectable);
return asyncComputed(async () => {
await when(() => !helmCharts.pending.get());
const rawVersions = await Promise.all((
helmCharts.value.get()
.filter(chart => chart.getName() === release.getChart())

View File

@ -6,8 +6,8 @@ import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
import type { IComputedValue, IObservableValue } from "mobx";
import { runInAction, action, observable, computed } from "mobx";
import type { TargetHelmRelease } from "../target-helm-release.injectable";
import type { RequestHelmRelease, DetailedHelmRelease } from "./request-helm-release.injectable";
import requestHelmReleaseInjectable from "./request-helm-release.injectable";
import type { RequestDetailedHelmRelease, DetailedHelmRelease } from "./request-detailed-helm-release.injectable";
import requestDetailedHelmReleaseInjectable from "./request-detailed-helm-release.injectable";
import type { LensTheme } from "../../../../themes/store";
import type { RequestHelmReleaseConfiguration } from "../../../../../common/k8s-api/endpoints/helm-releases.api/get-configuration.injectable";
import requestHelmReleaseConfigurationInjectable from "../../../../../common/k8s-api/endpoints/helm-releases.api/get-configuration.injectable";
@ -37,7 +37,7 @@ const releaseDetailsModelInjectable = getInjectable({
instantiate: async (di, targetRelease: TargetHelmRelease) => {
const model = new ReleaseDetailsModel({
requestHelmRelease: di.inject(requestHelmReleaseInjectable),
requestDetailedHelmRelease: di.inject(requestDetailedHelmReleaseInjectable),
targetRelease,
activeTheme: di.inject(activeThemeInjectable),
requestHelmReleaseConfiguration: di.inject(requestHelmReleaseConfigurationInjectable),
@ -78,7 +78,7 @@ export interface ConfigurationInput {
interface Dependencies {
readonly targetRelease: TargetHelmRelease;
readonly activeTheme: IComputedValue<LensTheme>;
requestHelmRelease: RequestHelmRelease;
requestDetailedHelmRelease: RequestDetailedHelmRelease;
requestHelmReleaseConfiguration: RequestHelmReleaseConfiguration;
getResourceDetailsUrl: GetResourceDetailsUrl;
updateRelease: RequestHelmReleaseUpdate;
@ -165,7 +165,7 @@ export class ReleaseDetailsModel {
load = async () => {
const { name, namespace } = this.dependencies.targetRelease;
const result = await this.dependencies.requestHelmRelease(
const result = await this.dependencies.requestDetailedHelmRelease(
name,
namespace,
);

View File

@ -14,15 +14,15 @@ export interface DetailedHelmRelease {
details: HelmReleaseDetails;
}
export type RequestHelmRelease = (
export type RequestDetailedHelmRelease = (
name: string,
namespace: string
) => Promise<AsyncResult<DetailedHelmRelease>>;
const requestHelmReleaseInjectable = getInjectable({
id: "call-for-helm-release",
const requestDetailedHelmReleaseInjectable = getInjectable({
id: "request-detailed-helm-release",
instantiate: (di): RequestHelmRelease => {
instantiate: (di): RequestDetailedHelmRelease => {
const requestHelmReleases = di.inject(requestHelmReleasesInjectable);
const requestHelmReleaseDetails = di.inject(requestHelmReleaseDetailsInjectable);
@ -48,4 +48,4 @@ const requestHelmReleaseInjectable = getInjectable({
},
});
export default requestHelmReleaseInjectable;
export default requestDetailedHelmReleaseInjectable;

View File

@ -73,13 +73,14 @@ const toHelmReleaseInjectable = getInjectable({
// so we have to try to guess it by searching charts
async getRepo() {
const versionsComputed = helmChartVersions(this);
const version = this.getVersion();
await when(() => !versionsComputed.pending.get());
const version = this.getVersion();
const versions = versionsComputed.value.get();
return versions.find((chartVersion) => chartVersion.version === version)?.repo ?? "";
return versionsComputed.value
.get()
.find((chartVersion) => chartVersion.version === version)?.repo
?? "";
},
});
},

View File

@ -68,9 +68,11 @@ const upgradeChartModelInjectable = getInjectable({
error: computed(() => configrationEditError.get()),
setError: action((error) => configrationEditError.set(String(error))),
};
const versionValue = observable.box<ChartVersion | undefined>(versions.value.get()[0]);
const versionValue = observable.box<ChartVersion>(undefined, {
deep: false,
});
const version: UpgradeChartModel["version"] = {
value: computed(() => versionValue.get()),
value: computed(() => versionValue.get() ?? versions.value.get()[0]),
set: action((option) => versionValue.set(option?.value)),
};
const versionOptions = computed(() => (
@ -88,9 +90,9 @@ const upgradeChartModelInjectable = getInjectable({
configration,
version,
submit: async () => {
const version = versionValue.get();
const selectedVersion = version.value.get();
if (!version || configrationEditError.get()) {
if (!selectedVersion || configrationEditError.get()) {
return {
completedSuccessfully: false,
};
@ -102,7 +104,7 @@ const upgradeChartModelInjectable = getInjectable({
{
chart: release.getChart(),
values: configration.value.get(),
...version,
...selectedVersion,
},
);
storedConfigration.invalidate();

View File

@ -80,7 +80,7 @@ export class NonInjectedUpgradeChart extends React.Component<UpgradeChartProps &
<Badge label={release.getNs()} />
<span>Version</span>
{" "}
<Badge label={model.version.value.get()} />
<Badge label={release.getVersion()} />
<span>Upgrade version</span>
<Select<ChartVersion, SelectOption<ChartVersion>, false>
id="char-version-input"