Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Add ticket archiving with separate archive view and restore functiona…#26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b422d5be05d0d190e08c0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import type { Migration } from "../migrator.ts"; | ||
| export default { | ||
| name: "011_add_archive", | ||
| up(db) { | ||
| db.run("ALTER TABLE tickets ADD COLUMN archived_at INTEGER DEFAULT NULL"); | ||
| }, | ||
| } satisfies Migration; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,6 +19,8 @@ export function ticketsRouter(orchestrator: OrchestratorService) { | ||
| app.get("/", (c) => c.json(ticketStmts.list.all())); | ||
| app.get("/archived", (c) => c.json(ticketStmts.listArchived.all())); | ||
| app.post("/", async (c) => { | ||
| const body = await c.req.json<{ title?: string; description?: string }>(); | ||
| if (!body.title?.trim()) { | ||
| @@ -175,6 +177,39 @@ export function ticketsRouter(orchestrator: OrchestratorService) { | ||
| } | ||
| }); | ||
| app.post("/:id/archive", async (c) => { | ||
| const id = c.req.param("id"); | ||
| const now = Date.now(); | ||
| const result = ticketStmts.archive.run({ $archivedAt: now, $id: id }); | ||
| if (result.changes === 0) { | ||
| const existing = ticketStmts.get.get(id); | ||
| if (!existing) { | ||
| return c.json({ error: "ticket not found" }, 404); | ||
| } | ||
| return c.json({ error: "ticket already archived" }, 409); | ||
| } | ||
| const updated = ticketStmts.get.get(id); | ||
| broadcastNotification({ tickets: ticketStmts.list.all(), type: "kanban-sync" }); | ||
| return c.json(updated); | ||
| }); | ||
| app.post("/:id/unarchive", (c) => { | ||
| const id = c.req.param("id"); | ||
| const result = ticketStmts.unarchive.run({ $updatedAt: Date.now(), $id: id }); | ||
| if (result.changes === 0) { | ||
| const existing = ticketStmts.get.get(id); | ||
| if (!existing) { | ||
| return c.json({ error: "ticket not found" }, 404); | ||
| } | ||
| return c.json({ error: "ticket is not archived" }, 409); | ||
| } | ||
| const updated = ticketStmts.get.get(id); | ||
| broadcastNotification({ tickets: ticketStmts.list.all(), type: "kanban-sync" }); | ||
| return c.json(updated); | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| app.delete("/:id", async (c) => { | ||
| const id = c.req.param("id"); | ||
| const existing = ticketStmts.get.get(id); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { useCallback, useEffect, useMemo, useState } from "react"; | ||
| import { Route, Routes, useNavigate } from "react-router-dom"; | ||
| import { ArchiveDrawer } from "./components/ArchiveDrawer"; | ||
roulpriya marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import { CreateTicketModal } from "./components/CreateTicketModal"; | ||
| import { IntegrationsModal } from "./components/IntegrationsModal"; | ||
| import { KanbanBoard } from "./components/kanban-board/KanbanBoard"; | ||
| @@ -22,20 +23,26 @@ function NavigateFnRegistrar() { | ||
| function KanbanPage() { | ||
| const [shellOpen, setShellOpen] = useState(false); | ||
| const [integrationsOpen, setIntegrationsOpen] = useState(false); | ||
| const { isArchiveOpen, openArchive, closeArchive } = useStore(); | ||
| const openShell = useCallback(() => setShellOpen(true), []); | ||
| const closeShell = useCallback(() => setShellOpen(false), []); | ||
| const openIntegrations = useCallback(() => setIntegrationsOpen(true), []); | ||
| const closeIntegrations = useCallback(() => setIntegrationsOpen(false), []); | ||
| return ( | ||
| <div className="h-full flex flex-col bg-forge-black overflow-hidden"> | ||
| <Header onOpenShell={openShell} onOpenIntegrations={openIntegrations} /> | ||
| <Header | ||
| onOpenShell={openShell} | ||
| onOpenIntegrations={openIntegrations} | ||
| onOpenArchive={openArchive} | ||
| /> | ||
| <main className="flex-1 overflow-hidden"> | ||
| <KanbanBoard /> | ||
| </main> | ||
| <CreateTicketModal /> | ||
| <IntegrationsModal open={integrationsOpen} onClose={closeIntegrations} /> | ||
| {shellOpen && <ShellTerminal onClose={closeShell} />} | ||
| {isArchiveOpen && <ArchiveDrawer onClose={closeArchive} />} | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import { Archive, RotateCcw, X } from "lucide-react"; | ||
| import { useCallback, type MouseEvent } from "react"; | ||
| import { useStore } from "../store"; | ||
| interface Props { | ||
| onClose: () => void; | ||
| } | ||
| export function ArchiveDrawer({ onClose }: Props) { | ||
| const { archivedTickets, isFetchingArchived, unarchiveTicket } = useStore(); | ||
| const titleId = "archive-drawer-title"; | ||
| const handleUnarchive = useCallback( | ||
| (e: MouseEvent<HTMLButtonElement>) => { | ||
| const id = e.currentTarget.dataset.id; | ||
| if (id) unarchiveTicket(id); | ||
| }, | ||
| [unarchiveTicket], | ||
| ); | ||
| return ( | ||
| <> | ||
| {/* Backdrop */} | ||
| <div aria-hidden="true" className="fixed inset-0 bg-black/50 z-40" onClick={onClose} /> | ||
| {/* Drawer */} | ||
| <div | ||
| aria-labelledby={titleId} | ||
| aria-modal="true" | ||
| className="fixed right-0 top-0 bottom-0 w-[400px] z-50 flex flex-col bg-forge-panel border-l border-forge-border shadow-2xl" | ||
| role="dialog" | ||
| > | ||
| {/* Header */} | ||
| <div className="flex items-center justify-between px-4 py-3 border-b border-forge-border flex-shrink-0"> | ||
| <div className="flex items-center gap-2"> | ||
| <Archive size={14} className="text-forge-amber" strokeWidth={1.5} /> | ||
| <span | ||
| className="text-xs uppercase tracking-widest font-semibold text-forge-amber" | ||
| id={titleId} | ||
| > | ||
| ARCHIVE | ||
| </span> | ||
| {!isFetchingArchived && ( | ||
| <span className="text-forge-text-muted text-xs">[{archivedTickets.length}]</span> | ||
| )} | ||
| </div> | ||
| <button | ||
| aria-label="Close archive drawer" | ||
| className="text-forge-text-muted hover:text-forge-text transition-colors" | ||
| onClick={onClose} | ||
| type="button" | ||
| > | ||
| <X size={14} strokeWidth={1.5} /> | ||
| </button> | ||
| </div> | ||
| {/* Body */} | ||
| <div className="flex-1 overflow-y-auto p-3 flex flex-col gap-2"> | ||
| {isFetchingArchived && ( | ||
| <div className="flex items-center justify-center h-32"> | ||
| <span className="text-forge-text-muted text-xs uppercase tracking-widest"> | ||
| LOADING... | ||
| </span> | ||
| </div> | ||
| )} | ||
| {!isFetchingArchived && archivedTickets.length === 0 && ( | ||
| <div className="flex flex-col items-center justify-center h-32 gap-2"> | ||
| <Archive size={24} className="text-forge-text-muted" strokeWidth={1} /> | ||
| <span className="text-forge-text-muted text-xs uppercase tracking-widest"> | ||
| NO ARCHIVED TICKETS | ||
| </span> | ||
| </div> | ||
| )} | ||
| {!isFetchingArchived && | ||
| archivedTickets.map((ticket) => ( | ||
| <div key={ticket.id} className="forge-surface group"> | ||
| <div className="flex items-start justify-between gap-2 px-3 pt-2.5 pb-1"> | ||
| <p className="text-forge-text-bright text-xs leading-snug font-medium flex-1"> | ||
| {ticket.title} | ||
| </p> | ||
| <button | ||
| className="text-forge-text-muted hover:text-forge-green transition-colors opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus-visible:opacity-100 focus:opacity-100 flex-shrink-0 flex items-center gap-1" | ||
| data-id={ticket.id} | ||
| onClick={handleUnarchive} | ||
| title="Restore ticket" | ||
| type="button" | ||
| > | ||
| <RotateCcw size={12} strokeWidth={1.5} /> | ||
| <span className="text-xs uppercase tracking-widest">RESTORE</span> | ||
| </button> | ||
| </div> | ||
| <div className="px-3 pb-3"> | ||
| {ticket.agentTitle && ( | ||
| <p className="text-forge-accent text-xs leading-snug mb-1 font-mono opacity-80"> | ||
| ↳ {ticket.agentTitle} | ||
| </p> | ||
| )} | ||
| {ticket.description && ( | ||
| <p className="text-forge-text-dim text-xs leading-relaxed line-clamp-2 mb-2"> | ||
| {ticket.description} | ||
| </p> | ||
| )} | ||
| <div className="flex items-center justify-between"> | ||
| <span className="text-forge-text-muted text-xs uppercase tracking-widest"> | ||
| {ticket.status} | ||
| </span> | ||
| <span className="text-forge-text-muted text-xs">#{ticket.id.slice(0, 6)}</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.