summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_related_links.vue
blob: 2cef37d5c2e94109550d794b71444adb8dc4f8ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script>
import { GlSafeHtmlDirective as SafeHtml, GlLink } from '@gitlab/ui';
import { s__, n__ } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';

export default {
  name: 'MRWidgetRelatedLinks',
  directives: {
    SafeHtml,
  },
  components: {
    GlLink,
  },
  mixins: [glFeatureFlagMixin()],
  props: {
    relatedLinks: {
      type: Object,
      required: true,
      default: () => ({}),
    },
    state: {
      type: String,
      required: false,
      default: '',
    },
    showAssignToMe: {
      type: Boolean,
      required: false,
      default: true,
    },
  },
  computed: {
    closesText() {
      if (this.state === 'merged') {
        return s__('mrWidget|Closed');
      }
      if (this.state === 'closed') {
        return s__('mrWidget|Did not close');
      }

      return n__('mrWidget|Closes issue', 'mrWidget|Closes issues', this.relatedLinks.closingCount);
    },
    assignIssueText() {
      if (this.relatedLinks.unassignedCount > 1) {
        return s__('mrWidget|Assign yourself to these issues');
      }
      return s__('mrWidget|Assign yourself to this issue');
    },
    shouldShowAssignToMeLink() {
      return (
        this.relatedLinks.unassignedCount && this.relatedLinks.assignToMe && this.showAssignToMe
      );
    },
  },
};
</script>
<template>
  <section>
    <p
      v-if="relatedLinks.closing"
      :class="{ 'gl-display-inline gl-m-0': glFeatures.restructuredMrWidget }"
    >
      {{ closesText }}
      <span v-safe-html="relatedLinks.closing"></span>
    </p>
    <p
      v-if="relatedLinks.mentioned"
      :class="{ 'gl-display-inline gl-m-0': glFeatures.restructuredMrWidget }"
    >
      <span v-if="relatedLinks.closing && glFeatures.restructuredMrWidget">&middot;</span>
      {{ n__('mrWidget|Mentions issue', 'mrWidget|Mentions issues', relatedLinks.mentionedCount) }}
      <span v-safe-html="relatedLinks.mentioned"></span>
    </p>
    <p
      v-if="shouldShowAssignToMeLink"
      :class="{ 'gl-display-inline gl-m-0': glFeatures.restructuredMrWidget }"
    >
      <span>
        <gl-link rel="nofollow" data-method="post" :href="relatedLinks.assignToMe">{{
          assignIssueText
        }}</gl-link>
      </span>
    </p>
  </section>
</template>