debian-mirror-gitlab/app/assets/javascripts/issuable/components/issuable_header_warnings.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

84 lines
2.2 KiB
Vue
Raw Normal View History

2020-10-24 23:57:45 +05:30
<script>
2021-11-11 11:23:49 +05:30
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapGetters } from 'vuex';
2023-03-17 16:20:25 +05:30
import { sprintf, __ } from '~/locale';
2023-04-23 21:23:45 +05:30
import { TYPE_ISSUE, WorkspaceType } from '~/issues/constants';
2022-07-16 23:28:13 +05:30
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue';
2020-10-24 23:57:45 +05:30
2023-03-17 16:20:25 +05:30
const NoteableTypeText = {
issue: __('issue'),
merge_request: __('merge request'),
};
2020-10-24 23:57:45 +05:30
export default {
2023-04-23 21:23:45 +05:30
TYPE_ISSUE,
2022-07-16 23:28:13 +05:30
WorkspaceType,
2020-10-24 23:57:45 +05:30
components: {
GlIcon,
2022-07-16 23:28:13 +05:30
ConfidentialityBadge,
2020-10-24 23:57:45 +05:30
},
2021-11-11 11:23:49 +05:30
directives: {
GlTooltip: GlTooltipDirective,
},
2022-07-16 23:28:13 +05:30
mixins: [glFeatureFlagMixin()],
2021-11-11 11:23:49 +05:30
inject: ['hidden'],
2020-10-24 23:57:45 +05:30
computed: {
...mapGetters(['getNoteableData']),
isLocked() {
return this.getNoteableData.discussion_locked;
},
isConfidential() {
return this.getNoteableData.confidential;
},
2022-07-16 23:28:13 +05:30
isMergeRequest() {
2022-07-23 23:45:48 +05:30
return this.getNoteableData.targetType === 'merge_request';
2022-07-16 23:28:13 +05:30
},
2020-10-24 23:57:45 +05:30
warningIconsMeta() {
return [
{
iconName: 'lock',
visible: this.isLocked,
dataTestId: 'locked',
},
2021-11-11 11:23:49 +05:30
{
iconName: 'spam',
visible: this.hidden,
dataTestId: 'hidden',
2023-03-17 16:20:25 +05:30
tooltip: sprintf(__('This %{issuable} is hidden because its author has been banned'), {
issuable: NoteableTypeText[this.getNoteableData.targetType],
}),
2021-11-11 11:23:49 +05:30
},
2020-10-24 23:57:45 +05:30
];
},
},
};
</script>
<template>
<div class="gl-display-inline-block">
2022-07-16 23:28:13 +05:30
<confidentiality-badge
v-if="isConfidential"
data-testid="confidential"
:workspace-type="$options.WorkspaceType.project"
2023-04-23 21:23:45 +05:30
:issuable-type="$options.TYPE_ISSUE"
2022-07-16 23:28:13 +05:30
/>
2020-10-24 23:57:45 +05:30
<template v-for="meta in warningIconsMeta">
2021-11-11 11:23:49 +05:30
<div
v-if="meta.visible"
:key="meta.iconName"
v-gl-tooltip
:data-testid="meta.dataTestId"
:title="meta.tooltip || null"
2022-07-16 23:28:13 +05:30
: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"
2021-11-11 11:23:49 +05:30
>
<gl-icon :name="meta.iconName" class="icon" />
2020-10-24 23:57:45 +05:30
</div>
</template>
</div>
</template>