environment.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div>
  3. <div class="row-wrapper">
  4. <div>
  5. <button class="icon" @click="$emit('edit-environment')">
  6. <i class="material-icons">layers</i>
  7. <span>{{ environment.name }}</span>
  8. </button>
  9. </div>
  10. <v-popover>
  11. <button class="tooltip-target icon" v-tooltip.left="$t('more')">
  12. <i class="material-icons">more_vert</i>
  13. </button>
  14. <template slot="popover">
  15. <div>
  16. <button class="icon" @click="$emit('edit-environment')" v-close-popover>
  17. <i class="material-icons">create</i>
  18. <span>{{ $t("edit") }}</span>
  19. </button>
  20. </div>
  21. <div>
  22. <button class="icon" @click="confirmRemove = true" v-close-popover>
  23. <i class="material-icons">delete</i>
  24. <span>{{ $t("delete") }}</span>
  25. </button>
  26. </div>
  27. </template>
  28. </v-popover>
  29. </div>
  30. <confirm-modal
  31. :show="confirmRemove"
  32. :title="$t('are_you_sure_remove_environment')"
  33. @hide-modal="confirmRemove = false"
  34. @resolve="removeEnvironment"
  35. />
  36. </div>
  37. </template>
  38. <script>
  39. import { fb } from "~/helpers/fb"
  40. export default {
  41. props: {
  42. environment: Object,
  43. environmentIndex: Number,
  44. },
  45. data() {
  46. return {
  47. confirmRemove: false,
  48. }
  49. },
  50. methods: {
  51. syncEnvironments() {
  52. if (fb.currentUser !== null && fb.currentSettings[1]) {
  53. if (fb.currentSettings[1].value) {
  54. fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
  55. }
  56. }
  57. },
  58. removeEnvironment() {
  59. this.$store.commit("postwoman/removeEnvironment", this.environmentIndex)
  60. this.$toast.error(this.$t("deleted"), {
  61. icon: "delete",
  62. })
  63. this.syncEnvironments()
  64. },
  65. },
  66. }
  67. </script>