|
| 1 | +<script> |
| 2 | +import { GlIcon, GlLink, GlTable, GlTooltipDirective } from '@gitlab/ui'; |
| 3 | +import { sprintf, s__, __ } from '~/locale'; |
| 4 | +import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; |
| 5 | +
|
| 6 | +export default { |
| 7 | + components: { |
| 8 | + GlIcon, |
| 9 | + GlLink, |
| 10 | + GlTable, |
| 11 | + TimeAgoTooltip, |
| 12 | + }, |
| 13 | + directives: { |
| 14 | + GlTooltip: GlTooltipDirective, |
| 15 | + }, |
| 16 | + props: { |
| 17 | + integrations: { |
| 18 | + type: Array, |
| 19 | + required: true, |
| 20 | + }, |
| 21 | + showUpdatedAt: { |
| 22 | + type: Boolean, |
| 23 | + required: false, |
| 24 | + default: false, |
| 25 | + }, |
| 26 | + emptyText: { |
| 27 | + type: String, |
| 28 | + required: false, |
| 29 | + default: undefined, |
| 30 | + }, |
| 31 | + }, |
| 32 | + computed: { |
| 33 | + fields() { |
| 34 | + return [ |
| 35 | + { |
| 36 | + key: 'active', |
| 37 | + label: '', |
| 38 | + thClass: 'gl-w-10', |
| 39 | + }, |
| 40 | + { |
| 41 | + key: 'title', |
| 42 | + label: __('Integration'), |
| 43 | + thClass: 'gl-w-quarter', |
| 44 | + }, |
| 45 | + { |
| 46 | + key: 'description', |
| 47 | + label: __('Description'), |
| 48 | + thClass: 'gl-display-none d-sm-table-cell', |
| 49 | + tdClass: 'gl-display-none d-sm-table-cell', |
| 50 | + }, |
| 51 | + { |
| 52 | + key: 'updated_at', |
| 53 | + label: this.showUpdatedAt ? __('Last updated') : '', |
| 54 | + thClass: 'gl-w-20p', |
| 55 | + }, |
| 56 | + ]; |
| 57 | + }, |
| 58 | + }, |
| 59 | + methods: { |
| 60 | + getStatusTooltipTitle(integration) { |
| 61 | + return sprintf(s__('Integrations|%{integrationTitle}: active'), { |
| 62 | + integrationTitle: integration.title, |
| 63 | + }); |
| 64 | + }, |
| 65 | + }, |
| 66 | +}; |
| 67 | +</script> |
| 68 | + |
| 69 | +<template> |
| 70 | + <gl-table :items="integrations" :fields="fields" :empty-text="emptyText" show-empty fixed> |
| 71 | + <template #cell(active)="{ item }"> |
| 72 | + <gl-icon |
| 73 | + v-if="item.active" |
| 74 | + v-gl-tooltip |
| 75 | + name="check" |
| 76 | + class="gl-text-green-500" |
| 77 | + :title="getStatusTooltipTitle(item)" |
| 78 | + /> |
| 79 | + </template> |
| 80 | + |
| 81 | + <template #cell(title)="{ item }"> |
| 82 | + <gl-link |
| 83 | + :href="item.edit_path" |
| 84 | + class="gl-font-weight-bold" |
| 85 | + :data-qa-selector="`${item.name}_link`" |
| 86 | + > |
| 87 | + {{ item.title }} |
| 88 | + </gl-link> |
| 89 | + </template> |
| 90 | + |
| 91 | + <template #cell(updated_at)="{ item }"> |
| 92 | + <time-ago-tooltip v-if="showUpdatedAt && item.updated_at" :time="item.updated_at" /> |
| 93 | + </template> |
| 94 | + </gl-table> |
| 95 | +</template> |
0 commit comments