Commit ca45e81e authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Nicolò Maria Mezzopera

Disable board configuration options for users without edit permission

parent 83c7e006
...@@ -14,6 +14,10 @@ export default { ...@@ -14,6 +14,10 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
readonly: {
type: Boolean,
required: true,
},
}, },
}; };
</script> </script>
...@@ -28,12 +32,14 @@ export default { ...@@ -28,12 +32,14 @@ export default {
</p> </p>
<gl-form-checkbox <gl-form-checkbox
:checked="!hideBacklogList" :checked="!hideBacklogList"
:disabled="readonly"
data-testid="backlog-list-checkbox" data-testid="backlog-list-checkbox"
@change="$emit('update:hideBacklogList', !hideBacklogList)" @change="$emit('update:hideBacklogList', !hideBacklogList)"
>{{ __('Show the Open list') }} >{{ __('Show the Open list') }}
</gl-form-checkbox> </gl-form-checkbox>
<gl-form-checkbox <gl-form-checkbox
:checked="!hideClosedList" :checked="!hideClosedList"
:disabled="readonly"
data-testid="closed-list-checkbox" data-testid="closed-list-checkbox"
@change="$emit('update:hideClosedList', !hideClosedList)" @change="$emit('update:hideClosedList', !hideClosedList)"
>{{ __('Show the Closed list') }} >{{ __('Show the Closed list') }}
......
...@@ -308,6 +308,7 @@ export default { ...@@ -308,6 +308,7 @@ export default {
<board-configuration-options <board-configuration-options
:hide-backlog-list.sync="board.hide_backlog_list" :hide-backlog-list.sync="board.hide_backlog_list"
:hide-closed-list.sync="board.hide_closed_list" :hide-closed-list.sync="board.hide_closed_list"
:readonly="readonly"
/> />
<board-scope <board-scope
......
---
title: Disable board configuration options for users without edit permission
merge_request: 52077
author:
type: fixed
...@@ -7,6 +7,7 @@ describe('BoardConfigurationOptions', () => { ...@@ -7,6 +7,7 @@ describe('BoardConfigurationOptions', () => {
const defaultProps = { const defaultProps = {
hideBacklogList: false, hideBacklogList: false,
hideClosedList: false, hideClosedList: false,
readonly: false,
}; };
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
...@@ -61,4 +62,18 @@ describe('BoardConfigurationOptions', () => { ...@@ -61,4 +62,18 @@ describe('BoardConfigurationOptions', () => {
expect(wrapper.emitted('update:hideClosedList')).toEqual([[true]]); expect(wrapper.emitted('update:hideClosedList')).toEqual([[true]]);
}); });
it('renders checkboxes disabled when user does not have edit rights', () => {
createComponent({ readonly: true });
expect(closedListCheckbox().attributes('disabled')).toBe('true');
expect(backlogListCheckbox().attributes('disabled')).toBe('true');
});
it('renders checkboxes enabled when user has edit rights', () => {
createComponent();
expect(closedListCheckbox().attributes('disabled')).toBeUndefined();
expect(backlogListCheckbox().attributes('disabled')).toBeUndefined();
});
}); });
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