diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-07 03:14:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-07 03:14:07 +0300 |
commit | ec6dd14345a117d1ff4db3b0b19a1c0fa4c7e61b (patch) | |
tree | 17fc96a7b90cf9cd5f1ad6eeff335234ebaf8a97 /app/assets/javascripts/issuable | |
parent | 36c5bf80d4aaedba332a420e3d620b2ee9e2bb65 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/issuable')
-rw-r--r-- | app/assets/javascripts/issuable/components/issuable_header_warnings.vue | 61 | ||||
-rw-r--r-- | app/assets/javascripts/issuable/init_issuable_header_warning.js | 22 |
2 files changed, 83 insertions, 0 deletions
diff --git a/app/assets/javascripts/issuable/components/issuable_header_warnings.vue b/app/assets/javascripts/issuable/components/issuable_header_warnings.vue new file mode 100644 index 00000000000..82223ab9ef4 --- /dev/null +++ b/app/assets/javascripts/issuable/components/issuable_header_warnings.vue @@ -0,0 +1,61 @@ +<script> +import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; +import { mapGetters } from 'vuex'; +import { __ } from '~/locale'; + +export default { + components: { + GlIcon, + }, + directives: { + GlTooltip: GlTooltipDirective, + }, + inject: ['hidden'], + computed: { + ...mapGetters(['getNoteableData']), + isLocked() { + return this.getNoteableData.discussion_locked; + }, + isConfidential() { + return this.getNoteableData.confidential; + }, + warningIconsMeta() { + return [ + { + iconName: 'lock', + visible: this.isLocked, + dataTestId: 'locked', + }, + { + iconName: 'eye-slash', + visible: this.isConfidential, + dataTestId: 'confidential', + }, + { + iconName: 'spam', + visible: this.hidden, + dataTestId: 'hidden', + tooltip: __('This issue is hidden because its author has been banned'), + }, + ]; + }, + }, +}; +</script> + +<template> + <div class="gl-display-inline-block"> + <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="issuable-warning-icon inline" + > + <gl-icon :name="meta.iconName" class="icon" /> + </div> + </template> + </div> +</template> diff --git a/app/assets/javascripts/issuable/init_issuable_header_warning.js b/app/assets/javascripts/issuable/init_issuable_header_warning.js new file mode 100644 index 00000000000..bf73615a4dd --- /dev/null +++ b/app/assets/javascripts/issuable/init_issuable_header_warning.js @@ -0,0 +1,22 @@ +import Vue from 'vue'; +import { parseBoolean } from '~/lib/utils/common_utils'; +import IssuableHeaderWarnings from './components/issuable_header_warnings.vue'; + +export default function issuableHeaderWarnings(store) { + const el = document.getElementById('js-issuable-header-warnings'); + + if (!el) { + return false; + } + + const { hidden } = el.dataset; + + return new Vue({ + el, + store, + provide: { hidden: parseBoolean(hidden) }, + render(createElement) { + return createElement(IssuableHeaderWarnings); + }, + }); +} |