Commit 55b04976 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '224587-hide-apply-suggestion-button-for-certain-users' into 'master'

Hide Apply Suggestion Button for anonymous Users

See merge request gitlab-org/gitlab!47071
parents 0b596bf8 3881697d
......@@ -72,6 +72,9 @@ export default {
}
return __('Applying suggestions...');
},
isLoggedIn() {
return Boolean(gon.current_user_id);
},
},
methods: {
applySuggestion() {
......@@ -141,6 +144,7 @@ export default {
</gl-button>
<span v-gl-tooltip.viewport="tooltipMessage" tabindex="0">
<gl-button
v-if="isLoggedIn"
class="btn-inverted js-apply-btn btn-grouped"
:disabled="isDisableButton"
variant="success"
......
---
title: Hide apply suggestion button for anonymous users
merge_request: 47071
author:
type: changed
......@@ -29,6 +29,10 @@ describe('Suggestion Diff component', () => {
});
};
beforeEach(() => {
window.gon.current_user_id = 1;
});
afterEach(() => {
wrapper.destroy();
});
......@@ -71,6 +75,14 @@ describe('Suggestion Diff component', () => {
expect(addToBatchBtn.html().includes('Add suggestion to batch')).toBe(true);
});
it('does not render apply suggestion button with anonymous user', () => {
window.gon.current_user_id = null;
createComponent();
expect(findApplyButton().exists()).toBe(false);
});
describe('when apply suggestion is clicked', () => {
beforeEach(() => {
createComponent();
......
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