2020-01-01 13:55:28 +05:30
|
|
|
<script>
|
2020-04-22 19:07:51 +05:30
|
|
|
import { escape as esc } from 'lodash';
|
2020-01-01 13:55:28 +05:30
|
|
|
import SplitButton from '~/vue_shared/components/split_button.vue';
|
2020-04-22 19:07:51 +05:30
|
|
|
import { GlModal, GlDeprecatedButton, GlFormInput } from '@gitlab/ui';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { s__, sprintf } from '~/locale';
|
|
|
|
import csrf from '~/lib/utils/csrf';
|
|
|
|
|
|
|
|
const splitButtonActionItems = [
|
|
|
|
{
|
|
|
|
title: s__('ClusterIntegration|Remove integration and resources'),
|
|
|
|
description: s__(
|
|
|
|
'ClusterIntegration|Deletes all GitLab resources attached to this cluster during removal',
|
|
|
|
),
|
|
|
|
eventName: 'remove-cluster-and-cleanup',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: s__('ClusterIntegration|Remove integration'),
|
|
|
|
description: s__(
|
|
|
|
'ClusterIntegration|Removes cluster from project but keeps associated resources',
|
|
|
|
),
|
|
|
|
eventName: 'remove-cluster',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export default {
|
|
|
|
splitButtonActionItems,
|
|
|
|
components: {
|
|
|
|
SplitButton,
|
|
|
|
GlModal,
|
2020-04-22 19:07:51 +05:30
|
|
|
GlDeprecatedButton,
|
2020-01-01 13:55:28 +05:30
|
|
|
GlFormInput,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
clusterPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
clusterName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
enteredClusterName: '',
|
|
|
|
confirmCleanup: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
csrfToken() {
|
|
|
|
return csrf.token;
|
|
|
|
},
|
|
|
|
modalTitle() {
|
|
|
|
return this.confirmCleanup
|
|
|
|
? s__('ClusterIntegration|Remove integration and resources?')
|
|
|
|
: s__('ClusterIntegration|Remove integration?');
|
|
|
|
},
|
|
|
|
warningMessage() {
|
|
|
|
return this.confirmCleanup
|
|
|
|
? s__(
|
|
|
|
'ClusterIntegration|You are about to remove your cluster integration and all GitLab-created resources associated with this cluster.',
|
|
|
|
)
|
|
|
|
: s__('ClusterIntegration|You are about to remove your cluster integration.');
|
|
|
|
},
|
|
|
|
warningToBeRemoved() {
|
|
|
|
return s__(`ClusterIntegration|
|
|
|
|
This will permanently delete the following resources:
|
|
|
|
<ul>
|
|
|
|
<li>All installed applications and related resources</li>
|
|
|
|
<li>The <code>gitlab-managed-apps</code> namespace</li>
|
|
|
|
<li>Any project namespaces</li>
|
|
|
|
<li><code>clusterroles</code></li>
|
|
|
|
<li><code>clusterrolebindings</code></li>
|
|
|
|
</ul>
|
|
|
|
`);
|
|
|
|
},
|
|
|
|
confirmationTextLabel() {
|
|
|
|
return sprintf(
|
|
|
|
this.confirmCleanup
|
|
|
|
? s__(
|
|
|
|
'ClusterIntegration|To remove your integration and resources, type %{clusterName} to confirm:',
|
|
|
|
)
|
|
|
|
: s__('ClusterIntegration|To remove your integration, type %{clusterName} to confirm:'),
|
|
|
|
{
|
2020-04-22 19:07:51 +05:30
|
|
|
clusterName: `<code>${esc(this.clusterName)}</code>`,
|
2020-01-01 13:55:28 +05:30
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
canSubmit() {
|
|
|
|
return this.enteredClusterName === this.clusterName;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleClickRemoveCluster(cleanup = false) {
|
|
|
|
this.confirmCleanup = cleanup;
|
|
|
|
this.$refs.modal.show();
|
|
|
|
},
|
|
|
|
handleCancel() {
|
|
|
|
this.$refs.modal.hide();
|
|
|
|
this.enteredClusterName = '';
|
|
|
|
},
|
|
|
|
handleSubmit(cleanup = false) {
|
|
|
|
this.$refs.cleanup.name = cleanup === true ? 'cleanup' : 'no_cleanup';
|
|
|
|
this.$refs.form.submit();
|
|
|
|
this.enteredClusterName = '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<split-button
|
|
|
|
:action-items="$options.splitButtonActionItems"
|
|
|
|
menu-class="dropdown-menu-large"
|
|
|
|
variant="danger"
|
|
|
|
@remove-cluster="handleClickRemoveCluster(false)"
|
|
|
|
@remove-cluster-and-cleanup="handleClickRemoveCluster(true)"
|
|
|
|
/>
|
|
|
|
<gl-modal
|
|
|
|
ref="modal"
|
|
|
|
size="lg"
|
|
|
|
modal-id="delete-cluster-modal"
|
|
|
|
:title="modalTitle"
|
|
|
|
kind="danger"
|
|
|
|
>
|
|
|
|
<template>
|
|
|
|
<p>{{ warningMessage }}</p>
|
|
|
|
<div v-if="confirmCleanup" v-html="warningToBeRemoved"></div>
|
|
|
|
<strong v-html="confirmationTextLabel"></strong>
|
|
|
|
<form ref="form" :action="clusterPath" method="post" class="append-bottom-20">
|
|
|
|
<input ref="method" type="hidden" name="_method" value="delete" />
|
|
|
|
<input :value="csrfToken" type="hidden" name="authenticity_token" />
|
|
|
|
<input ref="cleanup" type="hidden" name="cleanup" value="true" />
|
|
|
|
<gl-form-input
|
|
|
|
v-model="enteredClusterName"
|
|
|
|
autofocus
|
|
|
|
type="text"
|
|
|
|
name="confirm_cluster_name_input"
|
|
|
|
autocomplete="off"
|
|
|
|
/>
|
|
|
|
</form>
|
|
|
|
<span v-if="confirmCleanup">{{
|
|
|
|
s__(
|
|
|
|
'ClusterIntegration|If you do not wish to delete all associated GitLab resources, you can simply remove the integration.',
|
|
|
|
)
|
|
|
|
}}</span>
|
|
|
|
</template>
|
|
|
|
<template slot="modal-footer">
|
2020-04-22 19:07:51 +05:30
|
|
|
<gl-deprecated-button variant="secondary" @click="handleCancel">{{
|
|
|
|
s__('Cancel')
|
|
|
|
}}</gl-deprecated-button>
|
2020-01-01 13:55:28 +05:30
|
|
|
<template v-if="confirmCleanup">
|
2020-04-22 19:07:51 +05:30
|
|
|
<gl-deprecated-button :disabled="!canSubmit" variant="warning" @click="handleSubmit">{{
|
2020-01-01 13:55:28 +05:30
|
|
|
s__('ClusterIntegration|Remove integration')
|
2020-04-22 19:07:51 +05:30
|
|
|
}}</gl-deprecated-button>
|
|
|
|
<gl-deprecated-button
|
|
|
|
:disabled="!canSubmit"
|
|
|
|
variant="danger"
|
|
|
|
@click="handleSubmit(true)"
|
|
|
|
>{{ s__('ClusterIntegration|Remove integration and resources') }}</gl-deprecated-button
|
|
|
|
>
|
2020-01-01 13:55:28 +05:30
|
|
|
</template>
|
|
|
|
<template v-else>
|
2020-04-22 19:07:51 +05:30
|
|
|
<gl-deprecated-button :disabled="!canSubmit" variant="danger" @click="handleSubmit">{{
|
2020-01-01 13:55:28 +05:30
|
|
|
s__('ClusterIntegration|Remove integration')
|
2020-04-22 19:07:51 +05:30
|
|
|
}}</gl-deprecated-button>
|
2020-01-01 13:55:28 +05:30
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</gl-modal>
|
|
|
|
</div>
|
|
|
|
</template>
|