ActionStatusDisplay.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <router-link
  3. v-if="showQueueLink"
  4. to="/logs/queue"
  5. class="tag"
  6. :class="statusTagClass"
  7. >
  8. {{ statusText }}
  9. </router-link>
  10. <span
  11. v-else
  12. class="tag"
  13. :class="statusTagClass"
  14. >{{ statusText }}{{ exitCodeText }}</span>
  15. </template>
  16. <script setup>
  17. import { computed } from 'vue'
  18. const props = defineProps({
  19. logEntry: {
  20. type: Object,
  21. required: true
  22. },
  23. linkQueuedStatus: {
  24. type: Boolean,
  25. default: false
  26. }
  27. })
  28. function isWaitingInQueue (logEntry) {
  29. return logEntry &&
  30. !logEntry.executionFinished &&
  31. !logEntry.executionStarted
  32. }
  33. const statusText = computed(() => {
  34. const logEntry = props.logEntry
  35. if (!logEntry) return 'unknown'
  36. if (logEntry.executionFinished) {
  37. if (logEntry.blocked) {
  38. return 'Blocked'
  39. } else if (logEntry.timedOut) {
  40. return 'Timed out'
  41. } else {
  42. return 'Completed'
  43. }
  44. }
  45. if (isWaitingInQueue(logEntry)) {
  46. return 'Queued'
  47. }
  48. return 'Still running...'
  49. })
  50. const exitCodeText = computed(() => {
  51. const logEntry = props.logEntry
  52. if (!logEntry) return ''
  53. if (logEntry.exitCode === 0) {
  54. return ''
  55. }
  56. if (logEntry.executionFinished) {
  57. if (logEntry.blocked || logEntry.timedOut) {
  58. return ''
  59. }
  60. return ' (Exit code: ' + logEntry.exitCode + ')'
  61. }
  62. return ''
  63. })
  64. const showQueueLink = computed(() => {
  65. return props.linkQueuedStatus && isWaitingInQueue(props.logEntry)
  66. })
  67. const statusTagClass = computed(() => {
  68. const logEntry = props.logEntry
  69. if (!logEntry) {
  70. return ''
  71. }
  72. if (!logEntry.executionFinished) {
  73. if (isWaitingInQueue(logEntry)) {
  74. return 'note'
  75. }
  76. return 'info'
  77. }
  78. if (logEntry.blocked) {
  79. return 'status-blocked'
  80. }
  81. if (logEntry.timedOut) {
  82. return ['warning', 'status-timeout']
  83. }
  84. if (logEntry.exitCode === 0) {
  85. return ['good', 'status-success']
  86. }
  87. return ['error', 'status-nonzero-exit']
  88. })
  89. </script>
  90. <style scoped>
  91. .tag {
  92. text-transform: none;
  93. }
  94. .tag.status-blocked {
  95. border-color: transparent;
  96. background-color: color-mix(in srgb, #ca79ff 30%, var(--standout-bg-color));
  97. color: var(--text-color);
  98. }
  99. a.tag {
  100. text-decoration: none;
  101. }
  102. </style>