19
19
class =" path-input"
20
20
v-model =" editedPath"
21
21
:placeholder =" $t('components.folder-explorer.toolbar.placeholder')"
22
- icon-left =" edit"
22
+ icon-right =" edit"
23
23
@keyup.esc =" editingPath = false"
24
24
@keyup.enter =" submitPathEdit()"
25
25
/>
29
29
v-else
30
30
:query =" require('@/graphql/cwd.gql')"
31
31
class =" current-path"
32
- v-tooltip =" $t('components.folder-explorer.toolbar.tooltips.edit-path')"
33
- @click.native =" openPathEdit()"
32
+ @dblclick.native =" openPathEdit()"
34
33
>
35
34
<ApolloSubscribeToMore
36
35
:document =" require('@/graphql/cwdChanged.gql')"
37
36
:update-query =" cwdChangedUpdate"
38
37
/>
39
38
40
39
<template slot-scope="{ result: { data } }">
41
- <span v-if =" data" >{{ data.cwd }}</span >
40
+ <div
41
+ v-if =" data"
42
+ class =" path-value"
43
+ >
44
+ <VueButton
45
+ v-for =" (slice, index) of slicePath(data.cwd)"
46
+ :key =" index"
47
+ class =" path-folder flat"
48
+ :icon-left =" !slice.name ? 'folder' : null"
49
+ :class =" {
50
+ 'icon-button': !slice.name
51
+ }"
52
+ @click =" openFolder(slice.path)"
53
+ >
54
+ {{ slice.name }}
55
+ </VueButton >
56
+ </div >
57
+ <VueButton
58
+ class =" edit-path-button icon-button"
59
+ icon-left =" edit"
60
+ v-tooltip =" $t('components.folder-explorer.toolbar.tooltips.edit-path')"
61
+ @click =" openPathEdit()"
62
+ />
42
63
</template >
43
64
</ApolloQuery >
44
65
45
- <VueIcon
46
- v-if =" error"
47
- icon =" error"
48
- class =" error-icon big"
66
+ <VueButton
67
+ class =" icon-button"
68
+ icon-left =" refresh"
69
+ v-tooltip =" $t('components.folder-explorer.toolbar.tooltips.refresh')"
70
+ @click =" refreshFolder"
49
71
/>
50
72
51
73
<VueButton
80
102
</div >
81
103
</VueDropdown >
82
104
83
- <VueButton
84
- class = " icon-button "
85
- icon-left = " refresh "
86
- v-tooltip = " $t('components.folder-explorer.toolbar.tooltips.refresh') "
87
- @click = " refreshFolder "
105
+ <VueIcon
106
+ v-if = " error "
107
+ icon = " error "
108
+ class = " error-icon big "
109
+ v-tooltip = " error.message "
88
110
/>
111
+
112
+ <VueDropdown placement =" bottom-end" >
113
+ <VueButton
114
+ slot =" trigger"
115
+ icon-left =" more_vert"
116
+ class =" icon-button"
117
+ />
118
+
119
+ <VueSwitch
120
+ icon =" visibility"
121
+ v-model =" showHidden"
122
+ class =" extend-left"
123
+ >
124
+ {{ $t('components.folder-explorer.toolbar.show-hidden') }}
125
+ </VueSwitch >
126
+ </VueDropdown >
89
127
</div >
90
128
91
129
<div ref =" folders" class =" folders" >
92
130
<template v-if =" folderCurrent .children " >
93
131
<FolderExplorerItem
94
132
v-for =" folder of folderCurrent.children"
133
+ v-if =" showHidden || !folder.hidden"
95
134
:key =" folder.name"
96
135
:folder =" folder"
97
136
@select =" openFolder(folder.path)"
@@ -109,14 +148,17 @@ import FOLDER_OPEN_PARENT from '../graphql/folderOpenParent.gql'
109
148
import FOLDER_SET_FAVORITE from ' ../graphql/folderSetFavorite.gql'
110
149
import PROJECT_CWD_RESET from ' ../graphql/projectCwdReset.gql'
111
150
151
+ const SHOW_HIDDEN = ' vue-ui.show-hidden-folders'
152
+
112
153
export default {
113
154
data () {
114
155
return {
115
156
error: false ,
116
157
editingPath: false ,
117
158
editedPath: ' ' ,
118
159
folderCurrent: {},
119
- foldersFavorite: []
160
+ foldersFavorite: [],
161
+ showHidden: localStorage .getItem (SHOW_HIDDEN ) === ' true'
120
162
}
121
163
},
122
164
@@ -133,6 +175,16 @@ export default {
133
175
foldersFavorite: FOLDERS_FAVORITE
134
176
},
135
177
178
+ watch: {
179
+ showHidden (value ) {
180
+ if (value) {
181
+ localStorage .setItem (SHOW_HIDDEN , ' true' )
182
+ } else {
183
+ localStorage .removeItem (SHOW_HIDDEN )
184
+ }
185
+ }
186
+ },
187
+
136
188
beforeRouteLeave (to , from , next ) {
137
189
if (to .matched .some (m => m .meta .needProject )) {
138
190
this .resetProjectCwd ()
@@ -143,7 +195,7 @@ export default {
143
195
methods: {
144
196
async openFolder (path ) {
145
197
this .editingPath = false
146
- this .error = false
198
+ this .error = null
147
199
try {
148
200
await this .$apollo .mutate ({
149
201
mutation: FOLDER_OPEN ,
@@ -155,13 +207,13 @@ export default {
155
207
}
156
208
})
157
209
} catch (e) {
158
- this .error = true
210
+ this .error = e
159
211
}
160
212
},
161
213
162
214
async openParentFolder (folder ) {
163
215
this .editingPath = false
164
- this .error = false
216
+ this .error = null
165
217
try {
166
218
await this .$apollo .mutate ({
167
219
mutation: FOLDER_OPEN_PARENT ,
@@ -170,7 +222,7 @@ export default {
170
222
}
171
223
})
172
224
} catch (e) {
173
- this .error = true
225
+ this .error = e
174
226
}
175
227
},
176
228
@@ -223,6 +275,36 @@ export default {
223
275
this .$apollo .mutate ({
224
276
mutation: PROJECT_CWD_RESET
225
277
})
278
+ },
279
+
280
+ slicePath (path ) {
281
+ const parts = []
282
+ let startIndex = 0
283
+ let index
284
+
285
+ const findSeparator = () => {
286
+ index = path .indexOf (' /' , startIndex)
287
+ if (index === - 1 ) index = path .indexOf (' \\ ' , startIndex)
288
+ return index !== - 1
289
+ }
290
+
291
+ const addPart = index => {
292
+ const folder = path .substring (startIndex, index)
293
+ const slice = path .substring (0 , index + 1 )
294
+ parts .push ({
295
+ name: folder,
296
+ path: slice
297
+ })
298
+ }
299
+
300
+ while (findSeparator ()) {
301
+ addPart (index)
302
+ startIndex = index + 1
303
+ }
304
+
305
+ if (startIndex < path .length ) addPart (path .length )
306
+
307
+ return parts
226
308
}
227
309
}
228
310
}
@@ -232,7 +314,7 @@ export default {
232
314
@import "~@/style/imports"
233
315
234
316
.toolbar
235
- padding $padding-item
317
+ padding $padding-item 0
236
318
h-box ()
237
319
align-items center
238
320
@@ -241,8 +323,36 @@ export default {
241
323
242
324
.current-path
243
325
flex 100% 1 1
244
- ellipsis ()
245
- cursor pointer
326
+ h-box ()
327
+ align-items stretch
328
+ border-radius $br
329
+ background $vue-ui-color-light-neutral
330
+ .vue-ui-dark-mode &
331
+ background $vue-ui-color-dark
332
+
333
+ .path-value
334
+ flex auto 1 1
335
+ h-box ()
336
+ align-items stretch
337
+
338
+ .path-folder
339
+ padding 0 9px
340
+ & :not (:first-child )
341
+ position relative
342
+ & ::before
343
+ display block
344
+ content ''
345
+ position absolute
346
+ top 0
347
+ left - 1px
348
+ height 100%
349
+ width 2px
350
+ background $vue-ui-color-light
351
+ .vue-ui-dark-mode &
352
+ background $vue-ui-color-darker
353
+
354
+ .edit-path-button
355
+ margin-left 4px
246
356
247
357
.path-edit
248
358
flex 100% 1 1
@@ -264,8 +374,4 @@ export default {
264
374
flex 100% 1 1
265
375
overflow-x hidden
266
376
overflow-y auto
267
-
268
- & .error
269
- .current-path
270
- color $vue-ui-color-danger
271
377
</style >
0 commit comments