Skip to content
代码片段 群组 项目
未验证 提交 0f41069b 编辑于 作者: Kushal Pandya's avatar Kushal Pandya 提交者: GitLab
浏览文件

Merge branch 'ph/individualBotCommentsNotWorking' into 'master'

Fixes a bug with bot comment filtering

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/143552



Merged-by: default avatarKushal Pandya <kushal@gitlab.com>
Approved-by: default avatarKushal Pandya <kushal@gitlab.com>
Co-authored-by: default avatarPhil Hughes <me@iamphill.com>
No related branches found
No related tags found
无相关合并请求
...@@ -23,31 +23,37 @@ const getDraftComments = (state) => { ...@@ -23,31 +23,37 @@ const getDraftComments = (state) => {
}; };
const hideActivity = (filters, discussion) => { const hideActivity = (filters, discussion) => {
if (filters.length === constants.MR_FILTER_OPTIONS) return false;
if (filters.length === 0) return true;
const firstNote = discussion.notes[0]; const firstNote = discussion.notes[0];
const hidingFilters = constants.MR_FILTER_OPTIONS.filter(({ value }) => !filters.includes(value));
return constants.MR_FILTER_OPTIONS.some((f) => { for (let i = 0, len = hidingFilters.length; i < len; i += 1) {
if (filters.includes(f.value) || f.value === '*') return false; const filter = hidingFilters[i];
if ( if (
// For all of the below firstNote is the first note of a discussion, whether that be // For all of the below firstNote is the first note of a discussion, whether that be
// the first in a discussion or a single note // the first in a discussion or a single note
// If the filter option filters based on icon check against the first notes system note icon // If the filter option filters based on icon check against the first notes system note icon
f.systemNoteIcons?.includes(firstNote.system_note_icon_name) || filter.systemNoteIcons?.includes(firstNote.system_note_icon_name) ||
// If the filter option filters based on note type use the first notes type // If the filter option filters based on note type use the first notes type
(f.noteType?.includes(firstNote.type) && !firstNote.author.bot) || (filter.noteType?.includes(firstNote.type) && !firstNote.author?.bot) ||
// If the filter option filters based on the note text then check if it is sytem // If the filter option filters based on the note text then check if it is sytem
// and filter based on the text of the system note // and filter based on the text of the system note
(firstNote.system && f.noteText?.some((t) => firstNote.note.includes(t))) || (firstNote.system && filter.noteText?.some((t) => firstNote.note.includes(t))) ||
// For individual notes we filter if the discussion is a single note and is not a sytem // For individual notes we filter if the discussion is a single note and is not a sytem
(f.individualNote === discussion.individual_note && !firstNote.system) || (filter.individualNote === discussion.individual_note &&
!firstNote.system &&
!firstNote.author?.bot) ||
// For bot comments we filter on the authors `bot` boolean attribute // For bot comments we filter on the authors `bot` boolean attribute
(f.bot && firstNote.author.bot) (filter.bot && firstNote.author?.bot)
) { ) {
return true; return true;
} }
}
return false; return false;
});
}; };
export const discussions = (state, getters, rootState) => { export const discussions = (state, getters, rootState) => {
......
...@@ -89,14 +89,23 @@ describe('Getters Notes Store', () => { ...@@ -89,14 +89,23 @@ describe('Getters Notes Store', () => {
describe('merge request filters', () => { describe('merge request filters', () => {
it('returns only bot comments', () => { it('returns only bot comments', () => {
const normalDiscussion = JSON.parse(JSON.stringify(discussionMock));
const discussion = JSON.parse(JSON.stringify(discussionMock)); const discussion = JSON.parse(JSON.stringify(discussionMock));
discussion.notes[0].author.bot = true; discussion.notes[0].author.bot = true;
const individualBotNote = JSON.parse(JSON.stringify(discussionMock));
individualBotNote.notes[0].author.bot = true;
individualBotNote.individual_note = true;
state.noteableData = { targetType: 'merge_request' }; state.noteableData = { targetType: 'merge_request' };
state.discussions = [discussion]; state.discussions = [discussion, normalDiscussion, individualBotNote];
state.mergeRequestFilters = ['bot_comments']; state.mergeRequestFilters = ['bot_comments'];
expect(getDiscussions()).toContain(discussion); const discussions = getDiscussions();
expect(discussions).toContain(discussion);
expect(discussions).not.toContain(normalDiscussion);
expect(discussions).toContain(individualBotNote);
}); });
}); });
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册