ActionStatusDisplay.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <span>
  3. <span :class="['action-status', statusClass]">{{ statusText }}</span><span>{{ exitCodeText }}</span>
  4. </span>
  5. </template>
  6. <script setup>
  7. import { computed } from 'vue'
  8. const props = defineProps({
  9. logEntry: {
  10. type: Object,
  11. required: true
  12. }
  13. })
  14. const statusText = computed(() => {
  15. const logEntry = props.logEntry
  16. if (!logEntry) return 'unknown'
  17. if (logEntry.executionFinished) {
  18. if (logEntry.blocked) {
  19. return 'Blocked'
  20. } else if (logEntry.timedOut) {
  21. return 'Timed out'
  22. } else {
  23. return 'Completed'
  24. }
  25. } else {
  26. return 'Still running...'
  27. }
  28. })
  29. const exitCodeText = computed(() => {
  30. const logEntry = props.logEntry
  31. if (!logEntry) return ''
  32. if (logEntry.executionFinished) {
  33. if (logEntry.blocked || logEntry.timedOut) {
  34. return ''
  35. }
  36. return ' Exit code: ' + logEntry.exitCode
  37. }
  38. return ''
  39. })
  40. const statusClass = computed(() => {
  41. const logEntry = props.logEntry
  42. if (!logEntry) return ''
  43. if (logEntry.executionFinished) {
  44. if (logEntry.blocked) {
  45. return 'action-blocked'
  46. } else if (logEntry.timedOut) {
  47. return 'action-timeout'
  48. } else if (logEntry.exitCode === 0) {
  49. return 'action-success'
  50. } else {
  51. return 'action-nonzero-exit'
  52. }
  53. }
  54. return ''
  55. })
  56. </script>