Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a warning message for non semver versions #1038

Merged
merged 3 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions dashboard/src/actions/apps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe("fetches applications", () => {
expect(store.getActions()).toEqual(expectedActions);
});

it("set up upToDate=true if the application version is not semver compatible", async () => {
it("set an error if the application version is not semver compatible", async () => {
const appsResponse = [
{
releaseName: "foobar",
Expand All @@ -142,7 +142,12 @@ describe("fetches applications", () => {
type: getType(actions.apps.receiveAppUpdateInfo),
payload: {
releaseName: "foobar",
updateInfo: { upToDate: true, latestVersion: "", repository: { name: "", url: "" } },
updateInfo: {
error: new Error("Invalid Version: 1.0"),
upToDate: false,
latestVersion: "",
repository: { name: "", url: "" },
},
},
},
];
Expand Down
18 changes: 7 additions & 11 deletions dashboard/src/actions/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,13 @@ function getAppUpdateInfo(
}
dispatch(receiveAppUpdateInfo({ releaseName, updateInfo }));
} catch (e) {
if (e.message.includes("Invalid Version")) {
// The version is not semver compatible so we cannot look for new versions
const updateInfo: IChartUpdateInfo = {
upToDate: true,
repository: { name: "", url: "" },
latestVersion: "",
};
dispatch(receiveAppUpdateInfo({ releaseName, updateInfo }));
return;
}
dispatch(errorApps(e));
const updateInfo: IChartUpdateInfo = {
error: e,
upToDate: false,
repository: { name: "", url: "" },
latestVersion: "",
};
dispatch(receiveAppUpdateInfo({ releaseName, updateInfo }));
}
};
}
Expand Down
24 changes: 24 additions & 0 deletions dashboard/src/components/AppList/AppListItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,27 @@ it("should set a banner if there are updates available", () => {
const card = wrapper.find(InfoCard);
expect(card.prop("banner")).toBe("v1.1.0 available");
});

it("should not set a banner if there are errors in the update info", () => {
const wrapper = shallow(
<AppListItem
app={
{
namespace: "default",
releaseName: "foo",
status: "DEPLOYED",
version: "1.0.0",
chart: "myapp",
updateInfo: {
error: new Error("Boom!"),
upToDate: false,
latestVersion: "",
repository: { name: "", url: "" },
},
} as IAppOverview
}
/>,
);
const card = wrapper.find(InfoCard);
expect(card.prop("banner")).toBe(undefined);
});
2 changes: 1 addition & 1 deletion dashboard/src/components/AppList/AppListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppListItem extends React.Component<IAppListItemProps> {
const { app } = this.props;
const icon = app.icon ? app.icon : placeholder;
const banner =
app.updateInfo && !app.updateInfo.upToDate
app.updateInfo && !app.updateInfo.error && !app.updateInfo.upToDate
? `v${app.updateInfo.latestVersion} available`
: undefined;
return (
Expand Down
8 changes: 8 additions & 0 deletions dashboard/src/components/AppView/ChartInfo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ context("when information about updates is available", () => {
.text(),
).toContain("1.0.0 available");
});
it("renders a warning if there are errors with the update info", () => {
const appWithUpdates = {
...defaultProps.app,
updateInfo: { error: new Error("Boom!"), upToDate: false, latestVersion: "" },
} as IRelease;
const wrapper = shallow(<ChartInfo {...defaultProps} app={appWithUpdates} />);
expect(wrapper.html()).toContain("Update check failed. Boom!");
});
});
16 changes: 15 additions & 1 deletion dashboard/src/components/AppView/ChartInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { ArrowUpCircle, CheckCircle } from "react-feather";
import { AlertTriangle, ArrowUpCircle, CheckCircle } from "react-feather";
import { Link } from "react-router-dom";

import { IRelease } from "shared/types";
Expand Down Expand Up @@ -51,6 +51,20 @@ class ChartInfo extends React.Component<IChartInfoProps> {
// If update is not set yet we cannot know if there is
// an update available or not
if (app.updateInfo) {
if (app.updateInfo.error) {
return (
<div>
<AlertTriangle
color="white"
fill="#FDBA12"
className="icon"
size={15}
style={{ bottom: "-0.2em" }}
/>{" "}
<span>Update check failed. {app.updateInfo.error.message}</span>
</div>
);
}
if (app.updateInfo.upToDate) {
return (
<span>
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface IChartUpdateInfo {
upToDate: boolean;
latestVersion: string;
repository: IRepo;
error?: Error;
}

export interface IDeployment {
Expand Down