ActionStatusDisplay.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div :class = "statusClass + ' annotation'">
  3. <span>{{ statusText }}</span><span>{{ exitCodeText }}</span>
  4. </div>
  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.exitCode === 0) {
  33. return ''
  34. }
  35. if (logEntry.executionFinished) {
  36. if (logEntry.blocked || logEntry.timedOut) {
  37. return ''
  38. }
  39. return ' (Exit code: ' + logEntry.exitCode + ')'
  40. }
  41. return ''
  42. })
  43. const statusClass = computed(() => {
  44. const logEntry = props.logEntry
  45. if (!logEntry) return ''
  46. if (logEntry.executionFinished) {
  47. if (logEntry.blocked) {
  48. return 'status-blocked'
  49. } else if (logEntry.timedOut) {
  50. return 'status-timeout'
  51. } else if (logEntry.exitCode === 0) {
  52. return 'status-success'
  53. } else {
  54. return 'status-nonzero-exit'
  55. }
  56. }
  57. return ''
  58. })
  59. </script>
  60. <style scoped>
  61. .status-success {
  62. color: var(--karma-good-fg);
  63. }
  64. .status-nonzero-exit {
  65. color: var(--karma-bad-fg);
  66. }
  67. .status-timeout {
  68. color: var(--karma-warning-fg);
  69. }
  70. .status-blocked {
  71. color: #ca79ff;
  72. }
  73. </style>