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