Skip to content
Snippets Groups Projects
Unverified Commit 23c2e1e6 authored by Phil Hughes's avatar Phil Hughes
Browse files

Store tree list preference in localStorage

Fixed clear search button not clearing
parent 297f1906
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5,6 +5,8 @@ import Icon from '~/vue_shared/components/icon.vue';
import FileRow from '~/vue_shared/components/file_row.vue';
import FileRowStats from './file_row_stats.vue';
 
const treeListStorageKey = 'mr_diff_tree_list';
export default {
directives: {
Tooltip,
Loading
Loading
@@ -14,9 +16,11 @@ export default {
FileRow,
},
data() {
const treeListStored = localStorage.getItem(treeListStorageKey);
return {
search: '',
renderTreeList: true,
renderTreeList: treeListStored !== null ? treeListStored === 'true' : true,
focusSearch: false,
};
},
Loading
Loading
@@ -42,13 +46,20 @@ export default {
...mapActions('diffs', ['toggleTreeOpen', 'scrollToFile']),
clearSearch() {
this.search = '';
this.toggleFocusSearch(false)
},
toggleRenderTreeList(toggle) {
this.renderTreeList = toggle;
localStorage.setItem(treeListStorageKey, this.renderTreeList);
},
toggleFocusSearch(toggle) {
this.focusSearch = toggle;
},
blurSearch() {
if (this.search.trim() === '') {
this.toggleFocusSearch(false);
}
},
},
FileRowStats,
};
Loading
Loading
@@ -68,13 +79,13 @@ export default {
type="search"
class="form-control"
@focus="toggleFocusSearch(true)"
@blur="toggleFocusSearch(false)"
@blur="blurSearch"
/>
<button
v-show="search"
:aria-label="__('Clear search')"
type="button"
class="position-absolute tree-list-icon tree-list-clear-icon border-0 p-0"
class="position-absolute bg-transparent tree-list-icon tree-list-clear-icon border-0 p-0"
@click="clearSearch"
>
<icon
Loading
Loading
@@ -88,8 +99,8 @@ export default {
>
<button
v-tooltip.hover
:aria-label="__('Switch to file list')"
:title="__('Switch to file list')"
:aria-label="__('File view')"
:title="__('File view')"
:class="{
active: !renderTreeList
}"
Loading
Loading
@@ -103,8 +114,8 @@ export default {
</button>
<button
v-tooltip.hover
:aria-label="__('Switch to tree list')"
:title="__('Switch to tree list')"
:aria-label="__('Tree view')"
:title="__('Tree view')"
:class="{
active: renderTreeList
}"
Loading
Loading
Loading
Loading
@@ -2774,6 +2774,9 @@ msgstr ""
msgid "File templates"
msgstr ""
 
msgid "File view"
msgstr ""
msgid "Files"
msgstr ""
 
Loading
Loading
@@ -5817,12 +5820,6 @@ msgstr ""
msgid "Switch branch/tag"
msgstr ""
 
msgid "Switch to file list"
msgstr ""
msgid "Switch to tree list"
msgstr ""
msgid "System Hooks"
msgstr ""
 
Loading
Loading
@@ -6501,6 +6498,9 @@ msgstr ""
msgid "Track time with quick actions"
msgstr ""
 
msgid "Tree view"
msgstr ""
msgid "Trending"
msgstr ""
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment