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

WD-12910 - Use application layout from react-components #106

Merged
merged 1 commit into from
Jul 10, 2024
Merged
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
268 changes: 144 additions & 124 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import Button from "@canonical/react-components/dist/components/Button";
import Col from "@canonical/react-components/dist/components/Col";
import Form from "@canonical/react-components/dist/components/Form";
import Input from "@canonical/react-components/dist/components/Input";
import Row from "@canonical/react-components/dist/components/Row";
import {
AppAside,
ApplicationLayout,
Icon,
Button,
Col,
Form,
Input,
Panel,
Row,
} from "@canonical/react-components";
import { useState } from "react";
import type { NavLinkProps } from "react-router-dom";
import { Link, NavLink, Outlet } from "react-router-dom";

import {
Expand All @@ -16,143 +23,156 @@ import {
UsersLink,
} from "components/links";

import ApplicationLayout, { AppAside } from "./components/ApplicationLayout";

const rebacAdminBaseURL = "/permissions";

const App = () => {
const [showAside, setShowAside] = useState(false);
const [asidePinned, setAsidePinned] = useState(false);

const logo = {
component: Link,
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
name: "https://assets.ubuntu.com/v1/2e04d794-logo-jaas.svg",
nameAlt: "JAAS",
to: "/",
};

return (
<ApplicationLayout
<ApplicationLayout<NavLinkProps>
id="app-layout"
logo={{
component: Link,
icon: "https://assets.ubuntu.com/v1/7144ec6d-logo-jaas-icon.svg",
name: "https://assets.ubuntu.com/v1/2e04d794-logo-jaas.svg",
nameAlt: "JAAS",
to: "/",
}}
logo={logo}
navItems={[
{
icon: "drag",
label: "Models",
to: "/models",
},
{
icon: "menu",
label: "Controllers",
to: "/controllers",
items: [
{
icon: "drag",
label: "Models",
to: "/models",
},
{
icon: "menu",
label: "Controllers",
to: "/controllers",
},
{
icon: "user",
label: "Permissions",
to: rebacAdminBaseURL,
end: true,
},
<AccessGovernanceLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<AuthenticationLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<EntitlementsLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<GroupsLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<ResourcesLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<RolesLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<UsersLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
],
},
{
icon: "user",
label: "Permissions",
to: rebacAdminBaseURL,
end: true,
},
<AccessGovernanceLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<AuthenticationLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<EntitlementsLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<GroupsLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<ResourcesLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<RolesLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
<UsersLink
className="p-side-navigation__link"
baseURL={rebacAdminBaseURL}
/>,
]}
navLinkComponent={NavLink}
aside={
showAside ? (
<AppAside
controls={
<Button
onClick={() => setAsidePinned(!asidePinned)}
dense
className="u-no-margin"
>
Pin aside
</Button>
}
onClose={() => {
setShowAside(false);
setAsidePinned(false);
}}
title="Aside panel"
pinned={asidePinned}
>
<Form stacked>
<Input
label="Full name"
type="text"
name="fullName"
autoComplete="name"
stacked
/>
<Input
label="Username"
type="text"
name="username-stacked"
autoComplete="username"
aria-describedby="exampleHelpTextMessage"
stacked
help="30 characters or fewer."
/>
<Input
type="text"
label="Email address"
aria-invalid="true"
name="username-stackederror"
autoComplete="email"
required
error="This field is required."
stacked
/>
<Input
label="Address line 1"
type="text"
name="address-optional-stacked"
autoComplete="address-line1"
stacked
/>
<Input
label="Address line 2"
type="text"
name="address-optional-stacked"
autoComplete="address-line3"
stacked
/>
<Row>
<Col size={12}>
<AppAside title="Aside panel" pinned={asidePinned}>
<Panel
controls={
<>
<Button
onClick={() => setAsidePinned(!asidePinned)}
dense
className="u-no-margin"
>
Pin aside
</Button>
<Button
appearance="positive"
className="u-float-right"
name="add-details"
appearance="base"
className="u-no-margin--bottom"
hasIcon
onClick={() => {
setShowAside(false);
setAsidePinned(false);
}}
>
Add details
<Icon name="close">Close</Icon>
</Button>
</Col>
</Row>
</Form>
</>
}
>
<Form stacked>
<Input
label="Full name"
type="text"
name="fullName"
autoComplete="name"
stacked
/>
<Input
label="Username"
type="text"
name="username-stacked"
autoComplete="username"
aria-describedby="exampleHelpTextMessage"
stacked
help="30 characters or fewer."
/>
<Input
type="text"
label="Email address"
aria-invalid="true"
name="username-stackederror"
autoComplete="email"
required
error="This field is required."
stacked
/>
<Input
label="Address line 1"
type="text"
name="address-optional-stacked"
autoComplete="address-line1"
stacked
/>
<Input
label="Address line 2"
type="text"
name="address-optional-stacked"
autoComplete="address-line3"
stacked
/>
<Row>
<Col size={12}>
<Button
appearance="positive"
className="u-float-right"
name="add-details"
>
Add details
</Button>
</Col>
</Row>
</Form>
</Panel>
</AppAside>
) : null
}
Expand Down
22 changes: 0 additions & 22 deletions demo/src/components/ApplicationLayout/AppAside/AppAside.test.tsx

This file was deleted.

60 changes: 0 additions & 60 deletions demo/src/components/ApplicationLayout/AppAside/AppAside.tsx

This file was deleted.

1 change: 0 additions & 1 deletion demo/src/components/ApplicationLayout/AppAside/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions demo/src/components/ApplicationLayout/AppMain/AppMain.test.tsx

This file was deleted.

Loading