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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(web): do not allow unregistering a product #1882

Merged
merged 5 commits into from
Jan 10, 2025
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
6 changes: 6 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
Fri Jan 10 13:46:42 UTC 2025 - David Diaz <dgonzalez@suse.com>

- Drop the feature for deregistering a product
(gh#agama-project/agama#1882).
-------------------------------------------------------------------

Fri Jan 10 13:22:27 UTC 2025 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Do not allow changing the storage setup when Agama is using the
Expand Down
8 changes: 1 addition & 7 deletions web/src/api/software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
RegistrationInfo,
SoftwareProposal,
} from "~/types/software";
import { del, get, post, put } from "~/api/http";
import { get, post, put } from "~/api/http";

/**
* Returns the software configuration
Expand Down Expand Up @@ -67,11 +67,6 @@ const updateConfig = (config: SoftwareConfig) => put("/api/software/config", con
const register = ({ key, email }: { key: string; email?: string }) =>
post("/api/software/registration", { key, email });

/**
* Request deregistering selected product
*/
const deregister = () => del("/api/software/registration");

export {
fetchConfig,
fetchPatterns,
Expand All @@ -80,5 +75,4 @@ export {
fetchRegistration,
updateConfig,
register,
deregister,
};
9 changes: 0 additions & 9 deletions web/src/components/product/ProductRegistrationPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ const sle: Product = {
let selectedProduct: Product;
let registrationInfoMock: RegistrationInfo;
const registerMutationMock = jest.fn();
const deregisterMutationMock = jest.fn();

jest.mock("~/queries/software", () => ({
...jest.requireActual("~/queries/software"),
useRegisterMutation: () => ({ mutate: registerMutationMock }),
useDeregisterMutation: () => ({ mutate: deregisterMutationMock }),
useRegistration: (): ReturnType<typeof useRegistration> => registrationInfoMock,
useProduct: (): ReturnType<typeof useProduct> => {
return {
Expand Down Expand Up @@ -128,13 +126,6 @@ describe("ProductRegistrationPage", () => {
screen.getByText(/\*?5678/);
});

it("allows deregistering the product", async () => {
const { user } = installerRender(<ProductRegistrationPage />);
const deregisterButton = screen.getByRole("button", { name: "deregister" });
await user.click(deregisterButton);
expect(deregisterMutationMock).toHaveBeenCalled();
});

// describe("but at registration path already", () => {
// beforeEach(() => {
// mockRoutes(REGISTRATION.root);
Expand Down
21 changes: 1 addition & 20 deletions web/src/components/product/ProductRegistrationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ import {
import { Page, PasswordInput } from "~/components/core";
import textStyles from "@patternfly/react-styles/css/utilities/Text/text";
import spacingStyles from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import {
useProduct,
useRegistration,
useRegisterMutation,
useDeregisterMutation,
} from "~/queries/software";
import { useProduct, useRegistration, useRegisterMutation } from "~/queries/software";
import { isEmpty, mask } from "~/utils";
import { _ } from "~/i18n";
import { sprintf } from "sprintf-js";
Expand All @@ -55,29 +50,15 @@ const EMAIL_LABEL = "Email";

const RegisteredProductSection = () => {
const { selectedProduct: product } = useProduct();
const { mutate: deregister } = useDeregisterMutation();
const registration = useRegistration();
const [showCode, setShowCode] = useState(false);
const toggleCodeVisibility = () => setShowCode(!showCode);

const footer = _("For using a different registration code, please %s the product first.");
const deregisterButtonLabel = _("deregister");
const [footerStart, footerEnd] = footer.split("%s");

return (
<Page.Section
title={_("Product registered")}
description={sprintf(_("%s has been registered with below information."), product.name)}
pfCardProps={{ isCompact: false }}
actions={
<p>
{footerStart}{" "}
<Button onClick={() => deregister()} variant="link" isInline>
{deregisterButtonLabel}
</Button>{" "}
{footerEnd}
</p>
}
>
<DescriptionList className={spacingStyles.myMd}>
<DescriptionListGroup>
Expand Down
21 changes: 0 additions & 21 deletions web/src/queries/software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
SoftwareProposal,
} from "~/types/software";
import {
deregister,
fetchConfig,
fetchPatterns,
fetchProducts,
Expand Down Expand Up @@ -142,25 +141,6 @@ const useRegisterMutation = () => {
return useMutation(query);
};

/**
* Hook that builds a mutation for deregistering a product
*
* @note it would trigger a general probing as a side-effect when mutation
* includes a product.
*/
const useDeregisterMutation = () => {
const queryClient = useQueryClient();

const query = {
mutationFn: deregister,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["software/registration"] });
startProbing();
},
};
return useMutation(query);
};

/**
* Returns available products and selected one, if any
*/
Expand Down Expand Up @@ -286,5 +266,4 @@ export {
useProposalChanges,
useRegistration,
useRegisterMutation,
useDeregisterMutation,
};
Loading