62 lines
2.3 KiB
Vue
62 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
import { Label } from "@/components/ui/label";
|
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import { computed } from "vue";
|
|
|
|
import SpecList from "./SpecList.vue";
|
|
import { setWorkflowField, workflowField } from "./workflow-edit";
|
|
|
|
const props = defineProps<{ yaml: string }>();
|
|
const emit = defineEmits<{ "update:yaml": [string] }>();
|
|
|
|
const text = (key: string) => {
|
|
const value = workflowField(props.yaml, key);
|
|
return typeof value === "string" ? value : "";
|
|
};
|
|
function set(key: string, value: unknown): void {
|
|
emit("update:yaml", setWorkflowField(props.yaml, key, value));
|
|
}
|
|
|
|
const MODES = [
|
|
{ value: "required", label: "Repository", hint: "Clones the run's repository" },
|
|
{ value: "optional", label: "If given", hint: "Clones one when the run names it" },
|
|
{ value: "none", label: "None", hint: "Scratch workspace, no clone" },
|
|
];
|
|
const repository = computed(() => text("repository") || "required");
|
|
</script>
|
|
|
|
<template>
|
|
<div class="space-y-4 px-3 py-3">
|
|
<!-- The main field first: what the workflow is told, then how it runs. -->
|
|
<section class="space-y-1.5">
|
|
<Label for="workflow-instructions" class="text-caption font-medium text-fg-muted">Instructions</Label>
|
|
<Textarea
|
|
id="workflow-instructions"
|
|
:model-value="text('instructions')"
|
|
:rows="4"
|
|
class="font-mono text-label"
|
|
@change="set('instructions', ($event.target as HTMLTextAreaElement).value)"
|
|
/>
|
|
</section>
|
|
|
|
<div class="divide-y divide-border rounded-md border border-border">
|
|
<div class="flex min-h-10 items-center gap-3 px-3 py-1.5">
|
|
<span class="flex-1 text-label">Works on</span>
|
|
<ToggleGroup
|
|
type="single"
|
|
variant="outline"
|
|
size="sm"
|
|
:model-value="repository"
|
|
aria-label="Works on"
|
|
@update:model-value="(value) => { if (value) set('repository', value === 'required' ? undefined : String(value)); }"
|
|
>
|
|
<ToggleGroupItem v-for="mode in MODES" :key="mode.value" :value="mode.value" :title="mode.hint">{{ mode.label }}</ToggleGroupItem>
|
|
</ToggleGroup>
|
|
</div>
|
|
</div>
|
|
|
|
<SpecList :yaml="yaml" field="inputs" @update:yaml="emit('update:yaml', $event)" />
|
|
</div>
|
|
</template>
|