Welcome to mirror list, hosted at ThFree Co, Russian Federation.

child_content.vue « extensions « components « vue_merge_request_widget « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38f83a61b30bf26ba73bb74e688251dd8d7bcf0b (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
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
<script>
import { GlBadge, GlLink, GlSafeHtmlDirective, GlModalDirective } from '@gitlab/ui';
import StatusIcon from './status_icon.vue';
import Actions from './actions.vue';
import { generateText } from './utils';

export default {
  name: 'ChildContent',
  components: {
    GlBadge,
    GlLink,
    StatusIcon,
    Actions,
  },
  directives: {
    SafeHtml: GlSafeHtmlDirective,
    GlModal: GlModalDirective,
  },
  props: {
    data: {
      type: Object,
      required: true,
    },
    widgetLabel: {
      type: String,
      required: true,
    },
    modalId: {
      type: String,
      required: false,
      default: null,
    },
    level: {
      type: Number,
      required: true,
    },
  },
  methods: {
    isArray(arr) {
      return Array.isArray(arr);
    },
    onClickedAction(action) {
      this.$emit('clickedAction', action);
    },
    generateText,
  },
};
</script>

<template>
  <div :class="{ 'gl-pl-6': level === 3 }" class="gl-w-full">
    <div v-if="data.header" class="gl-mb-2">
      <template v-if="isArray(data.header)">
        <component
          :is="headerI === 0 ? 'strong' : 'span'"
          v-for="(header, headerI) in data.header"
          :key="headerI"
          v-safe-html="generateText(header)"
          class="gl-display-block"
        />
      </template>
      <strong v-else v-safe-html="generateText(data.header)"></strong>
    </div>
    <div class="gl-display-flex">
      <status-icon v-if="data.icon" :icon-name="data.icon.name" :size="12" class="gl-pl-0" />
      <div class="gl-w-full">
        <div class="gl-display-flex gl-flex-nowrap">
          <div class="gl-flex-wrap gl-display-flex gl-w-full">
            <div class="gl-display-flex gl-align-items-center">
              <p v-safe-html="generateText(data.text)" class="gl-m-0"></p>
            </div>
            <div v-if="data.link" class="gl-pr-2">
              <gl-link :href="data.link.href">{{ data.link.text }}</gl-link>
            </div>
            <div v-if="data.modal" class="gl-pr-2">
              <gl-link v-gl-modal="modalId" data-testid="modal-link" @click="data.modal.onClick">
                {{ data.modal.text }}
              </gl-link>
            </div>
            <div v-if="data.supportingText">
              <p v-safe-html="generateText(data.supportingText)" class="gl-m-0"></p>
            </div>
            <gl-badge v-if="data.badge" :variant="data.badge.variant || 'info'">
              {{ data.badge.text }}
            </gl-badge>
          </div>
          <actions
            :widget="widgetLabel"
            :tertiary-buttons="data.actions"
            class="gl-ml-auto gl-pl-3"
            @clickedAction="onClickedAction"
          />
        </div>
        <p
          v-if="data.subtext"
          v-safe-html="generateText(data.subtext)"
          class="gl-m-0 gl-font-sm"
        ></p>
      </div>
    </div>
    <template v-if="data.children && level === 2">
      <ul class="gl-m-0 gl-p-0 gl-list-style-none">
        <li>
          <child-content
            v-for="childData in data.children"
            :key="childData.id"
            :data="childData"
            :widget-label="widgetLabel"
            :modal-id="modalId"
            :level="3"
            data-testid="child-content"
            @clickedAction="onClickedAction"
          />
        </li>
      </ul>
    </template>
  </div>
</template>