evidence_block.vue 1.9 KB
Newer Older
1
2
<script>
import { GlLink, GlTooltipDirective } from '@gitlab/ui';
3
import { __, sprintf } from '~/locale';
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
import { truncateSha } from '~/lib/utils/text_utility';
import Icon from '~/vue_shared/components/icon.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import ExpandButton from '~/vue_shared/components/expand_button.vue';

export default {
  name: 'EvidenceBlock',
  components: {
    ClipboardButton,
    ExpandButton,
    GlLink,
    Icon,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    release: {
      type: Object,
      required: true,
    },
  },
  computed: {
    evidenceTitle() {
      return sprintf(__('%{tag}-evidence.json'), { tag: this.release.tag_name });
    },
    evidenceUrl() {
      return this.release.assets && this.release.assets.evidence_file_path;
    },
    shortSha() {
      return truncateSha(this.sha);
    },
    sha() {
      return this.release.evidence_sha;
    },
  },
};
</script>

<template>
  <div>
    <div class="card-text prepend-top-default">
      <b>
        {{ __('Evidence collection') }}
      </b>
    </div>
    <div class="d-flex align-items-baseline">
      <gl-link
        v-gl-tooltip
        class="monospace"
        :title="__('Download evidence JSON')"
        :download="evidenceTitle"
        :href="evidenceUrl"
      >
        <icon name="review-list" class="align-top append-right-4" /><span>{{ evidenceTitle }}</span>
      </gl-link>

      <expand-button>
        <template slot="short">
          <span class="js-short monospace">{{ shortSha }}</span>
        </template>
        <template slot="expanded">
          <span class="js-expanded monospace gl-pl-1">{{ sha }}</span>
        </template>
      </expand-button>
      <clipboard-button
        :title="__('Copy commit SHA')"
        :text="sha"
        css-class="btn-default btn-transparent btn-clipboard"
      />
    </div>
  </div>
</template>