debian-mirror-gitlab/app/assets/javascripts/releases/components/evidence_block.vue

101 lines
2.9 KiB
Vue
Raw Normal View History

2020-01-01 13:55:28 +05:30
<script>
2020-04-22 19:07:51 +05:30
import { GlLink, GlTooltipDirective, GlIcon } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import dateFormat from 'dateformat';
2020-04-22 19:07:51 +05:30
import { getTimeago } from '~/lib/utils/datetime_utility';
2021-03-11 19:13:27 +05:30
import { truncateSha } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale';
2020-01-01 13:55:28 +05:30
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,
2020-04-22 19:07:51 +05:30
GlIcon,
2020-01-01 13:55:28 +05:30
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
release: {
type: Object,
required: true,
},
},
computed: {
2020-04-22 19:07:51 +05:30
evidences() {
return this.release.evidences;
2020-01-01 13:55:28 +05:30
},
2020-04-22 19:07:51 +05:30
},
methods: {
evidenceTitle(index) {
const [tag, evidence, filename] = this.release.evidences[index].filepath.split('/').slice(-3);
return sprintf(__('%{tag}-%{evidence}-%{filename}'), { tag, evidence, filename });
},
evidenceUrl(index) {
return this.release.evidences[index].filepath;
},
sha(index) {
return this.release.evidences[index].sha;
2020-01-01 13:55:28 +05:30
},
2020-04-22 19:07:51 +05:30
shortSha(index) {
return truncateSha(this.release.evidences[index].sha);
2020-01-01 13:55:28 +05:30
},
2020-04-22 19:07:51 +05:30
collectedAt(index) {
return dateFormat(this.release.evidences[index].collectedAt, 'mmmm dS, yyyy, h:MM TT');
},
timeSummary(index) {
const { format } = getTimeago();
const summary = sprintf(__(' Collected %{time}'), {
time: format(this.release.evidences[index].collectedAt),
});
return summary;
2020-01-01 13:55:28 +05:30
},
},
};
</script>
<template>
<div>
2020-07-28 23:09:34 +05:30
<div class="card-text gl-mt-3">
2020-04-22 19:07:51 +05:30
<b>{{ __('Evidence collection') }}</b>
2020-01-01 13:55:28 +05:30
</div>
2020-04-22 19:07:51 +05:30
<div v-for="(evidence, index) in evidences" :key="evidenceTitle(index)" class="mb-2">
<div class="d-flex align-items-center">
<gl-link
v-gl-tooltip
class="d-flex align-items-center monospace"
:title="__('Download evidence JSON')"
:download="evidenceTitle(index)"
:href="evidenceUrl(index)"
>
2020-06-23 00:09:42 +05:30
<gl-icon name="review-list" class="align-middle gl-mr-3" />
2020-04-22 19:07:51 +05:30
<span>{{ evidenceTitle(index) }}</span>
</gl-link>
<expand-button>
2020-05-24 23:13:21 +05:30
<template #short>
2020-04-22 19:07:51 +05:30
<span class="js-short monospace">{{ shortSha(index) }}</span>
</template>
2020-05-24 23:13:21 +05:30
<template #expanded>
2020-11-24 15:15:51 +05:30
<span class="js-expanded monospace gl-pl-2">{{ sha(index) }}</span>
2020-04-22 19:07:51 +05:30
</template>
</expand-button>
2021-01-03 14:25:43 +05:30
<clipboard-button :title="__('Copy evidence SHA')" :text="sha(index)" category="tertiary" />
2020-04-22 19:07:51 +05:30
</div>
2020-01-01 13:55:28 +05:30
2020-04-22 19:07:51 +05:30
<div class="d-flex align-items-center text-muted">
<gl-icon
v-gl-tooltip
name="clock"
2020-06-23 00:09:42 +05:30
class="align-middle gl-mr-3"
2020-04-22 19:07:51 +05:30
:title="collectedAt(index)"
/>
<span>{{ timeSummary(index) }}</span>
</div>
2020-01-01 13:55:28 +05:30
</div>
</div>
</template>