52 lines
2.9 KiB
Vue
52 lines
2.9 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from "vue";
|
|
import { Plus } from "@lucide/vue";
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import { statusKind, statusLabel, type Binding } from "@/bindings/binding-draft";
|
|
import BindEvent from "./BindEvent.vue";
|
|
import SpecList from "./SpecList.vue";
|
|
import type { WorkflowTrigger } from "./workflow-triggers";
|
|
|
|
defineProps<{ yaml: string; triggers: WorkflowTrigger[] }>();
|
|
const emit = defineEmits<{ "update:yaml": [string]; bound: [] }>();
|
|
|
|
// The bind flow takes over the card; a null binding is a new one.
|
|
const binding = ref<Binding | null | undefined>();
|
|
function bound(): void {
|
|
binding.value = undefined;
|
|
emit("bound");
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<BindEvent v-if="binding !== undefined" :yaml="yaml" :binding="binding" @back="binding = undefined" @saved="bound" />
|
|
<div v-else class="space-y-4 px-3 py-3">
|
|
<section class="space-y-1.5">
|
|
<div class="flex justify-end">
|
|
<Button type="button" variant="ghost" size="xs" @click="binding = null"><Plus data-icon="inline-start" />Bind an event</Button>
|
|
</div>
|
|
<ul v-if="triggers.length" class="divide-y divide-border rounded-md border border-border">
|
|
<li v-for="trigger in triggers" :key="trigger.kind + trigger.label" class="text-label">
|
|
<button v-if="trigger.binding" type="button" class="flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-secondary" @click="binding = trigger.binding">
|
|
<span class="truncate">{{ trigger.label }}</span>
|
|
<Badge v-if="trigger.binding.status !== 'armed'" :variant="statusKind(trigger.binding.status)">{{ statusLabel(trigger.binding.status) }}</Badge>
|
|
<span v-if="trigger.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ trigger.detail }}</span>
|
|
</button>
|
|
<RouterLink v-else-if="trigger.kind === 'workflow' || trigger.kind === 'playbook'" :to="trigger.kind === 'workflow' ? { path: '/workflows', query: { workflow: trigger.label } } : { path: '/org/playbooks' }" class="flex items-center gap-2 px-3 py-2 hover:bg-secondary">
|
|
<span class="truncate">{{ trigger.label }}</span><span class="ml-auto truncate text-xs text-fg-subtle">{{ trigger.detail }}</span>
|
|
</RouterLink>
|
|
<div v-else class="flex items-center gap-2 px-3 py-2" title="Built-in issue routing. Disable this workflow to stop it running automatically.">
|
|
<span class="truncate">{{ trigger.label }}</span>
|
|
<Badge v-if="trigger.kind === 'issue'" variant="outline" class="ml-auto">Built-in</Badge>
|
|
<span v-if="trigger.detail" class="ml-auto truncate text-xs text-fg-subtle">{{ trigger.detail }}</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
<p v-else class="text-xs text-fg-subtle">Manual runs only.</p>
|
|
</section>
|
|
<SpecList :yaml="yaml" field="inputs" @update:yaml="emit('update:yaml', $event)" />
|
|
</div>
|
|
</template>
|