sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #08413
Re: [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<Pick<ReturnType<typeof useAppContext>, "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 (
> <aside
> 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}
> >
> <Row>
> - <Col size={12}>{children}</Col>
> + <Col size={12}>
> + {/* use context based on the route? */}
> + {!!sidebar && sidebar === "createToken" ? (
Good catch, it's a leftover from previous implementations. Will update.
> + <TokensCreate />
> + ) : !!sidebar && sidebar === "removeRegions" ? (
> + <RemoveRegions />
> + ) : null}
> + </Col>
> </Row>
> </aside>
> );
--
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.
References