api-client/components/environments/Environment.vue

74 lines
1.9 KiB
Vue
Raw Normal View History

2020-02-23 16:38:15 +00:00
<template>
<div>
<div class="row-wrapper">
<div>
<button class="icon" @click="$emit('edit-environment')">
<i class="material-icons">layers</i>
<span>{{ environment.name }}</span>
</button>
</div>
<v-popover>
<button class="tooltip-target icon" v-tooltip.left="$t('more')">
<i class="material-icons">more_vert</i>
</button>
<template slot="popover">
<div>
<button class="icon" @click="$emit('edit-environment')" v-close-popover>
<i class="material-icons">create</i>
<span>{{ $t("edit") }}</span>
</button>
</div>
<div>
<button class="icon" @click="confirmRemove = true" v-close-popover>
<i class="material-icons">delete</i>
<span>{{ $t("delete") }}</span>
</button>
</div>
</template>
</v-popover>
2020-02-23 16:38:15 +00:00
</div>
<SmartConfirmModal
:show="confirmRemove"
:title="$t('are_you_sure_remove_environment')"
@hide-modal="confirmRemove = false"
@resolve="removeEnvironment"
/>
2020-02-23 16:38:15 +00:00
</div>
</template>
<script>
import { fb } from "~/helpers/fb"
import { getSettingSubject } from "~/newstore/settings"
2020-02-23 16:38:15 +00:00
export default {
props: {
environment: Object,
2020-02-24 18:44:50 +00:00
environmentIndex: Number,
2020-02-23 16:38:15 +00:00
},
data() {
return {
confirmRemove: false,
}
},
subscriptions() {
return {
SYNC_ENVIRONMENTS: getSettingSubject("syncEnvironments")
}
},
2020-02-23 16:38:15 +00:00
methods: {
syncEnvironments() {
if (fb.currentUser !== null && this.SYNC_ENVIRONMENTS) {
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
}
},
2020-02-23 16:38:15 +00:00
removeEnvironment() {
this.$store.commit("postwoman/removeEnvironment", this.environmentIndex)
this.$toast.error(this.$t("deleted"), {
2020-08-16 11:56:33 +00:00
icon: "delete",
})
this.syncEnvironments()
2020-02-24 18:44:50 +00:00
},
},
}
2020-02-23 16:38:15 +00:00
</script>