Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/environments/components/new_environment.vue')
-rw-r--r--app/assets/javascripts/environments/components/new_environment.vue51
1 files changed, 51 insertions, 0 deletions
diff --git a/app/assets/javascripts/environments/components/new_environment.vue b/app/assets/javascripts/environments/components/new_environment.vue
new file mode 100644
index 00000000000..14da2668417
--- /dev/null
+++ b/app/assets/javascripts/environments/components/new_environment.vue
@@ -0,0 +1,51 @@
+<script>
+import createFlash from '~/flash';
+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];
+ createFlash({ message });
+ this.loading = false;
+ });
+ },
+ },
+};
+</script>
+<template>
+ <environment-form
+ :cancel-path="projectEnvironmentsPath"
+ :environment="environment"
+ :title="__('New environment')"
+ :loading="loading"
+ @change="onChange($event)"
+ @submit="onSubmit"
+ />
+</template>