api-client/components/environments/Add.vue

65 lines
1.4 KiB
Vue
Raw Normal View History

2020-02-23 16:38:15 +00:00
<template>
2021-08-16 16:32:18 +00:00
<SmartModal v-if="show" :title="$t('environment.new')" @close="hideModal">
<template #body>
2021-07-17 17:40:28 +00:00
<div class="flex flex-col px-2">
2021-07-09 17:19:45 +00:00
<input
id="selectLabelEnvAdd"
v-model="name"
v-focus
2021-08-07 09:21:13 +00:00
class="input floating-input"
placeholder=" "
2021-07-09 17:19:45 +00:00
type="text"
@keyup.enter="addNewEnvironment"
/>
2021-08-07 09:21:13 +00:00
<label for="selectLabelEnvAdd">
{{ $t("action.label") }}
2021-08-07 09:21:13 +00:00
</label>
2021-07-09 17:19:45 +00:00
</div>
</template>
<template #footer>
<span>
<ButtonPrimary
:label="$t('action.save')"
@click.native="addNewEnvironment"
/>
<ButtonSecondary
:label="$t('action.cancel')"
@click.native="hideModal"
/>
</span>
</template>
</SmartModal>
2020-02-23 16:38:15 +00:00
</template>
<script lang="ts">
2021-08-24 03:44:46 +00:00
import { defineComponent } from "@nuxtjs/composition-api"
import { createEnvironment } from "~/newstore/environments"
2020-02-23 19:00:22 +00:00
2021-08-24 03:44:46 +00:00
export default defineComponent({
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) {
2021-08-20 09:38:54 +00:00
this.$toast.error(this.$t("environment.invalid_name").toString(), {
icon: "error_outline",
})
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>