Commit 65c81fd1 authored by Phil Hughes's avatar Phil Hughes

Fixes diffs tree list showing incorrectly

This fixes the tree list on merge requests showing
even if the user has chosen to previously hide it.
parent 2b9355e6
...@@ -429,7 +429,7 @@ export default { ...@@ -429,7 +429,7 @@ export default {
let showTreeList = true; let showTreeList = true;
if (storedTreeShow !== null) { if (storedTreeShow !== null) {
showTreeList = Boolean(storedTreeShow); showTreeList = parseBoolean(storedTreeShow);
} else if (!bp.isDesktop() || (!this.isBatchLoading && this.diffFiles.length <= 1)) { } else if (!bp.isDesktop() || (!this.isBatchLoading && this.diffFiles.length <= 1)) {
showTreeList = false; showTreeList = false;
} }
......
...@@ -678,8 +678,12 @@ describe('diffs/components/app', () => { ...@@ -678,8 +678,12 @@ describe('diffs/components/app', () => {
expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false }); expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false });
}); });
it('calls setShowTreeList with localstorage value', () => { it.each`
localStorage.setItem('mr_tree_show', 'true'); showTreeList
${true}
${false}
`('calls setShowTreeList with localstorage $showTreeList', ({ showTreeList }) => {
localStorage.setItem('mr_tree_show', showTreeList);
createComponent({}, ({ state }) => { createComponent({}, ({ state }) => {
state.diffs.diffFiles.push({ sha: '123' }); state.diffs.diffFiles.push({ sha: '123' });
...@@ -691,7 +695,7 @@ describe('diffs/components/app', () => { ...@@ -691,7 +695,7 @@ describe('diffs/components/app', () => {
wrapper.vm.setTreeDisplay(); wrapper.vm.setTreeDisplay();
expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList: true, saving: false }); expect(setShowTreeList).toHaveBeenCalledWith({ showTreeList, saving: false });
}); });
}); });
......
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