@@ -4,6 +4,7 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
4
4
import { debounce , throttle } from ' lodash' ;
5
5
// eslint-disable-next-line no-restricted-imports
6
6
import { mapState , mapGetters , mapActions } from ' vuex' ;
7
+ import { mapState as mapPiniaState , mapActions as mapPiniaActions } from ' pinia' ;
7
8
import FindingsDrawer from ' ee_component/diffs/components/shared/findings_drawer.vue' ;
8
9
import glFeatureFlagsMixin from ' ~/vue_shared/mixins/gl_feature_flags_mixin' ;
9
10
import { convertToGraphQLId } from ' ~/graphql_shared/utils' ;
@@ -18,7 +19,7 @@ import {
18
19
import { createAlert } from ' ~/alert' ;
19
20
import { InternalEvents } from ' ~/tracking' ;
20
21
import { helpPagePath } from ' ~/helpers/help_page_helper' ;
21
- import { parseBoolean , handleLocationHash } from ' ~/lib/utils/common_utils' ;
22
+ import { parseBoolean , handleLocationHash , getCookie } from ' ~/lib/utils/common_utils' ;
22
23
import { BV_HIDE_TOOLTIP , DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from ' ~/lib/utils/constants' ;
23
24
import { Mousetrap } from ' ~/lib/mousetrap' ;
24
25
import { updateHistory , getLocationHash } from ' ~/lib/utils/url_utility' ;
@@ -27,9 +28,9 @@ import { __ } from '~/locale';
27
28
import notesEventHub from ' ~/notes/event_hub' ;
28
29
import { DynamicScroller , DynamicScrollerItem } from ' vendor/vue-virtual-scroller' ;
29
30
import getMRCodequalityAndSecurityReports from ' ee_else_ce/diffs/components/graphql/get_mr_codequality_and_security_reports.query.graphql' ;
31
+ import { useFileBrowser } from ' ~/diffs/stores/file_browser' ;
30
32
import { sortFindingsByFile } from ' ../utils/sort_findings_by_file' ;
31
33
import {
32
- MR_TREE_SHOW_KEY ,
33
34
ALERT_OVERFLOW_HIDDEN ,
34
35
ALERT_MERGE_CONFLICT ,
35
36
ALERT_COLLAPSED_FILES ,
@@ -44,6 +45,7 @@ import {
44
45
TRACKING_MULTIPLE_FILES_MODE ,
45
46
EVT_MR_PREPARED ,
46
47
EVT_DISCUSSIONS_ASSIGNED ,
48
+ FILE_BROWSER_VISIBLE ,
47
49
} from ' ../constants' ;
48
50
49
51
import { isCollapsed } from ' ../utils/diff_file' ;
@@ -243,7 +245,6 @@ export default {
243
245
' showWhitespace' ,
244
246
' targetBranchName' ,
245
247
' branchName' ,
246
- ' showTreeList' ,
247
248
' addedLines' ,
248
249
' removedLines' ,
249
250
]),
@@ -259,6 +260,7 @@ export default {
259
260
]),
260
261
... mapGetters ([' isNotesFetched' , ' getNoteableData' ]),
261
262
... mapGetters (' findingsDrawer' , [' activeDrawer' ]),
263
+ ... mapPiniaState (useFileBrowser, [' fileBrowserVisible' ]),
262
264
diffs () {
263
265
if (! this .viewDiffsFileByFile ) {
264
266
return this .diffFiles ;
@@ -316,7 +318,7 @@ export default {
316
318
return convertToGraphQLId (' MergeRequest' , this .getNoteableData .id );
317
319
},
318
320
renderFileTree () {
319
- return this .renderDiffFiles && this .showTreeList ;
321
+ return this .renderDiffFiles && this .fileBrowserVisible ;
320
322
},
321
323
hideTooltips () {
322
324
const hide = () => {
@@ -455,19 +457,18 @@ export default {
455
457
' setCurrentFileHash' ,
456
458
' setHighlightedRow' ,
457
459
' goToFile' ,
458
- ' setShowTreeList' ,
459
460
' navigateToDiffFileIndex' ,
460
461
' setFileByFile' ,
461
462
' disableVirtualScroller' ,
462
463
' fetchLinkedFile' ,
463
- ' toggleTreeList' ,
464
464
' expandAllFiles' ,
465
465
' collapseAllFiles' ,
466
466
' setDiffViewType' ,
467
467
' setShowWhitespace' ,
468
468
' goToFile' ,
469
469
]),
470
470
... mapActions (' findingsDrawer' , [' setDrawer' ]),
471
+ ... mapPiniaActions (useFileBrowser, [' setFileBrowserVisibility' , ' toggleFileBrowserVisibility' ]),
471
472
closeDrawer () {
472
473
this .setDrawer ({});
473
474
},
@@ -684,16 +685,14 @@ export default {
684
685
}
685
686
},
686
687
setTreeDisplay () {
687
- const storedTreeShow = localStorage . getItem ( MR_TREE_SHOW_KEY );
688
- let showTreeList = true ;
689
-
690
- if (storedTreeShow !== null ) {
691
- showTreeList = parseBoolean (storedTreeShow);
692
- } else if ( ! bp .isDesktop () || (! this .isBatchLoading && this .flatBlobsList .length <= 1 )) {
693
- showTreeList = false ;
688
+ const hideBrowserPreference = getCookie ( FILE_BROWSER_VISIBLE );
689
+ if (hideBrowserPreference) {
690
+ this . setFileBrowserVisibility ( parseBoolean (hideBrowserPreference));
691
+ } else {
692
+ const shouldHide =
693
+ ! bp .isDesktop () || (! this .isBatchLoading && this .flatBlobsList .length <= 1 );
694
+ this . setFileBrowserVisibility ( ! shouldHide) ;
694
695
}
695
-
696
- return this .setShowTreeList ({ showTreeList, saving: false });
697
696
},
698
697
async scrollVirtualScrollerToFileHash (hash ) {
699
698
const index = this .diffFiles .findIndex ((f ) => f .file_hash === hash);
@@ -741,7 +740,7 @@ export default {
741
740
}
742
741
},
743
742
fileTreeToggled () {
744
- this .toggleTreeList ();
743
+ this .toggleFileBrowserVisibility ();
745
744
this .adjustView ();
746
745
},
747
746
isDiffViewActive (item ) {
0 commit comments