debian-mirror-gitlab/app/assets/javascripts/badges/components/badge_list_row.vue

78 lines
2.1 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
import { mapActions, mapState } from 'vuex';
2020-01-01 13:55:28 +05:30
import { GlLoadingIcon } from '@gitlab/ui';
2018-05-09 12:01:36 +05:30
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,
2018-12-13 13:39:08 +05:30
GlLoadingIcon,
2018-05-09 12:01:36 +05:30
},
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"
2020-01-01 13:55:28 +05:30
class="table-section section-30"
2018-05-09 12:01:36 +05:30
/>
2020-01-01 13:55:28 +05:30
<div class="table-section section-30">
<label class="label-bold str-truncated mb-0">{{ badge.name }}</label>
2018-11-20 20:47:30 +05:30
<span class="badge badge-pill">{{ badgeKindText }}</span>
2018-05-09 12:01:36 +05:30
</div>
2020-01-01 13:55:28 +05:30
<span class="table-section section-30 str-truncated">{{ badge.linkUrl }}</span>
<div class="table-section section-10 table-button-footer">
2019-02-15 15:39:39 +05:30
<div v-if="canEditBadge" class="table-action-buttons">
2018-05-09 12:01:36 +05:30
<button
2018-11-08 19:23:39 +05:30
:disabled="badge.isDeleting"
2018-05-09 12:01:36 +05:30
class="btn btn-default append-right-8"
type="button"
2019-03-02 22:35:43 +05:30
@click="editBadge(badge)"
2018-05-09 12:01:36 +05:30
>
2019-02-15 15:39:39 +05:30
<icon :size="16" :aria-label="__('Edit')" name="pencil" />
2018-05-09 12:01:36 +05:30
</button>
<button
2018-11-08 19:23:39 +05:30
:disabled="badge.isDeleting"
2018-05-09 12:01:36 +05:30
class="btn btn-danger"
type="button"
data-toggle="modal"
data-target="#delete-badge-modal"
2019-03-02 22:35:43 +05:30
@click="updateBadgeInModal(badge)"
2018-05-09 12:01:36 +05:30
>
2019-02-15 15:39:39 +05:30
<icon :size="16" :aria-label="__('Delete')" name="remove" />
2018-05-09 12:01:36 +05:30
</button>
2019-02-15 15:39:39 +05:30
<gl-loading-icon v-show="badge.isDeleting" :inline="true" />
2018-05-09 12:01:36 +05:30
</div>
</div>
</div>
</template>