2019-11-22 04:06:20 -05:00
|
|
|
<script>
|
2020-03-24 08:09:42 -04:00
|
|
|
import { GlLink, GlTooltipDirective, GlIcon } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import dateFormat from 'dateformat';
|
2020-03-24 08:09:42 -04:00
|
|
|
import { getTimeago } from '~/lib/utils/datetime_utility';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { truncateSha } from '~/lib/utils/text_utility';
|
|
|
|
import { __, sprintf } from '~/locale';
|
2019-11-22 04:06:20 -05:00
|
|
|
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-03-24 08:09:42 -04:00
|
|
|
GlIcon,
|
2019-11-22 04:06:20 -05:00
|
|
|
},
|
|
|
|
directives: {
|
|
|
|
GlTooltip: GlTooltipDirective,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
release: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2020-03-24 08:09:42 -04:00
|
|
|
evidences() {
|
|
|
|
return this.release.evidences;
|
2019-11-22 04:06:20 -05:00
|
|
|
},
|
2020-03-24 08:09:42 -04:00
|
|
|
},
|
|
|
|
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;
|
2019-11-22 04:06:20 -05:00
|
|
|
},
|
2020-03-24 08:09:42 -04:00
|
|
|
shortSha(index) {
|
|
|
|
return truncateSha(this.release.evidences[index].sha);
|
2019-11-22 04:06:20 -05:00
|
|
|
},
|
2020-03-24 08:09:42 -04:00
|
|
|
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;
|
2019-11-22 04:06:20 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2020-06-26 02:09:03 -04:00
|
|
|
<div class="card-text gl-mt-3">
|
2020-03-24 08:09:42 -04:00
|
|
|
<b>{{ __('Evidence collection') }}</b>
|
2019-11-22 04:06:20 -05:00
|
|
|
</div>
|
2020-03-24 08:09:42 -04:00
|
|
|
<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-01 11:08:16 -04:00
|
|
|
<gl-icon name="review-list" class="align-middle gl-mr-3" />
|
2020-03-24 08:09:42 -04:00
|
|
|
<span>{{ evidenceTitle(index) }}</span>
|
|
|
|
</gl-link>
|
|
|
|
|
|
|
|
<expand-button>
|
2020-05-19 02:08:03 -04:00
|
|
|
<template #short>
|
2020-03-24 08:09:42 -04:00
|
|
|
<span class="js-short monospace">{{ shortSha(index) }}</span>
|
|
|
|
</template>
|
2020-05-19 02:08:03 -04:00
|
|
|
<template #expanded>
|
2020-08-20 14:10:16 -04:00
|
|
|
<span class="js-expanded monospace gl-pl-2">{{ sha(index) }}</span>
|
2020-03-24 08:09:42 -04:00
|
|
|
</template>
|
|
|
|
</expand-button>
|
2020-10-02 20:08:46 -04:00
|
|
|
<clipboard-button :title="__('Copy evidence SHA')" :text="sha(index)" category="tertiary" />
|
2020-03-24 08:09:42 -04:00
|
|
|
</div>
|
2019-11-22 04:06:20 -05:00
|
|
|
|
2020-03-24 08:09:42 -04:00
|
|
|
<div class="d-flex align-items-center text-muted">
|
|
|
|
<gl-icon
|
|
|
|
v-gl-tooltip
|
|
|
|
name="clock"
|
2020-06-01 11:08:16 -04:00
|
|
|
class="align-middle gl-mr-3"
|
2020-03-24 08:09:42 -04:00
|
|
|
:title="collectedAt(index)"
|
|
|
|
/>
|
|
|
|
<span>{{ timeSummary(index) }}</span>
|
|
|
|
</div>
|
2019-11-22 04:06:20 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|