From 90064932baae2f5412319bfdfd8869be066d49a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:50:25 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20table=20column?= =?UTF-8?q?=20alignment=20and=20unified=20action=20menus=20-=20add=20share?= =?UTF-8?q?d=20TableRowActions=20dropdown=20component=20with=20IconDotsVer?= =?UTF-8?q?tical=20trigger=20-=20replace=20inline=20view/edit/remove=20but?= =?UTF-8?q?tons=20with=20TableRowActions=20in=205=20tables=20-=20center=20?= =?UTF-8?q?all=20action=20columns=20(w-14),=20remove=20right-align=20overr?= =?UTF-8?q?ides=20-=20add=20border-r=20column=20separators=20to=20data-tab?= =?UTF-8?q?le=20th/td=20globally=20-=20switch=20exams=20table=20column=20w?= =?UTF-8?q?idths=20from=20px=20to=20%,=20left-align=20start=20date=20-=20r?= =?UTF-8?q?esolve=20creator=20names=20on=20courses=20page=20via=20getUsers?= =?UTF-8?q?=20for=20search=20&=20display=20-=20compact=20dashboard=20porta?= =?UTF-8?q?l=20cards,=20grid=20timeline=20with=20date+subtitle=20on=20one?= =?UTF-8?q?=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/events/attendance-table.tsx | 27 ++++---- src/components/ui/icons.tsx | 10 +++ src/components/ui/table-row-actions.tsx | 47 +++++++++++++ src/index.css | 4 +- src/pages/course-detail-page.tsx | 34 +++++----- src/pages/courses-page.tsx | 45 ++++++++---- src/pages/dashboard-page.tsx | 79 ++++++++++------------ src/pages/exam-detail-page.tsx | 55 +++++++-------- src/pages/exams-page.tsx | 55 ++++++++------- 9 files changed, 210 insertions(+), 146 deletions(-) create mode 100644 src/components/ui/table-row-actions.tsx diff --git a/src/components/events/attendance-table.tsx b/src/components/events/attendance-table.tsx index 7c04dd8..b52dd27 100644 --- a/src/components/events/attendance-table.tsx +++ b/src/components/events/attendance-table.tsx @@ -1,9 +1,9 @@ import { For, Show, createSignal } from "solid-js"; import type { Attendance } from "@/api/types"; -import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTableFrame } from "@/components/ui/data-table"; import { IconTrash } from "@/components/ui/icons"; +import { TableRowActions } from "@/components/ui/table-row-actions"; import { Table, TableBody, @@ -43,7 +43,7 @@ export function AttendanceTable(props: { {t("events.status")} {t("events.markedBy")} - + {t("common.actions")} @@ -59,17 +59,18 @@ export function AttendanceTable(props: { {personLabel(row.marked_by)} - - + + , + destructive: true, + onSelect: () => setTargetUser(personId(row.user)), + }, + ]} + /> diff --git a/src/components/ui/icons.tsx b/src/components/ui/icons.tsx index 1d1ccfa..79bd103 100644 --- a/src/components/ui/icons.tsx +++ b/src/components/ui/icons.tsx @@ -199,6 +199,16 @@ export function IconMenu(props: IconProps) { ); } +export function IconDotsVertical(props: IconProps) { + return ( + + + + + + ); +} + export function IconPanelLeft(props: IconProps) { return ( diff --git a/src/components/ui/table-row-actions.tsx b/src/components/ui/table-row-actions.tsx new file mode 100644 index 0000000..08fc79b --- /dev/null +++ b/src/components/ui/table-row-actions.tsx @@ -0,0 +1,47 @@ +import type { JSX } from "solid-js"; +import { For } from "solid-js"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { IconDotsVertical } from "@/components/ui/icons"; + +type TableRowAction = { + label: string; + icon: JSX.Element; + onSelect: () => void; + destructive?: boolean; + disabled?: boolean; +}; + +export function TableRowActions(props: { label: string; actions: TableRowAction[] }) { + return ( +
+ + + + + + + {(action) => ( + + {action.icon} + {action.label} + + )} + + + +
+ ); +} diff --git a/src/index.css b/src/index.css index 50ea6c7..b3cf779 100644 --- a/src/index.css +++ b/src/index.css @@ -141,11 +141,11 @@ } .data-table th { - @apply h-9 whitespace-nowrap px-3 text-left text-[11px] font-semibold uppercase tracking-[0.08em]; + @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; } .data-table td { - @apply h-9 whitespace-nowrap px-3 py-1.5 align-middle; + @apply h-9 whitespace-nowrap border-r border-border/50 px-3 py-1.5 align-middle last:border-r-0; } .data-table tbody tr { diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index f14b389..9f3bd29 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -36,6 +36,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { TableRowActions } from "@/components/ui/table-row-actions"; import { Textarea } from "@/components/ui/textarea"; import { UserSearchSelect } from "@/components/users/user-search-select"; import { useAuth } from "@/stores/auth-context"; @@ -466,7 +467,7 @@ function CourseDetailContent() { {t("admin.username")} {t("admin.id")} - + {t("common.actions")} @@ -479,22 +480,23 @@ function CourseDetailContent() { {row.user.id} - + - + , + destructive: true, + onSelect: () => + setRemoveTarget({ + userId: row.user.id, + userName: row.user.display_name || row.user.username, + }), + }, + ]} + /> diff --git a/src/pages/courses-page.tsx b/src/pages/courses-page.tsx index 58ba268..a352097 100644 --- a/src/pages/courses-page.tsx +++ b/src/pages/courses-page.tsx @@ -1,8 +1,9 @@ import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; -import { Link } from "@tanstack/solid-router"; +import { useNavigate } from "@tanstack/solid-router"; import { getCourses } from "@/api/getCourses"; import { getMyCourses } from "@/api/getMyCourses"; import { getTerms } from "@/api/getTerms"; +import { getUsers } from "@/api/getUsers"; import { postCourse } from "@/api/postCourse"; import { formatApiError } from "@/api/client"; import { Alert } from "@/components/ui/alert"; @@ -18,6 +19,7 @@ import { Label } from "@/components/ui/label"; import { Select } from "@/components/ui/select"; import { SidePanel } from "@/components/ui/side-panel"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { TableRowActions } from "@/components/ui/table-row-actions"; import { Textarea } from "@/components/ui/textarea"; import { PaginationControls } from "@/components/ui/pagination-controls"; import { useAuth } from "@/stores/auth-context"; @@ -36,9 +38,14 @@ export default function CoursesPage() { function CoursesContent() { const auth = useAuth(); + const navigate = useNavigate(); const t = useT(); const [courses, { refetch }] = createResource(() => getCourses()); const [terms] = createResource(() => getTerms()); + const [users] = createResource( + () => (hasMinRole(auth.user()?.role, "manager") ? true : null), + async (enabled) => (enabled ? getUsers().catch(() => []) : []), + ); const [mine] = createResource( () => (auth.user()?.role === "student" ? true : null), async (enabled) => (enabled ? getMyCourses() : []), @@ -56,11 +63,15 @@ function CoursesContent() { const isStudent = () => auth.user()?.role === "student"; const courseList = createMemo(() => (isStudent() ? mine() : courses()) ?? []); const termName = (termId: string | null | undefined) => terms()?.find((term) => term.id === termId)?.name ?? t("terms.unassigned"); + const creatorName = (creatorId: string) => { + if (creatorId === auth.user()?.id) return auth.user()?.username ?? creatorId; + return users()?.find((user) => user.id === creatorId)?.username ?? creatorId; + }; const filteredCourses = createMemo(() => { const needle = query().trim().toLocaleLowerCase(); if (!needle) return courseList(); return courseList().filter((course) => - [course.title, course.description, course.creator, termName(course.term_id)] + [course.title, course.description, course.creator, creatorName(course.creator), termName(course.term_id)] .join(" ") .toLocaleLowerCase() .includes(needle), @@ -193,11 +204,11 @@ function CoursesContent() { - - - - + + + + @@ -205,7 +216,7 @@ function CoursesContent() { {t("form.description")} {t("terms.term")} {t("common.creator")} - {t("common.actions")} + {t("common.actions")} @@ -226,14 +237,18 @@ function CoursesContent() { {termName(course.term_id)} - {course.creator} - - - - + {creatorName(course.creator)} + + , + onSelect: () => void navigate({ to: "/courses/$id", params: { id: course.id } }), + }, + ]} + /> )} diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 0fe789c..8303b05 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -279,7 +279,7 @@ function PortalCard(props: { card: PortalCard }) {
-
+
{icon}
- - - +

{t(titleKey)}

+ + + {t(ROLE_KEY[minRole!])} + +
-
-
-

{t(titleKey)}

- - - {t(ROLE_KEY[minRole!])} - - -
-
- {statValue || "—"} - - {(suffix) => {t(suffix())}} - -
-

{t(descKey)}

+
+ +
+ {statValue} + + {(suffix) => {t(suffix())}} + +
+
+

{t(descKey)}

); @@ -358,11 +347,11 @@ function UpcomingTimeline(props: {
: }
-
-

{item.title}

-

{item.subtitle}

-
- - {item.at == null ? props.t("exams.unscheduled") : formatDateTime(item.at, props.locale)} - +

{item.title}

+

+ + {formatDateTime(item.at!, props.locale)} + + + {" · "}{item.subtitle} + +

)} diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index 876a61f..9b7b364 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -35,6 +35,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { TableRowActions } from "@/components/ui/table-row-actions"; import { hasMinRole } from "@/lib/roles"; import { createNow } from "@/lib/create-now"; import { examKindLabel } from "@/lib/exam-labels"; @@ -447,10 +448,7 @@ function ExamDetailContent() { {t("events.userId")} {t("form.mark")} {t("exams.gradedBy")} - {t("exams.answerSheet")} - - - + {t("common.actions")} @@ -462,34 +460,29 @@ function ExamDetailContent() { {personLabel(row.graded_by)} - - + + , + onSelect: () => { + const rowUserId = personId(row.user); + setSheetUserId(sheetUserId() === rowUserId ? null : rowUserId); + }, + }, + ...(!isFinished() + ? [{ + label: t("common.remove"), + icon: , + destructive: true, + onSelect: () => setRemoveUserId(personId(row.user)), + }] + : []), + ]} + /> - - - - - )} diff --git a/src/pages/exams-page.tsx b/src/pages/exams-page.tsx index 937e0b8..8fceb37 100644 --- a/src/pages/exams-page.tsx +++ b/src/pages/exams-page.tsx @@ -1,5 +1,5 @@ import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; -import { Link } from "@tanstack/solid-router"; +import { useNavigate } from "@tanstack/solid-router"; import { getCourses } from "@/api/getCourses"; import { getExams } from "@/api/getExams"; import { getMyCourses } from "@/api/getMyCourses"; @@ -20,6 +20,7 @@ import { PaginationControls } from "@/components/ui/pagination-controls"; import { Select } from "@/components/ui/select"; import { SidePanel } from "@/components/ui/side-panel"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { TableRowActions } from "@/components/ui/table-row-actions"; import { createNow } from "@/lib/create-now"; import { examKindLabel } from "@/lib/exam-labels"; import { formatDateTime } from "@/lib/format"; @@ -42,6 +43,7 @@ export default function ExamsPage() { function ExamsContent() { const auth = useAuth(); + const navigate = useNavigate(); const t = useT(); const { locale } = usePreferences(); const now = createNow(); @@ -218,21 +220,21 @@ function ExamsContent() {
- - - - - - + + + + + + {t("exams.title")} {t("nav.courses")} - {t("events.starts")} + {t("events.starts")} {t("attempt.status")} {t("exams.kind")} - {t("common.actions")} + {t("common.actions")} @@ -248,28 +250,31 @@ function ExamsContent() { {courseTitle(exam.course)} - {formatDateTime(exam.starts_at, locale())} + {formatDateTime(exam.starts_at, locale())} {statusLabel(status())} {examKindLabel(String(exam.kind), t)} - -
- - - - - - -
+ + , + onSelect: () => void navigate({ to: "/exams/$id", params: { id: exam.id } }), + }, + ...(isTeacherPlus() + ? [{ + label: t("common.edit"), + icon: , + onSelect: () => setEditingExam(exam), + }] + : []), + ]} + /> );