summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Ming <sming@gitlab.com>2019-09-12 07:41:19 +0000
committerKushal Pandya <kushalspandya@gmail.com>2019-09-12 07:41:19 +0000
commit589c8d5625f64edf4dfaf9ddf1f9f4b2fe7efb32 (patch)
tree45bf0e41e0b754f378b654b59820f23702e8df56
parent42b8e6838e8d63dcad7641a6164d178e9e09262a (diff)
downloadgitlab-ce-589c8d5625f64edf4dfaf9ddf1f9f4b2fe7efb32.tar.gz
Hide resolve thread button from guest
- Show if user can_resolve all of the notes
-rw-r--r--app/assets/javascripts/notes/components/discussion_actions.vue9
-rw-r--r--changelogs/unreleased/62122-hide-resolve-thread-button-from-guest.yml5
-rw-r--r--spec/frontend/notes/components/discussion_actions_spec.js9
-rw-r--r--spec/javascripts/notes/components/noteable_discussion_spec.js4
-rw-r--r--spec/javascripts/notes/mock_data.js3
5 files changed, 29 insertions, 1 deletions
diff --git a/app/assets/javascripts/notes/components/discussion_actions.vue b/app/assets/javascripts/notes/components/discussion_actions.vue
index edab750b572..e3be91a4966 100644
--- a/app/assets/javascripts/notes/components/discussion_actions.vue
+++ b/app/assets/javascripts/notes/components/discussion_actions.vue
@@ -35,6 +35,13 @@ export default {
required: true,
},
},
+ computed: {
+ userCanResolveDiscussion() {
+ return this.discussion.notes.every(
+ note => note.current_user && note.current_user.can_resolve,
+ );
+ },
+ },
};
</script>
@@ -46,7 +53,7 @@ export default {
@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">
<resolve-discussion-button
v-if="discussion.resolvable"
diff --git a/changelogs/unreleased/62122-hide-resolve-thread-button-from-guest.yml b/changelogs/unreleased/62122-hide-resolve-thread-button-from-guest.yml
new file mode 100644
index 00000000000..0576b15b3aa
--- /dev/null
+++ b/changelogs/unreleased/62122-hide-resolve-thread-button-from-guest.yml
@@ -0,0 +1,5 @@
+---
+title: Hide resolve thread button from guest
+merge_request: 32859
+author:
+type: changed
diff --git a/spec/frontend/notes/components/discussion_actions_spec.js b/spec/frontend/notes/components/discussion_actions_spec.js
index 0a52c81571e..f582729d773 100644
--- a/spec/frontend/notes/components/discussion_actions_spec.js
+++ b/spec/frontend/notes/components/discussion_actions_spec.js
@@ -65,6 +65,15 @@ describe('DiscussionActions', () => {
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', () => {
diff --git a/spec/javascripts/notes/components/noteable_discussion_spec.js b/spec/javascripts/notes/components/noteable_discussion_spec.js
index 74805ca8c00..ea5c57b8a7c 100644
--- a/spec/javascripts/notes/components/noteable_discussion_spec.js
+++ b/spec/javascripts/notes/components/noteable_discussion_spec.js
@@ -255,6 +255,10 @@ describe('noteable_discussion component', () => {
discussion.notes = discussion.notes.map(note => ({
...note,
resolved: false,
+ current_user: {
+ ...note.current_user,
+ can_resolve: true,
+ },
}));
wrapper.setProps({ discussion });
diff --git a/spec/javascripts/notes/mock_data.js b/spec/javascripts/notes/mock_data.js
index 3812d46f838..f0e58cbda4d 100644
--- a/spec/javascripts/notes/mock_data.js
+++ b/spec/javascripts/notes/mock_data.js
@@ -200,6 +200,7 @@ export const discussionMock = {
current_user: {
can_edit: true,
can_award_emoji: true,
+ can_resolve: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,
@@ -246,6 +247,7 @@ export const discussionMock = {
current_user: {
can_edit: true,
can_award_emoji: true,
+ can_resolve: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,
@@ -292,6 +294,7 @@ export const discussionMock = {
current_user: {
can_edit: true,
can_award_emoji: true,
+ can_resolve: true,
},
discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1',
emoji_awardable: true,