Files
kandev/apps/web/components/task-create-dialog-defaults.ts
T
José Almeida 68c94dfa3a feat: refine workbench chrome (#761)
* 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
2026-05-01 21:02:41 +01:00

49 lines
1.7 KiB
TypeScript

import type { DialogComputedArgs, StepType } from "@/components/task-create-dialog-types";
import { computeEffectiveStepId } from "@/components/task-create-dialog-helpers";
export function computeSingleWorkflowFallbackId(
selectedWorkflowId: string | null,
workflowId: string | null,
workflows: DialogComputedArgs["workflows"],
): string | null {
if (selectedWorkflowId || workflowId || workflows.length !== 1) return null;
return workflows[0]?.id ?? null;
}
export function computeSnapshotDefaultStepId(
workflowId: string | null,
snapshots: DialogComputedArgs["snapshots"],
): string | null {
if (!workflowId) return null;
const steps = snapshots[workflowId]?.steps ?? [];
const startStep = steps.find((step) => step.is_start_step);
if (startStep) return startStep.id;
return [...steps].sort((a, b) => a.position - b.position)[0]?.id ?? null;
}
type ComputeDialogDefaultStepIdArgs = {
selectedWorkflowId: string | null;
workflowId: string | null;
fetchedSteps: StepType[] | null;
defaultStepId: string | null;
effectiveWorkflowId: string | null;
snapshots: DialogComputedArgs["snapshots"];
};
export function computeDialogDefaultStepId({
selectedWorkflowId,
workflowId,
fetchedSteps,
defaultStepId,
effectiveWorkflowId,
snapshots,
}: ComputeDialogDefaultStepIdArgs): string | null {
const switchedWorkflowWithoutFetchedSteps =
Boolean(selectedWorkflowId) && selectedWorkflowId !== workflowId && !fetchedSteps;
const computedStepId = switchedWorkflowWithoutFetchedSteps
? null
: computeEffectiveStepId(selectedWorkflowId, workflowId, fetchedSteps, defaultStepId);
return computedStepId ?? computeSnapshotDefaultStepId(effectiveWorkflowId, snapshots);
}