Peter Makowski has proposed merging
~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main.
Commit message:
update API data shapes
Requested reviews:
MAAS Committers (maas-committers)
For more details, see:
https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441774
- update API data shapes
- update pagination to start at index 1
QA Steps
Go to sites, tokens, and requests pages and make sure they load correctly using
the mock API
--
Your team MAAS Committers is requested to review the proposed merge of
~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main.
diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts
index 8f0ae7a..c124177 100644
--- a/frontend/src/api/types.ts
+++ b/frontend/src/api/types.ts
@@ -18,12 +18,10 @@ export type Site = {
url: string; // ,
connection: Stats["connection"];
last_seen: string; // ,
- address: {
-countrycode: string; // ,
-city: string;
-zip: string;
-street: string;
- };
+ country: string; // ,
+ city: string;
+ zip: string;
+ street: string;
timezone: string; // IANA time zone name,
stats: Stats;
};
@@ -40,7 +38,7 @@ export type SitesQueryResult = PaginatedQueryResult;
export type Token = {
id: string;
site_id: Site["id"] | null;
- token: string;
+ value: string;
expires: string; //,
created: string; //
};
diff --git a/frontend/src/components/RequestsList/RequestsList.tsx b/frontend/src/components/RequestsList/RequestsList.tsx
index 313bf06..3f5be3c 100644
--- a/frontend/src/components/RequestsList/RequestsList.tsx
+++ b/frontend/src/components/RequestsList/RequestsList.tsx
@@ -30,7 +30,7 @@ const Requests: React.FC = () => {
{
- const [page, setPage] = useState(0);
+ const [page, setPage] = useState(1);
const [size] = useState(DEFAULT_PAGE_SIZE);
const [searchText, setSearchText] = useState("");
const debounceSearchText = useDebounce(searchText);
@@ -22,7 +22,7 @@ const SitesList = () => {
);
useEffect(() => {
-setPage(0);
+setPage(1);
}, [searchText]);
return (
@@ -34,11 +34,11 @@ const SitesList = () => {
setSearchText={setSearchText}
/>
{
- setPage(page - 1);
+ setPage(page);
}}
totalItems={data?.total || 0}
/>
diff --git a/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx b/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
index c0cd2e3..70e7291 100644
--- a/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
+++ b/frontend/src/components/SitesList/SitesTable/SitesTable.test.tsx
@@ -94,7 +94,7 @@ it("displays correct local time", () => {
});
it("displays full name of the country", () => {
- const item = siteFactory.build({ address: { countrycode: "GB" } });
+ const item = siteFactory.build({ country: "GB" });
renderWithMemoryRouter(
(
<>
connection
@@ -96,13 +96,13 @@ const SitesTable = ({
),
cell: ({ getValue }) => {
- const { connection, last_seen } = getValue();
- return connection ? : null;
+ const { stats } = getValue();
+ return stats ? : null;
},
},
{
id: "address",
-accessorFn: createAccessor("address"),
+accessorFn: createAccessor(["country", "city", "zip", "street"]),
header: () => (
<>
country
@@ -110,11 +110,10 @@ const SitesTable = ({
),
cell: ({ getValue }) => {
- const { address } = getValue();
- const { countrycode, city, zip, street } = address || {};
+ const { country, city, zip, street } = getValue();
return (
<>
- {countrycode ? getCountryName(countrycode) : ""}
+ {country ? getCountryName(country) : ""}
{street}, {city}, {zip}
diff --git a/frontend/src/components/TokensList/TokensList.test.tsx b/frontend/src/components/TokensList/TokensList.test.tsx
index 631096a..8738cd4 100644
--- a/frontend/src/components/TokensList/TokensList.test.tsx
+++ b/frontend/src/components/TokensList/TokensList.test.tsx
@@ -39,7 +39,7 @@ it("should display table with tokens", async () => {
expect(within(tableBody).getAllByRole("row")).toHaveLength(tokens.length);
within(tableBody)
.getAllByRole("row")
-.forEach((row, idx) => expect(row).toHaveTextContent(new RegExp(tokens[idx].token, "i")));
+.forEach((row, idx) => expect(row).toHaveTextContent(new RegExp(tokens[idx].value, "i")));
});
it("should display a token count description (default=50)", () => {
diff --git a/frontend/src/components/TokensList/TokensList.tsx b/frontend/src/components/TokensList/TokensList.tsx
index d2e6da9..aac942a 100644
--- a/frontend/src/components/TokensList/TokensList.tsx
+++