2020-10-24 23:57:45 +05:30
|
|
|
<script>
|
2022-04-04 11:22:00 +05:30
|
|
|
import { GlModal, GlModalDirective, GlFormInput, GlButton, GlAlert, GlSprintf } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { uniqueId } from 'lodash';
|
2020-10-24 23:57:45 +05:30
|
|
|
import csrf from '~/lib/utils/csrf';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { __ } from '~/locale';
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2022-04-04 11:22:00 +05:30
|
|
|
GlAlert,
|
2020-10-24 23:57:45 +05:30
|
|
|
GlModal,
|
|
|
|
GlFormInput,
|
|
|
|
GlButton,
|
2022-04-04 11:22:00 +05:30
|
|
|
GlSprintf,
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlModal: GlModalDirective,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
confirmPhrase: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
formPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2022-04-04 11:22:00 +05:30
|
|
|
isFork: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
issuesCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
mergeRequestsCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
forksCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
starsCount: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
userInput: null,
|
|
|
|
modalId: uniqueId('delete-project-modal-'),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
confirmDisabled() {
|
|
|
|
return this.userInput !== this.confirmPhrase;
|
|
|
|
},
|
|
|
|
csrfToken() {
|
|
|
|
return csrf.token;
|
|
|
|
},
|
|
|
|
modalActionProps() {
|
|
|
|
return {
|
|
|
|
primary: {
|
|
|
|
text: __('Yes, delete project'),
|
2023-01-13 00:05:48 +05:30
|
|
|
attributes: [
|
|
|
|
{ variant: 'danger' },
|
|
|
|
{ disabled: this.confirmDisabled },
|
|
|
|
{ 'data-qa-selector': 'confirm_delete_button' },
|
|
|
|
],
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
cancel: {
|
|
|
|
text: __('Cancel, keep project'),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submitForm() {
|
|
|
|
this.$refs.form.submit();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
strings: {
|
|
|
|
deleteProject: __('Delete project'),
|
2022-04-04 11:22:00 +05:30
|
|
|
title: __('Are you absolutely sure?'),
|
|
|
|
confirmText: __('Enter the following to confirm:'),
|
|
|
|
isForkAlertTitle: __('You are about to delete this forked project containing:'),
|
|
|
|
isNotForkAlertTitle: __('You are about to delete this project containing:'),
|
|
|
|
isForkAlertBody: __('This process deletes the project repository and all related resources.'),
|
|
|
|
isNotForkAlertBody: __(
|
|
|
|
'This project is %{strongStart}NOT%{strongEnd} a fork. This process deletes the project repository and all related resources.',
|
|
|
|
),
|
|
|
|
isNotForkMessage: __(
|
|
|
|
'This project is %{strongStart}NOT%{strongEnd} a fork, and has the following:',
|
|
|
|
),
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<form ref="form" :action="formPath" method="post">
|
|
|
|
<input type="hidden" name="_method" value="delete" />
|
|
|
|
<input :value="csrfToken" type="hidden" name="authenticity_token" />
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
<gl-button
|
|
|
|
v-gl-modal="modalId"
|
|
|
|
category="primary"
|
|
|
|
variant="danger"
|
|
|
|
data-qa-selector="delete_button"
|
|
|
|
>{{ $options.strings.deleteProject }}</gl-button
|
|
|
|
>
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
<gl-modal
|
|
|
|
ref="removeModal"
|
|
|
|
:modal-id="modalId"
|
|
|
|
ok-variant="danger"
|
|
|
|
footer-class="gl-bg-gray-10 gl-p-5"
|
|
|
|
title-class="gl-text-red-500"
|
|
|
|
:action-primary="modalActionProps.primary"
|
|
|
|
:action-cancel="modalActionProps.cancel"
|
|
|
|
@ok="submitForm"
|
|
|
|
>
|
|
|
|
<template #modal-title>{{ $options.strings.title }}</template>
|
|
|
|
<div>
|
2022-04-04 11:22:00 +05:30
|
|
|
<gl-alert class="gl-mb-5" variant="danger" :dismissible="false">
|
|
|
|
<h4 v-if="isFork" data-testid="delete-alert-title" class="gl-alert-title">
|
|
|
|
{{ $options.strings.isForkAlertTitle }}
|
|
|
|
</h4>
|
|
|
|
<h4 v-else data-testid="delete-alert-title" class="gl-alert-title">
|
|
|
|
{{ $options.strings.isNotForkAlertTitle }}
|
|
|
|
</h4>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<gl-sprintf :message="n__('%d issue', '%d issues', issuesCount)">
|
|
|
|
<template #issuesCount>{{ issuesCount }}</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<gl-sprintf
|
|
|
|
:message="n__('%d merge requests', '%d merge requests', mergeRequestsCount)"
|
|
|
|
>
|
|
|
|
<template #mergeRequestsCount>{{ mergeRequestsCount }}</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<gl-sprintf :message="n__('%d fork', '%d forks', forksCount)">
|
|
|
|
<template #forksCount>{{ forksCount }}</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<gl-sprintf :message="n__('%d star', '%d stars', starsCount)">
|
|
|
|
<template #starsCount>{{ starsCount }}</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<gl-sprintf
|
|
|
|
v-if="isFork"
|
|
|
|
data-testid="delete-alert-body"
|
|
|
|
:message="$options.strings.isForkAlertBody"
|
|
|
|
/>
|
|
|
|
<gl-sprintf
|
|
|
|
v-else
|
|
|
|
data-testid="delete-alert-body"
|
|
|
|
:message="$options.strings.isNotForkAlertBody"
|
|
|
|
>
|
|
|
|
<template #strong="{ content }">
|
|
|
|
<strong>{{ content }}</strong>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</gl-alert>
|
2020-10-24 23:57:45 +05:30
|
|
|
<p class="gl-mb-1">{{ $options.strings.confirmText }}</p>
|
|
|
|
<p>
|
2020-11-24 15:15:51 +05:30
|
|
|
<code class="gl-white-space-pre-wrap">{{ confirmPhrase }}</code>
|
2020-10-24 23:57:45 +05:30
|
|
|
</p>
|
|
|
|
<gl-form-input
|
|
|
|
id="confirm_name_input"
|
|
|
|
v-model="userInput"
|
|
|
|
name="confirm_name_input"
|
|
|
|
type="text"
|
2023-01-13 00:05:48 +05:30
|
|
|
data-qa-selector="confirm_name_field"
|
2020-10-24 23:57:45 +05:30
|
|
|
/>
|
|
|
|
<slot name="modal-footer"></slot>
|
|
|
|
</div>
|
|
|
|
</gl-modal>
|
|
|
|
</form>
|
|
|
|
</template>
|