diff options
| author | soryu <soryu@soryu.co> | 2026-03-09 16:53:49 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-09 16:53:49 +0000 |
| commit | afaae8aba719bf74404a64b57426ecc6a7e70775 (patch) | |
| tree | 81c17946d8f0347c7cebf83ecd731d205983cfc7 /makima/frontend/src/routes/directives.tsx | |
| parent | ef643072234477685614ed281e34ef77e45caad4 (diff) | |
| parent | e11e7225861c3063f08461ac01005f3315d41be5 (diff) | |
| download | soryu-afaae8aba719bf74404a64b57426ecc6a7e70775.tar.gz soryu-afaae8aba719bf74404a64b57426ecc6a7e70775.zip | |
Merge pull request #87 from soryu-co/makima/directive-soryu-co-soryu---makima-19fd3e1d-v1772943648
feat: compact order header & add context menus to orders/directives
Diffstat (limited to 'makima/frontend/src/routes/directives.tsx')
| -rw-r--r-- | makima/frontend/src/routes/directives.tsx | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/makima/frontend/src/routes/directives.tsx b/makima/frontend/src/routes/directives.tsx index 846f52f..8de0335 100644 --- a/makima/frontend/src/routes/directives.tsx +++ b/makima/frontend/src/routes/directives.tsx @@ -6,13 +6,13 @@ import { DirectiveDetail } from "../components/directives/DirectiveDetail"; import { useDirectives, useDirective } from "../hooks/useDirectives"; import { useDogs } from "../hooks/useDogs"; import { useAuth } from "../contexts/AuthContext"; -import { getRepositorySuggestions, type RepositoryHistoryEntry } from "../lib/api"; +import { getRepositorySuggestions, startDirective, pauseDirective, updateDirective, type RepositoryHistoryEntry, type DirectiveSummary } from "../lib/api"; export default function DirectivesPage() { const { isAuthenticated, isAuthConfigured, isLoading: authLoading } = useAuth(); const navigate = useNavigate(); const { id: selectedId } = useParams<{ id: string }>(); - const { directives, loading: listLoading, create, remove } = useDirectives(); + const { directives, loading: listLoading, create, remove, refresh: refreshList } = useDirectives(); const { directive, refresh: refreshDetail, update, start, pause, advance, completeStep, failStep, skipStep, updateGoal, cleanup, pickUpOrders, createPR } = useDirective(selectedId); const { dogs, loading: dogsLoading, create: createDog, update: updateDog, remove: removeDog, pickUpOrders: pickUpDogOrders } = useDogs(selectedId); @@ -68,6 +68,47 @@ export default function DirectivesPage() { ); } + const handleContextStart = async (directive: DirectiveSummary) => { + try { + await startDirective(directive.id); + await refreshList(); + } catch (e) { + console.error("Failed to start directive:", e); + } + }; + + const handleContextPause = async (directive: DirectiveSummary) => { + try { + await pauseDirective(directive.id); + await refreshList(); + } catch (e) { + console.error("Failed to pause directive:", e); + } + }; + + const handleContextArchive = async (directive: DirectiveSummary) => { + try { + await updateDirective(directive.id, { status: "archived" }); + await refreshList(); + } catch (e) { + console.error("Failed to archive directive:", e); + } + }; + + const handleContextDelete = async (directive: DirectiveSummary) => { + if (!window.confirm("Delete this directive?")) return; + try { + await remove(directive.id); + if (directive.id === selectedId) navigate("/directives"); + } catch (e) { + console.error("Failed to delete:", e); + } + }; + + const handleContextGoToPR = (directive: DirectiveSummary) => { + if (directive.prUrl) window.open(directive.prUrl, "_blank"); + }; + const handleCreate = async () => { if (!newTitle.trim() || !newGoal.trim()) return; try { @@ -108,6 +149,11 @@ export default function DirectivesPage() { selectedId={selectedId ?? null} onSelect={(id) => navigate(`/directives/${id}`)} onCreate={() => setShowCreate(true)} + onStart={handleContextStart} + onPause={handleContextPause} + onArchive={handleContextArchive} + onDelete={handleContextDelete} + onGoToPR={handleContextGoToPR} /> </div> |
