sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #07742
[Merge] ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main.
Commit message:
add non-unique name warning MAASENG-1578
- remove default TooltipButton iconName
Requested reviews:
MAAS Lander (maas-lander): unittests
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442008
design spec: https://zpl.io/Z0vYxwq
QA Steps
go to /sites
hover over any displayed warning icons in the name column
verify that the correct copy is displayed
--
Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main.
diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts
index 486a255..e4ff44a 100644
--- a/frontend/src/api/types.ts
+++ b/frontend/src/api/types.ts
@@ -15,6 +15,7 @@ export type Stats = {
export type Site = {
id: string;
name: string;
+ name_unique: boolean;
url: string; // <full URL including protocol>,
country: string; // <alpha2 country code>,
city: string;
diff --git a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx
index 764d9da..031abde 100644
--- a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx
+++ b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx
@@ -31,7 +31,6 @@ const ConnectionInfo = ({ connection, lastSeen }: ConnectionInfoProps) => {
return (
<>
<TooltipButton
- iconName=""
message={
connection === "unknown" ? (
"Haven't received a heartbeat from this region yet"
diff --git a/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx b/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
index 70e7291..9b753ef 100644
--- a/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
+++ b/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
@@ -127,3 +127,33 @@ it("displays correct number of deployed machines", () => {
expect(screen.getByText("100 of 1000 deployed")).toBeInTheDocument();
});
+
+it("if name is not unique a warning is displayed.", async () => {
+ const itemUnique = siteFactory.build({
+ name_unique: true,
+ });
+ const { rerender } = renderWithMemoryRouter(
+ <SitesTable
+ data={sitesQueryResultFactory.build({ items: [itemUnique], total: 1, page: 1, size: 1 })}
+ isFetchedAfterMount={true}
+ isLoading={false}
+ setSearchText={() => {}}
+ />,
+ );
+
+ expect(screen.queryByRole("button", { name: /warning - name is not unique/i })).not.toBeInTheDocument();
+
+ const itemNonUnique = siteFactory.build({
+ name_unique: false,
+ });
+ rerender(
+ <SitesTable
+ data={sitesQueryResultFactory.build({ items: [itemNonUnique], total: 1, page: 1, size: 1 })}
+ isFetchedAfterMount={true}
+ isLoading={false}
+ setSearchText={() => {}}
+ />,
+ );
+
+ expect(screen.getByRole("button", { name: /warning - name is not unique/i })).toBeInTheDocument();
+});
diff --git a/frontend/src/components/SitesList/SitesTable/SitesTable.tsx b/frontend/src/components/SitesList/SitesTable/SitesTable.tsx
index f27ea4a..2d26837 100644
--- a/frontend/src/components/SitesList/SitesTable/SitesTable.tsx
+++ b/frontend/src/components/SitesList/SitesTable/SitesTable.tsx
@@ -14,6 +14,7 @@ import type { SitesQueryResult } from "@/api/types";
import ExternalLink from "@/components/ExternalLink";
import NoRegions from "@/components/NoRegions";
import SelectAllCheckbox from "@/components/SelectAllCheckbox";
+import TooltipButton from "@/components/base/TooltipButton/TooltipButton";
import { isDev } from "@/constants";
import { useAppContext } from "@/context";
import type { UseSitesQueryResult } from "@/hooks/api";
@@ -73,19 +74,37 @@ const SitesTable = ({
},
{
id: "name",
- accessorFn: createAccessor(["name", "url"]),
+ accessorFn: createAccessor(["name", "url", "name_unique"]),
header: () => (
<>
<div>Name</div>
<div className="u-text--muted">URL</div>
</>
),
- cell: ({ getValue }) => (
- <>
- <div>{getValue().name}</div>
- <ExternalLink to={getValue().url || ""}>{getValue().url}</ExternalLink>
- </>
- ),
+ cell: ({ getValue }) => {
+ return (
+ <>
+ <div>
+ {getValue().name}
+ {!getValue().name_unique ? (
+ <TooltipButton
+ buttonProps={{ "aria-label": "warning - name is not unique" }}
+ iconName="warning"
+ iconProps={{ className: "u-no-margin--left" }}
+ message={
+ <>
+ This MAAS name is not unique in Site Manager.
+ <br />
+ You can change this name in the MAAS region itself.
+ </>
+ }
+ ></TooltipButton>
+ ) : null}
+ </div>
+ <ExternalLink to={getValue().url || ""}>{getValue().url}</ExternalLink>
+ </>
+ );
+ },
},
{
id: "connection",
diff --git a/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx b/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx
index e64c1c0..531d875 100644
--- a/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx
+++ b/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx
@@ -90,7 +90,6 @@ const TokensTable = ({
const { expires } = getValue();
return (
<TooltipButton
- iconName=""
message={expires ? `${format(new Date(expires), "yyyy-MM-dd HH:mm")} (UTC)` : null}
position="btm-center"
>
diff --git a/frontend/src/components/base/TooltipButton/TooltipButton.tsx b/frontend/src/components/base/TooltipButton/TooltipButton.tsx
index 97176d6..9fa491c 100644
--- a/frontend/src/components/base/TooltipButton/TooltipButton.tsx
+++ b/frontend/src/components/base/TooltipButton/TooltipButton.tsx
@@ -15,7 +15,7 @@ const TooltipButton = ({
"aria-label": ariaLabel,
buttonProps,
children,
- iconName = "information",
+ iconName,
iconProps,
message,
...tooltipProps
diff --git a/frontend/src/mocks/factories.ts b/frontend/src/mocks/factories.ts
index 8c7b9b7..d0734fd 100644
--- a/frontend/src/mocks/factories.ts
+++ b/frontend/src/mocks/factories.ts
@@ -39,6 +39,7 @@ export const siteFactory = Factory.define<Site>(({ sequence }) => {
return {
id: `${sequence}`,
name,
+ name_unique: chance.bool(),
url: `http://${name}.${chance.tld()}`,
country: chance.country(), // <alpha2 country code>,
city: chance.city(),