♻️ one row-actions menu on every table
Browse files at this commit365bc383c3d75386b345f7731ab957ed11c3f2c2Parent: 691fcf8- refactor
- ♻️ one row-actions menu on every table
13 changed files +131 -96
- src/components/courses/course-teachers-panel.tsx +10 -9
- src/components/homework/course-homework-panel.tsx +2 -1
- src/components/notes/note-files-panel.tsx +5 -5
- src/components/notes/rag-output-drawer.test.tsx +3 -2
- src/components/ui/table-row-actions.tsx +33 -44
- src/components/whiteboard/board-settings-panel.tsx +17 -2
- src/pages/bank-question-detail-page.tsx +10 -4
- src/pages/builder-school-detail-page.tsx +10 -4
- src/pages/class-detail-page.tsx +10 -1
- src/pages/event-detail-page.tsx +10 -4
- src/pages/meal-detail-page.tsx +2 -1
- src/pages/payments-page.tsx +9 -15
- src/pages/question-detail-page.tsx +10 -4
src/components/courses/course-teachers-panel.tsxmodified+10 -9
| @@ -10,6 +10,7 @@ import { DataTable } from "@/components/ui/data-table"; | ||
| 10 | 10 | import { EmptyState } from "@/components/ui/empty-state"; |
| 11 | 11 | import { IconTrash } from "@/components/ui/icons"; |
| 12 | 12 | import { SidePanel } from "@/components/ui/side-panel"; |
| 13 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | |
| 13 | 14 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 14 | 15 | import { createFlash } from "@/lib/flash"; |
| 15 | 16 | import { useT } from "@/stores/preferences-context"; |
| @@ -48,15 +49,15 @@ export function CourseTeachersPanel(props: { | ||
| 48 | 49 | header: t("common.actions"), |
| 49 | 50 | meta: { headerClass: "w-14 text-center", cellClass: "px-1 text-center" }, |
| 50 | 51 | cell: (cell: { row: { original: PersonRef } }) => ( |
| 51 | - <Button | |
| 52 | - variant="ghost" | |
| 53 | - size="sm" | |
| 54 | - class="h-8 w-8 rounded-lg p-0 text-destructive-text hover:bg-destructive/10" | |
| 55 | - onClick={() => setRemoveTarget(cell.row.original)} | |
| 56 | - > | |
| 57 | - <IconTrash class="h-4 w-4" /> | |
| 58 | - <span class="sr-only">{t("courses.unassignTeacher")}</span> | |
| 59 | - </Button> | |
| 52 | + <TableRowActions | |
| 53 | + label={t("common.actions")} | |
| 54 | + actions={[{ | |
| 55 | + label: t("courses.unassignTeacher"), | |
| 56 | + icon: <IconTrash class="h-4 w-4" />, | |
| 57 | + destructive: true, | |
| 58 | + onSelect: () => setRemoveTarget(cell.row.original), | |
| 59 | + }]} | |
| 60 | + /> | |
| 60 | 61 | ), |
| 61 | 62 | }, |
| 62 | 63 | ] |
src/components/homework/course-homework-panel.tsxmodified+2 -1
| @@ -15,7 +15,7 @@ import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | ||
| 15 | 15 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 16 | 16 | import { DatePicker } from "@/components/ui/date-picker"; |
| 17 | 17 | import { EmptyState } from "@/components/ui/empty-state"; |
| 18 | -import { IconEdit, IconTrash } from "@/components/ui/icons"; | |
| 18 | +import { IconEdit, IconEye, IconTrash } from "@/components/ui/icons"; | |
| 19 | 19 | import { Input } from "@/components/ui/input"; |
| 20 | 20 | import { Label } from "@/components/ui/label"; |
| 21 | 21 | import { Select } from "@/components/ui/select"; |
| @@ -193,6 +193,7 @@ export function CourseHomeworkPanel(props: { | ||
| 193 | 193 | <TableRowActions |
| 194 | 194 | label={t("common.actions")} |
| 195 | 195 | actions={[ |
| 196 | + { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => void navigate({ to: "/homework/$id", params: { id: cell.row.original.id } }) }, | |
| 196 | 197 | { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => openEdit(cell.row.original) }, |
| 197 | 198 | { label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteTarget(cell.row.original) }, |
| 198 | 199 | ]} |
src/components/notes/note-files-panel.tsxmodified+5 -5
| @@ -210,6 +210,11 @@ export function NoteFilesPanel(props: { | ||
| 210 | 210 | <TableRowActions |
| 211 | 211 | label={t("common.actions")} |
| 212 | 212 | actions={[ |
| 213 | + { | |
| 214 | + label: t("common.view"), | |
| 215 | + icon: <IconEye class="h-4 w-4" />, | |
| 216 | + onSelect: () => setPreviewFile(file), | |
| 217 | + }, | |
| 213 | 218 | ...(canManage() && isDrawing(file) |
| 214 | 219 | ? [ |
| 215 | 220 | { |
| @@ -219,11 +224,6 @@ export function NoteFilesPanel(props: { | ||
| 219 | 224 | }, |
| 220 | 225 | ] |
| 221 | 226 | : []), |
| 222 | - { | |
| 223 | - label: t("common.view"), | |
| 224 | - icon: <IconEye class="h-4 w-4" />, | |
| 225 | - onSelect: () => setPreviewFile(file), | |
| 226 | - }, | |
| 227 | 227 | { |
| 228 | 228 | label: t("notes.downloadFile"), |
| 229 | 229 | icon: <IconDownload class="h-4 w-4" />, |
src/components/notes/rag-output-drawer.test.tsxmodified+3 -2
| @@ -179,8 +179,9 @@ describe("RagOutputDrawer", () => { | ||
| 179 | 179 | expect(screen.getByText("Preview")).toBeTruthy(); |
| 180 | 180 | expect(screen.getByText("hücre zarı")).toBeTruthy(); |
| 181 | 181 | expect(screen.getByText("organel")).toBeTruthy(); |
| 182 | - expect(screen.queryByRole("button", { name: "Actions" })).toBeNull(); | |
| 183 | - expect(screen.getByRole("button", { name: "Delete" })).toBeTruthy(); | |
| 182 | + // Delete sits inside the shared actions menu, never as a bare icon button. | |
| 183 | + expect(screen.getByRole("button", { name: "Actions" })).toBeTruthy(); | |
| 184 | + expect(screen.queryByRole("button", { name: "Delete" })).toBeNull(); | |
| 184 | 185 | expect(screen.getByRole("button", { name: "Export" })).toBeTruthy(); |
| 185 | 186 | expect(screen.queryByRole("button", { name: "View" })).toBeNull(); |
| 186 | 187 | }); |
src/components/ui/table-row-actions.tsxmodified+33 -44
| @@ -4,6 +4,7 @@ import { | ||
| 4 | 4 | DropdownMenu, |
| 5 | 5 | DropdownMenuContent, |
| 6 | 6 | DropdownMenuItem, |
| 7 | + DropdownMenuSeparator, | |
| 7 | 8 | DropdownMenuTrigger, |
| 8 | 9 | } from "@/components/ui/dropdown-menu"; |
| 9 | 10 | import { IconDotsVertical } from "@/components/ui/icons"; |
| @@ -17,19 +18,37 @@ type TableRowAction = { | ||
| 17 | 18 | disabled?: boolean; |
| 18 | 19 | }; |
| 19 | 20 | |
| 21 | +/** | |
| 22 | + * The one row/header actions control: always a dropdown behind the same | |
| 23 | + * action-menu trigger, even for a single action, so every table reads the same. | |
| 24 | + * Order is normalised here — view/edit/other items first in the order given, | |
| 25 | + * then a separator and the destructive items last. Callers put "view" first | |
| 26 | + * and route destructive items through a ConfirmDialog. | |
| 27 | + */ | |
| 20 | 28 | export function TableRowActions(props: { label: string; actions: TableRowAction[]; compact?: boolean; triggerLabel?: string }) { |
| 21 | 29 | const t = useT(); |
| 22 | - const singleAction = () => props.actions.length === 1 ? props.actions[0] : undefined; | |
| 23 | - const run = (action: TableRowAction) => { | |
| 24 | - if (action.disabled) return; | |
| 25 | - setTimeout(action.onSelect, 0); | |
| 26 | - }; | |
| 30 | + const safeActions = () => props.actions.filter((action) => !action.destructive); | |
| 31 | + const destructiveActions = () => props.actions.filter((action) => action.destructive); | |
| 32 | + | |
| 33 | + const item = (action: TableRowAction) => ( | |
| 34 | + <DropdownMenuItem | |
| 35 | + class="flex items-center gap-2.5 text-xs" | |
| 36 | + destructive={action.destructive} | |
| 37 | + disabled={action.disabled} | |
| 38 | + // Defer to the next macrotask so the menu fully closes (and | |
| 39 | + // restores focus to its trigger) before the action opens a | |
| 40 | + // panel/dialog — otherwise the non-modal SidePanel reads that | |
| 41 | + // focus-restore as an outside interaction and instantly closes. | |
| 42 | + onSelect={() => setTimeout(action.onSelect, 0)} | |
| 43 | + > | |
| 44 | + {action.icon} | |
| 45 | + <span>{action.label}</span> | |
| 46 | + </DropdownMenuItem> | |
| 47 | + ); | |
| 27 | 48 | |
| 28 | 49 | return ( |
| 29 | 50 | <div class="flex justify-center"> |
| 30 | - <Show | |
| 31 | - when={singleAction()} | |
| 32 | - fallback={<DropdownMenu placement="bottom-end" gutter={6}> | |
| 51 | + <DropdownMenu placement="bottom-end" gutter={6}> | |
| 33 | 52 | <DropdownMenuTrigger |
| 34 | 53 | class={props.compact |
| 35 | 54 | ? "inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-muted data-expanded:text-foreground" |
| @@ -42,43 +61,13 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[ | ||
| 42 | 61 | <IconDotsVertical class="h-3.5 w-3.5" /> |
| 43 | 62 | </DropdownMenuTrigger> |
| 44 | 63 | <DropdownMenuContent class="w-48"> |
| 45 | - <For each={props.actions}> | |
| 46 | - {(action) => ( | |
| 47 | - <DropdownMenuItem | |
| 48 | - class="flex items-center gap-2.5 text-xs" | |
| 49 | - destructive={action.destructive} | |
| 50 | - disabled={action.disabled} | |
| 51 | - // Defer to the next macrotask so the menu fully closes (and | |
| 52 | - // restores focus to its trigger) before the action opens a | |
| 53 | - // panel/dialog — otherwise the non-modal SidePanel reads that | |
| 54 | - // focus-restore as an outside interaction and instantly closes. | |
| 55 | - onSelect={() => setTimeout(action.onSelect, 0)} | |
| 56 | - > | |
| 57 | - {action.icon} | |
| 58 | - <span>{action.label}</span> | |
| 59 | - </DropdownMenuItem> | |
| 60 | - )} | |
| 61 | - </For> | |
| 64 | + <For each={safeActions()}>{item}</For> | |
| 65 | + <Show when={safeActions().length > 0 && destructiveActions().length > 0}> | |
| 66 | + <DropdownMenuSeparator /> | |
| 67 | + </Show> | |
| 68 | + <For each={destructiveActions()}>{item}</For> | |
| 62 | 69 | </DropdownMenuContent> |
| 63 | - </DropdownMenu>} | |
| 64 | - > | |
| 65 | - {(action) => ( | |
| 66 | - <button | |
| 67 | - type="button" | |
| 68 | - data-row-actions-trigger | |
| 69 | - class="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-transparent text-muted-foreground outline-hidden transition-colors hover:border-primary/20 hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" | |
| 70 | - aria-label={action().label} | |
| 71 | - title={action().label} | |
| 72 | - disabled={action().disabled} | |
| 73 | - onClick={(event) => { | |
| 74 | - event.stopPropagation(); | |
| 75 | - run(action()); | |
| 76 | - }} | |
| 77 | - > | |
| 78 | - {action().icon} | |
| 79 | - </button> | |
| 80 | - )} | |
| 81 | - </Show> | |
| 70 | + </DropdownMenu> | |
| 82 | 71 | </div> |
| 83 | 72 | ); |
| 84 | 73 | } |
src/components/whiteboard/board-settings-panel.tsxmodified+17 -2
| @@ -4,6 +4,7 @@ import type { Board } from "@/api/boards"; | ||
| 4 | 4 | import { BoardBulkInvite } from "@/components/whiteboard/board-bulk-invite"; |
| 5 | 5 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 6 | 6 | import { Button } from "@/components/ui/button"; |
| 7 | +import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | |
| 7 | 8 | import { DataTable } from "@/components/ui/data-table"; |
| 8 | 9 | import { Input } from "@/components/ui/input"; |
| 9 | 10 | import { Label } from "@/components/ui/label"; |
| @@ -37,6 +38,7 @@ export function BoardSettingsPanel(props: { | ||
| 37 | 38 | const t = useT(); |
| 38 | 39 | const [title, setTitle] = createSignal(""); |
| 39 | 40 | const [personId, setPersonId] = createSignal(""); |
| 41 | + const [removeTarget, setRemoveTarget] = createSignal<ParticipantRow | null>(null); | |
| 40 | 42 | const [error, setError] = createSignal(""); |
| 41 | 43 | const [pending, setPending] = createSignal(false); |
| 42 | 44 | |
| @@ -105,14 +107,13 @@ export function BoardSettingsPanel(props: { | ||
| 105 | 107 | fallback={<span class="text-xs text-muted-foreground">{cell.row.original.creator ? t("whiteboard.creator") : "—"}</span>} |
| 106 | 108 | > |
| 107 | 109 | <TableRowActions |
| 108 | - compact | |
| 109 | 110 | label={t("common.actions")} |
| 110 | 111 | actions={[{ |
| 111 | 112 | label: t("whiteboard.removeParticipant"), |
| 112 | 113 | icon: <span class="text-base leading-none">×</span>, |
| 113 | 114 | destructive: true, |
| 114 | 115 | disabled: pending(), |
| 115 | - onSelect: () => void saveParticipants(props.participants().filter((id) => id !== cell.row.original.id)), | |
| 116 | + onSelect: () => setRemoveTarget(cell.row.original), | |
| 116 | 117 | }]} |
| 117 | 118 | /> |
| 118 | 119 | </Show> |
| @@ -173,6 +174,20 @@ export function BoardSettingsPanel(props: { | ||
| 173 | 174 | /> |
| 174 | 175 | </section> |
| 175 | 176 | |
| 177 | + <ConfirmDialog | |
| 178 | + open={removeTarget() != null} | |
| 179 | + onOpenChange={(open) => !open && setRemoveTarget(null)} | |
| 180 | + title={t("whiteboard.removeParticipant")} | |
| 181 | + variant="destructive" | |
| 182 | + summary={removeTarget()?.name ?? ""} | |
| 183 | + onConfirm={async () => { | |
| 184 | + const target = removeTarget(); | |
| 185 | + if (!target) return; | |
| 186 | + await saveParticipants(props.participants().filter((id) => id !== target.id)); | |
| 187 | + setRemoveTarget(null); | |
| 188 | + }} | |
| 189 | + /> | |
| 190 | + | |
| 176 | 191 | {/* Inviting a whole group is the creator's alone, exactly like the |
| 177 | 192 | roster edits above. */} |
| 178 | 193 | <Show when={props.canManageParticipants()}> |
src/pages/bank-question-detail-page.tsxmodified+10 -4
| @@ -25,6 +25,7 @@ import { formatDate } from "@/lib/format"; | ||
| 25 | 25 | import { hasMinRole } from "@/lib/roles"; |
| 26 | 26 | import { useAuth } from "@/stores/auth-context"; |
| 27 | 27 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 28 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | |
| 28 | 29 | |
| 29 | 30 | export default function BankQuestionDetailPage() { |
| 30 | 31 | return ( |
| @@ -105,10 +106,15 @@ function BankQuestionDetailContent() { | ||
| 105 | 106 | <IconEdit class="h-4 w-4" /> |
| 106 | 107 | {t("common.edit")} |
| 107 | 108 | </Button> |
| 108 | - <Button variant="destructive" size="sm" class="rounded-lg" onClick={() => setDeleteOpen(true)}> | |
| 109 | - <IconTrash class="h-4 w-4" /> | |
| 110 | - {t("common.delete")} | |
| 111 | - </Button> | |
| 109 | + <TableRowActions | |
| 110 | + label={t("common.actions")} | |
| 111 | + actions={[{ | |
| 112 | + label: t("common.delete"), | |
| 113 | + icon: <IconTrash class="h-4 w-4" />, | |
| 114 | + destructive: true, | |
| 115 | + onSelect: () => setDeleteOpen(true), | |
| 116 | + }]} | |
| 117 | + /> | |
| 112 | 118 | </Show> |
| 113 | 119 | </> |
| 114 | 120 | } |
src/pages/builder-school-detail-page.tsxmodified+10 -4
| @@ -34,6 +34,7 @@ import { formatDateTime } from "@/lib/format"; | ||
| 34 | 34 | import { useAuth } from "@/stores/auth-context"; |
| 35 | 35 | import { BuilderProvider } from "@/stores/builder-context"; |
| 36 | 36 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 37 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | |
| 37 | 38 | |
| 38 | 39 | export default function BuilderSchoolDetailPage() { |
| 39 | 40 | return ( |
| @@ -142,10 +143,15 @@ function BuilderSchoolDetailContent() { | ||
| 142 | 143 | <IconExternalLink class="h-4 w-4" /> |
| 143 | 144 | {t("builder.enterSchool")} |
| 144 | 145 | </Button> |
| 145 | - <Button type="button" variant="destructive" size="sm" class="rounded-lg" onClick={() => setDeleteOpen(true)}> | |
| 146 | - <IconTrash class="h-4 w-4" /> | |
| 147 | - {t("common.delete")} | |
| 148 | - </Button> | |
| 146 | + <TableRowActions | |
| 147 | + label={t("common.actions")} | |
| 148 | + actions={[{ | |
| 149 | + label: t("common.delete"), | |
| 150 | + icon: <IconTrash class="h-4 w-4" />, | |
| 151 | + destructive: true, | |
| 152 | + onSelect: () => setDeleteOpen(true), | |
| 153 | + }]} | |
| 154 | + /> | |
| 149 | 155 | </div> |
| 150 | 156 | } |
| 151 | 157 | /> |
src/pages/class-detail-page.tsxmodified+10 -1
| @@ -265,7 +265,16 @@ function ClassDetailContent() { | ||
| 265 | 265 | {t("classBlueprints.apply")} |
| 266 | 266 | </Button> |
| 267 | 267 | <Button size="sm" variant="outline" class="rounded-lg" onClick={() => { setName(c().name); setGrade(c().grade ?? ""); setYearId(c().year ?? ""); setTeacherId(c().teacher?.id ?? ""); setEditing(true); }}>{t("common.edit")}</Button> |
| 268 | - <Button size="sm" variant="outline" class="rounded-lg text-destructive-text" onClick={() => setDeleteOpen(true)}>{t("classGroups.deleteClass")}</Button> | |
| 268 | + <TableRowActions | |
| 269 | + label={t("common.actions")} | |
| 270 | + actions={[{ | |
| 271 | + label: t("classGroups.deleteClass"), | |
| 272 | + icon: <IconTrash class="h-4 w-4" />, | |
| 273 | + destructive: true, | |
| 274 | + disabled: pending(), | |
| 275 | + onSelect: () => setDeleteOpen(true), | |
| 276 | + }]} | |
| 277 | + /> | |
| 269 | 278 | </div> |
| 270 | 279 | </Show> |
| 271 | 280 | </header> |
src/pages/event-detail-page.tsxmodified+10 -4
| @@ -193,10 +193,16 @@ function EventDetailContent() { | ||
| 193 | 193 | <IconEdit class="h-4 w-4" /> |
| 194 | 194 | {t("common.edit")} |
| 195 | 195 | </Button> |
| 196 | - <Button type="button" variant="destructive" size="sm" class="flex-1 rounded-xl sm:flex-none" disabled={pending()} onClick={() => setDeleteOpen(true)}> | |
| 197 | - <IconTrash class="h-4 w-4" /> | |
| 198 | - {t("common.delete")} | |
| 199 | - </Button> | |
| 196 | + <TableRowActions | |
| 197 | + label={t("common.actions")} | |
| 198 | + actions={[{ | |
| 199 | + label: t("common.delete"), | |
| 200 | + icon: <IconTrash class="h-4 w-4" />, | |
| 201 | + destructive: true, | |
| 202 | + disabled: pending(), | |
| 203 | + onSelect: () => setDeleteOpen(true), | |
| 204 | + }]} | |
| 205 | + /> | |
| 200 | 206 | </div> |
| 201 | 207 | ) : undefined |
| 202 | 208 | } |
src/pages/meal-detail-page.tsxmodified+2 -1
| @@ -52,6 +52,7 @@ import { personLabel } from "@/lib/person"; | ||
| 52 | 52 | import { hasMinRole } from "@/lib/roles"; |
| 53 | 53 | import { useAuth } from "@/stores/auth-context"; |
| 54 | 54 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 55 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | |
| 55 | 56 | |
| 56 | 57 | export default function MealDetailPage() { |
| 57 | 58 | return <RouteGuard><MealDetailContent /></RouteGuard>; |
| @@ -190,7 +191,7 @@ function MealDetailContent() { | ||
| 190 | 191 | <PageHeader |
| 191 | 192 | title={t("meals.menu")} |
| 192 | 193 | description={t("meals.detailHelp")} |
| 193 | - actions={canManage() ? <div class="detail-action-group"><Button variant="outline" size="sm" onClick={() => { setCapacity(current().capacity == null ? "" : String(current().capacity)); setShowMenuEdit(true); }}><IconEdit class="h-4 w-4" />{t("common.edit")}</Button><Button variant="destructive" size="sm" onClick={() => setDeleteMenuOpen(true)}><IconTrash class="h-4 w-4" />{t("common.delete")}</Button></div> : undefined} | |
| 194 | + actions={canManage() ? <div class="detail-action-group"><Button variant="outline" size="sm" onClick={() => { setCapacity(current().capacity == null ? "" : String(current().capacity)); setShowMenuEdit(true); }}><IconEdit class="h-4 w-4" />{t("common.edit")}</Button><TableRowActions label={t("common.actions")} actions={[{ label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteMenuOpen(true) }]} /></div> : undefined} | |
| 194 | 195 | /> |
| 195 | 196 | </div> |
| 196 | 197 | <Show when={limits.error}><ErrorAlert message={formatApiError(limits.error)} onRetry={() => void refetchLimits()} /></Show> |
src/pages/payments-page.tsxmodified+9 -15
| @@ -477,21 +477,15 @@ function PaymentsContent() { | ||
| 477 | 477 | cellClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap", |
| 478 | 478 | }, |
| 479 | 479 | cell: (cell) => ( |
| 480 | - <div class="flex items-center justify-center gap-1"> | |
| 481 | - <Button size="sm" variant="outline" class="h-8 gap-1 rounded-lg px-2 text-xs" onClick={() => openAssign(cell.row.original)}> | |
| 482 | - <IconPlus class="h-4 w-4" /> | |
| 483 | - {t("payments.assign")} | |
| 484 | - </Button> | |
| 485 | - <TableRowActions | |
| 486 | - label={t("common.actions")} | |
| 487 | - compact | |
| 488 | - actions={[ | |
| 489 | - { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => setViewPlan(cell.row.original) }, | |
| 490 | - { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => startEdit(cell.row.original) }, | |
| 491 | - { label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteTarget(cell.row.original) }, | |
| 492 | - ]} | |
| 493 | - /> | |
| 494 | - </div> | |
| 480 | + <TableRowActions | |
| 481 | + label={t("common.actions")} | |
| 482 | + actions={[ | |
| 483 | + { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => setViewPlan(cell.row.original) }, | |
| 484 | + { label: t("payments.assign"), icon: <IconPlus class="h-4 w-4" />, onSelect: () => openAssign(cell.row.original) }, | |
| 485 | + { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => startEdit(cell.row.original) }, | |
| 486 | + { label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteTarget(cell.row.original) }, | |
| 487 | + ]} | |
| 488 | + /> | |
| 495 | 489 | ), |
| 496 | 490 | }, |
| 497 | 491 | ]); |
src/pages/question-detail-page.tsxmodified+10 -4
| @@ -15,6 +15,7 @@ import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | ||
| 15 | 15 | import { Label } from "@/components/ui/label"; |
| 16 | 16 | import { Textarea } from "@/components/ui/textarea"; |
| 17 | 17 | import { IconTrash, IconCheck, IconX, IconEdit, IconMessage, IconPhoto } from "@/components/ui/icons"; |
| 18 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | |
| 18 | 19 | import { ReplayableImage } from "@/components/ui/replayable-image"; |
| 19 | 20 | import { personLabel } from "@/lib/person"; |
| 20 | 21 | |
| @@ -138,10 +139,15 @@ function QuestionDetailContent() { | ||
| 138 | 139 | </Button> |
| 139 | 140 | </Show> |
| 140 | 141 | <Show when={q().asker.id === auth.user()?.id || isModerator()}> |
| 141 | - <Button variant="destructive" onClick={() => setDeleteConfirmQ(true)}> | |
| 142 | - <IconTrash class="mr-2 h-4 w-4" /> | |
| 143 | - {q().status === "pending" && isModerator() ? t("common.reject") : t("common.delete")} | |
| 144 | - </Button> | |
| 142 | + <TableRowActions | |
| 143 | + label={t("common.actions")} | |
| 144 | + actions={[{ | |
| 145 | + label: q().status === "pending" && isModerator() ? t("common.reject") : t("common.delete"), | |
| 146 | + icon: <IconTrash class="h-4 w-4" />, | |
| 147 | + destructive: true, | |
| 148 | + onSelect: () => setDeleteConfirmQ(true), | |
| 149 | + }]} | |
| 150 | + /> | |
| 145 | 151 | </Show> |
| 146 | 152 | </div> |
| 147 | 153 | </div> |