forge
Explore
Log in

Don't you dare go Hollow

♻️ table column alignment and unified action menus

Browse files at this commit

90064932baae2f5412319bfdfd8869be066d49a0Burak BoduroğluParent: f18fa6e
  • refactor
    • ♻️ table column alignment and unified action menus
Show full message
refactor: ♻️ table column alignment and unified action menus
- add shared TableRowActions dropdown component with IconDotsVertical trigger
- replace inline view/edit/remove buttons with TableRowActions in 5 tables
- center all action columns (w-14), remove right-align overrides
- add border-r column separators to data-table th/td globally
- switch exams table column widths from px to %, left-align start date
- resolve creator names on courses page via getUsers for search & display
- compact dashboard portal cards, grid timeline with date+subtitle on one line
src/components/events/attendance-table.tsxmodified+14 -13
@@ -1,9 +1,9 @@
1 import { For, Show, createSignal } from "solid-js";1 import { For, Show, createSignal } from "solid-js";
2 import type { Attendance } from "@/api/types";2 import type { Attendance } from "@/api/types";
3-import { Button } from "@/components/ui/button";
4 import { ConfirmDialog } from "@/components/ui/confirm-dialog";3 import { ConfirmDialog } from "@/components/ui/confirm-dialog";
5 import { DataTableFrame } from "@/components/ui/data-table";4 import { DataTableFrame } from "@/components/ui/data-table";
6 import { IconTrash } from "@/components/ui/icons";5 import { IconTrash } from "@/components/ui/icons";
6+import { TableRowActions } from "@/components/ui/table-row-actions";
7 import {7 import {
8 Table,8 Table,
9 TableBody,9 TableBody,
@@ -43,7 +43,7 @@ export function AttendanceTable(props: {
43 <TableHead>{t("events.status")}</TableHead>43 <TableHead>{t("events.status")}</TableHead>
44 <TableHead>{t("events.markedBy")}</TableHead>44 <TableHead>{t("events.markedBy")}</TableHead>
45 <Show when={props.canRemove}>45 <Show when={props.canRemove}>
46- <TableHead class="w-28" />46+ <TableHead class="w-14 text-center">{t("common.actions")}</TableHead>
47 </Show>47 </Show>
48 </TableRow>48 </TableRow>
49 </TableHeader>49 </TableHeader>
@@ -59,17 +59,18 @@ export function AttendanceTable(props: {
59 </TableCell>59 </TableCell>
60 <TableCell class="text-sm text-muted-foreground">{personLabel(row.marked_by)}</TableCell>60 <TableCell class="text-sm text-muted-foreground">{personLabel(row.marked_by)}</TableCell>
61 <Show when={props.canRemove && props.onRemove}>61 <Show when={props.canRemove && props.onRemove}>
62- <TableCell>62+ <TableCell class="px-1 text-center">
63- <Button63+ <TableRowActions
64- type="button"64+ label={t("common.actions")}
65- variant="ghost"65+ actions={[
66- size="sm"66+ {
67- class="h-7 rounded-sm text-destructive hover:bg-destructive/10 hover:text-destructive"67+ label: t("common.remove"),
68- onClick={() => setTargetUser(personId(row.user))}68+ icon: <IconTrash class="h-4 w-4" />,
69- >69+ destructive: true,
70- <IconTrash class="h-4 w-4" />70+ onSelect: () => setTargetUser(personId(row.user)),
71- {t("common.remove")}71+ },
72- </Button>72+ ]}
73+ />
73 </TableCell>74 </TableCell>
74 </Show>75 </Show>
75 </TableRow>76 </TableRow>
src/components/ui/icons.tsxmodified+10 -0
@@ -199,6 +199,16 @@ export function IconMenu(props: IconProps) {
199 );199 );
200 }200 }
201 201
202+export function IconDotsVertical(props: IconProps) {
203+ return (
204+ <Svg {...props}>
205+ <circle cx="12" cy="5" r="1" fill="currentColor" stroke="none" />
206+ <circle cx="12" cy="12" r="1" fill="currentColor" stroke="none" />
207+ <circle cx="12" cy="19" r="1" fill="currentColor" stroke="none" />
208+ </Svg>
209+ );
210+}
211+
202 export function IconPanelLeft(props: IconProps) {212 export function IconPanelLeft(props: IconProps) {
203 return (213 return (
204 <Svg {...props}>214 <Svg {...props}>
src/components/ui/table-row-actions.tsxadded+47 -0
@@ -0,0 +1,47 @@
1+import type { JSX } from "solid-js";
2+import { For } from "solid-js";
3+import {
4+ DropdownMenu,
5+ DropdownMenuContent,
6+ DropdownMenuItem,
7+ DropdownMenuTrigger,
8+} from "@/components/ui/dropdown-menu";
9+import { IconDotsVertical } from "@/components/ui/icons";
10+
11+type TableRowAction = {
12+ label: string;
13+ icon: JSX.Element;
14+ onSelect: () => void;
15+ destructive?: boolean;
16+ disabled?: boolean;
17+};
18+
19+export function TableRowActions(props: { label: string; actions: TableRowAction[] }) {
20+ return (
21+ <div class="flex justify-center">
22+ <DropdownMenu placement="bottom-end" gutter={6}>
23+ <DropdownMenuTrigger
24+ class="inline-flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted data-[expanded]:text-foreground"
25+ aria-label={props.label}
26+ >
27+ <IconDotsVertical class="h-4 w-4" />
28+ </DropdownMenuTrigger>
29+ <DropdownMenuContent class="w-44 rounded-lg border-border/80 p-1 shadow-soft">
30+ <For each={props.actions}>
31+ {(action) => (
32+ <DropdownMenuItem
33+ class="rounded-md"
34+ destructive={action.destructive}
35+ disabled={action.disabled}
36+ onSelect={action.onSelect}
37+ >
38+ {action.icon}
39+ <span>{action.label}</span>
40+ </DropdownMenuItem>
41+ )}
42+ </For>
43+ </DropdownMenuContent>
44+ </DropdownMenu>
45+ </div>
46+ );
47+}
src/index.cssmodified+2 -2
@@ -141,11 +141,11 @@
141 }141 }
142 142
143 .data-table th {143 .data-table th {
144- @apply h-9 whitespace-nowrap px-3 text-left text-[11px] font-semibold uppercase tracking-[0.08em];144+ @apply h-9 whitespace-nowrap border-r border-border/60 px-3 text-left text-[11px] font-semibold uppercase tracking-[0.08em] last:border-r-0;
145 }145 }
146 146
147 .data-table td {147 .data-table td {
148- @apply h-9 whitespace-nowrap px-3 py-1.5 align-middle;148+ @apply h-9 whitespace-nowrap border-r border-border/50 px-3 py-1.5 align-middle last:border-r-0;
149 }149 }
150 150
151 .data-table tbody tr {151 .data-table tbody tr {
src/pages/course-detail-page.tsxmodified+18 -16
@@ -36,6 +36,7 @@ import {
36 TableHeader,36 TableHeader,
37 TableRow,37 TableRow,
38 } from "@/components/ui/table";38 } from "@/components/ui/table";
39+import { TableRowActions } from "@/components/ui/table-row-actions";
39 import { Textarea } from "@/components/ui/textarea";40 import { Textarea } from "@/components/ui/textarea";
40 import { UserSearchSelect } from "@/components/users/user-search-select";41 import { UserSearchSelect } from "@/components/users/user-search-select";
41 import { useAuth } from "@/stores/auth-context";42 import { useAuth } from "@/stores/auth-context";
@@ -466,7 +467,7 @@ function CourseDetailContent() {
466 <TableRow>467 <TableRow>
467 <TableHead>{t("admin.username")}</TableHead>468 <TableHead>{t("admin.username")}</TableHead>
468 <TableHead>{t("admin.id")}</TableHead>469 <TableHead>{t("admin.id")}</TableHead>
469- <TableHead class="w-16 text-right" />470+ <TableHead class="w-14 text-center">{t("common.actions")}</TableHead>
470 </TableRow>471 </TableRow>
471 </TableHeader>472 </TableHeader>
472 <TableBody>473 <TableBody>
@@ -479,22 +480,23 @@ function CourseDetailContent() {
479 <TableCell class="mono text-xs text-muted-foreground">480 <TableCell class="mono text-xs text-muted-foreground">
480 {row.user.id}481 {row.user.id}
481 </TableCell>482 </TableCell>
482- <TableCell class="text-right">483+ <TableCell class="px-1 text-center">
483 <Show when={canManage()}>484 <Show when={canManage()}>
484- <Button485+ <TableRowActions
485- type="button"486+ label={t("common.actions")}
486- variant="ghost"487+ actions={[
487- size="sm"488+ {
488- class="h-7 rounded-sm text-destructive hover:bg-destructive/10 hover:text-destructive"489+ label: t("common.remove"),
489- onClick={() =>490+ icon: <IconTrash class="h-4 w-4" />,
490- setRemoveTarget({491+ destructive: true,
491- userId: row.user.id,492+ onSelect: () =>
492- userName: row.user.display_name || row.user.username,493+ setRemoveTarget({
493- })494+ userId: row.user.id,
494- }495+ userName: row.user.display_name || row.user.username,
495- >496+ }),
496- <IconTrash class="h-4 w-4" />497+ },
497- </Button>498+ ]}
499+ />
498 </Show>500 </Show>
499 </TableCell>501 </TableCell>
500 </TableRow>502 </TableRow>
src/pages/courses-page.tsxmodified+30 -15
@@ -1,8 +1,9 @@
1 import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js";1 import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js";
2-import { Link } from "@tanstack/solid-router";2+import { useNavigate } from "@tanstack/solid-router";
3 import { getCourses } from "@/api/getCourses";3 import { getCourses } from "@/api/getCourses";
4 import { getMyCourses } from "@/api/getMyCourses";4 import { getMyCourses } from "@/api/getMyCourses";
5 import { getTerms } from "@/api/getTerms";5 import { getTerms } from "@/api/getTerms";
6+import { getUsers } from "@/api/getUsers";
6 import { postCourse } from "@/api/postCourse";7 import { postCourse } from "@/api/postCourse";
7 import { formatApiError } from "@/api/client";8 import { formatApiError } from "@/api/client";
8 import { Alert } from "@/components/ui/alert";9 import { Alert } from "@/components/ui/alert";
@@ -18,6 +19,7 @@ import { Label } from "@/components/ui/label";
18 import { Select } from "@/components/ui/select";19 import { Select } from "@/components/ui/select";
19 import { SidePanel } from "@/components/ui/side-panel";20 import { SidePanel } from "@/components/ui/side-panel";
20 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";21 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
22+import { TableRowActions } from "@/components/ui/table-row-actions";
21 import { Textarea } from "@/components/ui/textarea";23 import { Textarea } from "@/components/ui/textarea";
22 import { PaginationControls } from "@/components/ui/pagination-controls";24 import { PaginationControls } from "@/components/ui/pagination-controls";
23 import { useAuth } from "@/stores/auth-context";25 import { useAuth } from "@/stores/auth-context";
@@ -36,9 +38,14 @@ export default function CoursesPage() {
36 38
37 function CoursesContent() {39 function CoursesContent() {
38 const auth = useAuth();40 const auth = useAuth();
41+ const navigate = useNavigate();
39 const t = useT();42 const t = useT();
40 const [courses, { refetch }] = createResource(() => getCourses());43 const [courses, { refetch }] = createResource(() => getCourses());
41 const [terms] = createResource(() => getTerms());44 const [terms] = createResource(() => getTerms());
45+ const [users] = createResource(
46+ () => (hasMinRole(auth.user()?.role, "manager") ? true : null),
47+ async (enabled) => (enabled ? getUsers().catch(() => []) : []),
48+ );
42 const [mine] = createResource(49 const [mine] = createResource(
43 () => (auth.user()?.role === "student" ? true : null),50 () => (auth.user()?.role === "student" ? true : null),
44 async (enabled) => (enabled ? getMyCourses() : []),51 async (enabled) => (enabled ? getMyCourses() : []),
@@ -56,11 +63,15 @@ function CoursesContent() {
56 const isStudent = () => auth.user()?.role === "student";63 const isStudent = () => auth.user()?.role === "student";
57 const courseList = createMemo(() => (isStudent() ? mine() : courses()) ?? []);64 const courseList = createMemo(() => (isStudent() ? mine() : courses()) ?? []);
58 const termName = (termId: string | null | undefined) => terms()?.find((term) => term.id === termId)?.name ?? t("terms.unassigned");65 const termName = (termId: string | null | undefined) => terms()?.find((term) => term.id === termId)?.name ?? t("terms.unassigned");
66+ const creatorName = (creatorId: string) => {
67+ if (creatorId === auth.user()?.id) return auth.user()?.username ?? creatorId;
68+ return users()?.find((user) => user.id === creatorId)?.username ?? creatorId;
69+ };
59 const filteredCourses = createMemo(() => {70 const filteredCourses = createMemo(() => {
60 const needle = query().trim().toLocaleLowerCase();71 const needle = query().trim().toLocaleLowerCase();
61 if (!needle) return courseList();72 if (!needle) return courseList();
62 return courseList().filter((course) =>73 return courseList().filter((course) =>
63- [course.title, course.description, course.creator, termName(course.term_id)]74+ [course.title, course.description, course.creator, creatorName(course.creator), termName(course.term_id)]
64 .join(" ")75 .join(" ")
65 .toLocaleLowerCase()76 .toLocaleLowerCase()
66 .includes(needle),77 .includes(needle),
@@ -193,11 +204,11 @@ function CoursesContent() {
193 <DataTableFrame>204 <DataTableFrame>
194 <Table class="data-table table-fixed min-w-[56rem]">205 <Table class="data-table table-fixed min-w-[56rem]">
195 <colgroup>206 <colgroup>
196- <col class="w-[30%]" />
197 <col class="w-[28%]" />207 <col class="w-[28%]" />
198- <col class="w-[16rem]" />208+ <col class="w-[30%]" />
199- <col class="w-[10rem]" />209+ <col class="w-[14rem]" />
200- <col class="w-[8rem]" />210+ <col class="w-[11rem]" />
211+ <col class="w-[3.5rem]" />
201 </colgroup>212 </colgroup>
202 <TableHeader>213 <TableHeader>
203 <TableRow>214 <TableRow>
@@ -205,7 +216,7 @@ function CoursesContent() {
205 <TableHead>{t("form.description")}</TableHead>216 <TableHead>{t("form.description")}</TableHead>
206 <TableHead>{t("terms.term")}</TableHead>217 <TableHead>{t("terms.term")}</TableHead>
207 <TableHead>{t("common.creator")}</TableHead>218 <TableHead>{t("common.creator")}</TableHead>
208- <TableHead class="text-right">{t("common.actions")}</TableHead>219+ <TableHead class="text-center">{t("common.actions")}</TableHead>
209 </TableRow>220 </TableRow>
210 </TableHeader>221 </TableHeader>
211 <TableBody>222 <TableBody>
@@ -226,14 +237,18 @@ function CoursesContent() {
226 <span class="truncate">{termName(course.term_id)}</span>237 <span class="truncate">{termName(course.term_id)}</span>
227 </Badge>238 </Badge>
228 </TableCell>239 </TableCell>
229- <TableCell class="mono truncate text-xs text-muted-foreground">{course.creator}</TableCell>240+ <TableCell class="truncate text-muted-foreground">{creatorName(course.creator)}</TableCell>
230- <TableCell class="text-right">241+ <TableCell class="px-1 text-center">
231- <Link to="/courses/$id" params={{ id: course.id }}>242+ <TableRowActions
232- <Button type="button" variant="ghost" size="sm" class="h-7 rounded-sm px-2">243+ label={t("common.actions")}
233- <IconEye class="h-4 w-4" />244+ actions={[
234- {t("common.view")}245+ {
235- </Button>246+ label: t("common.view"),
236- </Link>247+ icon: <IconEye class="h-4 w-4" />,
248+ onSelect: () => void navigate({ to: "/courses/$id", params: { id: course.id } }),
249+ },
250+ ]}
251+ />
237 </TableCell>252 </TableCell>
238 </TableRow>253 </TableRow>
239 )}254 )}
src/pages/dashboard-page.tsxmodified+35 -44
@@ -279,7 +279,7 @@ function PortalCard(props: { card: PortalCard }) {
279 <Link279 <Link
280 to={to}280 to={to}
281 class={cn(281 class={cn(
282- "group relative flex flex-col overflow-hidden rounded-xl border border-border/60 bg-card p-5 shadow-xs transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md",282+ "group relative flex flex-col overflow-hidden rounded-xl border border-border/60 bg-card p-4 shadow-xs transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md",
283 )}283 )}
284 >284 >
285 <div285 <div
@@ -288,48 +288,37 @@ function PortalCard(props: { card: PortalCard }) {
288 dotMap[accent],288 dotMap[accent],
289 )}289 )}
290 />290 />
291- <div class="flex items-start justify-between">291+ <div class="flex items-center gap-2.5">
292 <div292 <div
293 class={cn(293 class={cn(
294- "flex h-10 w-10 items-center justify-center rounded-lg border",294+ "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border",
295 iconAccentMap[accent],295 iconAccentMap[accent],
296 )}296 )}
297 >297 >
298 {icon}298 {icon}
299 </div>299 </div>
300- <svg300+ <h3 class="truncate font-display text-sm font-semibold">{t(titleKey)}</h3>
301- class="h-4 w-4 text-muted-foreground transition-transform duration-200 group-hover:translate-x-0.5"301+ <Show when={minRole && minRole !== "student"}>
302- viewBox="0 0 16 16"302+ <span
303- fill="none"303+ class={cn(
304- stroke="currentColor"304+ "ml-auto rounded px-1 py-0.5 text-[9px] font-medium uppercase leading-none",
305- stroke-width="2"305+ ROLE_BADGE_TONE[minRole!],
306- stroke-linecap="round"306+ )}
307- stroke-linejoin="round"307+ >
308- >308+ {t(ROLE_KEY[minRole!])}
309- <path d="M5 12l4-4-4-4" />309+ </span>
310- </svg>310+ </Show>
311 </div>311 </div>
312- <div class="mt-4 flex flex-1 flex-col">312+ <div class="mt-1 flex flex-1 flex-col justify-center">
313- <div class="flex items-center gap-2">313+ <Show when={statValue !== ""}>
314- <h3 class="font-display text-sm font-semibold">{t(titleKey)}</h3>314+ <div class="flex items-baseline gap-1 font-display text-xl font-bold tracking-tight">
315- <Show when={minRole && minRole !== "student"}>315+ <span>{statValue}</span>
316- <span316+ <Show when={statSuffix}>
317- class={cn(317+ {(suffix) => <span class="text-xs font-medium text-muted-foreground">{t(suffix())}</span>}
318- "rounded px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none",318+ </Show>
319- ROLE_BADGE_TONE[minRole!],319+ </div>
320- )}320+ </Show>
321- >321+ <p class="text-xs leading-relaxed text-muted-foreground">{t(descKey)}</p>
322- {t(ROLE_KEY[minRole!])}
323- </span>
324- </Show>
325- </div>
326- <div class="flex min-h-[2rem] items-baseline gap-1 font-display text-2xl font-bold tracking-tight">
327- <span class={cn(statValue === "" && "invisible")}>{statValue || "—"}</span>
328- <Show when={statSuffix}>
329- {(suffix) => <span class="text-xs font-medium text-muted-foreground">{t(suffix())}</span>}
330- </Show>
331- </div>
332- <p class="mt-auto text-xs leading-relaxed text-muted-foreground">{t(descKey)}</p>
333 </div>322 </div>
334 </Link>323 </Link>
335 );324 );
@@ -358,11 +347,11 @@ function UpcomingTimeline(props: {
358 <Link347 <Link
359 to={item.type === "event" ? "/events/$id" : "/exams/$id"}348 to={item.type === "event" ? "/events/$id" : "/exams/$id"}
360 params={{ id: item.id }}349 params={{ id: item.id }}
361- class="flex items-center gap-3 rounded-lg border border-transparent px-3 py-2 text-sm transition-colors hover:border-border/60 hover:bg-muted/25"350+ class="grid grid-cols-[28px_1fr] items-center gap-x-3 gap-y-0.5 rounded-lg border border-transparent px-3 py-2 text-sm transition-colors hover:border-border/60 hover:bg-muted/25"
362 >351 >
363 <div352 <div
364 class={cn(353 class={cn(
365- "flex h-7 w-7 shrink-0 items-center justify-center rounded-md",354+ "row-span-2 flex h-7 w-7 items-center justify-center rounded-md",
366 item.type === "exam"355 item.type === "exam"
367 ? "bg-amber-500/10 text-amber-600 dark:text-amber-400"356 ? "bg-amber-500/10 text-amber-600 dark:text-amber-400"
368 : "bg-sky-500/10 text-sky-600 dark:text-sky-400",357 : "bg-sky-500/10 text-sky-600 dark:text-sky-400",
@@ -372,13 +361,15 @@ function UpcomingTimeline(props: {
372 ? <IconExam class="h-3.5 w-3.5" />361 ? <IconExam class="h-3.5 w-3.5" />
373 : <IconCalendar class="h-3.5 w-3.5" />}362 : <IconCalendar class="h-3.5 w-3.5" />}
374 </div>363 </div>
375- <div class="min-w-0 flex-1">364+ <p class="truncate font-medium">{item.title}</p>
376- <p class="truncate font-medium">{item.title}</p>365+ <p class="truncate text-xs text-muted-foreground">
377- <p class="truncate text-xs text-muted-foreground">{item.subtitle}</p>366+ <Show when={item.at != null} fallback={props.t("exams.unscheduled")}>
378- </div>367+ {formatDateTime(item.at!, props.locale)}
379- <span class="shrink-0 whitespace-nowrap text-xs tabular-nums text-muted-foreground">368+ </Show>
380- {item.at == null ? props.t("exams.unscheduled") : formatDateTime(item.at, props.locale)}369+ <Show when={item.subtitle}>
381- </span>370+ {" · "}{item.subtitle}
371+ </Show>
372+ </p>
382 </Link>373 </Link>
383 )}374 )}
384 </For>375 </For>
src/pages/exam-detail-page.tsxmodified+24 -31
@@ -35,6 +35,7 @@ import {
35 TableHeader,35 TableHeader,
36 TableRow,36 TableRow,
37 } from "@/components/ui/table";37 } from "@/components/ui/table";
38+import { TableRowActions } from "@/components/ui/table-row-actions";
38 import { hasMinRole } from "@/lib/roles";39 import { hasMinRole } from "@/lib/roles";
39 import { createNow } from "@/lib/create-now";40 import { createNow } from "@/lib/create-now";
40 import { examKindLabel } from "@/lib/exam-labels";41 import { examKindLabel } from "@/lib/exam-labels";
@@ -447,10 +448,7 @@ function ExamDetailContent() {
447 <TableHead>{t("events.userId")}</TableHead>448 <TableHead>{t("events.userId")}</TableHead>
448 <TableHead>{t("form.mark")}</TableHead>449 <TableHead>{t("form.mark")}</TableHead>
449 <TableHead>{t("exams.gradedBy")}</TableHead>450 <TableHead>{t("exams.gradedBy")}</TableHead>
450- <TableHead>{t("exams.answerSheet")}</TableHead>451+ <TableHead class="w-14 text-center">{t("common.actions")}</TableHead>
451- <Show when={!isFinished()}>
452- <TableHead class="w-24" />
453- </Show>
454 </TableRow>452 </TableRow>
455 </TableHeader>453 </TableHeader>
456 <TableBody>454 <TableBody>
@@ -462,34 +460,29 @@ function ExamDetailContent() {
462 <ExamResultBadge mark={row.mark} />460 <ExamResultBadge mark={row.mark} />
463 </TableCell>461 </TableCell>
464 <TableCell class="text-sm text-muted-foreground">{personLabel(row.graded_by)}</TableCell>462 <TableCell class="text-sm text-muted-foreground">{personLabel(row.graded_by)}</TableCell>
465- <TableCell>463+ <TableCell class="px-1 text-center">
466- <Button464+ <TableRowActions
467- type="button"465+ label={t("common.actions")}
468- variant="ghost"466+ actions={[
469- size="sm"467+ {
470- class="h-7 rounded-sm"468+ label: t("exams.answerSheet"),
471- onClick={() => {469+ icon: <IconEye class="h-4 w-4" />,
472- const rowUserId = personId(row.user);470+ onSelect: () => {
473- setSheetUserId(sheetUserId() === rowUserId ? null : rowUserId);471+ const rowUserId = personId(row.user);
474- }}472+ setSheetUserId(sheetUserId() === rowUserId ? null : rowUserId);
475- >473+ },
476- <IconEye class="h-4 w-4" />474+ },
477- </Button>475+ ...(!isFinished()
476+ ? [{
477+ label: t("common.remove"),
478+ icon: <IconTrash class="h-4 w-4" />,
479+ destructive: true,
480+ onSelect: () => setRemoveUserId(personId(row.user)),
481+ }]
482+ : []),
483+ ]}
484+ />
478 </TableCell>485 </TableCell>
479- <Show when={!isFinished()}>
480- <TableCell>
481- <Button
482- type="button"
483- variant="ghost"
484- size="sm"
485- class="h-7 rounded-sm text-destructive hover:bg-destructive/10 hover:text-destructive"
486- onClick={() => setRemoveUserId(personId(row.user))}
487- >
488- <IconTrash class="h-4 w-4" />
489- {t("common.remove")}
490- </Button>
491- </TableCell>
492- </Show>
493 </TableRow>486 </TableRow>
494 )}487 )}
495 </For>488 </For>
src/pages/exams-page.tsxmodified+30 -25
@@ -1,5 +1,5 @@
1 import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js";1 import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js";
2-import { Link } from "@tanstack/solid-router";2+import { useNavigate } from "@tanstack/solid-router";
3 import { getCourses } from "@/api/getCourses";3 import { getCourses } from "@/api/getCourses";
4 import { getExams } from "@/api/getExams";4 import { getExams } from "@/api/getExams";
5 import { getMyCourses } from "@/api/getMyCourses";5 import { getMyCourses } from "@/api/getMyCourses";
@@ -20,6 +20,7 @@ import { PaginationControls } from "@/components/ui/pagination-controls";
20 import { Select } from "@/components/ui/select";20 import { Select } from "@/components/ui/select";
21 import { SidePanel } from "@/components/ui/side-panel";21 import { SidePanel } from "@/components/ui/side-panel";
22 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";22 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
23+import { TableRowActions } from "@/components/ui/table-row-actions";
23 import { createNow } from "@/lib/create-now";24 import { createNow } from "@/lib/create-now";
24 import { examKindLabel } from "@/lib/exam-labels";25 import { examKindLabel } from "@/lib/exam-labels";
25 import { formatDateTime } from "@/lib/format";26 import { formatDateTime } from "@/lib/format";
@@ -42,6 +43,7 @@ export default function ExamsPage() {
42 43
43 function ExamsContent() {44 function ExamsContent() {
44 const auth = useAuth();45 const auth = useAuth();
46+ const navigate = useNavigate();
45 const t = useT();47 const t = useT();
46 const { locale } = usePreferences();48 const { locale } = usePreferences();
47 const now = createNow();49 const now = createNow();
@@ -218,21 +220,21 @@ function ExamsContent() {
218 <DataTableFrame>220 <DataTableFrame>
219 <Table class="data-table table-fixed min-w-[64rem]">221 <Table class="data-table table-fixed min-w-[64rem]">
220 <colgroup>222 <colgroup>
221- <col class="w-[26%]" />223+ <col class="w-[28%]" />
222- <col class="w-[17%]" />224+ <col class="w-[22%]" />
223- <col class="w-[12rem]" />225+ <col class="w-[18%]" />
224- <col class="w-[9rem]" />226+ <col class="w-[14%]" />
225- <col class="w-[10rem]" />227+ <col class="w-[10%]" />
226- <col class="w-[12rem]" />228+ <col class="w-[8%]" />
227 </colgroup>229 </colgroup>
228 <TableHeader>230 <TableHeader>
229 <TableRow>231 <TableRow>
230 <TableHead>{t("exams.title")}</TableHead>232 <TableHead>{t("exams.title")}</TableHead>
231 <TableHead>{t("nav.courses")}</TableHead>233 <TableHead>{t("nav.courses")}</TableHead>
232- <TableHead class="text-right">{t("events.starts")}</TableHead>234+ <TableHead>{t("events.starts")}</TableHead>
233 <TableHead class="text-center">{t("attempt.status")}</TableHead>235 <TableHead class="text-center">{t("attempt.status")}</TableHead>
234 <TableHead>{t("exams.kind")}</TableHead>236 <TableHead>{t("exams.kind")}</TableHead>
235- <TableHead class="w-44 text-right">{t("common.actions")}</TableHead>237+ <TableHead class="text-center">{t("common.actions")}</TableHead>
236 </TableRow>238 </TableRow>
237 </TableHeader>239 </TableHeader>
238 <TableBody>240 <TableBody>
@@ -248,28 +250,31 @@ function ExamsContent() {
248 </div>250 </div>
249 </TableCell>251 </TableCell>
250 <TableCell class="truncate text-muted-foreground">{courseTitle(exam.course)}</TableCell>252 <TableCell class="truncate text-muted-foreground">{courseTitle(exam.course)}</TableCell>
251- <TableCell class="mono whitespace-nowrap text-right text-muted-foreground">{formatDateTime(exam.starts_at, locale())}</TableCell>253+ <TableCell class="mono whitespace-nowrap text-muted-foreground">{formatDateTime(exam.starts_at, locale())}</TableCell>
252 <TableCell class="text-center">254 <TableCell class="text-center">
253 <Badge variant="outline" class={cn("w-28 justify-center rounded-sm", statusTone(status()))}>255 <Badge variant="outline" class={cn("w-28 justify-center rounded-sm", statusTone(status()))}>
254 {statusLabel(status())}256 {statusLabel(status())}
255 </Badge>257 </Badge>
256 </TableCell>258 </TableCell>
257 <TableCell class="truncate text-muted-foreground">{examKindLabel(String(exam.kind), t)}</TableCell>259 <TableCell class="truncate text-muted-foreground">{examKindLabel(String(exam.kind), t)}</TableCell>
258- <TableCell>260+ <TableCell class="text-center">
259- <div class="flex justify-end gap-1">261+ <TableRowActions
260- <Link to="/exams/$id" params={{ id: exam.id }}>262+ label={t("common.actions")}
261- <Button type="button" variant="ghost" size="sm" class="h-7 rounded-sm px-2">263+ actions={[
262- <IconEye class="h-4 w-4" />264+ {
263- {t("common.view")}265+ label: t("common.view"),
264- </Button>266+ icon: <IconEye class="h-4 w-4" />,
265- </Link>267+ onSelect: () => void navigate({ to: "/exams/$id", params: { id: exam.id } }),
266- <Show when={isTeacherPlus()}>268+ },
267- <Button type="button" variant="ghost" size="sm" class="h-7 rounded-sm px-2" onClick={() => setEditingExam(exam)}>269+ ...(isTeacherPlus()
268- <IconEdit class="h-4 w-4" />270+ ? [{
269- {t("common.edit")}271+ label: t("common.edit"),
270- </Button>272+ icon: <IconEdit class="h-4 w-4" />,
271- </Show>273+ onSelect: () => setEditingExam(exam),
272- </div>274+ }]
275+ : []),
276+ ]}
277+ />
273 </TableCell>278 </TableCell>
274 </TableRow>279 </TableRow>
275 );280 );