blob: 87eff2451ecce629a1331bacf66fb72dc6ad1ba6 (
plain)
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
|
<script>
import { GlAlert } from '@gitlab/ui';
import EditorStateObserver from './editor_state_observer.vue';
export default {
components: {
GlAlert,
EditorStateObserver,
},
data() {
return {
message: null,
variant: 'danger',
};
},
methods: {
displayAlert({ message, variant, action, actionLabel }) {
this.message = message;
this.variant = variant;
this.action = action;
this.actionLabel = actionLabel;
},
dismissAlert() {
this.message = null;
},
primaryAction() {
this.dismissAlert();
this.action?.();
},
},
};
</script>
<template>
<editor-state-observer @alert="displayAlert">
<gl-alert
v-if="message"
class="gl-mb-6"
:variant="variant"
:primary-button-text="actionLabel"
@dismiss="dismissAlert"
@primaryAction="primaryAction"
>
{{ message }}
</gl-alert>
</editor-state-observer>
</template>
|