debian-mirror-gitlab/app/assets/javascripts/environments/components/new_environment.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.2 KiB
Vue
Raw Normal View History

2021-10-27 15:23:28 +05:30
<script>
2023-05-27 22:25:52 +05:30
import { createAlert } from '~/alert';
2021-10-27 15:23:28 +05:30
import axios from '~/lib/utils/axios_utils';
import { visitUrl } from '~/lib/utils/url_utility';
import EnvironmentForm from './environment_form.vue';
export default {
components: {
EnvironmentForm,
},
inject: ['projectEnvironmentsPath'],
data() {
return {
environment: {
name: '',
externalUrl: '',
},
loading: false,
};
},
methods: {
onChange(env) {
this.environment = env;
},
onSubmit() {
this.loading = true;
axios
.post(this.projectEnvironmentsPath, {
name: this.environment.name,
external_url: this.environment.externalUrl,
})
.then(({ data: { path } }) => visitUrl(path))
.catch((error) => {
const message = error.response.data.message[0];
2022-11-25 23:54:43 +05:30
createAlert({ message });
2021-10-27 15:23:28 +05:30
this.loading = false;
});
},
},
};
</script>
<template>
<environment-form
:cancel-path="projectEnvironmentsPath"
:environment="environment"
:title="__('New environment')"
:loading="loading"
@change="onChange($event)"
@submit="onSubmit"
/>
</template>