Commit 032a105a authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'maintenance/remove-unnecessary-local-state-diffs-dropdown' into 'master'

Remove unnecessary intermediate local state

See merge request gitlab-org/gitlab!49174
parents 86341c02 ed218e71
...@@ -14,26 +14,10 @@ export default { ...@@ -14,26 +14,10 @@ export default {
GlDropdown, GlDropdown,
GlFormCheckbox, GlFormCheckbox,
}, },
data() {
return {
checked: false,
};
},
computed: { computed: {
...mapGetters('diffs', ['isInlineView', 'isParallelView']), ...mapGetters('diffs', ['isInlineView', 'isParallelView']),
...mapState('diffs', ['renderTreeList', 'showWhitespace', 'viewDiffsFileByFile']), ...mapState('diffs', ['renderTreeList', 'showWhitespace', 'viewDiffsFileByFile']),
}, },
watch: {
viewDiffsFileByFile() {
this.checked = this.viewDiffsFileByFile;
},
checked() {
eventHub.$emit(EVT_VIEW_FILE_BY_FILE, { setting: this.checked });
},
},
created() {
this.checked = this.viewDiffsFileByFile;
},
methods: { methods: {
...mapActions('diffs', [ ...mapActions('diffs', [
'setInlineDiffViewType', 'setInlineDiffViewType',
...@@ -110,7 +94,12 @@ export default { ...@@ -110,7 +94,12 @@ export default {
</label> </label>
</div> </div>
<div class="gl-mt-3 gl-px-3"> <div class="gl-mt-3 gl-px-3">
<gl-form-checkbox v-model="checked" data-testid="file-by-file" class="gl-mb-0"> <gl-form-checkbox
data-testid="file-by-file"
class="gl-mb-0"
:checked="viewDiffsFileByFile"
@input="toggleFileByFile"
>
{{ $options.i18n.fileByFile }} {{ $options.i18n.fileByFile }}
</gl-form-checkbox> </gl-form-checkbox>
</div> </div>
......
...@@ -181,7 +181,7 @@ describe('Diff settings dropdown component', () => { ...@@ -181,7 +181,7 @@ describe('Diff settings dropdown component', () => {
${true} | ${true} ${true} | ${true}
${false} | ${false} ${false} | ${false}
`( `(
'sets { checked: $checked } if the fileByFile setting is $fileByFile', 'sets the checkbox to { checked: $checked } if the fileByFile setting is $fileByFile',
async ({ fileByFile, checked }) => { async ({ fileByFile, checked }) => {
createComponent(store => { createComponent(store => {
Object.assign(store.state.diffs, { Object.assign(store.state.diffs, {
...@@ -191,7 +191,7 @@ describe('Diff settings dropdown component', () => { ...@@ -191,7 +191,7 @@ describe('Diff settings dropdown component', () => {
await vm.$nextTick(); await vm.$nextTick();
expect(vm.checked).toBe(checked); expect(getFileByFileCheckbox(wrapper).element.checked).toBe(checked);
}, },
); );
......
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