mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
refactor: top level dir + moved route
create a root directory entry in table for each user and move file browser under /directories/$id
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { api } from "@fileone/convex/_generated/api"
|
||||
import { Link, useLocation } from "@tanstack/react-router"
|
||||
import { useAuth } from "@workos-inc/authkit-react"
|
||||
import { useQuery as useConvexQuery } from "convex/react"
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
FilesIcon,
|
||||
@@ -59,18 +61,34 @@ function MainSidebarMenu() {
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton asChild isActive={isActive("/files")}>
|
||||
<Link to="/files">
|
||||
<FilesIcon />
|
||||
<span>All Files</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
<AllFilesItem />
|
||||
</SidebarMenu>
|
||||
)
|
||||
}
|
||||
|
||||
function AllFilesItem() {
|
||||
const location = useLocation()
|
||||
const rootDirectory = useConvexQuery(api.files.fetchRootDirectory)
|
||||
|
||||
if (!rootDirectory) return null
|
||||
|
||||
return (
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
isActive={location.pathname.startsWith(
|
||||
`/directories/${rootDirectory._id}`,
|
||||
)}
|
||||
>
|
||||
<Link to={`/directories/${rootDirectory._id}`}>
|
||||
<FilesIcon />
|
||||
<span>All Files</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
)
|
||||
}
|
||||
|
||||
function UserMenu() {
|
||||
const { signOut } = useAuth()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user