Commit 95ce5e8a authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '62122-hide-resolve-thread-button-from-guest' into 'master'

Hide resolve thread button from guest

Closes #62122

See merge request gitlab-org/gitlab-ce!32859
parents 42b8e683 589c8d56
...@@ -35,6 +35,13 @@ export default { ...@@ -35,6 +35,13 @@ export default {
required: true, required: true,
}, },
}, },
computed: {
userCanResolveDiscussion() {
return this.discussion.notes.every(
note => note.current_user && note.current_user.can_resolve,
);
},
},
}; };
</script> </script>
...@@ -46,7 +53,7 @@ export default { ...@@ -46,7 +53,7 @@ export default {
@onClick="$emit('showReplyForm')" @onClick="$emit('showReplyForm')"
/> />
<div class="btn-group discussion-actions" role="group"> <div v-if="userCanResolveDiscussion" class="btn-group discussion-actions" role="group">
<div class="btn-group"> <div class="btn-group">
<resolve-discussion-button <resolve-discussion-button
v-if="discussion.resolvable" v-if="discussion.resolvable"
......
---
title: Hide resolve thread button from guest
merge_request: 32859
author:
type: changed
...@@ -65,6 +65,15 @@ describe('DiscussionActions', () => { ...@@ -65,6 +65,15 @@ describe('DiscussionActions', () => {
expect(wrapper.find(JumpToNextDiscussionButton).exists()).toBe(false); expect(wrapper.find(JumpToNextDiscussionButton).exists()).toBe(false);
}); });
it('does not renders discussion button for non-member', () => {
const discussion = JSON.parse(JSON.stringify(discussionMock));
discussion.notes[1].current_user.can_resolve = false;
createComponent({ discussion });
expect(wrapper.find(ResolveDiscussionButton).exists()).toBe(false);
expect(wrapper.find(ResolveWithIssueButton).exists()).toBe(false);
});
}); });
describe('events handling', () => { describe('events handling', () => {
......
...@@ -255,6 +255,10 @@ describe('noteable_discussion component', () => { ...@@ -255,6 +255,10 @@ describe('noteable_discussion component', () => {
discussion.notes = discussion.notes.map(note => ({ discussion.notes = discussion.notes.map(note => ({
...note, ...note,
resolved: false, resolved: false,
current_user: {
...note.current_user,
can_resolve: true,
},
})); }));
wrapper.setProps({ discussion }); wrapper.setProps({ discussion });
......
...@@ -200,6 +200,7 @@ export const discussionMock = { ...@@ -200,6 +200,7 @@ export const discussionMock = {
current_user: { current_user: {
can_edit: true, can_edit: true,
can_award_emoji: true, can_award_emoji: true,
can_resolve: true,
}, },
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true, emoji_awardable: true,
...@@ -246,6 +247,7 @@ export const discussionMock = { ...@@ -246,6 +247,7 @@ export const discussionMock = {
current_user: { current_user: {
can_edit: true, can_edit: true,
can_award_emoji: true, can_award_emoji: true,
can_resolve: true,
}, },
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true, emoji_awardable: true,
...@@ -292,6 +294,7 @@ export const discussionMock = { ...@@ -292,6 +294,7 @@ export const discussionMock = {
current_user: { current_user: {
can_edit: true, can_edit: true,
can_award_emoji: true, can_award_emoji: true,
can_resolve: true,
}, },
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true, emoji_awardable: true,
......
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