summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/registry/explorer/components/details_page/details_header.vue
blob: 3eeb7b2938673bddf0f9a94fbcd50898d0e5de6f (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
<script>
import { GlSprintf } from '@gitlab/ui';
import { sprintf } from '~/locale';
import TitleArea from '~/vue_shared/components/registry/title_area.vue';
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
import { DETAILS_PAGE_TITLE, UPDATED_AT } from '../../constants/index';

export default {
  components: { GlSprintf, TitleArea, MetadataItem },
  mixins: [timeagoMixin],
  props: {
    image: {
      type: Object,
      required: true,
    },
  },
  computed: {
    visibilityIcon() {
      return this.image?.project?.visibility === 'public' ? 'eye' : 'eye-slash';
    },
    timeAgo() {
      return this.timeFormatted(this.image.updatedAt);
    },
    updatedText() {
      return sprintf(UPDATED_AT, { time: this.timeAgo });
    },
  },
  i18n: {
    DETAILS_PAGE_TITLE,
  },
};
</script>

<template>
  <title-area>
    <template #title>
      <gl-sprintf :message="$options.i18n.DETAILS_PAGE_TITLE">
        <template #imageName>
          {{ image.name }}
        </template>
      </gl-sprintf>
    </template>
    <template #metadata-updated>
      <metadata-item
        :icon="visibilityIcon"
        :text="updatedText"
        size="xl"
        data-testid="updated-and-visibility"
      />
    </template>
  </title-area>
</template>