Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use application layout from react-components. #5434

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import type { ReactNode } from "react";
import { Suspense, useEffect } from "react";

import { Notification } from "@canonical/react-components";
import {
AppNavigationBar,

Check failure on line 5 in src/app/App.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'AppNavigationBar'.
AppStatus,

Check failure on line 6 in src/app/App.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'AppStatus'.
Application,

Check failure on line 7 in src/app/App.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'Application'.
Notification,
Panel,

Check failure on line 9 in src/app/App.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'Panel'.
} from "@canonical/react-components";
import { usePrevious } from "@canonical/react-components/dist/hooks";
import * as Sentry from "@sentry/browser";
import { useDispatch, useSelector } from "react-redux";
Expand Down Expand Up @@ -168,21 +174,20 @@
}

return (
<div className="l-application" id={MAAS_UI_ID}>
<ThemePreviewContextProvider>
<ThemePreviewContextProvider>
<Application id={MAAS_UI_ID}>
<ConnectionStatus />
{authLoaded && authenticated ? (
<AppSideNavigation />
) : (
<header className="l-navigation-bar is-pinned">
<div className="p-panel is-dark is-maas-default">
<div className="p-panel__header">
<NavigationBanner />
</div>
</div>
</header>
<AppNavigationBar className="is-pinned">
<Panel
className="is-maas-default"
dark
logo={<NavigationBanner />}
/>
</AppNavigationBar>
)}

<Suspense
fallback={
<PageContent
Expand All @@ -194,11 +199,11 @@
>
{content}
</Suspense>
<aside className="l-status">
<AppStatus>
<StatusBar />
</aside>
</ThemePreviewContextProvider>
</div>
</AppStatus>
</Application>
</ThemePreviewContextProvider>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from "react";

import { Navigation } from "@canonical/maas-react-components";
import { Button, Icon } from "@canonical/react-components";
import { Button, Icon, SideNavigation } from "@canonical/react-components";

Check failure on line 4 in src/app/base/components/AppSideNavigation/AppSideNavItems/AppSideNavItems.tsx

View workflow job for this annotation

GitHub Actions / Lint

'"@canonical/react-components"' has no exported member named 'SideNavigation'. Did you mean 'Navigation'?

import AppSideNavItem from "../AppSideNavItem";
import type { SideNavigationProps } from "../AppSideNavigation";
Expand Down Expand Up @@ -93,7 +93,7 @@
vaultIncomplete,
}: Props): JSX.Element => {
return (
<>
<SideNavigation hasIcons>
{showLinks ? (
<ul className="p-side-navigation__list">
{groups.map((group, i) => (
Expand Down Expand Up @@ -147,7 +147,7 @@
</ul>
</>
) : null}
</>
</SideNavigation>
);
};

Expand Down
98 changes: 50 additions & 48 deletions src/app/base/components/AppSideNavigation/AppSideNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useEffect, useMemo } from "react";

import { Navigation, NavigationBar } from "@canonical/maas-react-components";
import {
AppNavigation,

Check failure on line 5 in src/app/base/components/AppSideNavigation/AppSideNavigation.tsx

View workflow job for this annotation

GitHub Actions / Lint

'"@canonical/react-components"' has no exported member named 'AppNavigation'. Did you mean 'Navigation'?
AppNavigationBar,

Check failure on line 6 in src/app/base/components/AppSideNavigation/AppSideNavigation.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'AppNavigationBar'.
Panel,

Check failure on line 7 in src/app/base/components/AppSideNavigation/AppSideNavigation.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'Panel'.
} from "@canonical/react-components";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate, useLocation, useMatch } from "react-router-dom";
import { useStorageState } from "react-storage-hooks";
Expand Down Expand Up @@ -55,54 +60,51 @@
vaultIncomplete,
}: SideNavigationProps) => (
<>
<NavigationBar className={`is-maas-${theme}`}>
<Navigation.Header>
<NavigationBanner />
<Navigation.Controls>
<NavigationBar.MenuButton
onClick={() => {
setIsCollapsed(!isCollapsed);
}}
>
Menu
</NavigationBar.MenuButton>
</Navigation.Controls>
</Navigation.Header>
</NavigationBar>
<Navigation className={`is-maas-${theme}`} isCollapsed={isCollapsed}>
<Navigation.Drawer>
<Navigation.Header>
<NavigationBanner>
<Navigation.Controls>
<NavigationBar.MenuButton
onClick={() => {
setIsCollapsed(!isCollapsed);
}}
>
Close menu
</NavigationBar.MenuButton>
<Navigation.CollapseToggle
isCollapsed={isCollapsed}
setIsCollapsed={setIsCollapsed}
/>
</Navigation.Controls>
</NavigationBanner>
</Navigation.Header>
<Navigation.Content>
<AppSideNavItems
authUser={authUser}
groups={filteredGroups}
isAdmin={isAdmin}
isAuthenticated={isAuthenticated}
logout={logout}
path={path}
setIsCollapsed={setIsCollapsed}
showLinks={showLinks}
vaultIncomplete={vaultIncomplete}
/>
</Navigation.Content>
</Navigation.Drawer>
</Navigation>
<AppNavigationBar className={`is-maas-${theme}`}>
<Panel
dark
logo={<NavigationBanner />}
toggle={{
label: "Menu",
onClick: () => setIsCollapsed(!isCollapsed),
}}
/>
</AppNavigationBar>
<AppNavigation className={`is-maas-${theme}`} collapsed={isCollapsed}>
<Panel
controls={
<>
<NavigationBar.MenuButton
onClick={() => {
setIsCollapsed(!isCollapsed);
}}
>
Close menu
</NavigationBar.MenuButton>
<Navigation.CollapseToggle
isCollapsed={isCollapsed}
setIsCollapsed={setIsCollapsed}
/>
</>
}
controlsClassName="u-no-margin--top"
dark
logo={<NavigationBanner />}
stickyHeader
>
<AppSideNavItems
authUser={authUser}
groups={filteredGroups}
isAdmin={isAdmin}
isAuthenticated={isAuthenticated}
logout={logout}
path={path}
setIsCollapsed={setIsCollapsed}
showLinks={showLinks}
vaultIncomplete={vaultIncomplete}
/>
</Panel>
</AppNavigation>
</>
);

