All files / app/assets/javascripts/vue_shared/components/notes noteable_warning.vue

10% Statements 1/10
0% Branches 0/4
0% Functions 0/5
12.5% Lines 1/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116        37x                                                                                                                                                                                                                              
<script>
import { GlLink, GlIcon, GlSprintf } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
 
const noteableTypeText = {
  Issue: __('issue'),
  Epic: __('epic'),
  MergeRequest: __('merge request'),
  Task: __('task'),
  KeyResult: __('key result'),
  Objective: __('objective'),
};
 
export default {
  components: {
    GlIcon,
    GlLink,
    GlSprintf,
  },
  props: {
    isLocked: {
      type: Boolean,
      default: false,
      required: false,
    },
    isConfidential: {
      type: Boolean,
      default: false,
      required: false,
    },
    noteableType: {
      type: String,
      required: false,
      // eslint-disable-next-line @gitlab/require-i18n-strings
      default: 'Issue',
    },
    lockedNoteableDocsPath: {
      type: String,
      required: false,
      default: '',
    },
    confidentialNoteableDocsPath: {
      type: String,
      required: false,
      default: '',
    },
  },
  computed: {
    warningIcon() {
      Iif (this.isConfidential) return 'eye-slash';
      Iif (this.isLocked) return 'lock';
 
      return '';
    },
    isLockedAndConfidential() {
      return this.isConfidential && this.isLocked;
    },
    noteableTypeText() {
      return noteableTypeText[this.noteableType];
    },
    confidentialContextText() {
      return sprintf(__('This is a confidential %{noteableTypeText}.'), {
        noteableTypeText: this.noteableTypeText,
      });
    },
    lockedContextText() {
      return sprintf(__('The discussion in this %{noteableTypeText} is locked.'), {
        noteableTypeText: this.noteableTypeText,
      });
    },
  },
};
</script>
<template>
  <div class="issuable-note-warning" data-testid="issuable-note-warning">
    <gl-icon v-if="!isLockedAndConfidential" :name="warningIcon" :size="16" class="icon inline" />
 
    <span v-if="isLockedAndConfidential" ref="lockedAndConfidential">
      <span>
        <gl-sprintf
          :message="
            __(
              'This %{noteableTypeText} is %{confidentialLinkStart}confidential%{confidentialLinkEnd} and its %{lockedLinkStart}discussion is locked%{lockedLinkEnd}.',
            )
          "
        >
          <template #noteableTypeText>{{ noteableTypeText }}</template>
          <template #confidentialLink="{ content }">
            <gl-link :href="confidentialNoteableDocsPath" target="_blank">{{ content }}</gl-link>
          </template>
          <template #lockedLink="{ content }">
            <gl-link :href="lockedNoteableDocsPath" target="_blank">{{ content }}</gl-link>
          </template>
        </gl-sprintf>
      </span>
      {{
        __("People without permission will never get a notification and won't be able to comment.")
      }}
    </span>
 
    <span v-else-if="isConfidential" ref="confidential">
      {{ confidentialContextText }}
      {{ __('People without permission will never get a notification.') }}
      <gl-link :href="confidentialNoteableDocsPath" target="_blank">{{
        __('Learn more.')
      }}</gl-link>
    </span>
 
    <span v-else-if="isLocked" ref="locked">
      {{ lockedContextText }}
      {{ __('Only project members can comment.') }}
      <gl-link :href="lockedNoteableDocsPath" target="_blank">{{ __('Learn more.') }}</gl-link>
    </span>
  </div>
</template>