[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443547 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main. Commit message: test: add eslint-plugin-unused-imports - fix: remove unused error arg Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443547 This will automatically remove unused imports on save or when running eslint with --fix ## QA steps - Checkout this branch locally - Go to App.tsx - Add `import { copyToClipboard } from "@/utils";` at the top of the file - If you have autofix enabled on save in your code editor: - save the file and the import should be removed - If you do not have autofix enabled in your code editor: - Run yarn lint --fix and once done the import should be removed -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:add-eslint-plugin-unused-imports into maas-site-manager:main. diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 870950e..3a95201 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -2,7 +2,7 @@ const path = require("path"); module.exports = { root: true, - plugins: ["prettier", "no-relative-import-paths"], + plugins: ["unused-imports", "no-relative-import-paths", "prettier"], extends: [ "./.eslintrc-auto-import.json", "react-app", // Use the recommended rules from CRA. @@ -60,11 +60,16 @@ module.exports = { }, rules: { "prettier/prettier": "error", -"@typescript-eslint/no-unused-vars": [ - "error", +"@typescript-eslint/no-unused-vars": "off", +"unused-imports/no-unused-imports": "error", +"unused-imports/no-unused-vars": [ + "warn", { -args: "none", +vars: "all", +varsIgnorePattern: "^_", +args: "after-used", ignoreRestSiblings: true, +argsIgnorePattern: "^_", }, ], "no-restricted-syntax": [ diff --git a/frontend/package.json b/frontend/package.json index e28adf0..231006e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -66,6 +66,7 @@ "eslint-plugin-no-relative-import-paths": "1.5.2", "eslint-plugin-prettier": "4.2.1", "eslint-plugin-react": "7.32.2", +"eslint-plugin-unused-imports": "2.0.0", "fishery": "2.2.2", "i18n-iso-countries": "7.6.0", "jsdom": "21.1.2", diff --git a/frontend/src/components/RemoveRegions/RemoveRegions.tsx b/frontend/src/components/RemoveRegions/RemoveRegions.tsx index 303f7a2..d5a9357 100644 --- a/frontend/src/components/RemoveRegions/RemoveRegions.tsx +++ b/frontend/src/components/RemoveRegions/RemoveRegions.tsx @@ -27,7 +27,7 @@ const createHandleValidate = ({ expectedConfirmTextValue }: { expectedConfirmTextValue: string }) => async (values: RemoveRegionsFormValues) => { let errors = {}; -await RemoveRegionsFormSchema.validate(values, { context: { expectedConfirmTextValue } }).catch((error) => { +await RemoveRegionsFormSchema.validate(values, { context: { expectedConfirmTextValue } }).catch(() => { errors = { confirmText: `Confirmation string is not correct. Expected ${expectedConfirmTextValue}` }; }); return errors; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index f05b88c..10570bd 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -3539,6 +3539,18 @@ eslint-plugin-testing-library@^5.0.1: dependencies: "@typescript-eslint/utils" "^5.43.0" +eslint-plugin-unused-imports@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz#d8db8c4d0cfa0637a8b51ce3fd7d1b6bc3f08520"; + integrity sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A== + dependencies: +eslint-rule-composer "^0.3.0" + +eslint-rule-composer@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"; + integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== + eslint-scope@5.1.1, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"; -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-test-warnings into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:remove-test-warnings into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443196 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:remove-test-warnings. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-test-warnings into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:remove-test-warnings into maas-site-manager:main. Commit message: remove warnings in tests - set isDev to read value from NODE_ENV - render NoRegions inside a table to avoid warnings about invalid DOM nesting Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443196 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:remove-test-warnings into maas-site-manager:main. diff --git a/frontend/src/components/NoRegions/NoRegions.test.tsx b/frontend/src/components/NoRegions/NoRegions.test.tsx index b1eca0a..02d27db 100644 --- a/frontend/src/components/NoRegions/NoRegions.test.tsx +++ b/frontend/src/components/NoRegions/NoRegions.test.tsx @@ -6,13 +6,20 @@ import { createMockGetEnrollmentRequestsResolver } from "@/mocks/resolvers"; import { createMockGetServer } from "@/mocks/server"; import { getByTextContent, renderWithMemoryRouter, screen, waitFor } from "@/test-utils"; +const renderComponent = () => + renderWithMemoryRouter( +// render inside a table to avoid warnings about invalid DOM nesting + + +, + ); + describe("open enrollment requests available", () => { const enrollmentRequests = enrollmentRequestFactory.buildList(2); const mockServer = createMockGetServer( urls.enrollmentRequests, createMockGetEnrollmentRequestsResolver(enrollmentRequests), ); - beforeAll(() => { mockServer.listen(); }); @@ -24,12 +31,11 @@ describe("open enrollment requests available", () => { }); it("should display 'no enrolled regions' text", () => { -renderWithMemoryRouter(); - +renderComponent(); expect(screen.getByText(/no enroled maas regions/i)).toBeInTheDocument(); }); it("should display link to enrollment docs", () => { -renderWithMemoryRouter(); +renderComponent(); expect( screen.getByRole("link", { name: /learn more about the enrolment process in the documentation\./i }), @@ -37,8 +43,7 @@ describe("open enrollment requests available", () => { }); it("should display a link to the request page if there are open requests", async () => { -renderWithMemoryRouter(); - +renderComponent(); await waitFor(() => expect( screen.getByRole("link", { @@ -49,8 +54,7 @@ describe("open enrollment requests available", () => { }); it("should display the amount of open enrollment requests", async () => { -renderWithMemoryRouter(); - +renderComponent(); await waitFor(() => expect( getByTextContent(new RegExp("You have 2 open enrolment requests, inspect them in the Requests page.", "i")), @@ -77,8 +81,7 @@ describe("no open enrollment requests available", () => { }); it("should display a link to the tokens page", async () => { -renderWithMemoryRouter(); - +renderComponent(); await waitFor(() => expect( screen.getByRole("link", { @@ -89,8 +92,7 @@ describe("no open enrollment requests available", () => { }); it("should display a link to enrollment process docs", () => { -renderWithMemoryRouter(); - +renderComponent(); expect( screen.getByRole("link", { name: new RegExp("Learn more about the enrolment process in the documentation.", "i"), diff --git a/frontend/src/constants.ts b/frontend/src/constants.ts index 99b7c2a..215a164 100644 --- a/frontend/src/constants.ts +++ b/frontend/src/constants.ts @@ -1,2 +1,2 @@ -export const isDev = import.meta.env.DEV; +export const isDev = import.meta.env.NODE_ENV === "development"; export const useMockData = import.meta.env.VITE_USE_MOCK_DATA === "true"; diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index e65a61b..458a4e5 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -17,8 +17,10 @@ if (useMockData) { const environment = process.env.NODE_ENV; const version = packageInfo.version; const release = import.meta.env.VITE_APP_VERSION; -// eslint-disable-next-line no-console -console.log(`%cMAAS Site Manager \n${version} ${release}\n${environment}`, "color: #e95420; font-weight: bold;"); +if (environment !== "test") { + // eslint-disable-next-line no-console + console.log(`%cMAAS Site Manager \n${version} ${release}\n${environment}`, "color: #e95420; font-weight: bold;"); +} // https://sentry.is.canonical.com/canonical/maas-site-manager/ Sentry.init({ -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main has been updated. Commit message changed to: chore: remove @testing-library/react-hooks - use renderHook from @testing-library/react - update tests to use act - upgrade all front-end dependencies For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443183 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main. Commit message: chore: remove @testing-library/react-hooks - use renderHook from @testing-library/react - update tests to use act Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/443183 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:react-hooks-testing-lib-MAASENG-1713 into maas-site-manager:main. diff --git a/frontend/package.json b/frontend/package.json index e8ed433..49e2869 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -41,7 +41,6 @@ "@remix-run/web-fetch": "4.3.4", "@testing-library/jest-dom": "5.16.5", "@testing-library/react": "14.0.0", -"@testing-library/react-hooks": "8.0.1", "@testing-library/user-event": "14.4.3", "@total-typescript/ts-reset": "0.4.2", "@types/axios": "0.14.0", diff --git a/frontend/src/hooks/useDebouncedValue.test.ts b/frontend/src/hooks/useDebouncedValue.test.ts index ba6d055..f6739f9 100644 --- a/frontend/src/hooks/useDebouncedValue.test.ts +++ b/frontend/src/hooks/useDebouncedValue.test.ts @@ -1,17 +1,13 @@ import useDebouncedValue from "./useDebouncedValue"; -import { renderHook } from "@/test-utils"; +import { act, renderHook } from "@/test-utils"; describe("useDebouncedValue", () => { - beforeAll(() => { + beforeEach(() => { vi.useFakeTimers(); }); afterEach(() => { -vi.clearAllTimers(); - }); - - afterAll(() => { vi.useRealTimers(); }); @@ -21,12 +17,11 @@ describe("useDebouncedValue", () => { value: "value", }, }); - expect(result.current).toBe("value"); - -await rerender({ value: "new-value" }); -await vi.advanceTimersToNextTimer(); - +rerender({ value: "new-value" }); +await act(async () => { + await vi.runAllTimersAsync(); +}); expect(result.current).toBe("new-value"); }); @@ -37,12 +32,11 @@ describe("useDebouncedValue", () => { delay: 5, }, }); - expect(result.current).toBe("value"); - -await rerender({ value: "new-value", delay: 5 }); -await vi.advanceTimersByTime(5); - +rerender({ value: "new-value", delay: 5 }); +await act(async () => { + await vi.advanceTimersByTimeAsync(5); +}); expect(result.current).toBe("new-value"); }); }); diff --git a/frontend/src/hooks/useDebouncedValue.ts b/frontend/src/hooks/useDebouncedValue.ts index 1cf4167..4140266 100644 --- a/frontend/src/hooks/useDebouncedValue.ts +++ b/frontend/src/hooks/useDebouncedValue.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -const DEFAULT_DELAY = 500; +export const DEFAULT_DELAY = 500; function useDebouncedValue(value: T, delay = DEFAULT_DELAY): T { const [debouncedValue, setDebouncedValue] = useState(value); diff --git a/frontend/src/hooks/usePagination.test.ts b/frontend/src/hooks/usePagination.test.ts index a999c40..388d05e 100644 --- a/frontend/src/hooks/usePagination.test.ts +++ b/frontend/src/hooks/usePagination.test.ts @@ -1,6 +1,6 @@ import usePagination from "./usePagination"; -import { hookAct, renderHook } from "@/test-utils"; +import { renderHook, act } from "@/test-utils"; describe("usePagination", () => { const samplePageSize = 50; @@ -12,26 +12,22 @@ describe("usePagination", () => { expect(result.current.page).toBe(1); }); - it("next and previous page functions work correctly", () => { + it("next and previous page functions work correctly", async () => { const { result } = renderHook(() => usePagination(samplePageSize, sampleTotalCount)); - -hookAct(() => { +await act(() => { result.current.handleNextClick(); }); - expect(result.current.page).toBe(2); - -hookAct(() => { +await act(() => { result.current.handlePreviousClick(); }); - expect(result.current.page).toBe(1); }); - it("should reset page count after page size is changed", () => { + it("should reset page count after page size is changed", async () => { const { result } = renderHook(() => usePagination(samplePageSize, sampleTotalCount)); -hookAct(() => { +await act(() => { result.current.handleNextClick(); result.current.handlePageSizeChange(10); }); diff --git a/frontend/src/test-utils.tsx b/frontend/src/test
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main
> Is there a better way to select `tbody`? I think it's one of those rare examples where using specific DOM nodes is fine. This is a relatively low-level component. Plus, there's no semantic way for selecting tbody unfortunately. -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442849 Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:header-height-MAASENG-1609. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442849 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:header-height-MAASENG-1609. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-total_machines-key into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-total_machines-key into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442742 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-total_machines-key. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442736 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/MainLayout/MainLayout.tsx > b/frontend/src/components/MainLayout/MainLayout.tsx > index 9be3fca..3fe61c0 100644 > --- a/frontend/src/components/MainLayout/MainLayout.tsx > +++ b/frontend/src/components/MainLayout/MainLayout.tsx > @@ -19,21 +18,39 @@ export const sidebarLabels: Record<"removeRegions" | > "createToken", string> = { >createToken: "Generate tokens", > }; > > -type AsideProps = PropsWithChildren, > "sidebar" | "setSidebar">>; > -const Aside = ({ children, sidebar, setSidebar, ...props }: AsideProps) => { > +const Aside = () => { > + const { pathname } = useLocation(); > + const previousPathname = usePrevious(pathname); > + const { sidebar, setSidebar } = useAppContext(); > + > + // close any open panels on route change > + useEffect(() => { > +if (pathname !== previousPathname) { > + setSidebar(null); > +} > + }, [pathname, previousPathname, setSidebar]); > + >useOnEscapePressed(() => { > setSidebar(null); >}); > + >return ( > aria-hidden={!sidebar} > + aria-label={sidebar ? sidebarLabels[sidebar] : undefined} >className={classNames("l-aside is-maas-site-manager > u-padding-top--medium", { "is-collapsed": !sidebar })} >id="aside-panel" >role="dialog" > - {...props} > > > > -{children} > + > + {/* use context based on the route? */} > + {!!sidebar && sidebar === "createToken" ? ( Good catch, it's a leftover from previous implementations. Will update. > + > + ) : !!sidebar && sidebar === "removeRegions" ? ( > + > + ) : null} > + > > >); -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442736 Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main has been updated. Commit message changed to: set dynamic header height MAASENG-1609 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442849 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main has been updated. Description changed to: Adds DynamicTable component that sets a fixed height for the table body allowing it to be scrolled independently of the page. This ensures table header remains sticky regardless of the size of the content on the page. ## QA Steps Go to every page that contains a table Verify that the table header remains at the top on large screens Verify that the page is scrolled in full on mobile (without sticky table header) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442849 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main. Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442849 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:header-height-MAASENG-1609 into maas-site-manager:main. diff --git a/frontend/src/App.scss b/frontend/src/App.scss index cad8a9a..2c1dbd9 100644 --- a/frontend/src/App.scss +++ b/frontend/src/App.scss @@ -73,3 +73,4 @@ @import "@/components/base/TablePagination/TablePagination"; @import "@/components/base/PaginationBar/PaginationBar"; @import "@/components/base/TooltipButton/TooltipButton"; +@import "@/components/DynamicTable/DynamicTable"; diff --git a/frontend/src/_utils.scss b/frontend/src/_utils.scss index d82c0ab..cf65341 100644 --- a/frontend/src/_utils.scss +++ b/frontend/src/_utils.scss @@ -75,3 +75,4 @@ clip: rect(1px, 1px, 1px, 1px) !important; white-space: nowrap !important; } + diff --git a/frontend/src/components/DynamicTable/DynamicTable.test.tsx b/frontend/src/components/DynamicTable/DynamicTable.test.tsx new file mode 100644 index 000..5ff7851 --- /dev/null +++ b/frontend/src/components/DynamicTable/DynamicTable.test.tsx @@ -0,0 +1,37 @@ +import { render, fireEvent, waitFor } from "@testing-library/react"; + +import DynamicTable from "./DynamicTable"; + +import BREAKPOINTS from "@/base/breakpoints"; + +const offset = 100; + +beforeAll(() => { + // simulate top offset as JSDOM doesn't support getBoundingClientRect + // - equivalent of another element of height 100px being displayed above the table + vi.spyOn(window.HTMLElement.prototype, "getBoundingClientRect").mockReturnValue({ +bottom: 0, +height: 0, +left: 0, +right: 0, +top: offset, +width: 0, + } as DOMRect); +}); + +it("sets a fixed table body height based on top offset on large screens", async () => { + vi.spyOn(window, "innerWidth", "get").mockReturnValue(BREAKPOINTS.xSmall); + await fireEvent(window, new Event("resize")); + + const { container } = render(Test content); + // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access + const tbody = container.querySelector("tbody"); + fireEvent(window, new Event("resize")); + + // does not alter the height on small screens + expect(tbody).toHaveStyle("height: undefined"); + + vi.spyOn(window, "innerWidth", "get").mockReturnValue(BREAKPOINTS.large); + await fireEvent(window, new Event("resize")); + await waitFor(() => expect(tbody).toHaveStyle(`height: calc(100vh - ${offset + 1}px)`)); +}); diff --git a/frontend/src/components/DynamicTable/DynamicTable.tsx b/frontend/src/components/DynamicTable/DynamicTable.tsx new file mode 100644 index 000..b214fbf --- /dev/null +++ b/frontend/src/components/DynamicTable/DynamicTable.tsx @@ -0,0 +1,50 @@ +import type { PropsWithChildren, RefObject } from "react"; +import { useState, useEffect, useLayoutEffect } from "react"; + +import classNames from "classnames"; + +import BREAKPOINTS from "@/base/breakpoints"; + +const DynamicTable = ({ className, children }: PropsWithChildren<{ className?: string }>) => { + return {children}; +}; + +/** + * sets a fixed height for the table body + * allowing it to be scrolled independently of the page + */ +const DynamicTableBody = ({ className, children }: PropsWithChildren<{ className?: string }>) => { + const tableBodyRef: RefObject = useRef(null); + const [offset, setOffset] = useState(null); + + const handleResize = useCallback(() => { +if (window.innerWidth > BREAKPOINTS.small) { + const top = tableBodyRef.current?.getBoundingClientRect?.().top; + if (top) setOffset(top + 1); +} else { + setOffset(null); +} + }, []); + + useLayoutEffect(() => { +handleResize(); + }, [handleResize]); + + useEffect(() => { +window.addEventListener("resize", handleResize); +return () => window.removeEventListener("resize", handleResize); + }, [handleResize]); + + return ( + + {children} + + ); +}; +DynamicTable.Body = DynamicTableBody; + +export default DynamicTable; diff --git a/frontend/src/components/DynamicTable/_DynamicTable.scss b/frontend/src/components/DynamicTable/_DynamicTable.scss new file mode 100644 index 000..9b60ac2 --- /dev/null +++ b/frontend/src/components/DynamicTable/_DynamicTable.scss @@ -0,0 +1,23 @@ +.p-table--dynamic { + margin-bottom: 0; + + + thead, tbody { +display: block; +overflow-x: hidden; +overflow-y: auto; +scrollbar-gutter: stable; +} + + tbo
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442634 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~jonesogolo/maas-site-manager:1548-enrolment-tokens-export-action into maas-site-manager:main
A quick note on `useTokensExportQuery` - I'm not sure react query will be the right solution for handling file downloads. In case you're having issues with it, might make sense to use axios directly. -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442741 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1548-enrolment-tokens-export-action into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~jonesogolo/maas-site-manager:1548-enrolment-tokens-export-action into maas-site-manager:main
I'd suggest adding a static csv file to src/mocks instead of trying to generate it manually. In the mock service worker you'll most likely want to use binary response type https://mswjs.io/docs/recipes/binary-response-type You'd also need to add header for the response to be handled correctly by the browser, e.g.: ctx.set('Content-Type', 'text/csv') ctx.set('Content-Disposition', 'attachment; filename="tokens.csv') -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442741 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1548-enrolment-tokens-export-action into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-total_machines-key into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:add-total_machines-key into maas-site-manager:main. Commit message: add total_machines key Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442742 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:add-total_machines-key into maas-site-manager:main. diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index 248c6ac..1c6dd36 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -8,6 +8,7 @@ export type Stats = { deployed_machines: number; ready_machines: number; error_machines: number; + total_machines: number; last_seen: string; // connection: "stable" | "lost" | "unknown"; }; diff --git a/frontend/src/components/SitesList/SitesTable/AggregatedStatus/AggregatedStatus.tsx b/frontend/src/components/SitesList/SitesTable/AggregatedStatus/AggregatedStatus.tsx index 6cc474b..dd9eb15 100644 --- a/frontend/src/components/SitesList/SitesTable/AggregatedStatus/AggregatedStatus.tsx +++ b/frontend/src/components/SitesList/SitesTable/AggregatedStatus/AggregatedStatus.tsx @@ -1,10 +1,9 @@ import type { Stats } from "@/api/types"; import Meter, { color } from "@/components/Meter"; import Popover from "@/components/Popover/Popover"; -import { getAllMachines } from "@/utils"; const AggregatedStatus = ({ stats }: { stats: Stats }) => { - const { deployed_machines, allocated_machines, ready_machines, error_machines } = stats; + const { deployed_machines, allocated_machines, ready_machines, error_machines, total_machines } = stats; return ( <> @@ -51,7 +50,7 @@ const AggregatedStatus = ({ stats }: { stats: Stats }) => { { color: color.link, value: allocated_machines }, { color: color.linkFaded, value: ready_machines }, ]} -label={`${deployed_machines} of ${getAllMachines(stats)} deployed`} +label={`${deployed_machines} of ${total_machines} deployed`} labelClassName="u-text--muted" small /> diff --git a/frontend/src/components/SitesList/SitesTable/SitesTable.tsx b/frontend/src/components/SitesList/SitesTable/SitesTable.tsx index f368905..6045ccf 100644 --- a/frontend/src/components/SitesList/SitesTable/SitesTable.tsx +++ b/frontend/src/components/SitesList/SitesTable/SitesTable.tsx @@ -21,7 +21,7 @@ import TooltipButton from "@/components/base/TooltipButton/TooltipButton"; import { isDev } from "@/constants"; import { useAppContext } from "@/context"; import type { UseSitesQueryResult } from "@/hooks/react-query"; -import { getAllMachines, getCountryName, getTimezoneUTCString, getTimeInTimezone } from "@/utils"; +import { getCountryName, getTimezoneUTCString, getTimeInTimezone } from "@/utils"; const createAccessor = (keys: K[] | K) => @@ -173,7 +173,7 @@ const SitesTable = ({ ), cell: ({ getValue }) => { const { stats } = getValue(); - return stats ? getAllMachines(stats) : null; + return stats ? stats.total_machines : null; }, }, { diff --git a/frontend/src/mocks/factories.ts b/frontend/src/mocks/factories.ts index 741be81..c23383e 100644 --- a/frontend/src/mocks/factories.ts +++ b/frontend/src/mocks/factories.ts @@ -10,11 +10,15 @@ export const connections: Stats["connection"][] = ["stable", "lost", "unknown"]; export const statsFactory = Factory.define(({ sequence }) => { const chance = new Chance(`maas-${sequence}`); const now = new Date(); - return { + const machines = { deployed_machines: chance.integer({ min: 0, max: 500 }), allocated_machines: chance.integer({ min: 0, max: 500 }), ready_machines: chance.integer({ min: 0, max: 500 }), error_machines: chance.integer({ min: 0, max: 500 }), + }; + return { +...machines, +total_machines: Object.values(machines).reduce((acc, val) => acc + val, 0), last_seen: new Date(chance.date({ min: sub(now, { minutes: 15 }), max: now })).toISOString(), connection: connectionFactory.build(), }; diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts index 5e3be93..dc47165 100644 --- a/frontend/src/utils.ts +++ b/frontend/src/utils.ts @@ -74,8 +74,3 @@ export const copyToClipboard = (text: string, callback?: (text: string) => void) Sentry.captureException(new Error("copy to clipboard failed", { cause: error })); }); }; - -export const getAllMachines = (stats: Stats) => { - if (!stats) return null; - return stats.deployed_machines + stats.allocated_machines + stats.ready_machines + stats.error_machines; -}; -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main
> A little bit og the message is still cut off on the tokens page and the bottom > border also goes hidden when the error message is displayed, screenshot below > https://imgur.com/a/MADpezy This is due to the use of fixed height on this page, which will be addressed in https://warthogs.atlassian.net/browse/MAASENG-1609 If there are no other problems with this MP this should be good to merge. Could you look again please. -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442634 Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main. Commit message: separate context for different views MAASENG-1549 - extract RowSelectionContextProviders - move app context consumer logic to Aside Requested reviews: MAAS Lander (maas-lander) MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442736 QA Steps Verify that selection of table items for all tables (sites, requests, tokens) works correctly and selection is cleared on route change -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1bfb4ba..fead2d5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,8 @@ import "./App.scss"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { RowSelectionContextProviders } from "./context/RowSelectionContext"; + import apiClient from "@/api"; import { AppContextProvider, AuthContextProvider } from "@/context"; import { createBrowserRouter, RouterProvider } from "@/router"; @@ -14,7 +16,9 @@ const App: React.FC = () => { - + + + diff --git a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx index ed4f073..25f3361 100644 --- a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx +++ b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx @@ -2,11 +2,11 @@ import { Button, Notification } from "@canonical/react-components"; import EnrollmentNotification from "./EnrollmentNotification"; -import { useAppContext } from "@/context"; +import { useRowSelectionContext } from "@/context/RowSelectionContext"; import { useEnrollmentRequestsMutation } from "@/hooks/react-query"; const EnrollmentActions: React.FC = () => { - const { rowSelection, setRowSelection } = useAppContext(); + const { rowSelection, setRowSelection } = useRowSelectionContext("requests"); const selectedIds = Object.keys(rowSelection).map((id) => id); const enrollmentRequestsMutation = useEnrollmentRequestsMutation({ onSuccess: () => setRowSelection({}) }); const isActionDisabled = Object.keys(rowSelection).length === 0 || enrollmentRequestsMutation.isLoading; diff --git a/frontend/src/components/MainLayout/MainLayout.tsx b/frontend/src/components/MainLayout/MainLayout.tsx index 9be3fca..3fe61c0 100644 --- a/frontend/src/components/MainLayout/MainLayout.tsx +++ b/frontend/src/components/MainLayout/MainLayout.tsx @@ -1,4 +1,3 @@ -import type { PropsWithChildren } from "react"; import { useEffect } from "react"; import { Col, Row, useOnEscapePressed, usePrevious } from "@canonical/react-components"; @@ -19,21 +18,39 @@ export const sidebarLabels: Record<"removeRegions" | "createToken", string> = { createToken: "Generate tokens", }; -type AsideProps = PropsWithChildren, "sidebar" | "setSidebar">>; -const Aside = ({ children, sidebar, setSidebar, ...props }: AsideProps) => { +const Aside = () => { + const { pathname } = useLocation(); + const previousPathname = usePrevious(pathname); + const { sidebar, setSidebar } = useAppContext(); + + // close any open panels on route change + useEffect(() => { +if (pathname !== previousPathname) { + setSidebar(null); +} + }, [pathname, previousPathname, setSidebar]); + useOnEscapePressed(() => { setSidebar(null); }); + return ( -{children} + + {/* use context based on the route? */} + {!!sidebar && sidebar === "createToken" ? ( + + ) : !!sidebar && sidebar === "removeRegions" ? ( + + ) : null} + ); @@ -45,48 +62,29 @@ const getPageTitle = (pathname: RoutePath) => { }; const MainLayout: React.FC = () => { - const { sidebar, setSidebar } = useAppContext(); const { pathname } = useLocation(); - const previousPathname = usePrevious(pathname); const { status } = useAuthContext(); const isLoggedIn = status === "authenticated"; - - // close any open panels on route change - useEffect(() => { -if (pathname !== previousPathname) { - setSidebar(null); -} - }, [pathname, previousPathname, setSidebar]); - const isSideNavVisible = matchPath("/settings/
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:polling-frequency-value-MAASENG-1545 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:polling-frequency-value-MAASENG-1545 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442647 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442721 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main has been updated. Status: Needs review => Work in progress For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442736 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442646 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main. Commit message: separate context for different views MAASENG-1549 - extract RowSelectionContextProviders - move app context consumer logic to Aside 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/442736 QA Steps Verify that selection of table items for all tables (sites, requests, tokens) works correctly and selection is cleared on route change -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:separate-context-providers-for-different-views-MAASENG-1549 into maas-site-manager:main. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1bfb4ba..fead2d5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,8 @@ import "./App.scss"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { RowSelectionContextProviders } from "./context/RowSelectionContext"; + import apiClient from "@/api"; import { AppContextProvider, AuthContextProvider } from "@/context"; import { createBrowserRouter, RouterProvider } from "@/router"; @@ -14,7 +16,9 @@ const App: React.FC = () => { - + + + diff --git a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx index ed4f073..25f3361 100644 --- a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx +++ b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx @@ -2,11 +2,11 @@ import { Button, Notification } from "@canonical/react-components"; import EnrollmentNotification from "./EnrollmentNotification"; -import { useAppContext } from "@/context"; +import { useRowSelectionContext } from "@/context/RowSelectionContext"; import { useEnrollmentRequestsMutation } from "@/hooks/react-query"; const EnrollmentActions: React.FC = () => { - const { rowSelection, setRowSelection } = useAppContext(); + const { rowSelection, setRowSelection } = useRowSelectionContext("requests"); const selectedIds = Object.keys(rowSelection).map((id) => id); const enrollmentRequestsMutation = useEnrollmentRequestsMutation({ onSuccess: () => setRowSelection({}) }); const isActionDisabled = Object.keys(rowSelection).length === 0 || enrollmentRequestsMutation.isLoading; diff --git a/frontend/src/components/MainLayout/MainLayout.tsx b/frontend/src/components/MainLayout/MainLayout.tsx index 9be3fca..3fe61c0 100644 --- a/frontend/src/components/MainLayout/MainLayout.tsx +++ b/frontend/src/components/MainLayout/MainLayout.tsx @@ -1,4 +1,3 @@ -import type { PropsWithChildren } from "react"; import { useEffect } from "react"; import { Col, Row, useOnEscapePressed, usePrevious } from "@canonical/react-components"; @@ -19,21 +18,39 @@ export const sidebarLabels: Record<"removeRegions" | "createToken", string> = { createToken: "Generate tokens", }; -type AsideProps = PropsWithChildren, "sidebar" | "setSidebar">>; -const Aside = ({ children, sidebar, setSidebar, ...props }: AsideProps) => { +const Aside = () => { + const { pathname } = useLocation(); + const previousPathname = usePrevious(pathname); + const { sidebar, setSidebar } = useAppContext(); + + // close any open panels on route change + useEffect(() => { +if (pathname !== previousPathname) { + setSidebar(null); +} + }, [pathname, previousPathname, setSidebar]); + useOnEscapePressed(() => { setSidebar(null); }); + return ( -{children} + + {/* use context based on the route? */} + {!!sidebar && sidebar === "createToken" ? ( + + ) : !!sidebar && sidebar === "removeRegions" ? ( + + ) : null} + ); @@ -45,48 +62,29 @@ const getPageTitle = (pathname: RoutePath) => { }; const MainLayout: React.FC = () => { - const { sidebar, setSidebar } = useAppContext(); const { pathname } = useLocation(); - const previousPathname = usePrevious(pathname); const { status } = useAuthContext(); const isLoggedIn = status === "authenticated"; - - // close any open panels on route change - useEffect(() => { -if (pathname !== previousPathname) { - setSidebar(null); -} - }, [pathname, previousPathname, setSidebar]); - const isSideNavVisible = matchPath("/settings/
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main has been updated. Description changed to: QA Steps Go to /settings/requests Select a few requests Press Accept or Deny Verify the correct API call has been made using POST method For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442721 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main. Commit message: use POST method for requests MAASENG-1676 Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442721 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:MAASENG-1676-requests-endpoint-POST-method into maas-site-manager:main. diff --git a/frontend/src/api/handlers.test.ts b/frontend/src/api/handlers.test.ts index c03cbc3..6215bbe 100644 --- a/frontend/src/api/handlers.test.ts +++ b/frontend/src/api/handlers.test.ts @@ -1,11 +1,11 @@ import { setupServer } from "msw/node"; -import { patchEnrollmentRequests, postTokens } from "./handlers"; +import { postEnrollmentRequests, postTokens } from "./handlers"; import { durationFactory } from "@/mocks/factories"; import { postTokens as postTokensResolver, - patchEnrollmentRequests as postEnrollmentRequestsResolver, + postEnrollmentRequests as postEnrollmentRequestsResolver, } from "@/mocks/resolvers"; const mockServer = setupServer(postTokensResolver, postEnrollmentRequestsResolver); @@ -35,8 +35,8 @@ describe("postTokens handler", () => { describe("postEnrollmentRequests handler", () => { it("requires ids and accept values", async () => { // @ts-expect-error -await expect(patchEnrollmentRequests({})).rejects.toThrowError(); -await expect(patchEnrollmentRequests({ ids: [], accept: false })).resolves.toEqual(""); -await expect(patchEnrollmentRequests({ ids: [], accept: true })).resolves.toEqual(""); +await expect(postEnrollmentRequests({})).rejects.toThrowError(); +await expect(postEnrollmentRequests({ ids: [], accept: false })).resolves.toEqual(""); +await expect(postEnrollmentRequests({ ids: [], accept: true })).resolves.toEqual(""); }); }); diff --git a/frontend/src/api/handlers.ts b/frontend/src/api/handlers.ts index 70d4775..8f23c6b 100644 --- a/frontend/src/api/handlers.ts +++ b/frontend/src/api/handlers.ts @@ -100,12 +100,12 @@ export type PostEnrollmentRequestsData = { ids: string[]; accept: boolean; }; -export const patchEnrollmentRequests = async (data: PostEnrollmentRequestsData) => { +export const postEnrollmentRequests = async (data: PostEnrollmentRequestsData) => { if (!data?.ids || typeof data?.accept !== "boolean") { throw Error("Missing required fields"); } try { -const response = await api.patch(urls.enrollmentRequests, data); +const response = await api.post(urls.enrollmentRequests, data); return response.data; } catch (error) { throw error; diff --git a/frontend/src/components/RequestsList/RequestsList.test.tsx b/frontend/src/components/RequestsList/RequestsList.test.tsx index 25b150d..9bd6364 100644 --- a/frontend/src/components/RequestsList/RequestsList.test.tsx +++ b/frontend/src/components/RequestsList/RequestsList.test.tsx @@ -5,7 +5,7 @@ import RequestsList from "./RequestsList"; import urls from "@/api/urls"; import { enrollmentRequestFactory } from "@/mocks/factories"; -import { createMockGetEnrollmentRequestsResolver, patchEnrollmentRequests } from "@/mocks/resolvers"; +import { createMockGetEnrollmentRequestsResolver, postEnrollmentRequests } from "@/mocks/resolvers"; import { renderWithMemoryRouter, screen, userEvent, waitFor } from "@/test-utils"; const enrollmentRequest = enrollmentRequestFactory.build({ name: "new-maas-site" }); @@ -13,7 +13,7 @@ const enrollmentRequests = [enrollmentRequest, ...enrollmentRequestFactory.build const mockServer = setupServer( rest.get(urls.enrollmentRequests, createMockGetEnrollmentRequestsResolver(enrollmentRequests)), - patchEnrollmentRequests, + postEnrollmentRequests, ); beforeAll(() => { diff --git a/frontend/src/hooks/react-query.ts b/frontend/src/hooks/react-query.ts index 8636f61..3128959 100644 --- a/frontend/src/hooks/react-query.ts +++ b/frontend/src/hooks/react-query.ts @@ -12,7 +12,7 @@ import type { import { deleteTokens, postLogin, - patchEnrollmentRequests, + postEnrollmentRequests, getEnrollmentRequests, postTokens, getSites, @@ -104,7 +104,7 @@ export const useEnrollmentRequestsMutation = ( options: UseMutationOptions, ) => { const queryClient = useQueryClient(); - return useMutation(patchEnrollmentRequests, { + return useMutation(postEnrollmentRequests, { onSuccess: (...args) => { queryClient.invalidateQueries({ queryKey: ["requests"] }); options?.onSuccess?.(...args); diff --git a/frontend/src/mocks/browser.ts b/frontend/src/mocks/browser.ts inde
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:polling-frequency-value-MAASENG-1545 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:polling-frequency-value-MAASENG-1545 into maas-site-manager:main with ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 as a prerequisite. Commit message: set polling frequency value MAASENG-1545 Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442647 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:polling-frequency-value-MAASENG-1545 into maas-site-manager:main. diff --git a/.env b/.env index 7c416c2..e62b786 100644 --- a/.env +++ b/.env @@ -1,5 +1,6 @@ VITE_UI_PORT=8405 VITE_API_URL=http://localhost:8000 VITE_SENTRY_DSN="https://7236de0eb0354e2099b7efd7d310a...@sentry.is.canonical.com/60"; +VITE_POLLING_INTERVAL_MS=3 SECRET_KEY="09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" # XXX: Replace this, and all affected data, in actual release! using something like `openssl rand -hex 32` \ No newline at end of file diff --git a/frontend/src/hooks/react-query.ts b/frontend/src/hooks/react-query.ts index 8636f61..f466533 100644 --- a/frontend/src/hooks/react-query.ts +++ b/frontend/src/hooks/react-query.ts @@ -29,14 +29,13 @@ import type { export type UseSitesQueryResult = ReturnType; -// 30 seconds -const defaultRefetchInterval = 30 * 1000; +const refetchInterval = Number(import.meta.env.VITE_POLLING_INTERVAL_MS); export const useSitesQuery = ({ page, size }: GetSitesQueryParams, queryText?: string) => useQuery({ queryKey: ["sites", page, size, queryText], queryFn: () => getSites({ page, size }, queryText), keepPreviousData: true, -refetchInterval: defaultRefetchInterval, +refetchInterval, }); // return single site data from query cache @@ -89,7 +88,7 @@ export const useRequestsQuery = ({ page, size }: GetEnrollmentRequestsQueryParam queryKey: ["requests", page, size], queryFn: () => getEnrollmentRequests({ page, size }), keepPreviousData: true, -refetchInterval: defaultRefetchInterval, +refetchInterval, }); export const useRequestsCountQuery = () => @@ -97,7 +96,7 @@ export const useRequestsCountQuery = () => queryKey: ["requests", "1", "1"], queryFn: () => getEnrollmentRequests({ page: "1", size: "1" }), keepPreviousData: true, -refetchInterval: defaultRefetchInterval, +refetchInterval, }); export const useEnrollmentRequestsMutation = ( -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 into maas-site-manager:main. Commit message: display request errors - add vanilla animation utilities - update TableCaption width on mobile - rely on automatic Sentry error capturing instead of manual captureException - remove redundant isFetchedAfterMount Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442646 # QA Steps Edit `resolvers.ts` file by replacing lines `46`, `62`,`72` with `return res(ctx.status(400));` Go to /sites Verify that the error message (after a number of retries) has been displayed Go to /settings/tokens Verify that the error message (after a number of retries) has been displayed Go to /settings/requests Verify that the error message (after a number of retries) has been displayed # Screenshots https://share.cleanshot.com/SVdcb51c -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:display-request-errors-MAASENG-1629 into maas-site-manager:main. diff --git a/frontend/src/App.scss b/frontend/src/App.scss index b904532..cad8a9a 100644 --- a/frontend/src/App.scss +++ b/frontend/src/App.scss @@ -45,6 +45,7 @@ @include vf-u-align; @include vf-u-margin-collapse; @include vf-u-show; +@include vf-u-animations; // layout @include vf-l-application; diff --git a/frontend/src/api/handlers.ts b/frontend/src/api/handlers.ts index 70d4775..3b5c995 100644 --- a/frontend/src/api/handlers.ts +++ b/frontend/src/api/handlers.ts @@ -1,5 +1,3 @@ -import * as Sentry from "@sentry/browser"; - import api from "./api"; import type { Token } from "./types"; import urls from "./urls"; @@ -44,7 +42,7 @@ export const getSites = async (params: GetSitesQueryParams, queryText?: string) }); return response.data; } catch (error) { -Sentry.captureException(new Error("getSites failed", { cause: error })); +throw error; } }; @@ -71,7 +69,7 @@ export const getTokens = async (params: GetTokensQueryParams) => { const response = await api.get(urls.tokens, { params }); return response.data; } catch (error) { -Sentry.captureException(new Error("getTokens failed", { cause: error })); +throw error; } }; @@ -92,7 +90,7 @@ export const getEnrollmentRequests = async (params: GetEnrollmentRequestsQueryPa const response = await api.get(urls.enrollmentRequests, { params }); return response.data; } catch (error) { -Sentry.captureException(new Error("getEnrollmentRequests failed", { cause: error })); +throw error; } }; diff --git a/frontend/src/components/ErrorMessage/ErrorMessage.test.tsx b/frontend/src/components/ErrorMessage/ErrorMessage.test.tsx new file mode 100644 index 000..6900e42 --- /dev/null +++ b/frontend/src/components/ErrorMessage/ErrorMessage.test.tsx @@ -0,0 +1,20 @@ +import { render, screen } from "@testing-library/react"; + +import ErrorMessage from "./ErrorMessage"; + +it("renders the error message if error is an instance of Error", () => { + const testError = new Error("Test error message"); + render(); + expect(screen.getByText("Test error message")).toBeInTheDocument(); +}); + +it("renders provided error string", () => { + const error = "This is a string error"; + render(); + expect(screen.getByText("This is a string error")).toBeInTheDocument(); +}); + +it("renders a default error message if no error is provided", () => { + render(); + expect(screen.getByText("An unknown error has occured")).toBeInTheDocument(); +}); diff --git a/frontend/src/components/ErrorMessage/ErrorMessage.tsx b/frontend/src/components/ErrorMessage/ErrorMessage.tsx new file mode 100644 index 000..6f99272 --- /dev/null +++ b/frontend/src/components/ErrorMessage/ErrorMessage.tsx @@ -0,0 +1,5 @@ +const ErrorMessage = ({ error }: { error: unknown }) => ( + <>{error instanceof Error ? error.message : typeof error === "string" ? error : "An unknown error has occured"} +); + +export default ErrorMessage; diff --git a/frontend/src/components/ErrorMessage/index.ts b/frontend/src/components/ErrorMessage/index.ts new file mode 100644 index 000..3b2ac0c --- /dev/null +++ b/frontend/src/components/ErrorMessage/index.ts @@ -0,0 +1 @@ +export { default } from "./ErrorMessage"; diff --git a/frontend/src/components/RequestsList/RequestsList.tsx b/frontend/src/components/RequestsList/RequestsList.tsx index c3a3e8c..c86f595 100644 --- a/frontend/src/components/RequestsList/RequestsList.tsx +++ b/frontend/src/components/RequestsList/RequestsList.tsx @@ -13,7 +13,7 @@ const Requests: React.FC = () => { const [totalDataCount, setTotalDataCount] = u
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main has been updated. Description changed to: QA Steps Enter an invalid value into current page input field Verify that the error message is displayed correctly Screenshots https://share.cleanshot.com/HJr44gxG For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442634 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main. Commit message: fix: validation message cutoff MAASENG-1611 Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442634 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-validation-message-cutoff-MAASENG-1611 into maas-site-manager:main. diff --git a/frontend/src/components/base/PaginationBar/PaginationBar.tsx b/frontend/src/components/base/PaginationBar/PaginationBar.tsx index 0c1eefe..69d8bb4 100644 --- a/frontend/src/components/base/PaginationBar/PaginationBar.tsx +++ b/frontend/src/components/base/PaginationBar/PaginationBar.tsx @@ -49,28 +49,30 @@ const PaginationBar = ({ return ( - -Showing {getDisplayedDataCount()} out of {totalItems} {dataContext} - + + + Showing {getDisplayedDataCount()} out of {totalItems} {dataContext} + - - + + - + + ); diff --git a/frontend/src/components/base/PaginationBar/_PaginationBar.scss b/frontend/src/components/base/PaginationBar/_PaginationBar.scss index 7ee6678..4227570 100644 --- a/frontend/src/components/base/PaginationBar/_PaginationBar.scss +++ b/frontend/src/components/base/PaginationBar/_PaginationBar.scss @@ -5,6 +5,14 @@ padding: $spv--small 0; margin-bottom: $spv--large; + .p-form--inline { + width: 100%; + } + + label { +margin-bottom: 0; + } + .pagination-bar__description { margin: 0; padding: 0; @@ -12,6 +20,8 @@ .pagination-bar__right { width: 100%; +margin-left: auto; +margin-right: 0; @media screen and (min-width: $breakpoint-small) { width: auto; diff --git a/frontend/src/components/base/TablePagination/TablePagination.tsx b/frontend/src/components/base/TablePagination/TablePagination.tsx index b5887f1..ce8d599 100644 --- a/frontend/src/components/base/TablePagination/TablePagination.tsx +++ b/frontend/src/components/base/TablePagination/TablePagination.tsx @@ -70,7 +70,9 @@ const TablePagination = ({ > - Page + +Page + - of {totalPages} + + of {totalPages} + -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~jonesogolo/maas-site-manager:1602-display-token-delete-failure-msg into maas-site-manager:main
I noticed you placed tests in TokensListDelete.test.tsx but there is no component file named TokensListDelete.tsx. Let's follow our convention and place tests in the file related to the component it's testing (TokensList.tsx, TokensList.test.tsx). -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442449 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1602-display-token-delete-failure-msg into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~jonesogolo/maas-site-manager:1602-display-token-delete-failure-msg into maas-site-manager:main
Instead of mocking useDeleteTokensMutation it would be better to return an error from mock service worker handler for that particular endpoint. Diff comments: > diff --git a/frontend/src/components/TokensList/TokensListDelete.test.tsx > b/frontend/src/components/TokensList/TokensListDelete.test.tsx > new file mode 100644 > index 000..44e5116 > --- /dev/null > +++ b/frontend/src/components/TokensList/TokensListDelete.test.tsx > @@ -0,0 +1,53 @@ > +import { rest } from "msw"; > +import { setupServer } from "msw/node"; > + > +import TokensList from "./TokensList"; > + > +import urls from "@/api/urls"; > +import type * as apiHooks from "@/hooks/react-query"; > +import { tokenFactory } from "@/mocks/factories"; > +import { createMockGetTokensResolver } from "@/mocks/resolvers"; > +import { screen, renderWithMemoryRouter, userEvent } from "@/test-utils"; > + > +const tokens = tokenFactory.buildList(2); > +const tokensDeleteMock = vi.fn(); > +const errorMsg = "Unable to delete tokens"; > + > +const mockServer = setupServer(rest.get(urls.tokens, > createMockGetTokensResolver(tokens))); > + > +beforeAll(() => { > + mockServer.listen(); > +}); > + > +afterEach(() => { > + mockServer.resetHandlers(); > +}); > + > +afterAll(() => { > + mockServer.close(); > +}); > + > +describe("delete errors", () => { > + it("displays an error notification when delete fails", async () => { > +vi.mock("@/hooks/react-query", async (importOriginal) => { Instead of mocking useDeleteTokensMutation it would be better to return an error from mock service worker handler for that particular endpoint. > + const original: typeof apiHooks = await importOriginal(); > + return { > +...original, > +useDeleteTokensMutation: () => ({ mutate: tokensDeleteMock, isError: > true, error: new Error(errorMsg) }), > + }; > +}); > + > +renderWithMemoryRouter(); > +const checkboxes = screen.getAllByRole("checkbox"); > +await userEvent.click(checkboxes[1]); > +await userEvent.click(checkboxes[2]); > +await userEvent.click(screen.getByRole("button", { name: /delete/i })); > + > +expect( > + screen.getByRole("heading", { > +name: /error/i, > + }), > +).toBeInTheDocument(); > +expect(screen.getByText(new RegExp(errorMsg, "i"))).toBeInTheDocument(); > + }); > +}); -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442449 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1602-display-token-delete-failure-msg into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442286 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var into maas-site-manager:main. Commit message: add VITE_USE_MOCK_DATA env var Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442286 QA Steps - follow readme instructions and make sure mock server is enabled by default and you can disable it by following instructions to run local backend -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:add-VITE_USE_MOCK_DATA-env-var into maas-site-manager:main. diff --git a/.env b/.env index 8822115..7c416c2 100644 --- a/.env +++ b/.env @@ -1,6 +1,5 @@ VITE_UI_PORT=8405 VITE_API_URL=http://localhost:8000 VITE_SENTRY_DSN="https://7236de0eb0354e2099b7efd7d310a...@sentry.is.canonical.com/60"; - SECRET_KEY="09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7" # XXX: Replace this, and all affected data, in actual release! using something like `openssl rand -hex 32` \ No newline at end of file diff --git a/.env.development b/.env.development new file mode 100644 index 000..9bbcc67 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VITE_USE_MOCK_DATA=true \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 000..f8679f9 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_USE_MOCK_DATA=false \ No newline at end of file diff --git a/frontend/README.md b/frontend/README.md index d513d9c..78fde6d 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -4,36 +4,24 @@ This is the frontend for the [MAAS Site Manager Project](https://launchpad.net/m ## How to run a development environment -First start the backend +The quickest way to get started is run frontend with mock backend which is enabled by default. ```bash -$LP_USERNAME=your-username -sudo apt-get install tox - -git clone https://code.launchpad.net/~maas-committers/maas-site-manager/+git/site-manager - -cd site-manager - -docker run --rm -it \ --p 5432:5432 \ --e POSTGRES_PASSWORD=pass \ ---name postgres \ -postgres:14 - -tox -e run +yarn dev ``` -Then run this frontend +### Using a local backend + +Setup local environment variables ```bash -git clone https://code.launchpad.net/~maas-committers/maas-site-manager/+git/site-manager-frontend -cd site-manager-frontend +cp .env.development .env.local.development +``` -# TODO, possibly edit an env/config file to point to a local backend +Set `VITE_USE_MOCK_DATA` to `false` in `.env.local.development`. -yarn # install dependencies -yarn run dev -``` +Start the backend +[MAAS Site Manager Backend Readme](/backend/README.md). ## Project conventions diff --git a/frontend/src/constants.ts b/frontend/src/constants.ts index f793ce5..99b7c2a 100644 --- a/frontend/src/constants.ts +++ b/frontend/src/constants.ts @@ -1 +1,2 @@ -export const isDev = process.env.NODE_ENV === "development"; +export const isDev = import.meta.env.DEV; +export const useMockData = import.meta.env.VITE_USE_MOCK_DATA === "true"; diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index d10c7e9..e65a61b 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -6,10 +6,10 @@ import * as ReactDOM from "react-dom/client"; import packageInfo from "../package.json"; import App from "./App"; -import { isDev } from "./constants"; +import { useMockData } from "./constants"; /* c8 ignore next 4 */ -if (isDev) { +if (useMockData) { const { worker } = await import("./mocks/browser"); await worker.start(); } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 43be29c..ad48ac2 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -12,6 +12,7 @@ const commitHash = require("child_process").execSync("git rev-parse --short HEAD // https://vitejs.dev/config/ export default defineConfig({ + envDir: "../", define: { "import.meta.env.VITE_APP_VERSION": JSON.stringify(commitHash) }, plugins: [ react(), -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main
Review: Approve -- https://code.launchpad.net/~nickdv99/maas-site-manager/+git/site-manager/+merge/442192 Your team MAAS Committers is requested to review the proposed merge of ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main
Diff comments: > diff --git > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > b/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > index 2dd28ec..1793d8e 100644 > --- > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > +++ > b/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > @@ -3,6 +3,22 @@ >th { > vertical-align: middle; >} > + > + thead th { > +position: sticky; > +top: -0.75rem; > +background-color: white; > +z-index: 1; > +padding-top: $spv--large; > + > +@media only screen and (min-width: $breakpoint-small){ > + top: calc($header-height-medium - 0.75rem); You seem to have missed $spv--medium in a few places. > +} > + > +@media only screen and (min-width: $breakpoint-large) { > + top: calc($header-height-large - 0.75rem); > +} > + } > >thead th:first-child { > width: 3rem; -- https://code.launchpad.net/~nickdv99/maas-site-manager/+git/site-manager/+merge/442192 Your team MAAS Committers is requested to review the proposed merge of ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/TokensList/_TokensList.scss > b/frontend/src/components/TokensList/_TokensList.scss > index 3171cbd..cf0fca6 100644 > --- a/frontend/src/components/TokensList/_TokensList.scss > +++ b/frontend/src/components/TokensList/_TokensList.scss > @@ -1,9 +1,46 @@ > +$header-height-medium: 34.6875rem; > +$header-height-large: 23.4375rem; > +$instructions-height-medium: 10.9375rem; Thanks for updating. I created a follow up JIRA issue for this: https://warthogs.atlassian.net/browse/MAASENG-1609 > + > .tokens-list-header { > + display: grid; > + >@media only screen and (min-width: $breakpoint-small) { > +height: $header-height-medium; > position: sticky; > top: -0.75rem; > background-color: white; > z-index: 1; > padding-top: 0.75rem; >} > + > + @media only screen and (min-width: $breakpoint-large) { > +height: $header-height-large; > + } > + > + .tokens-list-certificate { > +display: grid; > +width: 100%; > +grid-template-columns: 1fr 1fr; > +grid-gap: $spv--small; > +overflow-x: auto; > +white-space: nowrap; > +margin-bottom: $spv--large * 2; > + > +@media only screen and (min-width: $breakpoint-large) { > + width: fit-content; > +} > + } > + > + .tokens-list-instructions { > +height: $instructions-height-medium; > + > +@media only screen and (min-width: $breakpoint-large) { > + height: auto; > +} > + } > + > + .pagination-bar { > +margin-bottom: 0; > + } > } > diff --git > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > b/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > index 2dd28ec..208e9f1 100644 > --- > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > +++ > b/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > @@ -1,4 +1,20 @@ > .tokens-table { > + thead th { > +position: sticky; > +top: -0.75rem; Please use $spv--medium variable > +background-color: white; > +z-index: 1; > +padding-top: $spv--large; > + > +@media only screen and (min-width: $breakpoint-small){ > + top: calc($header-height-medium - 0.75rem); > +} > + > +@media only screen and (min-width: $breakpoint-large) { > + top: calc($header-height-large - 0.75rem); > +} > + } > + >td, >th { > vertical-align: middle; -- https://code.launchpad.net/~nickdv99/maas-site-manager/+git/site-manager/+merge/442192 Your team MAAS Committers is requested to review the proposed merge of ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:enable-stylelint. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main has been updated. Description changed to: QA Steps Go to /settings/requests Inspect the pagination input component Verify that the expected browser prefix is present (-moz-appearance) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:enable-stylelint. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
Diff comments: > diff --git > a/frontend/src/components/base/TablePagination/_TablePagination.scss > b/frontend/src/components/base/TablePagination/_TablePagination.scss > index c663d8f..3c96af4 100644 > --- a/frontend/src/components/base/TablePagination/_TablePagination.scss > +++ b/frontend/src/components/base/TablePagination/_TablePagination.scss > @@ -34,16 +35,16 @@ > } > > // Remove input arrows > + > /* Chrome, Safari, Edge, Opera */ > input::-webkit-outer-spin-button, > input::-webkit-inner-spin-button { > - -webkit-appearance: none; You are correct, but this should be handled by an autoprefixer. It's not enabled by default in vite, will add to this MP. > + appearance: none; >margin: 0; > } > > /* Firefox */ > input[type="number"] { > - -moz-appearance: textfield; >appearance: textfield; > } > -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:enable-stylelint. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/_settings.scss b/frontend/src/_settings.scss > index 0588138..bdcb88c 100644 > --- a/frontend/src/_settings.scss > +++ b/frontend/src/_settings.scss > @@ -2,11 +2,9 @@ > > // Vanilla settings: > $grid-max-width: math.div(1920, 16) * 1rem; > - > $breakpoint-xx-large: 1920px; > $side-navigation-z-index: 103; > +/* stylelint-disable-next-line scss/dollar-variable-pattern */ https://github.com/canonical/vanilla-framework/blob/c4819c46b5eaaf70b849230ec696a658c526697d/scss/_layouts_application.scss#L8 > $application-layout--breakpoint-side-nav-expanded: $breakpoint-xx-large; > - > $increase-font-size-on-larger-screens: false; > - > $assets-path: "/assets/fonts/"; -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/_settings.scss b/frontend/src/_settings.scss > index 0588138..bdcb88c 100644 > --- a/frontend/src/_settings.scss > +++ b/frontend/src/_settings.scss > @@ -2,11 +2,9 @@ > > // Vanilla settings: > $grid-max-width: math.div(1920, 16) * 1rem; > - > $breakpoint-xx-large: 1920px; > $side-navigation-z-index: 103; > +/* stylelint-disable-next-line scss/dollar-variable-pattern */ stylelint expects kebabcase by default (each word is in lower case, and separated by dashes) > $application-layout--breakpoint-side-nav-expanded: $breakpoint-xx-large; > - > $increase-font-size-on-larger-screens: false; > - > $assets-path: "/assets/fonts/"; -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main has been updated. Commit message changed to: enable stylelint - fix existing stylelint errors via stylelint --fix For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/_settings.scss b/frontend/src/_settings.scss > index 0588138..bdcb88c 100644 > --- a/frontend/src/_settings.scss > +++ b/frontend/src/_settings.scss > @@ -2,11 +2,9 @@ > > // Vanilla settings: > $grid-max-width: math.div(1920, 16) * 1rem; > - > $breakpoint-xx-large: 1920px; > $side-navigation-z-index: 103; > +/* stylelint-disable-next-line scss/dollar-variable-pattern */ This fails due to "--" in the variable name ("application-layout--breakpoint-side-nav-expanded"). We cannot use a different name as it's not controlled by us (Vanilla). > $application-layout--breakpoint-side-nav-expanded: $breakpoint-xx-large; > - > $increase-font-size-on-larger-screens: false; > - > $assets-path: "/assets/fonts/"; -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442206 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. Commit message: enable stylelint - fix existing stylelint errors Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442220 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:enable-stylelint into maas-site-manager:main. diff --git a/frontend/package.json b/frontend/package.json index 1acaffe..a834207 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,8 +10,8 @@ "preview": "vite preview", "playwright-test": "playwright test", "playwright-ui": "playwright test --ui", -"lint": "npmPkgJsonLint . && tsc && eslint . --ext .ts,.tsx", -"lint-fix": "eslint . --ext .ts,.tsx --fix", +"lint": "npmPkgJsonLint . && tsc && eslint . --ext .ts,.tsx && stylelint src/**/*.scss", +"lint-fix": "eslint . --ext .ts,.tsx --fix && stylelint src/**/*.scss --fix", "upgrade-all": "yarn-upgrade-all -E" }, "dependencies": { diff --git a/frontend/src/_patterns_icons.scss b/frontend/src/_patterns_icons.scss index 41dedd6..249ea08 100644 --- a/frontend/src/_patterns_icons.scss +++ b/frontend/src/_patterns_icons.scss @@ -8,22 +8,25 @@ .p-icon--sidebar-toggle { @extend %icon; - @include maas-icon-sidebar-collapse(); + @include maas-icon-sidebar-collapse; } .p-icon--maas { @extend %icon; - @include maas-icon-maas-logo(); + @include maas-icon-maas-logo; } .p-icon--status-ready { @extend %icon; + background-image: url("data:image/svg+xml,%3Csvg width='17' height='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 4a4 4 0 110 8 4 4 0 010-8z' fill='#{vf-url-friendly-color(#D3E4ED)}' fill-rule='nonzero'/%3E%3C/svg%3E"); } + .p-icon--status-deployed { @extend %icon; @include vf-icon-status-small($color-x-dark); } + .p-icon--status-allocated { @extend %icon; @include vf-icon-status-small($color-information); diff --git a/frontend/src/_patterns_typography.scss b/frontend/src/_patterns_typography.scss index a629d0f..516faa3 100644 --- a/frontend/src/_patterns_typography.scss +++ b/frontend/src/_patterns_typography.scss @@ -1,9 +1,11 @@ .p-heading--small { @extend %table-header-label; + color: $color-dark; margin-bottom: $sp-unit * 0.25; text-transform: uppercase; } + .is-dark { .p-heading--small { color: $color-light; diff --git a/frontend/src/_settings.scss b/frontend/src/_settings.scss index 0588138..bdcb88c 100644 --- a/frontend/src/_settings.scss +++ b/frontend/src/_settings.scss @@ -2,11 +2,9 @@ // Vanilla settings: $grid-max-width: math.div(1920, 16) * 1rem; - $breakpoint-xx-large: 1920px; $side-navigation-z-index: 103; +/* stylelint-disable-next-line scss/dollar-variable-pattern */ $application-layout--breakpoint-side-nav-expanded: $breakpoint-xx-large; - $increase-font-size-on-larger-screens: false; - $assets-path: "/assets/fonts/"; diff --git a/frontend/src/_utils.scss b/frontend/src/_utils.scss index 972f9d4..f34cdf0 100644 --- a/frontend/src/_utils.scss +++ b/frontend/src/_utils.scss @@ -1,52 +1,67 @@ .u-flex { display: flex !important; } + .u-flex--large { @media (min-width: $breakpoint-large) { display: flex !important; } } + .u-flex--align-end { align-items: flex-end !important; } + .u-flex--justify-end { justify-content: flex-end !important; } + .u-flex--justify-between { justify-content: space-between !important; } + .u-flex--column { flex-direction: column !important; } + .u-flex--column-x-small { @media (max-width: $breakpoint-x-small) { flex-direction: column !important; } } + .u-flex--grow { flex-grow: 1 !important; } + .u-flex--wrap { flex-wrap: wrap !important; } + .u-capitalize { text-transform: capitalize !important; } + .u-no-wrap { white-space: nowrap !important; } + .u-no-border { border: 0 !important; } + .u-padding-top--medium { padding-top: $spv--medium !important; } + .u-width--100 { width: 100% !important; } + .u-no-padding { padding: 0 !important; } + // hide elements visually, but keep them accessible to screen readers .u-visually-hidden { position: absolute !important; diff --git a/frontend/src/components/MainLayout/_MainLayout.scss b/frontend/src/components/MainLayout/_MainLayout.scss index a9e170b..ae08fec 100644 --- a/frontend/src/components/MainLayout/_MainLayout.scss +++ b/frontend/src/components/MainLayout/_MainLayout.scss @@ -2,9 +2,11 @@ display: flex; flex-direction: column;
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main has been updated. Description changed to: https://warthogs.atlassian.net/browse/MAASENG-1559 https://warthogs.atlassian.net/browse/MAASENG-1500 QA Steps go to /sites select a single region go to another page click "Remove region" verify that the name of the region is required as the confirmation text submit the form without entering the confirmation text verify the error message has been displayed enter a valid confirmation text verify the error message has been removed and form submitted For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442206 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main has been updated. Commit message changed to: add useSiteQueryData hook - rename hooks/api to hooks/react-query For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442206 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main has been updated. Commit message changed to: add useSiteQueryData hook - rename hooks/api to hooks/react-query - MAASENG-1500 - MAASENG-1559 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442206 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~jonesogolo/maas-site-manager:1561-update-mobile-menu into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/Navigation/Navigation.tsx > b/frontend/src/components/Navigation/Navigation.tsx > index 701e93c..1b39a24 100644 > --- a/frontend/src/components/Navigation/Navigation.tsx > +++ b/frontend/src/components/Navigation/Navigation.tsx > @@ -37,6 +37,8 @@ type NavProps = { >isLoggedIn: boolean; > }; > > +const MOBILE_BREAKPOINT_WIDTH = 460; Agree with Thorsten here. We should at least try and keep them in sync with CSS breakpoints. breaktpoints.ts file with breakpoints referring to each scss value, clearly marked by a comment should be enough to begin with. FYI we use https://vanillaframework.io/docs/settings/breakpoint-settings > + > const Navigation = ({ isLoggedIn }: NavProps): JSX.Element => { >const [isCollapsed, setIsCollapsed] = > useLocalStorageState("appSideNavIsCollapsed", { defaultValue: true > }); >const location = useLocation(); > @@ -82,18 +90,38 @@ const Navigation = ({ isLoggedIn }: NavProps): > JSX.Element => { > > > setIsCollapsed={setIsCollapsed} /> > + + appearance="base" > + className="is-dark u-display-x-small b-btn-transparent" No need to create custom classes for this. You could use vanilla framework visibility util classes instead, e.g. u-hide--small u-hide--medium u-hide--large in this case: https://vanillaframework.io/docs/utilities/hide > + onClick={(e) => { > +setIsCollapsed(!isCollapsed); > +// Make sure the button does not have focus > +// .l-navigation remains open with :focus-within > +e.stopPropagation(); > +e.currentTarget.blur(); > + }} > +> > + Close menu > + > > > >{isLoggedIn && ( > > - path={path} /> > - path={path} /> > - path={path} /> > + onClick={handleNavlinkClick} path={path} /> > + onClick={handleNavlinkClick} path={path} /> > + onClick={handleNavlinkClick} path={path} /> > >)} > > - items={navItemsBottom} path={path} /> > + + hasIcons > + hideDivider > + isDark > + items={navItemsBottom} > + onClick={handleNavlinkClick} > + path={path} > +/> > > > -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442211 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1561-update-mobile-menu into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:adjust-sticky-styling into maas-site-manager:main
This works great, but would be good to get rid of arbitrary height values. Have you tried using grid with grid-auto-rows on the container? https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows Diff comments: > diff --git a/frontend/src/components/TokensList/TokensList.tsx > b/frontend/src/components/TokensList/TokensList.tsx > index 8b93285..b768e45 100644 > --- a/frontend/src/components/TokensList/TokensList.tsx > +++ b/frontend/src/components/TokensList/TokensList.tsx > @@ -66,46 +64,24 @@ const TokensList = () => { > > > > -Follow the enrolment steps to enrol new regions: > - - sections={[ > -{ > - content: ( > - > - > -Generate single use tokens by clicking > Generate tokens > - > - > -Install site-manager-agent alongside a MAAS region > controller > - > -snap install site-manager-agent > - > - > -In the site-manager-agent CLI paste the snippet > below. Download the{" "} > - > - {/* TODO: Update link once documentation is live > https://warthogs.atlassian.net/browse/MAASENG-1585 */} > - optional config file > -{" "} > -to provide additional data for a specific MAAS > region. > - > -site-manager-agent enrol location.host > $ENROLMENT_TOKEN [$CONFIG_FILE_PATH] > - > -{/* TODO: Add certificate here once endpoint is > ready https://warthogs.atlassian.net/browse/MAASENG-1584 */} > - > - > -Accept the incoming request in the to={routesConfig.requests.path}>Requests page > - > - > - ), > - title: "Enrolment steps", > -}, > - ]} > -/> > - > - Learn more about the enrolment process and bulk enrolment{" "} > + > + Follow the enrolment steps outlined in the{" "} >{/* TODO: Update link once documentation is live > https://warthogs.atlassian.net/browse/MAASENG-1585 */} > - in the > documentation. > + to={docsUrls.enrollmentRequest}>documentation to enrol new > regions. Once an > + enrolment request was made use the following certificate data > to compare against the certificate shown in > + the enrolment request: > > +{/* TODO: Add actual certificate here once endpoint is ready > https://warthogs.atlassian.net/browse/MAASENG-1584 */} 👍 for creating a JIRA issue > + > + CN: > + sitemanager.example.com > + Expiration date: > + Thu, 29 Jul. 2035 > + Fingerprint: > + > 15cf96e8bad3eea3ef3c10badcd88f66fe236e0de99027451120bc7cd69c0012 > + Issued by: > + Let's Encrypt > + > > > > diff --git a/frontend/src/components/TokensList/_TokensList.scss > b/frontend/src/components/TokensList/_TokensList.scss > index 64694b2..330a891 100644 > --- a/frontend/src/components/TokensList/_TokensList.scss > +++ b/frontend/src/components/TokensList/_TokensList.scss > @@ -1,10 +1,42 @@ > .tokens-list-header { > + > + display: grid; 👍 for using CSS grid > + >@media only screen and (min-width: $breakpoint-small) { > - > +height: 34.6875rem; > position: sticky; > top: -0.75rem; > background-color: white; > z-index: 1; > padding-top: 0.75rem; >} > + > + @media only screen and (min-width: $breakpoint-large) { > +height: 23.4375rem; > + } > + > + .tokens-list-certificate { > +display: grid; > +width: 100%; > +grid-template-columns: 1fr 1fr; > +grid-gap: $spv--small; > +overflow-x: auto; > +white-space: nowrap; > +margin-bottom: $spv--large * 2; > + > +@media only screen and (min-width: $breakpoint-large) { > + width: fit-content; > +} > + } > + > + .tokens-list-instructions { > +height: 10.9375rem; > +@media only screen and (min-width: $breakpoint-large) { > + height: auto; > +} > + } > + > + .pagination-bar { > +margin-bottom: 0; > + } > } > diff --git > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > b/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > index f3ee36a..a6b850d 100644 > --- > a/frontend/src/components/TokensList/components/TokensTable/_TokensTable.scss > +++ > b/frontend/src/compone
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main. Commit message: add useSiteQueryData hook - rename hooks/api to hooks/react-query Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442206 https://warthogs.atlassian.net/browse/MAASENG-1559 QA Steps go to /sites select a single region go to another page click "Remove region" verify that the name of the region is required as the confirmation text submit the form without entering the confirmation text verify the error message has been displayed enter a valid confirmation text verify the error message has been removed and form submitted -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:remove-region-dialog-MAASENG-1559 into maas-site-manager:main. diff --git a/frontend/src/components/EnrollmentActions/EnrollmentActions.test.tsx b/frontend/src/components/EnrollmentActions/EnrollmentActions.test.tsx index 1ffa6dd..3047677 100644 --- a/frontend/src/components/EnrollmentActions/EnrollmentActions.test.tsx +++ b/frontend/src/components/EnrollmentActions/EnrollmentActions.test.tsx @@ -1,6 +1,6 @@ import EnrollmentActions from "./EnrollmentActions"; -import type * as apiHooks from "@/hooks/api"; +import type * as apiHooks from "@/hooks/react-query"; import { render, screen, within } from "@/test-utils"; const enrollmentRequestsMutationMock = vi.fn(); @@ -13,7 +13,7 @@ it("displays enrollment action buttons", () => { }); it("can display an error message on request error", () => { - vi.mock("@/hooks/api", async (importOriginal) => { + vi.mock("@/hooks/react-query", async (importOriginal) => { const original: typeof apiHooks = await importOriginal(); return { ...original, diff --git a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx index 812ddad..ed4f073 100644 --- a/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx +++ b/frontend/src/components/EnrollmentActions/EnrollmentActions.tsx @@ -3,7 +3,7 @@ import { Button, Notification } from "@canonical/react-components"; import EnrollmentNotification from "./EnrollmentNotification"; import { useAppContext } from "@/context"; -import { useEnrollmentRequestsMutation } from "@/hooks/api"; +import { useEnrollmentRequestsMutation } from "@/hooks/react-query"; const EnrollmentActions: React.FC = () => { const { rowSelection, setRowSelection } = useAppContext(); diff --git a/frontend/src/components/LoginForm/LoginForm.tsx b/frontend/src/components/LoginForm/LoginForm.tsx index 1ec8e96..7e69dae 100644 --- a/frontend/src/components/LoginForm/LoginForm.tsx +++ b/frontend/src/components/LoginForm/LoginForm.tsx @@ -70,6 +70,7 @@ const LoginForm = () => { initialValues={initialValues} onSubmit={handleSubmit} +validateOnBlur={false} validationSchema={LoginFormSchema} > {({ isSubmitting, errors, touched, isValid, dirty }) => ( diff --git a/frontend/src/components/NoRegions/NoRegions.tsx b/frontend/src/components/NoRegions/NoRegions.tsx index 21fa552..b06e77e 100644 --- a/frontend/src/components/NoRegions/NoRegions.tsx +++ b/frontend/src/components/NoRegions/NoRegions.tsx @@ -1,7 +1,7 @@ import docsUrls from "@/base/docsUrls"; import ExternalLink from "@/components/ExternalLink"; import TableCaption from "@/components/TableCaption"; -import { useRequestsCountQuery } from "@/hooks/api"; +import { useRequestsCountQuery } from "@/hooks/react-query"; import { Link } from "@/router"; const NoRegions = () => { diff --git a/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx b/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx index 5b1c6ef..80b268d 100644 --- a/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx +++ b/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx @@ -11,20 +11,22 @@ vi.mock("@/context", () => ({ }), })); -it("if the correct phrase has been entered the 'Remove' button becomes enabled.", async () => { +it("submit button should not be disabled when something has been typed", async () => { render(); + const errorMessage = /Confirmation string is not correct/i; expect(screen.getByRole("button", { name: /Remove/i })).toBeDisabled(); - await userEvent.type(screen.getByRole("textbox"), "remove 2 regions"); - expect(screen.queryByText(/Confirmation string is not corre
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:update-frontend-deps into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:update-frontend-deps into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442178 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:update-frontend-deps. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:update-frontend-deps into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:update-frontend-deps into maas-site-manager:main. Commit message: chore(deps): update all front-end deps Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442178 update all front-end dependencies -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:update-frontend-deps into maas-site-manager:main. diff --git a/frontend/package.json b/frontend/package.json index d2d5dd1..1acaffe 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,11 +17,11 @@ "dependencies": { "@canonical/react-components": "0.40.1", "@sentry/browser": "5.30.0", -"@tanstack/react-query": "4.29.1", -"@tanstack/react-table": "8.8.5", -"axios": "1.3.5", +"@tanstack/react-query": "4.29.5", +"@tanstack/react-table": "8.9.0", +"axios": "1.4.0", "classnames": "2.3.2", -"date-fns": "2.29.3", +"date-fns": "2.30.0", "date-fns-tz": "2.0.0", "formik": "2.2.9", "human-interval": "2.0.1", @@ -29,16 +29,16 @@ "pluralize": "8.0.0", "react": "18.2.0", "react-dom": "18.2.0", -"react-error-boundary": "4.0.3", -"react-router-dom": "6.10.0", +"react-error-boundary": "4.0.4", +"react-router-dom": "6.11.0", "use-local-storage-state": "18.3.2", -"vanilla-framework": "3.13.0", -"yup": "1.0.2" +"vanilla-framework": "3.14.0", +"yup": "1.1.1" }, "devDependencies": { -"@axe-core/playwright": "4.6.1", -"@playwright/test": "1.32.3", -"@remix-run/web-fetch": "4.3.3", +"@axe-core/playwright": "4.7.0", +"@playwright/test": "1.33.0", +"@remix-run/web-fetch": "4.3.4", "@testing-library/jest-dom": "5.16.5", "@testing-library/react": "14.0.0", "@testing-library/react-hooks": "8.0.1", @@ -46,41 +46,41 @@ "@total-typescript/ts-reset": "0.4.2", "@types/axios": "0.14.0", "@types/chance": "1.1.3", -"@types/lodash": "4.14.192", +"@types/lodash": "4.14.194", "@types/pluralize": "0.0.29", -"@types/react": "18.0.34", -"@types/react-dom": "18.0.11", -"@typescript-eslint/parser": "5.58.0", +"@types/react": "18.2.0", +"@types/react-dom": "18.2.1", +"@typescript-eslint/parser": "5.59.2", "@vitejs/plugin-react-swc": "3.3.0", "@vitest/coverage-c8": "0.30.1", "abort-controller": "3.0.0", "chance": "1.1.11", "dotenv": "16.0.3", -"eslint": "8.38.0", +"eslint": "8.39.0", "eslint-config-prettier": "8.8.0", "eslint-config-react-app": "7.0.1", "eslint-import-resolver-typescript": "3.5.5", -"eslint-plugin-cypress": "2.13.2", +"eslint-plugin-cypress": "2.13.3", "eslint-plugin-jsx-a11y": "6.7.1", "eslint-plugin-no-only-tests": "3.1.0", "eslint-plugin-no-relative-import-paths": "1.5.2", "eslint-plugin-prettier": "4.2.1", "eslint-plugin-react": "7.32.2", "fishery": "2.2.2", -"i18n-iso-countries": "7.5.0", -"jsdom": "21.1.1", +"i18n-iso-countries": "7.6.0", +"jsdom": "21.1.2", "mockdate": "3.0.5", "msw": "1.2.1", "npm-package-json-lint": "6.4.0", -"prettier": "2.8.7", -"sass": "1.62.0", -"stylelint": "15.5.0", -"stylelint-config-standard-scss": "8.0.0", +"prettier": "2.8.8
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442091 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:refactor-auth-context-useReducer. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:1583-add-sticky-styling into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/TokensList/_TokensList.scss > b/frontend/src/components/TokensList/_TokensList.scss > new file mode 100644 > index 000..25d995b > --- /dev/null > +++ b/frontend/src/components/TokensList/_TokensList.scss > @@ -0,0 +1,7 @@ > +.tokens-list-header { Screenshot https://share.cleanshot.com/D7Q4vlC7 > + position: sticky; > + top: -0.75rem; > + background-color: white; > + z-index: 1; > + padding-top: 0.75rem; > +} -- https://code.launchpad.net/~nickdv99/maas-site-manager/+git/site-manager/+merge/442096 Your team MAAS Committers is requested to review the proposed merge of ~nickdv99/maas-site-manager:1583-add-sticky-styling into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~nickdv99/maas-site-manager:1583-add-sticky-styling into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/TokensList/_TokensList.scss > b/frontend/src/components/TokensList/_TokensList.scss > new file mode 100644 > index 000..25d995b > --- /dev/null > +++ b/frontend/src/components/TokensList/_TokensList.scss > @@ -0,0 +1,7 @@ > +.tokens-list-header { Let's add a media query here for it to work on screens medium and up. > + position: sticky; > + top: -0.75rem; > + background-color: white; > + z-index: 1; > + padding-top: 0.75rem; > +} -- https://code.launchpad.net/~nickdv99/maas-site-manager/+git/site-manager/+merge/442096 Your team MAAS Committers is requested to review the proposed merge of ~nickdv99/maas-site-manager:1583-add-sticky-styling into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442091 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:refactor-auth-context-useReducer. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442091 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:refactor-auth-context-useReducer. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441882 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:strict-router-types. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442026 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:invalidate-queries-on-mutation. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441882 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:strict-router-types. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main has been updated. Status: Approved => Needs review For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441882 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441882 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:strict-router-types into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main. Commit message: refactor: auth context useReducer - split context providers into AppContext and AuthContext Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442091 refactor auth context to use useReducer next step will be extracting async logic to middleware QA Steps Verify you can login to site manager and logout successfully -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:refactor-auth-context-useReducer into maas-site-manager:main. diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index cee9a8b..51431fb 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2,10 +2,9 @@ import "./App.scss"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { createBrowserRouter, RouterProvider } from "react-router-dom"; -import { AppContextProvider, AuthContextProvider } from "./context"; -import routes from "./routes"; - import apiClient from "@/api"; +import { AppContextProvider, AuthContextProvider } from "@/context"; +import routes from "@/routes"; const queryClient = new QueryClient(); const router = createBrowserRouter(routes); diff --git a/frontend/src/components/MainLayout/MainLayout.tsx b/frontend/src/components/MainLayout/MainLayout.tsx index ee4e970..3347511 100644 --- a/frontend/src/components/MainLayout/MainLayout.tsx +++ b/frontend/src/components/MainLayout/MainLayout.tsx @@ -5,13 +5,12 @@ import { Col, Row, useOnEscapePressed, usePrevious } from "@canonical/react-comp import classNames from "classnames"; import { matchPath, Outlet, useLocation } from "react-router-dom"; -import SecondaryNavigation from "../SecondaryNavigation"; - import { routesConfig } from "@/base/routesConfig"; import type { RoutePath } from "@/base/routesConfig"; import DocumentTitle from "@/components/DocumentTitle/DocumentTitle"; import Navigation from "@/components/Navigation"; import RemoveRegions from "@/components/RemoveRegions"; +import SecondaryNavigation from "@/components/SecondaryNavigation"; import { useAppContext, useAuthContext } from "@/context"; import TokensCreate from "@/pages/tokens/create"; diff --git a/frontend/src/context/AppContext.tsx b/frontend/src/context/AppContext.tsx new file mode 100644 index 000..c7c41ec --- /dev/null +++ b/frontend/src/context/AppContext.tsx @@ -0,0 +1,26 @@ +import { createContext, useContext, useState } from "react"; + +import type { OnChangeFn, RowSelectionState } from "@tanstack/react-table"; + +export const AppContext = createContext<{ + rowSelection: RowSelectionState; + setRowSelection: OnChangeFn; + sidebar: "removeRegions" | "createToken" | null; + setSidebar: (sidebar: "removeRegions" | "createToken" | null) => void; +}>({ + rowSelection: {}, + setRowSelection: () => ({}), + sidebar: null, + setSidebar: () => null, +}); + +export const AppContextProvider = ({ children }: { children: React.ReactNode }) => { + const [rowSelection, setRowSelection] = useState({}); + const [sidebar, setSidebar] = useState<"removeRegions" | "createToken" | null>(null); + + return ( +{children} + ); +}; + +export const useAppContext = () => useContext(AppContext); diff --git a/frontend/src/context.tsx b/frontend/src/context/AuthContext.tsx similarity index 51% rename from frontend/src/context.tsx rename to frontend/src/context/AuthContext.tsx index 9cd0980..69387ba 100644 --- a/frontend/src/context.tsx +++ b/frontend/src/context/AuthContext.tsx @@ -1,40 +1,16 @@ -import { createContext, useContext, useEffect, useState } from "react"; +import type { Reducer } from "react"; +import React, { createContext, useContext, useReducer } from "react"; -import type { OnChangeFn, RowSelectionState } from "@tanstack/react-table"; import type { AxiosInstance } from "axios"; import useLocalStorageState from "use-local-storage-state"; -import type { LoginError } from "@/hooks/api"; import { useLoginMutation } from "@/hooks/api"; - -export const AppContext = createContext<{ - rowSelection: RowSelectionState; - setRowSelection: OnChangeFn; - sidebar: "removeRegions" | "createToken" | null; - setSidebar: (sidebar: "removeRegions" | "createToken" | null) => void; -}>({ - rowSelection: {}, - setRowSelection: () => ({}), - sidebar: null, - setSidebar: () => null, -}); - -e
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main has been updated. Description changed to: QA Steps Go to /settings/tokens Open developer tools in the network tab Select a token and click Delete Verify that a /tokens DELETE request has been made followed by /tokens GET Click Generate tokens and complete the form Verify that a /tokens POST request has been made followed by /tokens GET Go to /settings/requests Select a few requests and click Deny/Accept Verify that a PATCH /requests request has been made followed by GET /requests For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442026 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main has been updated. Description changed to: QA Steps Go to /tokens Open developer tools in the network tab Select a token and click Delete Verify that a DELETE request has been made followed by tokens GET Click Generate tokens and complete the form Verify that a /tokens POST request has been made followed by /tokens GET For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442026 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main. Commit message: invalidate queries on mutation success - fix displayed dates by using internal UTC formatting util functions - update token post data to match back-end properties Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442026 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:invalidate-queries-on-mutation into maas-site-manager:main. diff --git a/frontend/src/api/handlers.test.ts b/frontend/src/api/handlers.test.ts index 02f92f6..c03cbc3 100644 --- a/frontend/src/api/handlers.test.ts +++ b/frontend/src/api/handlers.test.ts @@ -2,6 +2,7 @@ import { setupServer } from "msw/node"; import { patchEnrollmentRequests, postTokens } from "./handlers"; +import { durationFactory } from "@/mocks/factories"; import { postTokens as postTokensResolver, patchEnrollmentRequests as postEnrollmentRequestsResolver, @@ -23,7 +24,7 @@ describe("postTokens handler", () => { it("requires name, amount and expiration time", async () => { // @ts-expect-error await expect(postTokens({})).rejects.toThrowError(); -await expect(postTokens({ amount: 1, expires: "P0Y0M7DT0H0M0S" })).resolves.toEqual( +await expect(postTokens({ amount: 1, duration: durationFactory.build() })).resolves.toEqual( expect.objectContaining({ items: expect.any(Array), }), diff --git a/frontend/src/api/handlers.ts b/frontend/src/api/handlers.ts index 046483d..70d4775 100644 --- a/frontend/src/api/handlers.ts +++ b/frontend/src/api/handlers.ts @@ -1,6 +1,7 @@ import * as Sentry from "@sentry/browser"; import api from "./api"; +import type { Token } from "./types"; import urls from "./urls"; import { customParamSerializer } from "@/utils"; @@ -50,10 +51,10 @@ export const getSites = async (params: GetSitesQueryParams, queryText?: string) export type PostTokensData = { amount: number; name?: string; - expires: string; // , + duration: string; // , }; export const postTokens = async (data: PostTokensData) => { - if (!data?.amount || !data?.expires) { + if (!data?.amount || !data?.duration) { throw Error("Missing required fields"); } try { @@ -74,7 +75,7 @@ export const getTokens = async (params: GetTokensQueryParams) => { } }; -export const deleteTokens = async (data: string[]) => { +export const deleteTokens = async (data: Token["id"][]) => { if (data.length === 0) { throw Error("No tokens selected"); } diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index e4ff44a..248c6ac 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -35,10 +35,10 @@ export type PaginatedQueryResult = { export type SitesQueryResult = PaginatedQueryResult; export type Token = { - id: string; + id: number; site_id: Site["id"] | null; value: string; - expires: string; //, + expired: string; //, created: string; // }; export type PostTokensResult = PaginatedQueryResult; diff --git a/frontend/src/components/TokensCreate/TokensCreate.test.tsx b/frontend/src/components/TokensCreate/TokensCreate.test.tsx index 25525c2..396a777 100644 --- a/frontend/src/components/TokensCreate/TokensCreate.test.tsx +++ b/frontend/src/components/TokensCreate/TokensCreate.test.tsx @@ -14,7 +14,7 @@ const tokensMutationMock = vi.fn(); vi.mock("@/hooks/api", async (importOriginal) => { const original: typeof apiHooks = await importOriginal(); - return { ...original, useTokensMutation: () => ({ mutateAsync: tokensMutationMock }) }; + return { ...original, useTokensCreateMutation: () => ({ mutateAsync: tokensMutationMock }) }; }); beforeAll(() => { @@ -67,7 +67,7 @@ it("can generate enrolment tokens", async () => { expect(tokensMutationMock).toHaveBeenCalledTimes(1); expect(tokensMutationMock).toHaveBeenCalledWith({ amount: 1, -expires: "P7DT0H0M0S", +duration: "P7DT0H0M0S", }); }); diff --git a/frontend/src/components/TokensCreate/TokensCreate.tsx b/frontend/src/components/TokensCreate/TokensCreate.tsx index 4f8e32d..b9e415e 100644 --- a/frontend/src/components/TokensCreate/TokensCreate.tsx +++ b/frontend/src/components/TokensCreate/TokensCreate.tsx @@ -8,7 +8,7 @@ import * as Yup from "yup"; import { humanIntervalToISODuration } from "./utils"; import { useAppContext } from "@/context"; -import { useTokensMutation } from "@/hooks/api"; +import { useTokensCreateMutation } from "@/hooks/api"; const initialValues = { amou
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441958 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-iso-duration-value. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442000 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:pagination-e2e-test. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442008 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [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; // , country: string; // , 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 ( <> { 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( + {}} +/>, + ); + + expect(screen.queryByRole("button", { name: /warning - name is not unique/i })).not.toBeInTheDocument(); + + const itemNonUnique = siteFactory.build({ +name_unique: false, + }); + rerender( + {}} +/>, + ); + + 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: () => ( <> Name URL ), -cell: ({ getValue }) => ( - <> -{getValue().name} -{getValue().url} - -), +cell: ({ getValue }) => { + return ( +<> + +{getValue().name} +{!getValue().name_unique ? ( + +This MAAS name is not unique in Site Manager. + +You can change this name in the MAAS region itself. + +} + > +) : null} + + {getValue().url} + + ); +}, }, { 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 ( 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/component
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:non-unique-name-MAASENG-1578 into maas-site-manager:main has been updated. Description changed to: 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 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442008 -- 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. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441958 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-iso-duration-value. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main. Commit message: fix pagination input index - add e2e test for pagination - add playwright yarn scripts Requested reviews: MAAS Committers (maas-committers) For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442000 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main. diff --git a/frontend/package.json b/frontend/package.json index 123987d..d2d5dd1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,6 +8,8 @@ "test": "vitest", "coverage": "vitest run --coverage", "preview": "vite preview", +"playwright-test": "playwright test", +"playwright-ui": "playwright test --ui", "lint": "npmPkgJsonLint . && tsc && eslint . --ext .ts,.tsx", "lint-fix": "eslint . --ext .ts,.tsx --fix", "upgrade-all": "yarn-upgrade-all -E" diff --git a/frontend/src/components/base/TablePagination/TablePagination.tsx b/frontend/src/components/base/TablePagination/TablePagination.tsx index c716638..070f187 100644 --- a/frontend/src/components/base/TablePagination/TablePagination.tsx +++ b/frontend/src/components/base/TablePagination/TablePagination.tsx @@ -34,10 +34,9 @@ const TablePagination = ({ setError(`${valueAsNumber} is not a valid page`); } else { setError(""); -setCurrentPage(valueAsNumber - 1); +setCurrentPage(valueAsNumber); } } else { - setPageNumber(undefined); setError("Enter a page number."); } }; diff --git a/frontend/tests/components/pagination.spec.ts b/frontend/tests/components/pagination.spec.ts new file mode 100644 index 000..5d9c045 --- /dev/null +++ b/frontend/tests/components/pagination.spec.ts @@ -0,0 +1,29 @@ +import { test, expect } from "@playwright/test"; + +import { adminAuthFile } from "../constants"; +import { routesConfig } from "@/base/routesConfig"; + +test.use({ storageState: adminAuthFile }); + +const pagesWithPagination = [routesConfig.tokens, routesConfig.requests]; + +for (const pageWithTable of pagesWithPagination) { + test.describe("navigates to the correct page on user input", () => { +test(`${pageWithTable.title} page`, async ({ page }) => { + await page.goto(pageWithTable.path); + + const currentPage = await page.getByRole("spinbutton", { name: /current page/i }); + const nextPage = await page.getByRole("button", { name: /next page/i }); + const previousPage = await page.getByRole("button", { name: /previous page/i }); + + await expect(currentPage).toHaveValue("1"); + await nextPage.click(); + await nextPage.click(); + await expect(currentPage).toHaveValue("3"); + await previousPage.click(); + await expect(currentPage).toHaveValue("2"); + await currentPage.fill("1"); + await expect(currentPage).toHaveValue("1"); +}); + }); +} -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/base/TablePagination/TablePagination.tsx > b/frontend/src/components/base/TablePagination/TablePagination.tsx > index c716638..070f187 100644 > --- a/frontend/src/components/base/TablePagination/TablePagination.tsx > +++ b/frontend/src/components/base/TablePagination/TablePagination.tsx > @@ -34,10 +34,9 @@ const TablePagination = ({ > setError(`${valueAsNumber} is not a valid page`); >} else { > setError(""); > -setCurrentPage(valueAsNumber - 1); > +setCurrentPage(valueAsNumber); Missed this single place when updating pagination to start at index 1. >} > } else { > - setPageNumber(undefined); >setError("Enter a page number."); > } >}; -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/442000 Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:pagination-e2e-test into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441890 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-a11y-tests. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441938 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:connection-column-MAASENG-1557. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441949 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main. Commit message: fix: use reduced iso duration format 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/441958 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-iso-duration-value into maas-site-manager:main. diff --git a/frontend/src/components/TokensCreate/TokensCreate.test.tsx b/frontend/src/components/TokensCreate/TokensCreate.test.tsx index 2519f7f..550cc77 100644 --- a/frontend/src/components/TokensCreate/TokensCreate.test.tsx +++ b/frontend/src/components/TokensCreate/TokensCreate.test.tsx @@ -68,7 +68,7 @@ describe("TokensCreate", () => { expect(tokensMutationMock).toHaveBeenCalledTimes(1); expect(tokensMutationMock).toHaveBeenCalledWith({ amount: 1, - expires: "P0Y0M7DT0H0M0S", + expires: "P7DT0H0M0S", }); }); }); diff --git a/frontend/src/components/TokensCreate/utils.test.ts b/frontend/src/components/TokensCreate/utils.test.ts index 0271d0c..cbbded8 100644 --- a/frontend/src/components/TokensCreate/utils.test.ts +++ b/frontend/src/components/TokensCreate/utils.test.ts @@ -1,7 +1,13 @@ import { humanIntervalToISODuration } from "./utils"; describe("humanIntervalToISODuration", () => { + it("returns a valid ISO duration string for weeks, days, hours and seconds", () => { +expect(humanIntervalToISODuration("5 weeks 7 days 3 hours 30 seconds")).toEqual("P42DT3H0M30S"); + }); + it("returns a valid ISO duration string for weeks", () => { +expect(humanIntervalToISODuration("2 weeks")).toEqual("P14DT0H0M0S"); + }); it("returns a valid ISO duration string for hours and seconds", () => { -expect(humanIntervalToISODuration("1 week 1 days 3 hours 30 seconds")).toEqual("P0Y0M8DT3H0M30S"); +expect(humanIntervalToISODuration("1 hours 10 seconds")).toEqual("P0DT1H0M10S"); }); }); diff --git a/frontend/src/components/TokensCreate/utils.ts b/frontend/src/components/TokensCreate/utils.ts index 718d876..d23b6d2 100644 --- a/frontend/src/components/TokensCreate/utils.ts +++ b/frontend/src/components/TokensCreate/utils.ts @@ -1,9 +1,26 @@ -import { formatISODuration, intervalToDuration } from "date-fns"; import humanInterval from "human-interval"; +function intervalToDuration(ms: number) { + let seconds = Math.floor(ms / 1000); + const days = Math.floor(seconds / (24 * 3600)); + seconds %= 24 * 3600; + const hours = Math.floor(seconds / 3600); + seconds %= 3600; + const minutes = Math.floor(seconds / 60); + seconds %= 60; + return { +days, +hours, +minutes, +seconds, + }; +} + +// return ISO 8601 duration only using days, hours, minutes and seconds export const humanIntervalToISODuration = (intervalString: string) => { const intervalNumber = humanInterval(intervalString); if (intervalNumber) { -return formatISODuration(intervalToDuration({ start: 0, end: intervalNumber })); +const duration = intervalToDuration(intervalNumber); +return `P${duration.days}DT${duration.hours}H${duration.minutes}M${duration.seconds}S`; } }; -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main has been updated. Commit message changed to: update connection column MAASENG-1557 - fix line-height 0 text collapsing issue - cleanup redundant table resizer code - update last_seen mock to return date within the last 15 minutes For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441938 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main
Diff comments: > diff --git a/frontend/src/components/TokensCreate/TokensCreate.test.tsx > b/frontend/src/components/TokensCreate/TokensCreate.test.tsx > index 2519f7f..4665b36 100644 > --- a/frontend/src/components/TokensCreate/TokensCreate.test.tsx > +++ b/frontend/src/components/TokensCreate/TokensCreate.test.tsx > @@ -29,46 +29,54 @@ afterAll(() => { >mockServer.close(); > }); > > -describe("TokensCreate", () => { > - it("renders the form", async () => { > -renderWithMemoryRouter(); > -expect(screen.getByRole("form", { name: /Generate new enrolment tokens/i > })).toBeInTheDocument(); > - }); > +it("renders the form", async () => { > + renderWithMemoryRouter(); > + expect(screen.getByRole("form", { name: /Generate new enrolment tokens/i > })).toBeInTheDocument(); > +}); > > - it("if not all required fields have been entered the submit button is > disabled", async () => { > -renderWithMemoryRouter(); > -const amount = screen.getByLabelText(/Amount of tokens to generate/i); > -const expires = screen.getByLabelText(/Expiration time/i); > -expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeDisabled(); > -await userEvent.type(amount, "1"); > -await userEvent.type(expires, "1 month"); > -expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeEnabled(); > - }); > +it("if not all required fields have been entered the submit button is > disabled", async () => { > + renderWithMemoryRouter(); > + const amount = screen.getByLabelText(/Amount of tokens to generate/i); > + const expires = screen.getByLabelText(/Expiration time/i); > + expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeDisabled(); > + await userEvent.type(amount, "1"); > + await userEvent.type(expires, "1 month"); > + expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeEnabled(); > +}); > > - it("displays an error for invalid expiration value", async () => { > -renderWithMemoryRouter(); > -const expires = screen.getByLabelText(/Expiration time/i); > -await userEvent.type(expires, "2"); > -await userEvent.tab(); > -expect(expires).toHaveErrorMessage( > - /Time unit must be a `string` type with a value of weeks, days, hours, > and\/or minutes./i, > -); > - }); > +it("displays an error for invalid expiration value", async () => { > + renderWithMemoryRouter(); > + const expires = screen.getByLabelText(/Expiration time/i); > + await userEvent.type(expires, "2"); > + await userEvent.tab(); > + expect(expires).toHaveErrorMessage( > +/Time unit must be a `string` type with a value of weeks, days, hours, > and\/or minutes./i, > + ); > +}); > > - it("can generate enrolment tokens", async () => { > -renderWithMemoryRouter(); > -const amount = screen.getByLabelText(/Amount of tokens to generate/i); > -const expires = screen.getByLabelText(/Expiration time/i); > -expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeDisabled(); > -// can specify the number of tokens to generate > -await userEvent.type(amount, "1"); > -// can specify the token expiration time (e.g. 1 week) > -await userEvent.type(expires, "1 week"); > -await userEvent.click(screen.getByRole("button", { name: /Generate > tokens/i })); > -expect(tokensMutationMock).toHaveBeenCalledTimes(1); > -expect(tokensMutationMock).toHaveBeenCalledWith({ > - amount: 1, > - expires: "P0Y0M7DT0H0M0S", > -}); > +it("can generate enrolment tokens", async () => { > + renderWithMemoryRouter(); > + const amount = screen.getByLabelText(/Amount of tokens to generate/i); > + const expires = screen.getByLabelText(/Expiration time/i); > + expect(screen.getByRole("button", { name: /Generate tokens/i > })).toBeDisabled(); > + // can specify the number of tokens to generate > + await userEvent.type(amount, "1"); > + // can specify the token expiration time (e.g. 1 week) > + await userEvent.type(expires, "1 week"); > + await userEvent.click(screen.getByRole("button", { name: /Generate > tokens/i })); > + expect(tokensMutationMock).toHaveBeenCalledTimes(1); > + expect(tokensMutationMock).toHaveBeenCalledWith({ > +amount: 1, > +expires: "P0Y0M7DT0H0M0S", >}); > }); > + > +it("does not display error message on blur if the value has not chagned", > async () => { This is the only change in the tests file, the others are just due to removal of the describe block. > + renderWithMemoryRouter(); > + const amount = screen.getByLabelText(/Amount of tokens to generate/i); > + await userEvent.type(amount, "{tab}"); > + expect(amount).not.toHaveErrorMessage(/Error/i); > + // enter a value and then delete it > + await userEvent.type(amount, "1{backspace}"); > + expect(amount).toHaveErrorMessage(/Error/i); > +}); -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441949 Your team MAAS Committers is req
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main. Commit message: fix validation onSubmit MAASENG-1571 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/441949 ## QA Steps Go to /sites Select a site Click "Remove" Click on the text input field Click cancel The side panel should close Click "Remove" again Press "Esc" button The side panel should close Go to /settings/tokens Click "Generate tokens" Click cancel The side panel should close -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-validation-onSubmit-MAASENG-1571 into maas-site-manager:main. diff --git a/frontend/src/_utils.scss b/frontend/src/_utils.scss index b666356..514f0bf 100644 --- a/frontend/src/_utils.scss +++ b/frontend/src/_utils.scss @@ -38,9 +38,6 @@ .u-no-border { border: 0 !important; } -.u-no-line-height { - line-height: 0 !important; -} .u-padding-top--medium { padding-top: $spv--medium !important; } diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index c124177..486a255 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -16,14 +16,12 @@ export type Site = { id: string; name: string; url: string; // , - connection: Stats["connection"]; - last_seen: string; // , country: string; // , city: string; zip: string; street: string; timezone: string; // IANA time zone name, - stats: Stats; + stats: Stats | null; }; export type PaginatedQueryResult = { diff --git a/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx b/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx index e5414c3..5b1c6ef 100644 --- a/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx +++ b/frontend/src/components/RemoveRegions/RemoveRegions.test.tsx @@ -19,10 +19,18 @@ it("if the correct phrase has been entered the 'Remove' button becomes enabled." expect(screen.getByRole("button", { name: /Remove/i })).toBeEnabled(); }); -it("if the confirmation string is not correct and the user unfoxuses the input field a error state is shown.", async () => { +it("if the confirmation string is not correct and the user unfocuses the input field a error state is shown.", async () => { render(); expect(screen.getByRole("button", { name: /Remove/i })).toBeDisabled(); await userEvent.type(screen.getByRole("textbox"), "incorrect string{tab}"); expect(screen.getByText(/Confirmation string is not correct/i)).toBeInTheDocument(); expect(screen.getByRole("button", { name: /Remove/i })).toBeDisabled(); }); + +it("does not display error message on blur if the value has not chagned", async () => { + render(); + expect(screen.getByRole("button", { name: /Remove/i })).toBeDisabled(); + await userEvent.type(screen.getByRole("textbox"), "{tab}"); + expect(screen.queryByText(/Confirmation string is not correct/i)).not.toBeInTheDocument(); + expect(screen.getByRole("button", { name: /Remove/i })).toBeDisabled(); +}); diff --git a/frontend/src/components/RemoveRegions/RemoveRegions.tsx b/frontend/src/components/RemoveRegions/RemoveRegions.tsx index 4136519..1f6f32a 100644 --- a/frontend/src/components/RemoveRegions/RemoveRegions.tsx +++ b/frontend/src/components/RemoveRegions/RemoveRegions.tsx @@ -60,6 +60,7 @@ const RemoveRegions = () => { initialValues={initialValues} onSubmit={handleSubmit} validate={createHandleValidate({ expectedConfirmTextValue })} + validateOnBlur={false} > {({ isSubmitting, errors, touched, isValid, dirty }) => ( diff --git a/frontend/src/components/RequestsTable/RequestsTable.tsx b/frontend/src/components/RequestsTable/RequestsTable.tsx index b4ccfc1..5a3bd3d 100644 --- a/frontend/src/components/RequestsTable/RequestsTable.tsx +++ b/frontend/src/components/RequestsTable/RequestsTable.tsx @@ -32,11 +32,10 @@ const RequestsTable = ({ const columns = useMemo( () => [ - { + columnHelper.accessor("name", { id: "select", -accessorKey: "name", header: ({ table }) => , -cell: ({ row, getValue }: { row: Row; getValue: Getter }) => { +cell: ({ row, getValue }) => { return ( ); }, - }, + }), columnHelper.accessor("name", { id: "name", header: () => Name, diff --git a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.test.tsx b/frontend/src/components/Site
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441890 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-a11y-tests. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441890 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-a11y-tests. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:fix-mobile-nav. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
Re: [Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:add-a11y-tests into maas-site-manager:main
Diff comments: > diff --git > a/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx > b/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx > index a4c2b15..a6a4354 100644 > --- > a/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx > +++ > b/frontend/src/components/TokensList/components/TokensTable/TokensTable.tsx > @@ -46,15 +45,20 @@ const TokensTable = ({ >{ > id: "select", > header: ({ table }) => , > -cell: ({ row }) => ( > - > - - checked={row.getIsSelected()} > - disabled={!row.getCanSelect()} > - onChange={row.getToggleSelectedHandler()} > +cell: ({ row, getValue }) => ( > + > + + aria-label={`select ${getValue()}`} > + className="p-checkbox__input" >type="checkbox" > + {...{ > +checked: row.getIsSelected(), > +disabled: !row.getCanSelect(), > +onChange: row.getToggleSelectedHandler(), > + }} > /> > - > + > + > ), >}, >{ -- https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441890 Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:add-a11y-tests. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main
Peter Makowski has proposed merging ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main. Commit message: update connection column MAASENG-1557 - fix line-height 0 text collapsing issue - cleanup redundant table resizer code 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/441938 https://warthogs.atlassian.net/browse/MAASENG-1557 QA Steps Go to sites Verify that last seen is displayed in human readable format, e.g. 1 minute ago Verify that rows for sites which have "Waiting for first" status are greyed out except from the "name" column -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:connection-column-MAASENG-1557 into maas-site-manager:main. diff --git a/frontend/src/_utils.scss b/frontend/src/_utils.scss index b666356..514f0bf 100644 --- a/frontend/src/_utils.scss +++ b/frontend/src/_utils.scss @@ -38,9 +38,6 @@ .u-no-border { border: 0 !important; } -.u-no-line-height { - line-height: 0 !important; -} .u-padding-top--medium { padding-top: $spv--medium !important; } diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index c124177..486a255 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -16,14 +16,12 @@ export type Site = { id: string; name: string; url: string; // , - connection: Stats["connection"]; - last_seen: string; // , country: string; // , city: string; zip: string; street: string; timezone: string; // IANA time zone name, - stats: Stats; + stats: Stats | null; }; export type PaginatedQueryResult = { diff --git a/frontend/src/components/RequestsTable/RequestsTable.tsx b/frontend/src/components/RequestsTable/RequestsTable.tsx index b4ccfc1..5a3bd3d 100644 --- a/frontend/src/components/RequestsTable/RequestsTable.tsx +++ b/frontend/src/components/RequestsTable/RequestsTable.tsx @@ -32,11 +32,10 @@ const RequestsTable = ({ const columns = useMemo( () => [ - { + columnHelper.accessor("name", { id: "select", -accessorKey: "name", header: ({ table }) => , -cell: ({ row, getValue }: { row: Row; getValue: Getter }) => { +cell: ({ row, getValue }) => { return ( ); }, - }, + }), columnHelper.accessor("name", { id: "name", header: () => Name, diff --git a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.test.tsx b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.test.tsx index 88e355c..3ebdf1b 100644 --- a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.test.tsx +++ b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.test.tsx @@ -1,8 +1,20 @@ +import * as timezoneMock from "timezone-mock"; + import ConnectionInfo, { connectionIcons, connectionLabels } from "./ConnectionInfo"; import { connections } from "@/mocks/factories"; import { render, screen } from "@/test-utils"; +beforeEach(() => { + vi.useFakeTimers(); + timezoneMock.register("Etc/GMT"); +}); + +afterEach(() => { + timezoneMock.unregister(); + vi.useRealTimers(); +}); + connections.forEach((connection) => { it(`displays correct connection status icon and label for ${connection} connection`, () => { const { container } = render(); @@ -11,3 +23,15 @@ connections.forEach((connection) => { expect(container.querySelector(".status-icon")).toHaveClass(connectionIcons[connection]); }); }); + +it("displays last seen text relative to local time correctly", () => { + const date = new Date("2000-01-01T12:00:00Z"); + vi.setSystemTime(date); + render(); + expect(screen.getByText("2 minutes ago")).toBeInTheDocument(); +}); + +it("displays 'waiting for first' text for the unknown status", () => { + render(); + expect(screen.getByText(/waiting for first/i)).toBeInTheDocument(); +}); diff --git a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx index 3eeef54..764d9da 100644 --- a/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx +++ b/frontend/src/components/SitesList/SitesTable/ConnectionInfo/ConnectionInfo.tsx @@ -1,50 +1,63 @@ import classNames from "classnames"; import get from "lodash/get"; -import type { Site } from "@/api/types"; +import type { Stats } from "@/api/types"; import docsUrls from "@/base/docsUrls&quo
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main has been updated. Status: Needs review => Approved For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441774 -- Your team MAAS Committers is subscribed to branch ~petermakowski/maas-site-manager:update-api-shapes. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main has been updated. Description changed to: - 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 Comment out the following lines from main.tsx: if (isDev) { const { worker } = await import("./mocks/browser"); await worker.start(); } Make sure you have the backend running and setup with test data (follow instructions in backend/README.md) Go to sites, tokens, and requests pages and make sure they load correctly using the real API For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441774 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:update-api-shapes into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Commit message changed to: fix: primary and secondary navigation on mobile - hide secondary navigation on mobile - fix primary navigation collapse on mobile - simplify stylesheet declarations For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown Open the primary navigation by clicking "Menu" Navigate to a different page Click to collapse navigation Open primary navigation again Click to collapse navigation Navigation should collapse ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 https://media.cleanshot.cloud/media/61681/CNp26dSdTSxKkMqdUhJ15cURXyo7UICDxygnRRBZ.jpeg?Expires=1682516950&Signature=kJfuqiLSs25zMyGOd2gyt9vi30RE24wC8wK40BpwR4K-rpUEecwgsd~nrJC92wQDt51P3OLpJ3q9qBB4QGSlbFmdszfb36wcBDUvIw3QIMmiB-we6MTsOdYQejR0nkn~0DaZzGcgU14WAISFVHAY5eQxDHIxVrJUffWa4uJ-K5Ep6xWNw9aJr19Eil3cz5~YHv5MlqitdC2y5yK72yIg0yrIWmkUmYPIiqJYRkUJRuNPwCwswIoz81Vrssfe~Mr7nVx37ktZQNTVnCl1T0Roia5vl72amWeqcP62r~MfD50PyKs7BiJ2GpZh1-D3PMXqElioasTPWaxzHyhvKiPUXQ__&Key-Pair-Id=K269JMAT9ZF4GZ For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 https://media.cleanshot.cloud/media/61681/CNp26dSdTSxKkMqdUhJ15cURXyo7UICDxygnRRBZ.jpeg For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://media.cleanshot.cloud/media/61681/CNp26dSdTSxKkMqdUhJ15cURXyo7UICDxygnRRBZ.jpeg?Expires=1682516710&Signature=kw1HGJGPU5xNXIFEB~RYPxZXEVkReymsIIWIVpmu3p58RMn72NWaLVP8G90dddoczpxdfUuIfCOGAfe-KsqC6CGBoXoy9lKDD48vcWsuOnv0ShdB85NbNuYhK8boFN3C3DWBvrbYJhtU-7EarTr8HVrgIEC0ExJNQEyac-WtdiEI9Amn6iliaztoF5I4lezrkrxWVIV3qUT0YfOFnnnUs8G9F~WDMi9pgZjn3TXiRFIZZjcQG1wvyS-UUVR5GhDD3KTv~lG6wTOF~m8cQYnFkVsxFI319GjJeI5mbJEZY08sr2eIRffX6y7UPrZb9YIV0pPFUUmjg8~dfQ6cLf1VaQ__&Key-Pair-Id=K269JMAT9ZF4GZ"; /> https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp
[Sts-sponsors] [Merge] ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main
The proposal to merge ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main has been updated. Description changed to: ### QA Steps Open google chrome Go to MAAS Site Manager Toggle device toolbar (ctrl/cmd + shift + M) Choose mobile phone dimensions (e.g. Google Pixel) Go to /sites and verify that there is no empty space below the primary navigation Go to /settings Verify that the secondary navigation is shown ### Screenshots After https://share.cleanshot.com/FjTKcBrk https://share.cleanshot.com/QsBJB800 For more details, see: https://code.launchpad.net/~petermakowski/maas-site-manager/+git/site-manager/+merge/441918 -- Your team MAAS Committers is requested to review the proposed merge of ~petermakowski/maas-site-manager:fix-mobile-nav into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp