summaryrefslogtreecommitdiff
path: root/lib/dolce/table/file-list-columns.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dolce/table/file-list-columns.tsx')
-rw-r--r--lib/dolce/table/file-list-columns.tsx55
1 files changed, 44 insertions, 11 deletions
diff --git a/lib/dolce/table/file-list-columns.tsx b/lib/dolce/table/file-list-columns.tsx
index 36a579a3..3018e240 100644
--- a/lib/dolce/table/file-list-columns.tsx
+++ b/lib/dolce/table/file-list-columns.tsx
@@ -3,23 +3,30 @@
import { ColumnDef } from "@tanstack/react-table";
import { FileInfoItem } from "../actions";
import { Button } from "@/components/ui/button";
-import { Download } from "lucide-react";
+import { Download, Trash2, Loader2 } from "lucide-react";
import { formatDolceDateTime } from "../utils/date-formatter";
interface FileListColumnsProps {
onDownload: (file: FileInfoItem) => void;
+ onDelete?: (file: FileInfoItem) => void;
lng?: string;
+ downloadingFileId?: string | null;
}
export const createFileListColumns = ({
onDownload,
+ onDelete,
lng = "ko",
+ downloadingFileId,
}: FileListColumnsProps): ColumnDef<FileInfoItem>[] => [
{
accessorKey: "FileSeq",
header: lng === "ko" ? "순번" : "No.",
minSize: 80,
cell: ({ row }) => {
+ if (row.original.FileServerId === "LOCAL") {
+ return <div className="text-center">-</div>;
+ }
return <div className="text-center">{row.getValue("FileSeq")}</div>;
},
},
@@ -55,18 +62,44 @@ export const createFileListColumns = ({
},
{
id: "actions",
- header: lng === "ko" ? "다운로드" : "Download",
- minSize: 120,
+ header: "Action",
+ minSize: 160,
cell: ({ row }) => {
+ const isLocal = row.original.FileServerId === "LOCAL";
+ const isDownloading = downloadingFileId === row.original.FileId;
+
return (
- <Button
- variant="outline"
- size="sm"
- onClick={() => onDownload(row.original)}
- >
- <Download className="h-4 w-4 mr-2" />
- {lng === "ko" ? "다운로드" : "Download"}
- </Button>
+ <div className="flex gap-2 items-center justify-center">
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={isDownloading}
+ onClick={(e) => {
+ e.stopPropagation();
+ onDownload(row.original);
+ }}
+ >
+ {isDownloading ? (
+ <Loader2 className="h-4 w-4 mr-2 animate-spin" />
+ ) : (
+ <Download className="h-4 w-4 mr-2" />
+ )}
+ {lng === "ko" ? "다운로드" : "Download"}
+ </Button>
+ {isLocal && onDelete && (
+ <Button
+ variant="destructive"
+ size="sm"
+ disabled={isDownloading}
+ onClick={(e) => {
+ e.stopPropagation();
+ onDelete(row.original);
+ }}
+ >
+ <Trash2 className="h-4 w-4" />
+ </Button>
+ )}
+ </div>
);
},
},