Commit 1624438f authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '351028-add-confidential-comments-support-for-epics' into 'master'

Add support for confidential comments in epics

See merge request gitlab-org/gitlab!83967
parents 387ccb03 8ddf4fc1
...@@ -6,10 +6,12 @@ import { ...@@ -6,10 +6,12 @@ import {
GlSafeHtmlDirective as SafeHtml, GlSafeHtmlDirective as SafeHtml,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { __ } from '~/locale'; import { __, s__ } from '~/locale';
import timeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import timeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import UserNameWithStatus from '../../sidebar/components/assignees/user_name_with_status.vue'; import UserNameWithStatus from '../../sidebar/components/assignees/user_name_with_status.vue';
import { NOTEABLE_TYPE_MAPPING } from '../constants';
export default { export default {
safeHtmlConfig: { ADD_TAGS: ['gl-emoji'] }, safeHtmlConfig: { ADD_TAGS: ['gl-emoji'] },
components: { components: {
...@@ -45,6 +47,11 @@ export default { ...@@ -45,6 +47,11 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
noteableType: {
type: String,
required: false,
default: '',
},
includeToggle: { includeToggle: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -103,6 +110,15 @@ export default { ...@@ -103,6 +110,15 @@ export default {
authorName() { authorName() {
return this.author.name; return this.author.name;
}, },
noteConfidentialityTooltip() {
if (
this.noteableType === NOTEABLE_TYPE_MAPPING.Issue ||
this.noteableType === NOTEABLE_TYPE_MAPPING.MergeRequest
) {
return s__('Notes|This comment is confidential and only visible to project members');
}
return s__('Notes|This comment is confidential and only visible to group members');
},
}, },
mounted() { mounted() {
this.emojiTitle = this.emojiElement ? this.emojiElement.getAttribute('title') : ''; this.emojiTitle = this.emojiElement ? this.emojiElement.getAttribute('title') : '';
...@@ -226,7 +242,7 @@ export default { ...@@ -226,7 +242,7 @@ export default {
data-testid="confidentialIndicator" data-testid="confidentialIndicator"
name="eye-slash" name="eye-slash"
:size="16" :size="16"
:title="s__('Notes|This comment is confidential and only visible to project members')" :title="noteConfidentialityTooltip"
class="gl-ml-1 gl-text-orange-700 align-middle" class="gl-ml-1 gl-text-orange-700 align-middle"
/> />
<slot name="extra-controls"></slot> <slot name="extra-controls"></slot>
......
...@@ -432,6 +432,7 @@ export default { ...@@ -432,6 +432,7 @@ export default {
:created-at="note.created_at" :created-at="note.created_at"
:note-id="note.id" :note-id="note.id"
:is-confidential="note.confidential" :is-confidential="note.confidential"
:noteable-type="noteableType"
> >
<template #note-header-info> <template #note-header-info>
<slot name="note-header-info"></slot> <slot name="note-header-info"></slot>
......
...@@ -18,6 +18,7 @@ class Groups::EpicsController < Groups::ApplicationController ...@@ -18,6 +18,7 @@ class Groups::EpicsController < Groups::ApplicationController
before_action do before_action do
push_frontend_feature_flag(:related_epics_widget, @group, type: :development, default_enabled: :yaml) push_frontend_feature_flag(:related_epics_widget, @group, type: :development, default_enabled: :yaml)
push_frontend_feature_flag(:confidential_notes, @group, type: :development, default_enabled: :yaml)
end end
feature_category :portfolio_management feature_category :portfolio_management
......
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import Vuex from 'vuex'; import Vuex from 'vuex';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import GitlabTeamMemberBadge from 'ee/vue_shared/components/user_avatar/badges/gitlab_team_member_badge.vue'; import GitlabTeamMemberBadge from 'ee/vue_shared/components/user_avatar/badges/gitlab_team_member_badge.vue';
import NoteHeader from '~/notes/components/note_header.vue'; import NoteHeader from '~/notes/components/note_header.vue';
...@@ -20,7 +20,7 @@ describe('NoteHeader component', () => { ...@@ -20,7 +20,7 @@ describe('NoteHeader component', () => {
}; };
const createComponent = (props) => { const createComponent = (props) => {
wrapper = shallowMount(NoteHeader, { wrapper = shallowMountExtended(NoteHeader, {
store: new Vuex.Store(), store: new Vuex.Store(),
propsData: { ...props }, propsData: { ...props },
}); });
...@@ -47,4 +47,12 @@ describe('NoteHeader component', () => { ...@@ -47,4 +47,12 @@ describe('NoteHeader component', () => {
expect(wrapper.findComponent(GitlabTeamMemberBadge).exists()).toBe(expected); expect(wrapper.findComponent(GitlabTeamMemberBadge).exists()).toBe(expected);
}, },
); );
it('shows confidential indicator tooltip for group context when isConfidential is true for epics', () => {
createComponent({ isConfidential: true, noteableType: 'epic' });
expect(wrapper.findByTestId('confidentialIndicator').attributes('title')).toBe(
'This comment is confidential and only visible to group members',
);
});
}); });
...@@ -25661,6 +25661,9 @@ msgstr "" ...@@ -25661,6 +25661,9 @@ msgstr ""
msgid "Notes|This comment has changed since you started editing, please review the %{open_link}updated comment%{close_link} to ensure information is not lost" msgid "Notes|This comment has changed since you started editing, please review the %{open_link}updated comment%{close_link} to ensure information is not lost"
msgstr "" msgstr ""
msgid "Notes|This comment is confidential and only visible to group members"
msgstr ""
msgid "Notes|This comment is confidential and only visible to project members" msgid "Notes|This comment is confidential and only visible to project members"
msgstr "" msgstr ""
......
...@@ -296,5 +296,13 @@ describe('NoteHeader component', () => { ...@@ -296,5 +296,13 @@ describe('NoteHeader component', () => {
createComponent({ isConfidential: status }); createComponent({ isConfidential: status });
expect(findConfidentialIndicator().exists()).toBe(status); expect(findConfidentialIndicator().exists()).toBe(status);
}); });
it('shows confidential indicator tooltip for project context', () => {
createComponent({ isConfidential: true, noteableType: 'issue' });
expect(findConfidentialIndicator().attributes('title')).toBe(
'This comment is confidential and only visible to project members',
);
});
}); });
}); });
...@@ -11,6 +11,7 @@ import NoteBody from '~/notes/components/note_body.vue'; ...@@ -11,6 +11,7 @@ import NoteBody from '~/notes/components/note_body.vue';
import NoteHeader from '~/notes/components/note_header.vue'; import NoteHeader from '~/notes/components/note_header.vue';
import issueNote from '~/notes/components/noteable_note.vue'; import issueNote from '~/notes/components/noteable_note.vue';
import NotesModule from '~/notes/stores/modules'; import NotesModule from '~/notes/stores/modules';
import { NOTEABLE_TYPE_MAPPING } from '~/notes/constants';
import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue'; import UserAvatarLink from '~/vue_shared/components/user_avatar/user_avatar_link.vue';
...@@ -226,6 +227,7 @@ describe('issue_note', () => { ...@@ -226,6 +227,7 @@ describe('issue_note', () => {
expect(noteHeaderProps.author).toBe(note.author); expect(noteHeaderProps.author).toBe(note.author);
expect(noteHeaderProps.createdAt).toBe(note.created_at); expect(noteHeaderProps.createdAt).toBe(note.created_at);
expect(noteHeaderProps.noteId).toBe(note.id); expect(noteHeaderProps.noteId).toBe(note.id);
expect(noteHeaderProps.noteableType).toBe(NOTEABLE_TYPE_MAPPING[note.noteable_type]);
}); });
it('should render note actions', () => { it('should render note actions', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment