1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<script>
import { GlSafeHtmlDirective as SafeHtml, GlModal } from '@gitlab/ui';
import { escape } from 'lodash';
import { __, s__, sprintf } from '~/locale';
export default {
components: {
GlModal,
},
directives: {
SafeHtml,
},
props: {
deleteProjectUrl: {
type: String,
required: false,
default: '',
},
projectName: {
type: String,
required: false,
default: '',
},
csrfToken: {
type: String,
required: false,
default: '',
},
},
data() {
return {
enteredProjectName: '',
};
},
computed: {
title() {
return sprintf(
s__('AdminProjects|Delete Project %{projectName}?'),
{
projectName: `'${escape(this.projectName)}'`,
},
false,
);
},
text() {
return sprintf(
s__(`AdminProjects|
You’re about to permanently delete the project %{projectName}, its repository,
and all related resources, including issues and merge requests. Once you confirm and press
%{strong_start}Delete project%{strong_end}, it cannot be undone or recovered.`),
{
projectName: `<strong>${escape(this.projectName)}</strong>`,
strong_start: '<strong>',
strong_end: '</strong>',
},
false,
);
},
confirmationTextLabel() {
return sprintf(
s__('AdminUsers|To confirm, type %{projectName}'),
{
projectName: `<code>${escape(this.projectName)}</code>`,
},
false,
);
},
canSubmit() {
return this.enteredProjectName === this.projectName;
},
primaryProps() {
return {
text: s__('Delete project'),
attributes: [{ variant: 'danger' }, { category: 'primary' }, { disabled: !this.canSubmit }],
};
},
},
methods: {
onCancel() {
this.enteredProjectName = '';
},
onSubmit() {
if (!this.canSubmit) {
return;
}
this.$refs.form.submit();
this.enteredProjectName = '';
},
},
cancelProps: {
text: __('Cancel'),
},
};
</script>
<template>
<gl-modal
modal-id="delete-project-modal"
:title="title"
:action-primary="primaryProps"
:action-cancel="$options.cancelProps"
:ok-disabled="!canSubmit"
@primary="onSubmit"
@cancel="onCancel"
>
<p v-safe-html="text"></p>
<p v-safe-html="confirmationTextLabel"></p>
<form ref="form" :action="deleteProjectUrl" method="post">
<input ref="method" type="hidden" name="_method" value="delete" />
<input :value="csrfToken" type="hidden" name="authenticity_token" />
<input
v-model="enteredProjectName"
name="projectName"
class="form-control"
type="text"
aria-labelledby="input-label"
autocomplete="off"
/>
</form>
</gl-modal>
</template>
|