1
0
Fork 0

feat(frontend): make the command-chain editor a collapsible panel

Wrap the mission command-chain editor content in a Collapsible with an
expand/collapse trigger in the header row, next to the Override/Legacy/
Defaults badge. The 'Command chain' title folds into the trigger so the
card header holds only the toggle and the status badge.
This commit is contained in:
Jason Fraley 2026-11-02 14:28:55 -05:00
parent b6e8fa6f90
commit 3ac6ebd87d

View file

@ -3,10 +3,13 @@
import { useState } from "react"; import { useState } from "react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { toast } from "sonner"; import { toast } from "sonner";
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
import { Alert, AlertDescription } from "@/components/ui/alert"; import { Alert, AlertDescription } from "@/components/ui/alert";
import { import {
Select, Select,
@ -54,6 +57,7 @@ export function MissionCommandChainEditor({
}: MissionCommandChainEditorProps) { }: MissionCommandChainEditorProps) {
const router = useRouter(); const router = useRouter();
const [pending, setPending] = useState(false); const [pending, setPending] = useState(false);
const [contentOpen, setContentOpen] = useState(true);
const initialSupervisors = (subordinateId: number) => const initialSupervisors = (subordinateId: number) =>
links.filter((l) => l.subordinateId === subordinateId).map((l) => l.supervisorId); links.filter((l) => l.subordinateId === subordinateId).map((l) => l.supervisorId);
const [draft, setDraft] = useState<Record<number, number[]>>(() => const [draft, setDraft] = useState<Record<number, number[]>>(() =>
@ -104,19 +108,35 @@ export function MissionCommandChainEditor({
}; };
return ( return (
<Collapsible open={contentOpen} onOpenChange={setContentOpen}>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle className="flex flex-wrap items-center justify-between gap-2 text-base"> <CardTitle className="flex flex-wrap items-center justify-between gap-2 text-base">
<span>Command chain</span> <div className="flex items-center gap-2">
<CollapsibleTrigger asChild>
<Button
variant="ghost"
size="sm"
className="h-7 w-7 p-0 text-muted-foreground hover:text-foreground"
aria-label={contentOpen ? "Collapse command chain" : "Expand command chain"}
>
<ChevronDown
aria-hidden
className={cn("h-4 w-4 transition-transform", contentOpen && "rotate-180")}
/>
</Button>
</CollapsibleTrigger>
<Badge variant="outline"> <Badge variant="outline">
{mode === "stored" ? "Override" : mode === "legacy" ? "Legacy" : "Defaults"} {mode === "stored" ? "Override" : mode === "legacy" ? "Legacy" : "Defaults"}
</Badge> </Badge>
</div>
</CardTitle> </CardTitle>
<CardDescription> <CardDescription>
Who was in command of whom for this operation only. Permanent assignments are not Who was in command of whom for this operation only. Permanent assignments are not
changed. Supervisors may rate their subordinate as a command review. changed. Supervisors may rate their subordinate as a command review.
</CardDescription> </CardDescription>
</CardHeader> </CardHeader>
<CollapsibleContent className="overflow-hidden">
<CardContent className="flex flex-col gap-4"> <CardContent className="flex flex-col gap-4">
{mode === "legacy" && ( {mode === "legacy" && (
<Alert> <Alert>
@ -193,6 +213,8 @@ export function MissionCommandChainEditor({
</div> </div>
)} )}
</CardContent> </CardContent>
</CollapsibleContent>
</Card> </Card>
</Collapsible>
); );
} }