summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages_and_registries/harbor_registry/components/list/harbor_list_row.vue
blob: 258472fe16e80da7abf416ba609d08e0b262000c (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
<script>
import { GlIcon, GlSprintf, GlSkeletonLoader } from '@gitlab/ui';
import { n__ } from '~/locale';

import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import ListItem from '~/vue_shared/components/registry/list_item.vue';

export default {
  name: 'HarborListRow',
  components: {
    ClipboardButton,
    GlSprintf,
    GlIcon,
    ListItem,
    GlSkeletonLoader,
  },
  props: {
    item: {
      type: Object,
      required: true,
    },
    metadataLoading: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  computed: {
    id() {
      return this.item.id;
    },
    artifactCountText() {
      return n__(
        'HarborRegistry|%{count} Tag',
        'HarborRegistry|%{count} Tags',
        this.item.artifactCount,
      );
    },
    imageName() {
      return this.item.name;
    },
  },
};
</script>

<template>
  <list-item v-bind="$attrs">
    <template #left-primary>
      <router-link
        class="gl-text-body gl-font-weight-bold"
        data-testid="details-link"
        data-qa-selector="registry_image_content"
        :to="{ name: 'details', params: { id } }"
      >
        {{ imageName }}
      </router-link>
      <clipboard-button
        v-if="item.location"
        :text="item.location"
        :title="item.location"
        category="tertiary"
      />
    </template>
    <template #left-secondary>
      <template v-if="!metadataLoading">
        <span class="gl-display-flex gl-align-items-center" data-testid="tags-count">
          <gl-icon name="tag" class="gl-mr-2" />
          <gl-sprintf :message="artifactCountText">
            <template #count>
              {{ item.artifactCount }}
            </template>
          </gl-sprintf>
        </span>
      </template>

      <div v-else class="gl-w-full">
        <gl-skeleton-loader :width="900" :height="16" preserve-aspect-ratio="xMinYMax meet">
          <circle cx="6" cy="8" r="6" />
          <rect x="16" y="4" width="100" height="8" rx="4" />
        </gl-skeleton-loader>
      </div>
    </template>
  </list-item>
</template>