<script setup lang="ts">
import type { PipelineRun } from '../../types/pipeline'

defineProps<{ run: PipelineRun; busy?: boolean }>()
defineEmits<{ resume: []; cancel: [] }>()
</script>

<template>
  <div class="pipeline-actions">
    <button
      :disabled="busy || !['failed', 'deadline_exceeded', 'cancelled'].includes(run.status)"
      @click="$emit('resume')"
    >
      {{ run.status === 'cancelled' ? '从取消点重新执行' : '从失败点恢复' }}
    </button>
    <button
      :disabled="busy || ['succeeded', 'failed', 'deadline_exceeded', 'cancelling', 'cancelled'].includes(run.status)"
      @click="$emit('cancel')"
    >
      取消批次
    </button>
  </div>
</template>

<style scoped>
.pipeline-actions { display: flex; gap: 8px; }
button { border: 1px solid #cbd2df; border-radius: 8px; background: white; padding: 8px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
</style>
