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

128 lines
3.5 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2020-04-08 14:13:33 +05:30
import { isEmpty } from 'lodash';
2020-03-13 15:44:24 +05:30
import $ from 'jquery';
import { slugify } from '~/lib/utils/text_utility';
import { getLocationHash } from '~/lib/utils/url_utility';
import { scrollToElement } from '~/lib/utils/common_utils';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import '~/behaviors/markdown/render_gfm';
import EvidenceBlock from './evidence_block.vue';
import ReleaseBlockAssets from './release_block_assets.vue';
import ReleaseBlockFooter from './release_block_footer.vue';
import ReleaseBlockHeader from './release_block_header.vue';
import ReleaseBlockMetadata from './release_block_metadata.vue';
import ReleaseBlockMilestoneInfo from './release_block_milestone_info.vue';
export default {
name: 'ReleaseBlock',
components: {
EvidenceBlock,
ReleaseBlockAssets,
ReleaseBlockFooter,
ReleaseBlockHeader,
ReleaseBlockMetadata,
ReleaseBlockMilestoneInfo,
},
mixins: [glFeatureFlagsMixin()],
props: {
release: {
type: Object,
required: true,
default: () => ({}),
},
},
data() {
return {
isHighlighted: false,
};
},
computed: {
2020-04-22 19:07:51 +05:30
htmlId() {
if (!this.release.tagName) {
return null;
}
2020-04-08 14:13:33 +05:30
return slugify(this.release.tagName);
2020-03-13 15:44:24 +05:30
},
assets() {
return this.release.assets || {};
},
hasEvidence() {
2020-04-22 19:07:51 +05:30
return Boolean(this.release.evidences && this.release.evidences.length);
2020-03-13 15:44:24 +05:30
},
milestones() {
return this.release.milestones || [];
},
shouldShowEvidence() {
return this.glFeatures.releaseEvidenceCollection;
},
shouldShowFooter() {
return this.glFeatures.releaseIssueSummary;
},
shouldRenderAssets() {
return Boolean(
this.assets.links.length || (this.assets.sources && this.assets.sources.length),
);
},
shouldRenderReleaseMetaData() {
return !this.glFeatures.releaseIssueSummary;
},
shouldRenderMilestoneInfo() {
2020-04-08 14:13:33 +05:30
return Boolean(this.glFeatures.releaseIssueSummary && !isEmpty(this.release.milestones));
2020-03-13 15:44:24 +05:30
},
},
mounted() {
this.renderGFM();
const hash = getLocationHash();
2020-04-22 19:07:51 +05:30
if (hash && slugify(hash) === this.htmlId) {
2020-03-13 15:44:24 +05:30
this.isHighlighted = true;
setTimeout(() => {
this.isHighlighted = false;
}, 2000);
scrollToElement(this.$el);
}
},
methods: {
renderGFM() {
$(this.$refs['gfm-content']).renderGFM();
},
},
};
</script>
<template>
2020-04-22 19:07:51 +05:30
<div :id="htmlId" :class="{ 'bg-line-target-blue': isHighlighted }" class="card release-block">
2020-03-13 15:44:24 +05:30
<release-block-header :release="release" />
<div class="card-body">
<div v-if="shouldRenderMilestoneInfo">
2020-04-08 14:13:33 +05:30
<release-block-milestone-info
:milestones="milestones"
:open-issues-path="release._links.issuesUrl"
/>
2020-03-13 15:44:24 +05:30
<hr class="mb-3 mt-0" />
</div>
<release-block-metadata v-if="shouldRenderReleaseMetaData" :release="release" />
<release-block-assets v-if="shouldRenderAssets" :assets="assets" />
<evidence-block v-if="hasEvidence && shouldShowEvidence" :release="release" />
<div ref="gfm-content" class="card-text prepend-top-default">
2020-04-08 14:13:33 +05:30
<div v-html="release.descriptionHtml"></div>
2020-03-13 15:44:24 +05:30
</div>
</div>
<release-block-footer
v-if="shouldShowFooter"
class="card-footer"
:commit="release.commit"
2020-04-08 14:13:33 +05:30
:commit-path="release.commitPath"
:tag-name="release.tagName"
:tag-path="release.tagPath"
2020-03-13 15:44:24 +05:30
:author="release.author"
2020-04-08 14:13:33 +05:30
:released-at="release.releasedAt"
2020-03-13 15:44:24 +05:30
/>
</div>
</template>