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
|
<script>
import { GlModal } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
import { __ } from '~/locale';
export default {
directives: {
SafeHtml,
},
components: {
GlModal,
},
props: {
title: {
type: String,
required: false,
default: '',
},
primaryText: {
type: String,
required: false,
default: __('OK'),
},
primaryVariant: {
type: String,
required: false,
default: 'confirm',
},
secondaryText: {
type: String,
required: false,
default: '',
},
secondaryVariant: {
type: String,
required: false,
default: 'confirm',
},
cancelText: {
type: String,
required: false,
default: __('Cancel'),
},
cancelVariant: {
type: String,
required: false,
default: 'default',
},
modalHtmlMessage: {
type: String,
required: false,
default: '',
},
hideCancel: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
primaryAction() {
return {
text: this.primaryText,
attributes: {
variant: this.primaryVariant,
'data-qa-selector': 'confirm_ok_button',
},
};
},
secondaryAction() {
if (!this.secondaryText) {
return null;
}
return {
text: this.secondaryText,
attributes: {
variant: this.secondaryVariant,
category: 'secondary',
},
};
},
cancelAction() {
return this.hideCancel
? null
: {
text: this.cancelText,
attributes: {
variant: this.cancelVariant,
},
};
},
shouldShowHeader() {
return Boolean(this.title?.length);
},
},
mounted() {
this.$refs.modal.show();
},
};
</script>
<template>
<gl-modal
ref="modal"
size="sm"
modal-id="confirmationModal"
body-class="gl-display-flex"
:title="title"
:action-primary="primaryAction"
:action-cancel="cancelAction"
:action-secondary="secondaryAction"
:hide-header="!shouldShowHeader"
@primary="$emit('confirmed')"
@hidden="$emit('closed')"
>
<div v-if="!modalHtmlMessage" class="gl-align-self-center"><slot></slot></div>
<div v-else v-safe-html="modalHtmlMessage" class="gl-align-self-center"></div>
</gl-modal>
</template>
|