From c6b2ccbc2bbe98f6109d86fb1b946bf7a1ffbddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz=20Gonz=C3=A1lez?= Date: Sat, 11 Mar 2023 00:54:40 +0000 Subject: [PATCH] [web] Simplify the change product link The logic for not rendering it when already on the product selection page is no longer needed now that it's rendered on demand (when the user is on the Overview page at this moment). --- .../components/software/ChangeProductLink.jsx | 8 ++------ .../software/ChangeProductLink.test.jsx | 17 +---------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/web/src/components/software/ChangeProductLink.jsx b/web/src/components/software/ChangeProductLink.jsx index d753e7572c..6fbf09cb4d 100644 --- a/web/src/components/software/ChangeProductLink.jsx +++ b/web/src/components/software/ChangeProductLink.jsx @@ -20,18 +20,14 @@ */ import React from "react"; -import { Link, useLocation } from "react-router-dom"; +import { Link } from "react-router-dom"; import { useSoftware } from "~/context/software"; import { Icon } from "~/components/layout"; export default function ChangeProductLink() { const { products } = useSoftware(); - const { pathname } = useLocation(); - const multiProduct = products?.length > 1; - if (!multiProduct || pathname === "/products") { - return null; - } + if (products?.length === 1) return null; return ( diff --git a/web/src/components/software/ChangeProductLink.test.jsx b/web/src/components/software/ChangeProductLink.test.jsx index 08eec11af5..549bdde46f 100644 --- a/web/src/components/software/ChangeProductLink.test.jsx +++ b/web/src/components/software/ChangeProductLink.test.jsx @@ -21,7 +21,7 @@ import React from "react"; import { screen, waitFor } from "@testing-library/react"; -import { installerRender, mockRoutes } from "~/test-utils"; +import { installerRender } from "~/test-utils"; import { createClient } from "~/client"; import { ChangeProductLink } from "~/components/software"; @@ -48,21 +48,6 @@ beforeEach(() => { }); describe("ChangeProductLink", () => { - describe("when it's already in the product selection path", () => { - beforeEach(() => { - mockRoutes("/products"); - mockProducts = [ - { id: "openSUSE", name: "openSUSE Tumbleweed" }, - { id: "Leap Micro", name: "openSUSE Micro" } - ]; - }); - - it("renders nothing", async () => { - const { container } = installerRender(); - await waitFor(() => expect(container).toBeEmptyDOMElement()); - }); - }); - describe("when there is only a single product", () => { beforeEach(() => { mockProducts = [