summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages_and_registries/package_registry/components/details/file_sha.vue
blob: b91af19d623bf7a8ec1c667caf6d3f3768a59ede (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
<script>
import { s__ } from '~/locale';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import DetailsRow from '~/vue_shared/components/registry/details_row.vue';
import Tracking from '~/tracking';
import { packageTypeToTrackCategory } from '~/packages_and_registries/package_registry/utils';
import {
  TRACKING_ACTION_COPY_PACKAGE_ASSET_SHA,
  TRACKING_LABEL_PACKAGE_ASSET,
} from '~/packages_and_registries/package_registry/constants';

export default {
  name: 'FileSha',
  components: {
    DetailsRow,
    ClipboardButton,
  },
  mixins: [Tracking.mixin()],
  props: {
    sha: {
      type: String,
      required: true,
    },
    title: {
      type: String,
      required: true,
    },
  },
  i18n: {
    copyButtonTitle: s__('PackageRegistry|Copy SHA'),
  },
  computed: {
    tracking() {
      return {
        category: packageTypeToTrackCategory(this.packageType),
      };
    },
  },
  methods: {
    copySha() {
      this.track(TRACKING_ACTION_COPY_PACKAGE_ASSET_SHA, { label: TRACKING_LABEL_PACKAGE_ASSET });
    },
  },
};
</script>

<template>
  <details-row dashed>
    <div class="gl-px-4">
      {{ title }}:
      {{ sha }}
      <clipboard-button
        :text="sha"
        :title="$options.i18n.copyButtonTitle"
        category="tertiary"
        size="small"
        @click="copySha"
      />
    </div>
  </details-row>
</template>