Commit 3881697d authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Vitaly Slobodin

Hide Apply Suggestion Button for anonymous Users

parent b40e8c75
......@@ -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