diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-22 15:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-22 15:09:21 +0300 |
commit | 4fc46d75644b28789e83c95ec4d1309498bb4ba3 (patch) | |
tree | c9609e71d701f19835ccad3f5f1c4b24490d4049 /app/assets/javascripts/merge_requests | |
parent | 48641ca0e8b4517fbc73704b132c0157943deec6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/merge_requests')
-rw-r--r-- | app/assets/javascripts/merge_requests/components/header_metadata.vue | 69 | ||||
-rw-r--r-- | app/assets/javascripts/merge_requests/index.js | 19 |
2 files changed, 88 insertions, 0 deletions
diff --git a/app/assets/javascripts/merge_requests/components/header_metadata.vue b/app/assets/javascripts/merge_requests/components/header_metadata.vue new file mode 100644 index 00000000000..fce7ba385b4 --- /dev/null +++ b/app/assets/javascripts/merge_requests/components/header_metadata.vue @@ -0,0 +1,69 @@ +<script> +import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; +// eslint-disable-next-line no-restricted-imports +import { mapGetters } from 'vuex'; +import { __ } from '~/locale'; +import { TYPE_ISSUE, WORKSPACE_PROJECT } from '~/issues/constants'; +import ConfidentialityBadge from '~/vue_shared/components/confidentiality_badge.vue'; + +export default { + TYPE_ISSUE, + WORKSPACE_PROJECT, + components: { + GlIcon, + ConfidentialityBadge, + }, + 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', + tooltip: __('This merge request is locked. Only project members can comment.'), + }, + { + iconName: 'spam', + visible: this.hidden, + dataTestId: 'hidden', + tooltip: __('This merge request is hidden because its author has been banned'), + }, + ]; + }, + }, +}; +</script> + +<template> + <div class="gl-display-inline-block"> + <confidentiality-badge + v-if="isConfidential" + class="gl-mr-3" + :issuable-type="$options.TYPE_ISSUE" + :workspace-type="$options.WORKSPACE_PROJECT" + /> + <template v-for="meta in warningIconsMeta"> + <div + v-if="meta.visible" + :key="meta.iconName" + v-gl-tooltip.bottom + :data-testid="meta.dataTestId" + :title="meta.tooltip || null" + class="issuable-warning-icon gl-mr-3 gl-mt-2 gl-display-flex gl-justify-content-center gl-align-items-center" + > + <gl-icon :name="meta.iconName" class="icon" /> + </div> + </template> + </div> +</template> diff --git a/app/assets/javascripts/merge_requests/index.js b/app/assets/javascripts/merge_requests/index.js new file mode 100644 index 00000000000..29218eb53e0 --- /dev/null +++ b/app/assets/javascripts/merge_requests/index.js @@ -0,0 +1,19 @@ +import Vue from 'vue'; +import { parseBoolean } from '~/lib/utils/common_utils'; +import HeaderMetadata from './components/header_metadata.vue'; + +export function mountHeaderMetadata(store) { + const el = document.querySelector('.js-header-metadata-root'); + + if (!el) { + return null; + } + + return new Vue({ + el, + name: 'HeaderMetadataRoot', + store, + provide: { hidden: parseBoolean(el.dataset.hidden) }, + render: (createElement) => createElement(HeaderMetadata), + }); +} |