import { useMemo, useState } from "react"; import { useParams } from "react-router"; import { CollapsibleFile } from "../components/collapsible-file"; import { StageSidebar } from "../components/stage-sidebar"; import { Badge, Count, Mono, Muted, Panel, PanelSkeleton, Row, type SettingsView, Toggle, ViewToggle, } from "../components/settings-panel"; import { useRunSettings, useRunStages } from "../lib/queries"; import { mapRunStagesToSidebarStages } from "../lib/stage-sidebar"; import { type Snapshot, type UnknownRecord, getArray, getBool, getObject, getString, objectKeyCount, } from "../lib/run-settings-snapshot"; export const handle = { wide: true }; export default function RunSettingsPage() { const { id } = useParams(); const stagesQuery = useRunStages(id); const settingsQuery = useRunSettings(id); const stages = useMemo( () => mapRunStagesToSidebarStages(stagesQuery.data), [stagesQuery.data], ); const [view, setView] = useState("settings"); const snapshot = settingsQuery.data; return (
{!snapshot ? ( <> ) : view === "settings" ? ( <> ) : ( )}
); } function PageIntro({ view, setView, }: { view: SettingsView; setView: (v: SettingsView) => void; }) { return (

Run settings

Frozen settings snapshot used by this run.

); } function WorkflowPanel({ snapshot }: { snapshot: Snapshot }) { const workflow = getObject(snapshot, "workflow"); const run = getObject(snapshot, "run"); const name = getString(workflow, "name"); const description = getString(workflow, "description"); const goal = getObject(run, "goal"); return ( {name ? {name} : Unnamed} {description ? ( {description} ) : null} ); } function SandboxPanel({ snapshot }: { snapshot: Snapshot }) { const sandbox = getObject(getObject(snapshot, "run"), "sandbox"); const provider = getString(sandbox, "provider"); const docker = getObject(sandbox, "docker"); const dockerImage = getString(docker, "image"); const local = getObject(sandbox, "local"); const worktreeMode = getString(local, "worktree_mode"); return ( {provider ? {provider} : Unknown} {provider === "docker" && dockerImage ? ( {dockerImage} ) : null} {provider === "local" && worktreeMode ? ( {worktreeMode} ) : null} ); } function GitPanel({ snapshot }: { snapshot: Snapshot }) { const run = getObject(snapshot, "run"); const author = getObject(getObject(run, "git"), "author"); const authorName = getString(author, "name"); const authorEmail = getString(author, "email"); const scm = getObject(run, "scm"); const scmProvider = getString(scm, "provider"); const scmOwner = getString(scm, "owner"); const scmRepo = getString(scm, "repository"); const repoLabel = scmOwner && scmRepo ? `${scmOwner}/${scmRepo}` : scmRepo ?? scmOwner; const pr = getObject(run, "pull_request"); return ( {scmProvider ? ( {scmProvider} {repoLabel ? {repoLabel} : null} ) : ( None )} ); } function ArtifactsPanel({ snapshot }: { snapshot: Snapshot }) { const artifacts = getObject(getObject(snapshot, "run"), "artifacts"); const include = getArray(artifacts, "include"); return ( {include && include.length > 0 ? ( typeof e === "string")} /> ) : ( None )} ); } function GoalValue({ goal }: { goal: UnknownRecord | undefined }) { if (!goal) return None; const type = getString(goal, "type"); const value = getString(goal, "value"); if (!value) return None; return ( {type ? {type} : null} {value} ); } function AuthorValue({ name, email }: { name?: string; email?: string }) { if (!name && !email) return Default; if (name && email) { return ( {name} <{email}> ); } return {name ?? email}; } function PullRequestValue({ pr }: { pr: UnknownRecord | undefined }) { const enabled = getBool(pr, "enabled") ?? false; if (!enabled) return ; const draft = getBool(pr, "draft") ?? false; const autoMerge = getBool(pr, "auto_merge") ?? false; const strategy = getString(pr, "merge_strategy"); return ( {draft ? draft : null} {autoMerge ? auto-merge : null} {strategy ? ( {strategy} ) : null} ); } function GlobList({ globs }: { globs: string[] }) { return ( {globs.map((g) => ( {g} ))} ); }