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', 'updateEnvironmentPath'],
|
|
|
|
props: {
|
|
|
|
environment: {
|
|
|
|
required: true,
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
formEnvironment: {
|
2021-11-11 11:23:49 +05:30
|
|
|
id: this.environment.id,
|
2021-10-27 15:23:28 +05:30
|
|
|
name: this.environment.name,
|
|
|
|
externalUrl: this.environment.external_url,
|
|
|
|
},
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onChange(environment) {
|
|
|
|
this.formEnvironment = environment;
|
|
|
|
},
|
|
|
|
onSubmit() {
|
|
|
|
this.loading = true;
|
|
|
|
axios
|
|
|
|
.put(this.updateEnvironmentPath, {
|
|
|
|
id: this.environment.id,
|
|
|
|
external_url: this.formEnvironment.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="formEnvironment"
|
|
|
|
:title="__('Edit environment')"
|
|
|
|
:loading="loading"
|
|
|
|
@change="onChange"
|
|
|
|
@submit="onSubmit"
|
|
|
|
/>
|
|
|
|
</template>
|