api-client/components/environments/Add.vue

59 lines
1.3 KiB
Vue
Raw Normal View History

2020-02-23 16:38:15 +00:00
<template>
<SmartModal v-if="show" @close="hideModal">
<template #header>
<h3 class="heading">{{ $t("new_environment") }}</h3>
<div>
2021-07-03 13:14:58 +00:00
<ButtonSecondary icon="close" @click.native="hideModal" />
2020-12-11 10:29:03 +00:00
</div>
</template>
<template #body>
2021-07-01 10:10:51 +00:00
<label for="selectLabelEnvAdd">{{ $t("label") }}</label>
2020-12-11 10:29:03 +00:00
<input
2021-07-01 10:10:51 +00:00
id="selectLabelEnvAdd"
2020-12-11 10:29:03 +00:00
v-model="name"
class="input"
2021-05-18 06:26:59 +00:00
type="text"
2020-12-11 10:29:03 +00:00
:placeholder="$t('my_new_environment')"
@keyup.enter="addNewEnvironment"
/>
</template>
<template #footer>
<span></span>
<span>
2021-07-03 13:14:58 +00:00
<ButtonSecondary :label="$t('cancel')" @click.native="hideModal" />
<ButtonPrimary :label="$t('save')" @click.native="addNewEnvironment" />
</span>
</template>
</SmartModal>
2020-02-23 16:38:15 +00:00
</template>
<script lang="ts">
import Vue from "vue"
import { createEnvironment } from "~/newstore/environments"
2020-02-23 19:00:22 +00:00
export default Vue.extend({
2020-02-23 16:38:15 +00:00
props: {
2020-02-24 18:44:50 +00:00
show: Boolean,
2020-02-23 16:38:15 +00:00
},
data() {
return {
name: null as string | null,
}
},
2020-02-23 16:38:15 +00:00
methods: {
addNewEnvironment() {
if (!this.name) {
this.$toast.info(this.$t("invalid_environment_name").toString())
2020-02-24 18:44:50 +00:00
return
2020-02-23 16:38:15 +00:00
}
createEnvironment(this.name)
this.hideModal()
2020-02-23 16:38:15 +00:00
},
hideModal() {
this.name = null
this.$emit("hide-modal")
2020-02-24 18:44:50 +00:00
},
},
})
2020-02-23 16:38:15 +00:00
</script>