Skip to content

Commit

Permalink
SideNav refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
salilponde committed Dec 24, 2023
1 parent 6204e0d commit dd69b8a
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 257 deletions.
2 changes: 1 addition & 1 deletion web/src/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Outlet, useNavigate } from "react-router-dom"
import SideNav from "../components/side-nav"
import SideNav from "../components/side-nav/side-nav"
import axios from "axios"
import apiBaseUrl from "@/lib/api-base-url"
import {
Expand Down
256 changes: 0 additions & 256 deletions web/src/components/side-nav.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions web/src/components/side-nav/side-nav-compose.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Bars3BottomLeftIcon,
Bars3Icon,
CubeIcon,
} from "@heroicons/react/24/outline"
import { useParams } from "react-router-dom"
import { SideBarItem, SideNavBack } from "./side-nav"

export function SideNavCompose() {
const { nodeId, composeProjectId } = useParams()

const baseUrl = `/nodes/${nodeId}/compose/${composeProjectId}`
const items = [
{
title: "Actions",
link: `${baseUrl}/actions`,
icon: (
<Bars3BottomLeftIcon className="h-6 w-6 shrink-0" aria-hidden="true" />
),
},
{
title: "Definition",
link: `${baseUrl}/definition`,
icon: (
<Bars3BottomLeftIcon className="h-6 w-6 shrink-0" aria-hidden="true" />
),
},
{
title: "Containers",
link: `${baseUrl}/containers`,
icon: <CubeIcon className="h-6 w-6 shrink-0" aria-hidden="true" />,
},
{
title: "Logs",
link: `${baseUrl}/logs`,
icon: <Bars3Icon className="h-6 w-6 shrink-0" aria-hidden="true" />,
},
]

return (
<>
<SideNavBack to={`/nodes/${nodeId}/compose`} />
<ul role="list" className="-mx-2 space-y-1">
{items.map((item) => (
<li>
<SideBarItem to={item.link}>
{item.icon}
{item.title}
</SideBarItem>
</li>
))}
</ul>
</>
)
}
29 changes: 29 additions & 0 deletions web/src/components/side-nav/side-nav-container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Bars3Icon, CommandLineIcon } from "@heroicons/react/24/outline"
import { useParams } from "react-router-dom"
import { SideBarItem, SideNavBack } from "./side-nav"

export function SideNavContainer() {
const { nodeId, containerId } = useParams()

return (
<>
<SideNavBack to={`/nodes/${nodeId}/containers`} />
<ul role="list" className="-mx-2 space-y-1">
<li>
<SideBarItem to={`/nodes/${nodeId}/containers/${containerId}/logs`}>
<Bars3Icon className="h-6 w-6 shrink-0" aria-hidden="true" />
Logs
</SideBarItem>
</li>
<li>
<SideBarItem
to={`/nodes/${nodeId}/containers/${containerId}/terminal`}
>
<CommandLineIcon className="h-6 w-6 shrink-0" aria-hidden="true" />
Terminal
</SideBarItem>
</li>
</ul>
</>
)
}
Loading

0 comments on commit dd69b8a

Please sign in to comment.