TestResultEnv.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 pl-2 break-all">
  16. {{ ` \xA0 — \xA0 ${env.value}` }}
  17. </span>
  18. <span
  19. v-if="status === 'updations'"
  20. class="text-secondaryLight px-2 break-all"
  21. >
  22. {{ ` \xA0 ← \xA0 ${env.previousValue}` }}
  23. </span>
  24. </div>
  25. <span
  26. v-if="global"
  27. class="px-1 rounded bg-accentLight text-accentContrast text-tiny"
  28. >
  29. Global
  30. </span>
  31. </div>
  32. </template>
  33. <script setup lang="ts">
  34. import { useI18n } from "~/helpers/utils/composables"
  35. type Status = "updations" | "additions" | "deletions"
  36. type Props = {
  37. env: {
  38. key: string
  39. value: string
  40. previousValue?: string
  41. }
  42. status: Status
  43. global: boolean
  44. }
  45. withDefaults(defineProps<Props>(), {
  46. global: false,
  47. })
  48. const t = useI18n()
  49. const getIcon = (status: Status) => {
  50. switch (status) {
  51. case "additions":
  52. return "add_circle"
  53. case "updations":
  54. return "check_circle"
  55. case "deletions":
  56. return "remove_circle"
  57. }
  58. }
  59. const getStyle = (status: Status) => {
  60. switch (status) {
  61. case "additions":
  62. return "text-green-500"
  63. case "updations":
  64. return "text-yellow-500"
  65. case "deletions":
  66. return "text-red-500"
  67. }
  68. }
  69. const getTooltip = (status: Status) => {
  70. switch (status) {
  71. case "additions":
  72. return "environment.added"
  73. case "updations":
  74. return "environment.updated"
  75. case "deletions":
  76. return "environment.deleted"
  77. }
  78. }
  79. </script>