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
|
<script>
import { GlBadge, GlLink } from '@gitlab/ui';
import SafeHtml from '~/vue_shared/directives/safe_html';
import Actions from '../action_buttons.vue';
import { generateText } from '../extensions/utils';
import ContentRow from './widget_content_row.vue';
export default {
name: 'DynamicContent',
components: {
GlBadge,
GlLink,
Actions,
ContentRow,
},
directives: {
SafeHtml,
},
props: {
data: {
type: Object,
required: true,
},
widgetName: {
type: String,
required: true,
},
level: {
type: Number,
required: false,
default: 2,
},
},
computed: {
statusIcon() {
return this.data.icon?.name || undefined;
},
generatedText() {
return generateText(this.data.text);
},
generatedSubtext() {
return generateText(this.data.subtext);
},
generatedSupportingText() {
return generateText(this.data.supportingText);
},
},
methods: {
onClickedAction(action) {
this.$emit('clickedAction', action);
},
},
};
</script>
<template>
<content-row
:level="level"
:status-icon-name="statusIcon"
:widget-name="widgetName"
:header="data.header"
:help-popover="data.helpPopover"
>
<template #body>
<div class="gl-display-flex gl-flex-direction-column">
<div>
<p v-safe-html="generatedText" class="gl-mb-0"></p>
<gl-link v-if="data.link" :href="data.link.href">{{ data.link.text }}</gl-link>
<p v-if="data.supportingText" v-safe-html="generatedSupportingText" class="gl-mb-0"></p>
<gl-badge v-if="data.badge" :variant="data.badge.variant || 'info'">
{{ data.badge.text }}
</gl-badge>
<actions
:widget="widgetName"
:tertiary-buttons="data.actions"
class="gl-ml-auto gl-pl-3"
@clickedAction="onClickedAction"
/>
<p v-if="data.subtext" v-safe-html="generatedSubtext" class="gl-m-0 gl-font-sm"></p>
</div>
<ul
v-if="data.children && data.children.length > 0 && level === 2"
class="gl-m-0 gl-p-0 gl-list-style-none"
>
<li>
<dynamic-content
v-for="(childData, index) in data.children"
:key="childData.id || index"
:data="childData"
:widget-name="widgetName"
:level="3"
data-qa-selector="child_content"
@clickedAction="onClickedAction"
/>
</li>
</ul>
</div>
</template>
</content-row>
</template>
|