debian-mirror-gitlab/app/assets/javascripts/clusters/components/remove_cluster_confirmation.vue

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

171 lines
5.1 KiB
Vue
Raw Normal View History

2020-01-01 13:55:28 +05:30
<script>
2021-12-11 22:18:48 +05:30
import { GlModal, GlButton, GlFormInput, GlSprintf } from '@gitlab/ui';
2020-01-01 13:55:28 +05:30
import csrf from '~/lib/utils/csrf';
2021-12-11 22:18:48 +05:30
import { s__ } from '~/locale';
2020-01-01 13:55:28 +05:30
export default {
components: {
GlModal,
2020-07-28 23:09:34 +05:30
GlButton,
2020-01-01 13:55:28 +05:30
GlFormInput,
2021-12-11 22:18:48 +05:30
GlSprintf,
2020-01-01 13:55:28 +05:30
},
props: {
clusterPath: {
type: String,
required: true,
},
clusterName: {
type: String,
required: true,
},
2020-07-28 23:09:34 +05:30
hasManagementProject: {
type: Boolean,
required: false,
},
2020-01-01 13:55:28 +05:30
},
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.');
},
confirmationTextLabel() {
2021-12-11 22:18:48 +05:30
return 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-01-01 13:55:28 +05:30
},
canSubmit() {
return this.enteredClusterName === this.clusterName;
},
2020-07-28 23:09:34 +05:30
canCleanupResources() {
return !this.hasManagementProject;
},
2022-07-23 23:45:48 +05:30
buttonCategory() {
return !this.hasManagementProject ? 'secondary' : 'primary';
},
2020-01-01 13:55:28 +05:30
},
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>
2022-07-23 23:45:48 +05:30
<div class="gl-display-flex">
<gl-button
2020-07-28 23:09:34 +05:30
v-if="canCleanupResources"
2022-07-23 23:45:48 +05:30
data-testid="remove-integration-and-resources-button"
class="gl-mr-3"
2020-01-01 13:55:28 +05:30
variant="danger"
2022-07-23 23:45:48 +05:30
@click="handleClickRemoveCluster(true)"
>
{{ s__('ClusterIntegration|Remove integration and resources') }}
</gl-button>
2020-07-28 23:09:34 +05:30
<gl-button
2022-07-23 23:45:48 +05:30
data-testid="remove-integration-button"
:category="buttonCategory"
2020-07-28 23:09:34 +05:30
variant="danger"
@click="handleClickRemoveCluster(false)"
>
{{ s__('ClusterIntegration|Remove integration') }}
</gl-button>
2020-01-01 13:55:28 +05:30
<gl-modal
ref="modal"
size="lg"
modal-id="delete-cluster-modal"
:title="modalTitle"
kind="danger"
>
2021-03-11 19:13:27 +05:30
<p>{{ warningMessage }}</p>
<div v-if="confirmCleanup">
{{ s__('ClusterIntegration|This will permanently delete the following resources:') }}
<ul>
<li>{{ s__('ClusterIntegration|Any project namespaces') }}</li>
<!-- eslint-disable @gitlab/vue-require-i18n-strings -->
<li><code>clusterroles</code></li>
<li><code>clusterrolebindings</code></li>
<!-- eslint-enable @gitlab/vue-require-i18n-strings -->
</ul>
</div>
2021-12-11 22:18:48 +05:30
<strong>
<gl-sprintf :message="confirmationTextLabel">
<template #clusterName>
<code>{{ clusterName }}</code>
</template>
</gl-sprintf>
</strong>
2021-03-11 19:13:27 +05:30
<form ref="form" :action="clusterPath" method="post" class="gl-mb-5">
<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>
2020-06-23 00:09:42 +05:30
<template #modal-footer>
2022-07-16 23:28:13 +05:30
<gl-button @click="handleCancel">{{ __('Cancel') }}</gl-button>
2020-01-01 13:55:28 +05:30
<template v-if="confirmCleanup">
2020-11-24 15:15:51 +05:30
<gl-button
:disabled="!canSubmit"
2022-07-23 23:45:48 +05:30
data-testid="remove-integration-and-resources-modal-button"
2020-04-22 19:07:51 +05:30
variant="danger"
2020-11-24 15:15:51 +05:30
category="primary"
2020-04-22 19:07:51 +05:30
@click="handleSubmit(true)"
2020-11-24 15:15:51 +05:30
>{{ s__('ClusterIntegration|Remove integration and resources') }}</gl-button
2020-04-22 19:07:51 +05:30
>
2020-01-01 13:55:28 +05:30
</template>
<template v-else>
2020-11-24 15:15:51 +05:30
<gl-button
:disabled="!canSubmit"
2022-07-23 23:45:48 +05:30
data-testid="remove-integration-modal-button"
2020-11-24 15:15:51 +05:30
variant="danger"
category="primary"
@click="handleSubmit"
>{{ s__('ClusterIntegration|Remove integration') }}</gl-button
>
2020-01-01 13:55:28 +05:30
</template>
</template>
</gl-modal>
</div>
</template>