Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions web/package/cockpit-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Nov 21 15:21:06 UTC 2023 - David Diaz <dgonzalez@suse.com>

- UI: Do not crash when clicking the install button. It started
failing after removing core-js dependency (gh#openSUSE/agama#880
and related to gh#openSUSE/agama#866).

-------------------------------------------------------------------
Fri Nov 17 13:27:22 UTC 2023 - David Diaz <dgonzalez@suse.com>

Expand Down
5 changes: 4 additions & 1 deletion web/src/components/core/InstallButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,12 @@ const InstallButton = ({ onClick }) => {
const open = async () => {
if (onClick) onClick();
const canInstall = await client.manager.canInstall();
if (canInstall) setHasIssues(await client.issues.any());
setIsOpen(true);
setError(!canInstall);
if (canInstall) {
const issues = await client.issues();
setHasIssues(Object.values(issues).some(n => n.length > 0));
}
};
const close = () => setIsOpen(false);
const install = () => client.manager.startInstallation();
Expand Down
24 changes: 14 additions & 10 deletions web/src/components/core/InstallButton.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,18 @@ jest.mock("~/client", () => ({
createClient: jest.fn()
}));

describe("when the button is clicked and there are not errors", () => {
let hasIssues = false;
let issues;

describe("when the button is clicked and there are not errors", () => {
beforeEach(() => {
issues = {};
createClient.mockImplementation(() => {
return {
manager: {
startInstallation: startInstallationFn,
canInstall: () => Promise.resolve(true),
},
issues: {
any: () => Promise.resolve(hasIssues)
}
issues: jest.fn().mockResolvedValue({ ...issues })
};
});
});
Expand Down Expand Up @@ -74,7 +73,16 @@ describe("when the button is clicked and there are not errors", () => {

describe("if there are issues", () => {
beforeEach(() => {
hasIssues = true;
issues = {
product: [],
storage: [
{ description: "storage issue 1", details: "Details 1", source: "system", severity: "warn" },
{ description: "storage issue 2", details: "Details 2", source: "config", severity: "error" }
],
software: [
{ description: "software issue 1", details: "Details 1", source: "system", severity: "warn" }
]
};
});

it("shows a link to go to the issues page", async () => {
Expand All @@ -87,10 +95,6 @@ describe("when the button is clicked and there are not errors", () => {
});

describe("if there are not issues", () => {
beforeEach(() => {
hasIssues = false;
});

it("does not show a link to go to the issues page", async () => {
const { user } = installerRender(<InstallButton />);
const button = await screen.findByRole("button", { name: "Install" });
Expand Down