1
1
<template >
2
- <div
3
- v-if =" fileTreeIsVisible"
4
- class =" gt-mr-3 gt-mt-3 diff-detail-box"
5
- >
2
+ <div v-if =" store.fileTreeIsVisible" class =" gt-mr-3 gt-mt-3 diff-detail-box" >
6
3
<!-- only render the tree if we're visible. in many cases this is something that doesn't change very often -->
7
4
<div class =" ui list" >
8
5
<DiffFileTreeItem v-for =" item in fileTree" :key =" item.name" :item =" item" />
9
6
</div >
10
- <div v-if =" isIncomplete" id = " diff-too-many-files-stats " class =" gt-pt-2" >
11
- <span class = " gt-mr-2 " >{{ tooManyFilesMessage }}</ span >< a :class =" ['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id = " diff-show-more-files-stats " @click.stop =" loadMoreData" >{{ showMoreMessage }}</a >
7
+ <div v-if =" store. isIncomplete" class =" gt-pt-2" >
8
+ <a :class =" ['ui', 'basic', 'tiny', 'button', store. isLoadingNewData ? 'disabled' : '']" @click.stop =" loadMoreData" >{{ store. showMoreMessage }}</a >
12
9
</div >
13
10
</div >
14
11
</template >
15
12
16
13
<script >
17
14
import DiffFileTreeItem from ' ./DiffFileTreeItem.vue' ;
18
- import {doLoadMoreFiles } from ' ../features/repo-diff.js' ;
15
+ import {loadMoreFiles } from ' ../features/repo-diff.js' ;
19
16
import {toggleElem } from ' ../utils/dom.js' ;
20
- import {DiffTreeStore } from ' ../modules/stores.js' ;
17
+ import {diffTreeStore } from ' ../modules/stores.js' ;
21
18
import {setFileFolding } from ' ../features/file-fold.js' ;
22
19
23
- const {pageData } = window .config ;
24
20
const LOCAL_STORAGE_KEY = ' diff_file_tree_visible' ;
25
21
26
22
export default {
27
23
components: {DiffFileTreeItem},
28
24
data : () => {
29
- const fileTreeIsVisible = localStorage .getItem (LOCAL_STORAGE_KEY ) === ' true' ;
30
- pageData .diffFileInfo .fileTreeIsVisible = fileTreeIsVisible;
31
- return {
32
- ... pageData .diffFileInfo ,
33
- store: DiffTreeStore,
34
- };
25
+ return {store: diffTreeStore ()};
35
26
},
36
27
computed: {
37
28
fileTree () {
38
29
const result = [];
39
- for (const file of this .files ) {
30
+ for (const file of this .store . files ) {
40
31
// Split file into directories
41
32
const splits = file .Name .split (' /' );
42
33
let index = 0 ;
@@ -98,9 +89,7 @@ export default {
98
89
}
99
90
},
100
91
mounted () {
101
- // replace the pageData.diffFileInfo.files with our watched data so we get updates
102
- pageData .diffFileInfo .files = this .files ;
103
-
92
+ this .store .fileTreeIsVisible = localStorage .getItem (LOCAL_STORAGE_KEY ) === ' true' ;
104
93
document .querySelector (' .diff-toggle-file-tree-button' ).addEventListener (' click' , this .toggleVisibility );
105
94
106
95
this .hashChangeListener = () => {
@@ -124,12 +113,12 @@ export default {
124
113
}
125
114
},
126
115
toggleVisibility () {
127
- this .updateVisibility (! this .fileTreeIsVisible );
116
+ this .updateVisibility (! this .store . fileTreeIsVisible );
128
117
},
129
118
updateVisibility (visible ) {
130
- this .fileTreeIsVisible = visible;
131
- localStorage .setItem (LOCAL_STORAGE_KEY , this .fileTreeIsVisible );
132
- this .updateState (this .fileTreeIsVisible );
119
+ this .store . fileTreeIsVisible = visible;
120
+ localStorage .setItem (LOCAL_STORAGE_KEY , this .store . fileTreeIsVisible );
121
+ this .updateState (this .store . fileTreeIsVisible );
133
122
},
134
123
updateState (visible ) {
135
124
const btn = document .querySelector (' .diff-toggle-file-tree-button' );
@@ -142,12 +131,7 @@ export default {
142
131
toggleElem (toHide, visible);
143
132
},
144
133
loadMoreData () {
145
- this .isLoadingNewData = true ;
146
- doLoadMoreFiles (this .link , this .diffEnd , () => {
147
- this .isLoadingNewData = false ;
148
- const {pageData } = window .config ;
149
- this .diffEnd = pageData .diffFileInfo .diffEnd ;
150
- });
134
+ loadMoreFiles (this .store .linkLoadMore );
151
135
},
152
136
},
153
137
};
0 commit comments