Expand Down
14 changes: 7 additions & 7 deletions src/app/base/components/AppSidePanel/AppSidePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, type ReactNode } from "react";

import { ContentSection } from "@canonical/maas-react-components";
import { useOnEscapePressed } from "@canonical/react-components";
import { AppAside, useOnEscapePressed } from "@canonical/react-components";

Check failure on line 4 in src/app/base/components/AppSidePanel/AppSidePanel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'AppAside'.
import classNames from "classnames";

import type { SidePanelSize } from "@/app/base/side-panel-context";
Expand Down Expand Up @@ -49,16 +49,16 @@
content,
}: AppSidePanelProps): JSX.Element => {
return (
<aside
<AppAside
aria-label={title ?? undefined}
className={classNames("l-aside", {
"is-collapsed": !content,
"is-narrow": size === "narrow",
className={classNames({
"is-large": size === "large",
"is-wide": size === "wide",
})}
collapsed={!content}
data-testid="app-side-panel"
id="aside-panel"
narrow={size === "narrow"}
wide={size === "wide"}
>
<ContentSection>
{title ? (
Expand All @@ -72,7 +72,7 @@
) : null}
{content}
</ContentSection>
</aside>
</AppAside>
);
};

Expand Down
5 changes: 3 additions & 2 deletions src/app/base/components/PageContent/PageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { HTMLProps, ReactNode } from "react";

import { AppMain } from "@canonical/react-components";

Check failure on line 3 in src/app/base/components/PageContent/PageContent.tsx

View workflow job for this annotation

GitHub Actions / Lint

Module '"@canonical/react-components"' has no exported member 'AppMain'.
import classNames from "classnames";
import { useSelector } from "react-redux";
import { matchPath, useLocation } from "react-router-dom";
Expand Down Expand Up @@ -44,7 +45,7 @@

return (
<>
<main className="l-main">
<AppMain>
{isSecondaryNavVisible ? (
<div
className={classNames("l-main__nav", `is-maas-${theme}--accent`)}
Expand Down Expand Up @@ -73,7 +74,7 @@
<ErrorBoundary>{children}</ErrorBoundary>
</MainContentSection>
</div>
</main>
</AppMain>
<AppSidePanel content={sidePanelContent} title={sidePanelTitle} />
</>
);
Expand Down
Loading