2020-02-23 16:38:15 +00:00
|
|
|
<template>
|
2021-03-01 03:58:14 +00:00
|
|
|
<SmartModal v-if="show" @close="hideModal">
|
2020-02-23 16:38:15 +00:00
|
|
|
<div slot="header">
|
2020-12-11 10:29:03 +00:00
|
|
|
<div class="row-wrapper">
|
|
|
|
|
<h3 class="title">{{ $t("new_environment") }}</h3>
|
|
|
|
|
<div>
|
|
|
|
|
<button class="icon" @click="hideModal">
|
|
|
|
|
<i class="material-icons">close</i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-02-23 16:38:15 +00:00
|
|
|
</div>
|
2020-12-11 16:54:34 +00:00
|
|
|
<div slot="body" class="flex flex-col">
|
2020-12-11 10:29:03 +00:00
|
|
|
<label for="selectLabel">{{ $t("label") }}</label>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
id="selectLabel"
|
|
|
|
|
v-model="name"
|
|
|
|
|
:placeholder="$t('my_new_environment')"
|
|
|
|
|
@keyup.enter="addNewEnvironment"
|
|
|
|
|
/>
|
2020-02-23 16:38:15 +00:00
|
|
|
</div>
|
|
|
|
|
<div slot="footer">
|
2020-09-22 17:06:37 +00:00
|
|
|
<div class="row-wrapper">
|
2020-02-23 16:38:15 +00:00
|
|
|
<span></span>
|
|
|
|
|
<span>
|
|
|
|
|
<button class="icon" @click="hideModal">
|
2020-02-25 02:06:23 +00:00
|
|
|
{{ $t("cancel") }}
|
2020-02-23 16:38:15 +00:00
|
|
|
</button>
|
|
|
|
|
<button class="icon primary" @click="addNewEnvironment">
|
2020-02-25 02:06:23 +00:00
|
|
|
{{ $t("save") }}
|
2020-02-23 16:38:15 +00:00
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2021-03-01 03:58:14 +00:00
|
|
|
</SmartModal>
|
2020-02-23 16:38:15 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2020-06-21 03:54:45 +00:00
|
|
|
import { fb } from "~/helpers/fb"
|
2021-03-23 15:18:14 +00:00
|
|
|
import { getSettingSubject } from "~/newstore/settings"
|
2020-02-23 19:00:22 +00:00
|
|
|
|
2020-02-23 16:38:15 +00:00
|
|
|
export default {
|
|
|
|
|
props: {
|
2020-02-24 18:44:50 +00:00
|
|
|
show: Boolean,
|
2020-02-23 16:38:15 +00:00
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-02-24 18:44:50 +00:00
|
|
|
name: undefined,
|
|
|
|
|
}
|
2020-02-23 16:38:15 +00:00
|
|
|
},
|
2021-03-23 15:18:14 +00:00
|
|
|
subscriptions() {
|
|
|
|
|
return {
|
|
|
|
|
SYNC_ENVIRONMENTS: getSettingSubject("syncEnvironments")
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-02-23 16:38:15 +00:00
|
|
|
methods: {
|
2020-02-23 19:00:22 +00:00
|
|
|
syncEnvironments() {
|
2021-03-23 15:18:14 +00:00
|
|
|
if (fb.currentUser !== null && this.SYNC_ENVIRONMENTS) {
|
|
|
|
|
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
|
2020-02-23 19:00:22 +00:00
|
|
|
}
|
|
|
|
|
},
|
2020-02-23 16:38:15 +00:00
|
|
|
addNewEnvironment() {
|
|
|
|
|
if (!this.$data.name) {
|
2020-02-25 02:06:23 +00:00
|
|
|
this.$toast.info(this.$t("invalid_environment_name"))
|
2020-02-24 18:44:50 +00:00
|
|
|
return
|
2020-02-23 16:38:15 +00:00
|
|
|
}
|
2020-02-23 17:13:12 +00:00
|
|
|
let newEnvironment = [
|
|
|
|
|
{
|
|
|
|
|
name: this.$data.name,
|
2020-02-24 18:44:50 +00:00
|
|
|
variables: [],
|
|
|
|
|
},
|
|
|
|
|
]
|
2020-02-25 02:06:23 +00:00
|
|
|
this.$store.commit("postwoman/importAddEnvironments", {
|
2020-02-24 03:21:10 +00:00
|
|
|
environments: newEnvironment,
|
2020-02-25 02:06:23 +00:00
|
|
|
confirmation: "Environment added",
|
2020-02-24 18:44:50 +00:00
|
|
|
})
|
2020-02-25 02:06:23 +00:00
|
|
|
this.$emit("hide-modal")
|
2020-02-24 18:44:50 +00:00
|
|
|
this.syncEnvironments()
|
2020-02-23 16:38:15 +00:00
|
|
|
},
|
|
|
|
|
hideModal() {
|
2020-02-25 02:06:23 +00:00
|
|
|
this.$emit("hide-modal")
|
2020-06-15 09:33:31 +00:00
|
|
|
this.$data.name = undefined
|
2020-02-24 18:44:50 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
2020-02-23 16:38:15 +00:00
|
|
|
</script>
|