-
Notifications
You must be signed in to change notification settings - Fork 1
feat: display files as expandable subrows in File Directory table #83
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
Merged
aakashg00
merged 9 commits into
main
from
81-spring-2026-display-files-as-subrows-in-file-bucket-table
Apr 12, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
457abd6
fix: use juno-sdk 0.0.10
llam36 6ebf7f2
feat: display files as expandable subrows in File Directory table
kworathur 2d254dd
feat: add mock data for File Directory table demo
kworathur c2c5ac4
test: mulit file select and delete
kworathur 53024f3
fix: handle clipboard api rejection
kworathur 2d0dadc
Merge branch 'main' into 81-spring-2026-display-files-as-subrows-in-f…
kworathur f168b14
feat: display files as expandable subrows in File Directory table
kworathur ab7102f
fix: merge conflicts with main
kworathur 49e0ce2
styles: fix code formatting
kworathur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,64 +1,159 @@ | ||
| "use client"; | ||
|
|
||
| import { Button } from "@/components/ui/button"; | ||
| import { Checkbox } from "@/components/ui/checkbox"; | ||
| import { ColumnDef } from "@tanstack/react-table"; | ||
| import { ItemListCell } from "../item-list-cell"; | ||
| import { ChevronDown, ChevronRight, Copy, File, Folder } from "lucide-react"; | ||
| import { toast } from "sonner"; | ||
|
|
||
| export type FileBucketColumn = { | ||
| export type FileStatus = "NOT UPLOADED" | "UPLOADED" | "EXTERNAL"; | ||
|
|
||
| export type FileDirectoryRow = { | ||
| type: "bucket" | "file"; | ||
| name: string; | ||
| configId: number; | ||
| configEnv: string; | ||
| providerName: string; | ||
| fileNames: string[]; | ||
| configId?: number; | ||
| configEnv?: string; | ||
| providerName?: string; | ||
| status?: FileStatus; | ||
| subRows?: FileDirectoryRow[]; | ||
| }; | ||
|
|
||
| const statusPill = | ||
| "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium text-white"; | ||
|
|
||
| const statusStyles: Record<FileStatus, string> = { | ||
| "NOT UPLOADED": `${statusPill} bg-red-400/70`, | ||
| UPLOADED: `${statusPill} bg-emerald-400/70`, | ||
| EXTERNAL: `${statusPill} bg-amber-400/70 text-black`, | ||
| }; | ||
|
kworathur marked this conversation as resolved.
|
||
|
|
||
| export const getFileBucketColumns = ( | ||
| isReadOnly: boolean, | ||
| ): ColumnDef<FileBucketColumn>[] => [ | ||
| { | ||
| id: "select", | ||
| header: ({ table }) => ( | ||
| <Checkbox | ||
| className="ms-2 align-middle mr-5" | ||
| checked={table.getIsAllPageRowsSelected()} | ||
| disabled={isReadOnly} | ||
| onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)} | ||
| /> | ||
| ), | ||
| cell: ({ row }) => ( | ||
| <Checkbox | ||
| className="ms-2 align-middle" | ||
| checked={row.getIsSelected()} | ||
| disabled={isReadOnly} | ||
| onCheckedChange={(value) => row.toggleSelected(!!value)} | ||
| /> | ||
| ), | ||
| size: 50, | ||
| }, | ||
| { | ||
| accessorKey: "name", | ||
| header: "Bucket Name", | ||
| }, | ||
| { | ||
| accessorKey: "configId", | ||
| header: "Config ID", | ||
| }, | ||
| { | ||
| accessorKey: "configEnv", | ||
| header: "Config Env", | ||
| }, | ||
| { | ||
| accessorKey: "providerName", | ||
| header: "Provider Name", | ||
| }, | ||
| { | ||
| accessorKey: "fileNames", | ||
| header: "Files", | ||
| cell: ({ row }) => ( | ||
| <ItemListCell | ||
| itemNames={row.original.fileNames} | ||
| badgeVariant="secondary" | ||
| /> | ||
| ), | ||
| }, | ||
| ]; | ||
| ): ColumnDef<FileDirectoryRow>[] => { | ||
| return [ | ||
| { | ||
| id: "select", | ||
| header: ({ table }) => ( | ||
| <Checkbox | ||
| className="ms-2 align-middle mr-5" | ||
| disabled={isReadOnly} | ||
| checked={table.getIsAllPageRowsSelected()} | ||
| onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)} | ||
| /> | ||
| ), | ||
| cell: ({ row }) => ( | ||
| <Checkbox | ||
| className="ms-2 align-middle" | ||
| checked={row.getIsSelected()} | ||
| onCheckedChange={(value) => row.toggleSelected(!!value)} | ||
| /> | ||
| ), | ||
| size: 50, | ||
| }, | ||
| { | ||
| id: "expand", | ||
| header: () => null, | ||
| cell: ({ row }) => | ||
| row.getCanExpand() ? ( | ||
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| onClick={row.getToggleExpandedHandler()} | ||
| className="p-0 h-6 w-6" | ||
| > | ||
| {row.getIsExpanded() ? ( | ||
| <ChevronDown className="h-4 w-4" /> | ||
| ) : ( | ||
| <ChevronRight className="h-4 w-4" /> | ||
| )} | ||
| </Button> | ||
| ) : null, | ||
| size: 40, | ||
| }, | ||
| { | ||
| accessorKey: "name", | ||
| header: "Name", | ||
| filterFn: (row, _columnId, filterValue: string) => { | ||
| const search = filterValue.toLowerCase(); | ||
| if (row.original.name.toLowerCase().includes(search)) return true; | ||
| return ( | ||
| row.original.subRows?.some((file) => | ||
| file.name.toLowerCase().includes(search), | ||
| ) ?? false | ||
| ); | ||
| }, | ||
| cell: ({ row }) => ( | ||
| <div | ||
| className={`flex items-center gap-2 ${row.original.type === "file" ? "pl-8" : ""}`} | ||
| > | ||
| {row.original.type === "bucket" ? ( | ||
| <Folder className="h-4 w-4 text-muted-foreground" /> | ||
| ) : ( | ||
| <File className="h-4 w-4 text-muted-foreground" /> | ||
| )} | ||
| <span>{row.original.name}</span> | ||
| </div> | ||
| ), | ||
| }, | ||
| { | ||
| accessorKey: "configId", | ||
| header: "Config ID", | ||
| cell: ({ row }) => | ||
| row.original.type === "bucket" ? row.original.configId : null, | ||
| }, | ||
| { | ||
| accessorKey: "configEnv", | ||
| header: "Config Env", | ||
| cell: ({ row }) => | ||
| row.original.type === "bucket" ? row.original.configEnv : null, | ||
| }, | ||
| { | ||
| accessorKey: "providerName", | ||
| header: "Provider Name", | ||
| cell: ({ row }) => | ||
| row.original.type === "bucket" ? row.original.providerName : null, | ||
| }, | ||
| { | ||
| id: "status", | ||
| header: () => <div className="text-center">Status</div>, | ||
| cell: ({ row }) => { | ||
| if (row.original.type !== "file" || !row.original.status) return null; | ||
| return ( | ||
| <div className="flex justify-center"> | ||
| <span className={statusStyles[row.original.status]}> | ||
| {row.original.status} | ||
| </span> | ||
| </div> | ||
| ); | ||
| }, | ||
| }, | ||
| { | ||
| id: "actions", | ||
| header: () => <div className="text-center">Actions</div>, | ||
| cell: ({ row }) => { | ||
| if (row.original.type !== "file") return null; | ||
| return ( | ||
| <div className="flex justify-center"> | ||
| <Button | ||
| variant="ghost" | ||
| size="sm" | ||
| className="h-8 w-8 p-0" | ||
| onClick={() => { | ||
| navigator.clipboard | ||
| .writeText(row.original.name) | ||
| .then(() => { | ||
| toast.success("Copied file name to clipboard"); | ||
| }) | ||
| .catch(() => { | ||
| toast.error("Failed to copy file name to clipboard"); | ||
| }); | ||
| }} | ||
| > | ||
| <Copy className="h-4 w-4" /> | ||
| </Button> | ||
| </div> | ||
| ); | ||
| }, | ||
| }, | ||
| ]; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.