Environment.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="flex items-center group">
  3. <span
  4. class="cursor-pointer flex px-4 justify-center items-center"
  5. @click="$emit('edit-environment')"
  6. >
  7. <SmartIcon class="svg-icons" name="layers" />
  8. </span>
  9. <span
  10. class="
  11. cursor-pointer
  12. flex flex-1
  13. min-w-0
  14. py-2
  15. pr-2
  16. transition
  17. group-hover:text-secondaryDark
  18. "
  19. @click="$emit('edit-environment')"
  20. >
  21. <span class="truncate">
  22. {{ environment.name }}
  23. </span>
  24. </span>
  25. <span>
  26. <tippy ref="options" interactive trigger="click" theme="popover" arrow>
  27. <template #trigger>
  28. <ButtonSecondary
  29. v-tippy="{ theme: 'tooltip' }"
  30. :title="$t('action.more')"
  31. svg="more-vertical"
  32. />
  33. </template>
  34. <SmartItem
  35. svg="edit"
  36. :label="$t('action.edit')"
  37. @click.native="
  38. $emit('edit-environment')
  39. $refs.options.tippy().hide()
  40. "
  41. />
  42. <SmartItem
  43. v-if="!(environmentIndex === 'Global')"
  44. svg="trash-2"
  45. color="red"
  46. :label="$t('action.delete')"
  47. @click.native="
  48. confirmRemove = true
  49. $refs.options.tippy().hide()
  50. "
  51. />
  52. </tippy>
  53. </span>
  54. <SmartConfirmModal
  55. :show="confirmRemove"
  56. :title="$t('confirm.remove_environment')"
  57. @hide-modal="confirmRemove = false"
  58. @resolve="removeEnvironment"
  59. />
  60. </div>
  61. </template>
  62. <script lang="ts">
  63. import { defineComponent, PropType } from "@nuxtjs/composition-api"
  64. import { deleteEnvironment } from "~/newstore/environments"
  65. export default defineComponent({
  66. props: {
  67. environment: { type: Object, default: () => {} },
  68. environmentIndex: {
  69. type: [Number, String] as PropType<number | "Global">,
  70. default: null,
  71. },
  72. },
  73. data() {
  74. return {
  75. confirmRemove: false,
  76. }
  77. },
  78. methods: {
  79. removeEnvironment() {
  80. if (this.environmentIndex !== "Global")
  81. deleteEnvironment(this.environmentIndex)
  82. this.$toast.success(this.$t("state.deleted").toString(), {
  83. icon: "delete",
  84. })
  85. },
  86. },
  87. })
  88. </script>