-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
412 additions
and
34 deletions.
There are no files selected for viewing
21 changes: 20 additions & 1 deletion
21
apps/dashboard/src/app/[locale]/@dashboard/(root)/vault/[[...folders]]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
export function Breadcrumbs({ folders }) { | ||
return folders?.map((folder) => <span key={folder}>{folder}</span>); | ||
"use client"; | ||
|
||
import { useI18n } from "@/locales/client"; | ||
import { Icons } from "@midday/ui/icons"; | ||
import Link from "next/link"; | ||
import { translatedFolderName } from "./tables/vault/data-table-row"; | ||
|
||
export function Breadcrumbs({ folders = [] }) { | ||
const t = useI18n(); | ||
|
||
const allFolders = ["all", ...folders]; | ||
|
||
const links = allFolders?.map((folder, index) => { | ||
const isLast = folders.length === index; | ||
const href = folder === "all" ? "/vault" : `/vault/${folder}`; | ||
|
||
return ( | ||
<div className="flex items-center" key={folder}> | ||
<Link href={href} className="max-w-[100px] truncate"> | ||
<span key={folder}>{translatedFolderName(t, folder)}</span> | ||
</Link> | ||
|
||
{folders.length > 0 && !isLast && ( | ||
<Icons.ArrowRight className="text-[#878787] mx-1" size={16} /> | ||
)} | ||
</div> | ||
); | ||
}); | ||
|
||
return <div className="flex">{links}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 73 additions & 21 deletions
94
apps/dashboard/src/components/tables/vault/data-table-row.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,89 @@ | ||
"use client"; | ||
|
||
import { FileIcon } from "@/components/file-icon"; | ||
import { useI18n } from "@/locales/client"; | ||
import { formatSize } from "@/utils/format"; | ||
import { Icons } from "@midday/ui/icons"; | ||
import { | ||
ContextMenu, | ||
ContextMenuContent, | ||
ContextMenuItem, | ||
ContextMenuSub, | ||
ContextMenuSubContent, | ||
ContextMenuSubTrigger, | ||
ContextMenuTrigger, | ||
} from "@midday/ui/context-menu"; | ||
import { TableCell, TableRow } from "@midday/ui/table"; | ||
import { format } from "date-fns"; | ||
import { usePathname, useRouter } from "next/navigation"; | ||
|
||
export const translatedFolderName = (t: any, folder: string) => { | ||
switch (folder) { | ||
case "all": | ||
return t("folders.all"); | ||
case "inbox": | ||
return t("folders.inbox"); | ||
case "transactions": | ||
return t("folders.transactions"); | ||
case "exports": | ||
return t("folders.exports"); | ||
|
||
default: | ||
return folder; | ||
} | ||
}; | ||
|
||
export function DataTableRow({ data }) { | ||
const t = useI18n(); | ||
const router = useRouter(); | ||
const pathname = usePathname(); | ||
|
||
const handleNavigate = () => router.push(`${pathname}/${data.name}`); | ||
const handleNavigate = () => { | ||
if (data.isFolder) { | ||
router.push(`${pathname}/${data.name}`); | ||
} | ||
}; | ||
|
||
return ( | ||
<TableRow className="h-[45px]" onClick={handleNavigate}> | ||
<TableCell> | ||
<div className="flex items-center space-x-2"> | ||
<FileIcon mimetype={data?.metadata?.mimetype} name={data.name} /> | ||
<span>{data.name}</span> | ||
{data?.metadata?.size && ( | ||
<span className="text-[#878787]"> | ||
{formatSize(data.metadata.size)} | ||
</span> | ||
)} | ||
</div> | ||
</TableCell> | ||
<TableCell> | ||
{data?.created_at && format(new Date(data.created_at), "MMM d, yyyy")} | ||
</TableCell> | ||
<TableCell> | ||
<Icons.MoreHoriz size={16} /> | ||
</TableCell> | ||
</TableRow> | ||
<ContextMenu> | ||
<ContextMenuTrigger asChild> | ||
<TableRow className="h-[45px] cursor-default" onClick={handleNavigate}> | ||
<TableCell> | ||
<div className="flex items-center space-x-2"> | ||
<FileIcon | ||
mimetype={data?.metadata?.mimetype} | ||
name={data.name} | ||
isFolder={data.isFolder} | ||
/> | ||
<span>{translatedFolderName(t, data.name)}</span> | ||
{data?.metadata?.size && ( | ||
<span className="text-[#878787]"> | ||
{formatSize(data.metadata.size)} | ||
</span> | ||
)} | ||
</div> | ||
</TableCell> | ||
<TableCell> | ||
{data?.created_at ? format(new Date(data.created_at), "Pp") : "-"} | ||
</TableCell> | ||
<TableCell> | ||
{data?.updated_at ? format(new Date(data.updated_at), "Pp") : "-"} | ||
</TableCell> | ||
</TableRow> | ||
</ContextMenuTrigger> | ||
|
||
<ContextMenuContent> | ||
<ContextMenuSub> | ||
<ContextMenuSubTrigger>Get URL</ContextMenuSubTrigger> | ||
<ContextMenuSubContent> | ||
<ContextMenuItem>Expire in 1 week</ContextMenuItem> | ||
<ContextMenuItem>Expire in 1 month</ContextMenuItem> | ||
<ContextMenuItem>Expire in 1 year</ContextMenuItem> | ||
</ContextMenuSubContent> | ||
</ContextMenuSub> | ||
<ContextMenuItem>Rename</ContextMenuItem> | ||
<ContextMenuItem>Download</ContextMenuItem> | ||
<ContextMenuItem>Delete</ContextMenuItem> | ||
</ContextMenuContent> | ||
</ContextMenu> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/dashboard/src/components/tables/vault/empty-table.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
type Props = { | ||
type: string; | ||
}; | ||
|
||
export function EmptyTable({ type }: Props) { | ||
switch (type) { | ||
case "inbox": | ||
return ( | ||
<div className="border border-t-0 p-4 h-[calc(100vh-240px)] flex justify-center items-center"> | ||
<div className="items-center flex flex-col text-center"> | ||
<h2 className="mb-2">This is your inbox</h2> | ||
<p className="text-sm text-[#878787]"> | ||
Everything that will be sent to your <br /> | ||
Midday email will end up here. | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
|
||
default: | ||
return ( | ||
<div className="border border-t-0 p-4 h-[calc(100vh-240px)] flex justify-center items-center"> | ||
<div className="items-center flex flex-col text-center"> | ||
<h2 className="mb-2">Drop your files here</h2> | ||
<p className="text-sm text-[#878787]"> | ||
Or upload them via the <br /> "Upload file" button above | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import { getVault } from "@midday/supabase/cached-queries"; | ||
import { DataTable } from "./data-table"; | ||
import { EmptyTable } from "./empty-table"; | ||
|
||
export async function Table({ path }) { | ||
const { data } = await getVault({ path }); | ||
|
||
return ( | ||
<div className="mt-8"> | ||
<div className="mt-6"> | ||
<DataTable data={data} /> | ||
{data.length === 0 && <EmptyTable type={path} />} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.