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

badge_list.vue « components « badges « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 76625fe9a607bcb7e6e5bce0bd9782f74b8cca19 (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
<script>
import { GlLoadingIcon, GlBadge } from '@gitlab/ui';
import { mapState } from 'vuex';
import { GROUP_BADGE } from '../constants';
import BadgeListRow from './badge_list_row.vue';

export default {
  name: 'BadgeList',
  components: {
    BadgeListRow,
    GlLoadingIcon,
    GlBadge,
  },
  computed: {
    ...mapState(['badges', 'isLoading', 'kind']),
    hasNoBadges() {
      return !this.isLoading && (!this.badges || !this.badges.length);
    },
    isGroupBadge() {
      return this.kind === GROUP_BADGE;
    },
  },
};
</script>

<template>
  <div class="card">
    <div class="card-header">
      {{ s__('Badges|Your badges') }}
      <gl-badge v-show="!isLoading" size="sm">{{ badges.length }}</gl-badge>
    </div>
    <gl-loading-icon v-show="isLoading" size="lg" class="card-body" />
    <div v-if="hasNoBadges" class="card-body">
      <span v-if="isGroupBadge">{{ s__('Badges|This group has no badges') }}</span>
      <span v-else>{{ s__('Badges|This project has no badges') }}</span>
    </div>
    <div v-else class="card-body" data-qa-selector="badge_list_content">
      <badge-list-row
        v-for="badge in badges"
        :key="badge.id"
        :badge="badge"
        data-qa-selector="badge_list_row"
        :data-qa-badge-name="badge.name"
      />
    </div>
  </div>
</template>