Environment.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. () => {
  39. $emit('edit-environment')
  40. $refs.options.tippy().hide()
  41. }
  42. "
  43. />
  44. <SmartItem
  45. v-if="!(environmentIndex === 'Global')"
  46. svg="trash-2"
  47. color="red"
  48. :label="`${$t('action.delete')}`"
  49. @click.native="
  50. () => {
  51. confirmRemove = true
  52. $refs.options.tippy().hide()
  53. }
  54. "
  55. />
  56. </tippy>
  57. </span>
  58. <SmartConfirmModal
  59. :show="confirmRemove"
  60. :title="`${$t('confirm.remove_environment')}`"
  61. @hide-modal="confirmRemove = false"
  62. @resolve="removeEnvironment"
  63. />
  64. </div>
  65. </template>
  66. <script lang="ts">
  67. import { defineComponent, PropType } from "@nuxtjs/composition-api"
  68. import { deleteEnvironment } from "~/newstore/environments"
  69. export default defineComponent({
  70. props: {
  71. environment: { type: Object, default: () => {} },
  72. environmentIndex: {
  73. type: [Number, String] as PropType<number | "Global">,
  74. default: null,
  75. },
  76. },
  77. data() {
  78. return {
  79. confirmRemove: false,
  80. }
  81. },
  82. methods: {
  83. removeEnvironment() {
  84. if (this.environmentIndex !== "Global")
  85. deleteEnvironment(this.environmentIndex)
  86. this.$toast.success(`${this.$t("state.deleted")}`, {
  87. icon: "delete",
  88. })
  89. },
  90. },
  91. })
  92. </script>