summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/sidebar/components/confidential/sidebar_confidentiality_content.vue
blob: 6afaee91d7a28a901ef6da5dc529c0363ac2b890 (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
<script>
import { GlIcon, GlAlert, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';
import { IssuableType, WorkspaceType } from '~/issues/constants';
import { confidentialityInfoText } from '~/vue_shared/constants';

export default {
  components: {
    GlIcon,
    GlAlert,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    confidential: {
      type: Boolean,
      required: true,
    },
    issuableType: {
      type: String,
      required: true,
    },
  },
  computed: {
    confidentialBodyText() {
      return confidentialityInfoText(
        this.issuableType === IssuableType.Epic ? WorkspaceType.group : WorkspaceType.project,
        this.issuableType,
      );
    },
    confidentialIcon() {
      return this.confidential ? 'eye-slash' : 'eye';
    },
    tooltipLabel() {
      return this.confidential ? __('Confidential') : __('Not confidential');
    },
  },
};
</script>

<template>
  <div>
    <div
      v-gl-tooltip.viewport.left
      :title="tooltipLabel"
      class="sidebar-collapsed-icon"
      data-testid="sidebar-collapsed-icon"
      @click="$emit('expandSidebar')"
    >
      <gl-icon
        :size="16"
        :name="confidentialIcon"
        class="sidebar-item-icon inline"
        :class="{ 'is-active': confidential }"
      />
    </div>
    <gl-icon
      :size="16"
      :name="confidentialIcon"
      class="sidebar-item-icon inline hide-collapsed"
      :class="{ 'is-active': confidential }"
    />
    <span class="hide-collapsed" data-testid="confidential-text">
      {{ tooltipLabel }}
      <gl-alert
        v-if="confidential"
        :show-icon="false"
        :dismissible="false"
        variant="warning"
        class="gl-mt-3"
      >
        {{ confidentialBodyText }}
      </gl-alert>
    </span>
  </div>
</template>