summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages_and_registries/infrastructure_registry/list/components/infrastructure_title.vue
blob: 9bab08b8548066dd2bff7391862699212cd9ea7d (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 { s__, n__ } from '~/locale';
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
import TitleArea from '~/vue_shared/components/registry/title_area.vue';

export default {
  name: 'InfrastructureTitle',
  components: {
    TitleArea,
    MetadataItem,
  },
  props: {
    count: {
      type: Number,
      required: false,
      default: null,
    },
    helpUrl: {
      type: String,
      required: true,
    },
  },
  computed: {
    hasModules() {
      return Number.isInteger(this.count) && this.count > 0;
    },
    moduleAmountText() {
      return n__(`%d Module`, `%d Modules`, this.count);
    },
    infoMessages() {
      if (!this.hasModules) {
        return [];
      }

      return [{ text: this.$options.i18n.LIST_INTRO_TEXT, link: this.helpUrl }];
    },
  },
  i18n: {
    LIST_TITLE_TEXT: s__('InfrastructureRegistry|Infrastructure Registry'),
    LIST_INTRO_TEXT: s__(
      'InfrastructureRegistry|Publish and share your modules. %{docLinkStart}More information%{docLinkEnd}',
    ),
  },
};
</script>

<template>
  <title-area :title="$options.i18n.LIST_TITLE_TEXT" :info-messages="infoMessages">
    <template #metadata-amount>
      <metadata-item v-if="hasModules" icon="infrastructure-registry" :text="moduleAmountText" />
    </template>
  </title-area>
</template>