summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/badges/components/badge_list_row.vue
blob: 5d16ba3ce6d5688f266c8eaabdfe069625d3aee6 (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
<script>
import { mapActions, mapState } from 'vuex';
import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
import { PROJECT_BADGE } from '../constants';
import Badge from './badge.vue';

export default {
  name: 'BadgeListRow',
  components: {
    Badge,
    Icon,
  },
  props: {
    badge: {
      type: Object,
      required: true,
    },
  },
  computed: {
    ...mapState(['kind']),
    badgeKindText() {
      if (this.badge.kind === PROJECT_BADGE) {
        return s__('Badges|Project Badge');
      }

      return s__('Badges|Group Badge');
    },
    canEditBadge() {
      return this.badge.kind === this.kind;
    },
  },
  methods: {
    ...mapActions(['editBadge', 'updateBadgeInModal']),
  },
};
</script>

<template>
  <div class="gl-responsive-table-row-layout gl-responsive-table-row">
    <badge
      :image-url="badge.renderedImageUrl"
      :link-url="badge.renderedLinkUrl"
      class="table-section section-40"
    />
    <span class="table-section section-30 str-truncated">{{ badge.linkUrl }}</span>
    <div class="table-section section-15">
      <span class="badge badge-pill">{{ badgeKindText }}</span>
    </div>
    <div class="table-section section-15 table-button-footer">
      <div
        v-if="canEditBadge"
        class="table-action-buttons">
        <button
          :disabled="badge.isDeleting"
          class="btn btn-default append-right-8"
          type="button"
          @click="editBadge(badge)"
        >
          <icon
            :size="16"
            :aria-label="__('Edit')"
            name="pencil"
          />
        </button>
        <button
          :disabled="badge.isDeleting"
          class="btn btn-danger"
          type="button"
          data-toggle="modal"
          data-target="#delete-badge-modal"
          @click="updateBadgeInModal(badge)"
        >
          <icon
            :size="16"
            :aria-label="__('Delete')"
            name="remove"
          />
        </button>
        <gl-loading-icon
          v-show="badge.isDeleting"
          :inline="true"
        />
      </div>
    </div>
  </div>
</template>