4
0

ActionStatusDisplay.vue 2.2 KB

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