Skip to content

Commit

Permalink
Small adjustments to #1823 (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
absoludity committed Jun 26, 2020
1 parent 4740a83 commit f49b3ef
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions dashboard/src/actions/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function fetchCharts(
export function fetchChartVersions(
namespace: string,
id: string,
): ThunkAction<Promise<IChartVersion[] | undefined>, IStoreState, null, ChartsAction> {
): ThunkAction<Promise<IChartVersion[]>, IStoreState, null, ChartsAction> {
return async dispatch => {
dispatch(requestCharts());
try {
Expand All @@ -101,7 +101,7 @@ export function fetchChartVersions(
return versions;
} catch (e) {
dispatchError(dispatch, e);
return;
return [];
}
};
}
Expand Down Expand Up @@ -166,7 +166,7 @@ export function fetchChartVersionsAndSelectVersion(
): ThunkAction<Promise<void>, IStoreState, null, ChartsAction> {
return async dispatch => {
const versions = (await dispatch(fetchChartVersions(namespace, id))) as IChartVersion[];
if (versions) {
if (versions.length > 0) {
let cv: IChartVersion = versions[0];
if (version) {
const found = versions.find(v => v.attributes.version === version);
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/AppUpgrade/AppUpgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface IAppUpgradeProps {
values?: string,
schema?: JSONSchema4,
) => Promise<boolean>;
fetchChartVersions: (namespace: string, id: string) => Promise<IChartVersion[] | undefined>;
fetchChartVersions: (namespace: string, id: string) => Promise<IChartVersion[]>;
getAppWithUpdateInfo: (namespace: string, releaseName: string) => void;
getChartVersion: (namespace: string, id: string, chartVersion: string) => void;
getDeployedChartVersion: (namespace: string, id: string, chartVersion: string) => void;
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/DeploymentForm/DeploymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IDeploymentFormProps {
schema?: JSONSchema4,
) => Promise<boolean>;
push: (location: string) => RouterAction;
fetchChartVersions: (namespace: string, id: string) => void;
fetchChartVersions: (namespace: string, id: string) => Promise<IChartVersion[]>;
getChartVersion: (namespace: string, id: string, chartVersion: string) => void;
namespace: string;
}
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/components/UpgradeForm/UpgradeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IUpgradeFormProps {
) => Promise<boolean>;
push: (location: string) => RouterAction;
goBack: () => RouterAction;
fetchChartVersions: (namespace: string, id: string) => Promise<IChartVersion[] | undefined>;
fetchChartVersions: (namespace: string, id: string) => Promise<IChartVersion[]>;
getChartVersion: (namespace: string, id: string, chartVersion: string) => void;
}

Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/shared/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class Chart {
return data.data;
}

public static async fetchChartVersions(namespace: string, id: string) {
public static async fetchChartVersions(namespace: string, id: string): Promise<IChartVersion[]> {
const { data } = await axiosWithAuth.get<{ data: IChartVersion[] }>(
URL.api.charts.listVersions(namespace, id),
);
Expand Down
10 changes: 8 additions & 2 deletions dashboard/src/shared/Config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Config", () => {

defaultJSON = require("../../public/config.json");

moxios.stubRequest("config.json", { status: 200, response: defaultJSON });
moxios.stubRequest("config.json", { status: 200, response: { ...defaultJSON } });
});

afterEach(() => {
Expand All @@ -31,7 +31,13 @@ describe("Config", () => {
});

it("does not returns the overriden namespace if NODE_ENV=production", async () => {
process.env.REACT_APP_KUBEAPPS_NS = "magic-playground";
const prodEnv = {
...initialEnv,
NODE_ENV: "production",
REACT_APP_KUBEAPPS_NS: "magic-playground",
};
process.env = prodEnv;

expect(await Config.getConfig()).toEqual(defaultJSON);
});
});

0 comments on commit f49b3ef

Please sign in to comment.