debian-mirror-gitlab/app/assets/javascripts/issuable/components/issuable_header_warnings.vue
2023-05-27 22:25:52 +05:30

83 lines
2.2 KiB
Vue

<script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { mapGetters } from 'vuex';
import { sprintf, __ } from '~/locale';
import { TYPE_ISSUE, TYPE_MERGE_REQUEST, WORKSPACE_PROJECT } from '~/issues/constants';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue';
const NoteableTypeText = {
issue: __('issue'),
merge_request: __('merge request'),
};
export default {
TYPE_ISSUE,
WORKSPACE_PROJECT,
components: {
GlIcon,
ConfidentialityBadge,
},
directives: {
GlTooltip: GlTooltipDirective,
},
mixins: [glFeatureFlagMixin()],
inject: ['hidden'],
computed: {
...mapGetters(['getNoteableData']),
isLocked() {
return this.getNoteableData.discussion_locked;
},
isConfidential() {
return this.getNoteableData.confidential;
},
isMergeRequest() {
return this.getNoteableData.targetType === TYPE_MERGE_REQUEST;
},
warningIconsMeta() {
return [
{
iconName: 'lock',
visible: this.isLocked,
dataTestId: 'locked',
},
{
iconName: 'spam',
visible: this.hidden,
dataTestId: 'hidden',
tooltip: sprintf(__('This %{issuable} is hidden because its author has been banned'), {
issuable: NoteableTypeText[this.getNoteableData.targetType],
}),
},
];
},
},
};
</script>
<template>
<div class="gl-display-inline-block">
<confidentiality-badge
v-if="isConfidential"
data-testid="confidential"
:workspace-type="$options.WORKSPACE_PROJECT"
:issuable-type="$options.TYPE_ISSUE"
/>
<template v-for="meta in warningIconsMeta">
<div
v-if="meta.visible"
:key="meta.iconName"
v-gl-tooltip
:data-testid="meta.dataTestId"
:title="meta.tooltip || null"
:class="{
'gl-mr-3 gl-mt-2 gl-display-flex gl-justify-content-center gl-align-items-center': isMergeRequest,
'gl-display-inline-block': !isMergeRequest,
}"
class="issuable-warning-icon"
>
<gl-icon :name="meta.iconName" class="icon" />
</div>
</template>
</div>
</template>