Read about our upcoming Code of Conduct on this issue

release_block.vue 3.15 KB
Newer Older
1
<script>
2
import _ from 'underscore';
3
4
5
import { slugify } from '~/lib/utils/text_utility';
import { getLocationHash } from '~/lib/utils/url_utility';
import { scrollToElement } from '~/lib/utils/common_utils';
6
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
7
import EvidenceBlock from './evidence_block.vue';
8
9
10
11
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';
12
import ReleaseBlockMilestoneInfo from './release_block_milestone_info.vue';
13
14
15
16

export default {
  name: 'ReleaseBlock',
  components: {
17
    EvidenceBlock,
18
    ReleaseBlockAssets,
19
    ReleaseBlockFooter,
20
21
    ReleaseBlockHeader,
    ReleaseBlockMetadata,
22
    ReleaseBlockMilestoneInfo,
23
  },
24
  mixins: [glFeatureFlagsMixin()],
25
  props: {
26
    release: {
27
28
      type: Object,
      required: true,
29
      default: () => ({}),
30
31
    },
  },
32
33
34
35
36
  data() {
    return {
      isHighlighted: false,
    };
  },
37
  computed: {
38
39
40
    id() {
      return slugify(this.release.tag_name);
    },
41
42
43
    assets() {
      return this.release.assets || {};
    },
44
45
46
    hasEvidence() {
      return Boolean(this.release.evidence_sha);
    },
47
48
    milestones() {
      return this.release.milestones || [];
49
    },
50
51
52
    shouldShowEvidence() {
      return this.glFeatures.releaseEvidenceCollection;
    },
53
54
55
    shouldShowFooter() {
      return this.glFeatures.releaseIssueSummary;
    },
56
57
58
59
60
    shouldRenderAssets() {
      return Boolean(
        this.assets.links.length || (this.assets.sources && this.assets.sources.length),
      );
    },
61
62
63
64
65
66
    shouldRenderReleaseMetaData() {
      return !this.glFeatures.releaseIssueSummary;
    },
    shouldRenderMilestoneInfo() {
      return Boolean(this.glFeatures.releaseIssueSummary && !_.isEmpty(this.release.milestones));
    },
67
  },
68
69
70
71
72
73
74
75
76
77
78
  mounted() {
    const hash = getLocationHash();
    if (hash && slugify(hash) === this.id) {
      this.isHighlighted = true;
      setTimeout(() => {
        this.isHighlighted = false;
      }, 2000);

      scrollToElement(this.$el);
    }
  },
79
80
81
};
</script>
<template>
82
  <div :id="id" :class="{ 'bg-line-target-blue': isHighlighted }" class="card release-block">
83
    <release-block-header :release="release" />
84
    <div class="card-body">
85
      <div v-if="shouldRenderMilestoneInfo">
86
        <release-block-milestone-info :milestones="milestones" />
87
        <hr class="mb-3 mt-0" />
88
      </div>
89

90
91
      <release-block-metadata v-if="shouldRenderReleaseMetaData" :release="release" />
      <release-block-assets v-if="shouldRenderAssets" :assets="assets" />
92
93
      <evidence-block v-if="hasEvidence && shouldShowEvidence" :release="release" />

94
95
96
      <div class="card-text prepend-top-default">
        <div v-html="release.description_html"></div>
      </div>
97
    </div>
98
99
100
101
102
103
104
105
106
107
108

    <release-block-footer
      v-if="shouldShowFooter"
      class="card-footer"
      :commit="release.commit"
      :commit-path="release.commit_path"
      :tag-name="release.tag_name"
      :tag-path="release.tag_path"
      :author="release.author"
      :released-at="release.released_at"
    />
109
110
  </div>
</template>