TestResultEnv.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="flex items-center justify-between px-4 py-2">
  3. <div class="flex items-center">
  4. <i
  5. v-tippy="{ theme: 'tooltip' }"
  6. class="mr-4 material-icons cursor-help"
  7. :class="getStyle(status)"
  8. :title="`${t(getTooltip(status))}`"
  9. >
  10. {{ getIcon(status) }}
  11. </i>
  12. <span class="text-secondaryDark">
  13. {{ env.key }}
  14. </span>
  15. <span class="text-secondaryDark">
  16. {{ ` \xA0 — \xA0 ${env.value}` }}
  17. </span>
  18. <span v-if="status === 'updations'" class="text-secondaryLight">
  19. {{ ` \xA0 ← \xA0 ${env.previousValue}` }}
  20. </span>
  21. </div>
  22. <span
  23. v-if="global"
  24. class="px-1 rounded bg-accentLight text-accentContrast text-tiny"
  25. >
  26. Global
  27. </span>
  28. </div>
  29. </template>
  30. <script setup lang="ts">
  31. import { useI18n } from "~/helpers/utils/composables"
  32. type Status = "updations" | "additions" | "deletions"
  33. type Props = {
  34. env: {
  35. key: string
  36. value: string
  37. previousValue?: string
  38. }
  39. status: Status
  40. global: boolean
  41. }
  42. withDefaults(defineProps<Props>(), {
  43. global: false,
  44. })
  45. const t = useI18n()
  46. const getIcon = (status: Status) => {
  47. switch (status) {
  48. case "additions":
  49. return "add_circle"
  50. case "updations":
  51. return "check_circle"
  52. case "deletions":
  53. return "remove_circle"
  54. }
  55. }
  56. const getStyle = (status: Status) => {
  57. switch (status) {
  58. case "additions":
  59. return "text-green-500"
  60. case "updations":
  61. return "text-yellow-500"
  62. case "deletions":
  63. return "text-red-500"
  64. }
  65. }
  66. const getTooltip = (status: Status) => {
  67. switch (status) {
  68. case "additions":
  69. return "environment.added"
  70. case "updations":
  71. return "environment.updated"
  72. case "deletions":
  73. return "environment.deleted"
  74. }
  75. }
  76. </script>