68c94dfa3a
* docs: define product and design direction * style: establish restrained workbench primitives * refactor: declutter board and task topbars * style: align dockview panel chrome * fix: align task topbar vcs control sizing * refactor: surface integrations navigation * fix: repair integrations and task creation workflow * refactor: include linear in integrations navigation * style: restore familiar workbench tones * fix: add dockview tab breathing room * fix: show configured integration shortcuts * fix: hover open integrations menu * fix: stabilize integrations hover menu * fix: align home and dockview topbars * fix: normalize home topbar controls * fix: compact home topbar height * fix: simplify home chrome and split buttons * fix: move integrations to left chrome * fix: restore home stats shortcut * fix: add dockview tab breathing room * fix: border home stats button * fix: streamline dockview topbar actions * fix: align task split button seam * fix: address review feedback * fix: restore topbar e2e affordances * fix: stabilize workflow e2e isolation * fix: add task topbar action overflow * fix: address PR review feedback
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { IconPlus, IconSubtask, IconChevronDown } from "@tabler/icons-react";
|
|
import { Button } from "@kandev/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@kandev/ui/dropdown-menu";
|
|
import { TaskCreateDialog } from "@/components/task-create-dialog";
|
|
import { NewSubtaskDialog } from "./new-subtask-dialog";
|
|
import type { Task } from "@/lib/types/http";
|
|
|
|
type NewTaskDropdownProps = {
|
|
workspaceId: string | null;
|
|
workflowId: string | null;
|
|
steps: Array<{ id: string; title: string; color?: string; events?: Record<string, unknown> }>;
|
|
activeTaskId: string | null;
|
|
activeTaskTitle: string;
|
|
onTaskCreated: (
|
|
task: Task,
|
|
mode: "create" | "edit",
|
|
meta?: { taskSessionId?: string | null },
|
|
) => void;
|
|
};
|
|
|
|
export function NewTaskDropdown({
|
|
workspaceId,
|
|
workflowId,
|
|
steps,
|
|
activeTaskId,
|
|
activeTaskTitle,
|
|
onTaskCreated,
|
|
}: NewTaskDropdownProps) {
|
|
const [showTaskDialog, setShowTaskDialog] = useState(false);
|
|
const [showSubtaskDialog, setShowSubtaskDialog] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<div className="flex items-center">
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
className={`h-6 gap-1 cursor-pointer ${activeTaskId ? "rounded-r-none border-r-0" : ""}`}
|
|
onClick={() => setShowTaskDialog(true)}
|
|
>
|
|
<IconPlus className="h-3.5 w-3.5" />
|
|
Task
|
|
</Button>
|
|
{activeTaskId && (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
className="-ml-px h-6 rounded-l-none px-1 cursor-pointer"
|
|
data-testid="new-task-chevron"
|
|
>
|
|
<IconChevronDown className="h-3 w-3" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuItem
|
|
className="cursor-pointer text-xs gap-1.5"
|
|
onClick={() => setShowSubtaskDialog(true)}
|
|
data-testid="new-subtask-button"
|
|
>
|
|
<IconSubtask className="h-3.5 w-3.5" />
|
|
Subtask
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
<TaskCreateDialog
|
|
open={showTaskDialog}
|
|
onOpenChange={setShowTaskDialog}
|
|
mode="create"
|
|
workspaceId={workspaceId}
|
|
workflowId={workflowId}
|
|
defaultStepId={steps[0]?.id ?? null}
|
|
steps={steps}
|
|
onSuccess={onTaskCreated}
|
|
/>
|
|
{activeTaskId && (
|
|
<NewSubtaskDialog
|
|
open={showSubtaskDialog}
|
|
onOpenChange={setShowSubtaskDialog}
|
|
parentTaskId={activeTaskId}
|
|
parentTaskTitle={activeTaskTitle}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
}
|