48 lines
1.7 KiB
Vue
48 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;
|
|
/** Why it is disabled, shown on the button. */
|
|
disabledReason?: string;
|
|
/** 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="disabled ? disabledReason : draft !== undefined ? 'Runs this draft once; deliveries are recorded, not sent' : 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>
|