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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
3.6 KiB
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
2021-11-18 22:05:49 +05:30
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import $ from 'jquery';
2021-03-11 19:13:27 +05:30
import { isEmpty } from 'lodash';
import { scrollToElement } from '~/lib/utils/common_utils';
2020-03-13 15:44:24 +05:30
import { slugify } from '~/lib/utils/text_utility';
import { getLocationHash } from '~/lib/utils/url_utility';
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 ReleaseBlockMilestoneInfo from './release_block_milestone_info.vue';
export default {
name: 'ReleaseBlock',
components: {
EvidenceBlock,
ReleaseBlockAssets,
ReleaseBlockFooter,
ReleaseBlockHeader,
ReleaseBlockMilestoneInfo,
},
2021-11-18 22:05:49 +05:30
directives: {
SafeHtml,
},
2020-03-13 15:44:24 +05:30
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 || [];
},
shouldRenderAssets() {
return Boolean(
this.assets.links.length || (this.assets.sources && this.assets.sources.length),
);
},
shouldRenderMilestoneInfo() {
2021-01-03 14:25:43 +05:30
return Boolean(!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();
},
},
2021-11-18 22:05:49 +05:30
safeHtmlConfig: { ADD_TAGS: ['gl-emoji'] },
2020-03-13 15:44:24 +05:30
};
</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">
2021-01-29 00:20:46 +05:30
<!-- TODO: Switch open* links to opened* once fields have been updated in GraphQL -->
2020-04-08 14:13:33 +05:30
<release-block-milestone-info
:milestones="milestones"
2021-01-29 00:20:46 +05:30
:opened-issues-path="release._links.openedIssuesUrl"
:closed-issues-path="release._links.closedIssuesUrl"
:opened-merge-requests-path="release._links.openedMergeRequestsUrl"
:merged-merge-requests-path="release._links.mergedMergeRequestsUrl"
:closed-merge-requests-path="release._links.closedMergeRequestsUrl"
2020-04-08 14:13:33 +05:30
/>
2020-03-13 15:44:24 +05:30
<hr class="mb-3 mt-0" />
</div>
<release-block-assets v-if="shouldRenderAssets" :assets="assets" />
2021-01-03 14:25:43 +05:30
<evidence-block v-if="hasEvidence" :release="release" />
2020-03-13 15:44:24 +05:30
2020-07-28 23:09:34 +05:30
<div ref="gfm-content" class="card-text gl-mt-3">
2021-11-18 22:05:49 +05:30
<div v-safe-html:[$options.safeHtmlConfig]="release.descriptionHtml" class="md"></div>
2020-03-13 15:44:24 +05:30
</div>
</div>
<release-block-footer
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>