Files
archie/ui/src/workflows/RunWorkflowButton.vue
T

46 lines
1.7 KiB
Vue

<script setup lang="ts">
import { FlaskConical, Play } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import NewTaskForm from "@/tasks/NewTaskForm.vue";
defineProps<{
workflow: string;
disabled?: boolean;
/** The unsaved definition to test-run; absent runs the stored one. */
draft?: string;
}>();
const emit = defineEmits<{ started: [taskId: number] }>();
// A controlled open lets the toolbar's one menu run this when its own button
// does not fit.
const open = defineModel<boolean>("open", { default: false });
function started(taskId: number): void {
open.value = false;
emit("started", taskId);
}
</script>
<template>
<Dialog v-model:open="open">
<DialogTrigger as-child>
<Button
type="button"
size="sm"
variant="outline"
:aria-label="`${draft !== undefined ? 'Test' : 'Run'} ${workflow}`"
:disabled="disabled"
:title="draft !== undefined ? 'Runs this draft once. Forge writes and pushes are skipped, including in called workflows; commands and tools still run' : disabled ? 'Save first' : undefined"
>
<component :is="draft !== undefined ? FlaskConical : Play" data-icon="inline-start" /> <span>{{ draft !== undefined ? "Test" : "Run" }}</span></Button>
</DialogTrigger>
<DialogContent class="sm:max-w-[640px]">
<DialogHeader>
<DialogTitle>{{ draft !== undefined ? "Test" : "Run" }} {{ workflow }}</DialogTitle>
</DialogHeader>
<NewTaskForm v-if="open" :workflow="workflow" :draft="draft" @started="started" @cancel="open = false" />
</DialogContent>
</Dialog>
</template>