This commit is contained in:
rgrgogu
2026-07-20 08:17:38 +08:00
parent cab0883512
commit d021725c1b
8 changed files with 149 additions and 168 deletions
@@ -2,7 +2,7 @@
// Column definitions and pinning for the standalone Lesson Library table. // Column definitions and pinning for the standalone Lesson Library table.
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Clock } from "lucide-react"; import { Clock, Layers } from "lucide-react";
import { buildColumns } from "@/utils/table.util"; import { buildColumns } from "@/utils/table.util";
import { buildSelectionColumn } from "@/components/generic/Table/buildSelectionColumn"; import { buildSelectionColumn } from "@/components/generic/Table/buildSelectionColumn";
import { buildRowActionsColumn } from "@/components/generic/Table/buildRowActionsColumn"; import { buildRowActionsColumn } from "@/components/generic/Table/buildRowActionsColumn";
@@ -13,13 +13,23 @@ export const columnPinning = {
left: [], left: [],
}; };
const COURSE_STATUS_BADGE = {
published: "default",
draft: "secondary",
standalone: "outline",
};
const cellOverrides = { const cellOverrides = {
title: (info) => {
const inUnit = parseInt(info.row.original.unit_count ?? 0, 10) > 0;
return (
<div className="flex items-center gap-1.5 min-w-0">
{inUnit && (
<Badge variant="secondary" className="gap-1 text-[10px] font-medium shrink-0">
<Layers className="h-3 w-3" />
Unit
</Badge>
)}
<span className="block truncate max-w-56 text-sm" title={info.getValue()}>
{info.getValue()}
</span>
</div>
);
},
duration_seconds: (info) => { duration_seconds: (info) => {
const seconds = parseInt(info.getValue() ?? 0, 10); const seconds = parseInt(info.getValue() ?? 0, 10);
return ( return (
@@ -39,11 +49,6 @@ const cellOverrides = {
</Badge> </Badge>
); );
}, },
course_status: (info) => (
<Badge variant={COURSE_STATUS_BADGE[info.getValue()] ?? "outline"} className="text-xs capitalize">
{info.getValue()}
</Badge>
),
}; };
export function buildDataColumns(attributes, rowActions) { export function buildDataColumns(attributes, rowActions) {
@@ -2,7 +2,7 @@
// Column definitions and pinning for the standalone Unit Library table. // Column definitions and pinning for the standalone Unit Library table.
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Clock } from "lucide-react"; import { Clock, GraduationCap } from "lucide-react";
import { buildColumns } from "@/utils/table.util"; import { buildColumns } from "@/utils/table.util";
import { buildSelectionColumn } from "@/components/generic/Table/buildSelectionColumn"; import { buildSelectionColumn } from "@/components/generic/Table/buildSelectionColumn";
import { buildRowActionsColumn } from "@/components/generic/Table/buildRowActionsColumn"; import { buildRowActionsColumn } from "@/components/generic/Table/buildRowActionsColumn";
@@ -13,13 +13,23 @@ export const columnPinning = {
left: [], left: [],
}; };
const COURSE_STATUS_BADGE = {
published: "default",
draft: "secondary",
standalone: "outline",
};
const cellOverrides = { const cellOverrides = {
title: (info) => {
const inCourse = parseInt(info.row.original.course_count ?? 0, 10) > 0;
return (
<div className="flex items-center gap-1.5 min-w-0">
{inCourse && (
<Badge variant="secondary" className="gap-1 text-[10px] font-medium shrink-0">
<GraduationCap className="h-3 w-3" />
Course
</Badge>
)}
<span className="block truncate max-w-56 text-sm" title={info.getValue()}>
{info.getValue()}
</span>
</div>
);
},
duration_seconds: (info) => { duration_seconds: (info) => {
const seconds = parseInt(info.getValue() ?? 0, 10); const seconds = parseInt(info.getValue() ?? 0, 10);
return ( return (
@@ -36,19 +46,6 @@ const cellOverrides = {
{info.getValue() ?? 0} lesson{(info.getValue() ?? 0) === 1 ? "" : "s"} {info.getValue() ?? 0} lesson{(info.getValue() ?? 0) === 1 ? "" : "s"}
</Badge> </Badge>
), ),
course_count: (info) => {
const n = parseInt(info.getValue() ?? 0, 10);
return (
<Badge variant="secondary" className="text-xs tabular-nums">
{n} course{n === 1 ? "" : "s"}
</Badge>
);
},
course_status: (info) => (
<Badge variant={COURSE_STATUS_BADGE[info.getValue()] ?? "outline"} className="text-xs capitalize">
{info.getValue()}
</Badge>
),
}; };
export function buildDataColumns(attributes, rowActions) { export function buildDataColumns(attributes, rowActions) {
@@ -14,12 +14,6 @@ export function buildRowActions({ onView, onEdit, onManageLessons, onArchive, on
icon: <Eye className="h-3.5 w-3.5" />, icon: <Eye className="h-3.5 w-3.5" />,
onClick: (row) => onView(row), onClick: (row) => onView(row),
}, },
{
key: "edit",
label: "Edit Unit",
icon: <Pencil className="h-3.5 w-3.5" />,
onClick: (row) => onEdit(row),
},
{ {
key: "manage_lessons", key: "manage_lessons",
label: "Manage Lessons", label: "Manage Lessons",
+7 -22
View File
@@ -185,12 +185,6 @@ export default function AddAsset() {
hasFileError = true; hasFileError = true;
} }
// Thumbnail is required for video, optional for audio
if (isVideo && !thumbnailRef.current) {
setError("_thumbnail", { message: "A thumbnail is required for video uploads." });
hasFileError = true;
}
if (hasFileError) return; if (hasFileError) return;
setProgress({ phase: "uploading", pct: 0 }); setProgress({ phase: "uploading", pct: 0 });
@@ -259,15 +253,14 @@ export default function AddAsset() {
</Link> </Link>
</div> </div>
{/* ── Thumbnail (video required / audio optional) ── */} {/* ── Thumbnail (optional for both video and audio) ── */}
{(isVideo || isAudio) && ( {(isVideo || isAudio) && (
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label> <Label>
Thumbnail{" "} Thumbnail{" "}
{isVideo <span className="text-muted-foreground text-xs">
? <span className="text-destructive">*</span> (optional — {isVideo ? "video preview" : "album / cover art"})
: <span className="text-muted-foreground text-xs">(optional — album / cover art)</span> </span>
}
</Label> </Label>
<DropZone <DropZone
key={thumbKey} key={thumbKey}
@@ -350,23 +343,15 @@ export default function AddAsset() {
/> />
</div> </div>
{/* Storage Provider */} {/* Storage Provider — TEMPORARY: locked to S3 (see zrok tunnel note above; revert after VPS migration) */}
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label>Storage</Label> <Label>Storage</Label>
<Controller <Select value="s3" disabled>
name="storage_provider" <SelectTrigger className="disabled:opacity-60 disabled:cursor-not-allowed"><SelectValue /></SelectTrigger>
control={control}
render={({ field }) => (
<Select value={field.value} onValueChange={field.onChange}>
<SelectTrigger><SelectValue /></SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="chibisafe">Chibisafe</SelectItem>
<SelectItem value="local">Local</SelectItem>
<SelectItem value="s3">S3</SelectItem> <SelectItem value="s3">S3</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
)}
/>
</div> </div>
</div> </div>
@@ -131,7 +131,8 @@ export default function AddAssetsBulk() {
const { user } = useAuth(); const { user } = useAuth();
const [isPublic, setIsPublic] = useState("false"); const [isPublic, setIsPublic] = useState("false");
const [storageProvider, setStorageProvider] = useState("s3"); // TEMPORARY: locked to S3 (see zrok tunnel note; revert after VPS migration)
const storageProvider = "s3";
const total = jobs.length; const total = jobs.length;
const done = jobs.filter((j) => j.status === "uploaded").length; const done = jobs.filter((j) => j.status === "uploaded").length;
@@ -177,11 +178,10 @@ export default function AddAssetsBulk() {
</div> </div>
<div className="flex-1 space-y-1.5"> <div className="flex-1 space-y-1.5">
<label className="text-sm font-medium">Storage</label> <label className="text-sm font-medium">Storage</label>
<Select value={storageProvider} onValueChange={setStorageProvider}> {/* TEMPORARY: locked to S3 (see zrok tunnel note; revert after VPS migration) */}
<SelectTrigger><SelectValue /></SelectTrigger> <Select value={storageProvider} disabled>
<SelectTrigger className="disabled:opacity-60 disabled:cursor-not-allowed"><SelectValue /></SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="chibisafe">Chibisafe</SelectItem>
<SelectItem value="local">Local</SelectItem>
<SelectItem value="s3">S3</SelectItem> <SelectItem value="s3">S3</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
@@ -113,7 +113,7 @@ function InviteLinkDialog({ open, onOpenChange, group }) {
{/* Invite link */} {/* Invite link */}
<div className="w-full flex flex-col gap-2"> <div className="w-full flex flex-col gap-2">
<div className="flex items-center gap-2 rounded-lg border bg-muted px-3 py-2 min-w-0"> <div className="flex items-center gap-2 rounded-lg border bg-muted px-3 py-2 min-w-0">
<p className="font-mono text-xs text-muted-foreground truncate flex-1"> <p className="font-mono text-xs text-muted-foreground truncate w-64">
{inviteUrl} {inviteUrl}
</p> </p>
</div> </div>
+1 -1
View File
@@ -112,7 +112,7 @@ function ReferDialog({ open, onOpenChange }) {
{/* Invite link */} {/* Invite link */}
<div className="w-full flex flex-col gap-2"> <div className="w-full flex flex-col gap-2">
<div className="flex items-center gap-2 rounded-lg border bg-muted px-3 py-2 min-w-0"> <div className="flex items-center gap-2 rounded-lg border bg-muted px-3 py-2 min-w-0">
<p className="font-mono text-xs text-muted-foreground truncate flex-1"> <p className="font-mono text-xs text-muted-foreground truncate w-64">
{inviteUrl} {inviteUrl}
</p> </p>
</div> </div>
+1 -1
View File
@@ -129,7 +129,7 @@ function renderCell(attr, value) {
} }
case "date": return <span className="text-xs text-muted-foreground">{formatDate(value)}</span>; case "date": return <span className="text-xs text-muted-foreground">{formatDate(value)}</span>;
case "number": return <span className="font-mono text-xs font-semibold text-muted-foreground">{value}</span>; case "number": return <span className="font-mono text-xs font-semibold text-muted-foreground">{value}</span>;
default: return <span className="text-sm">{value}</span>; default: return <span className="block truncate max-w-56 text-sm" title={String(value)}>{value}</span>;
} }
} }