116
116
class =" icon-button"
117
117
/>
118
118
119
+ <VueDropdownButton
120
+ :label =" $t('components.folder-explorer.new-folder.action')"
121
+ icon-left =" create_new_folder"
122
+ @click =" showNewFolder = true"
123
+ />
124
+
119
125
<VueSwitch
120
126
icon =" visibility"
121
127
v-model =" showHidden"
141
147
/>
142
148
</template >
143
149
</div >
150
+
151
+ <VueModal
152
+ v-if =" showNewFolder"
153
+ :title =" $t('components.folder-explorer.new-folder.title')"
154
+ class =" small new-folder-modal"
155
+ @close =" showNewFolder = false"
156
+ >
157
+ <div class =" default-body" >
158
+ <VueFormField
159
+ :title =" $t('components.folder-explorer.new-folder.field.title')"
160
+ :subtitle =" $t('components.folder-explorer.new-folder.field.subtitle')"
161
+ >
162
+ <VueInput
163
+ v-model =" newFolderName"
164
+ icon-left =" folder"
165
+ @keyup.enter =" createFolder()"
166
+ />
167
+ </VueFormField >
168
+ </div >
169
+
170
+ <div slot =" footer" class =" actions space-between" >
171
+ <VueButton
172
+ :label =" $t('components.folder-explorer.new-folder.cancel')"
173
+ class =" flat close"
174
+ @click =" showNewFolder = false"
175
+ />
176
+
177
+ <VueButton
178
+ :label =" $t('components.folder-explorer.new-folder.create')"
179
+ icon-left =" create_new_folder"
180
+ class =" primary save"
181
+ :disabled =" !newFolderValid"
182
+ @click =" createFolder()"
183
+ />
184
+ </div >
185
+ </VueModal >
144
186
</div >
145
187
</template >
146
188
147
189
<script >
190
+ import { isValidMultiName } from ' ../util/folders'
191
+
148
192
import FOLDER_CURRENT from ' ../graphql/folderCurrent.gql'
149
193
import FOLDERS_FAVORITE from ' ../graphql/foldersFavorite.gql'
150
194
import FOLDER_OPEN from ' ../graphql/folderOpen.gql'
151
195
import FOLDER_OPEN_PARENT from ' ../graphql/folderOpenParent.gql'
152
196
import FOLDER_SET_FAVORITE from ' ../graphql/folderSetFavorite.gql'
153
197
import PROJECT_CWD_RESET from ' ../graphql/projectCwdReset.gql'
198
+ import FOLDER_CREATE from ' ../graphql/folderCreate.gql'
154
199
155
200
const SHOW_HIDDEN = ' vue-ui.show-hidden-folders'
156
201
@@ -163,7 +208,9 @@ export default {
163
208
editedPath: ' ' ,
164
209
folderCurrent: {},
165
210
foldersFavorite: [],
166
- showHidden: localStorage .getItem (SHOW_HIDDEN ) === ' true'
211
+ showHidden: localStorage .getItem (SHOW_HIDDEN ) === ' true' ,
212
+ showNewFolder: false ,
213
+ newFolderName: ' '
167
214
}
168
215
},
169
216
@@ -181,6 +228,12 @@ export default {
181
228
foldersFavorite: FOLDERS_FAVORITE
182
229
},
183
230
231
+ computed: {
232
+ newFolderValid () {
233
+ return isValidMultiName (this .newFolderName )
234
+ }
235
+ },
236
+
184
237
watch: {
185
238
showHidden (value ) {
186
239
if (value) {
@@ -311,6 +364,22 @@ export default {
311
364
if (startIndex < path .length ) addPart (path .length )
312
365
313
366
return parts
367
+ },
368
+
369
+ async createFolder () {
370
+ if (! this .newFolderValid ) return
371
+
372
+ const result = await this .$apollo .mutate ({
373
+ mutation: FOLDER_CREATE ,
374
+ variables: {
375
+ name: this .newFolderName
376
+ }
377
+ })
378
+
379
+ this .openFolder (result .data .folderCreate .path )
380
+
381
+ this .newFolderName = ' '
382
+ this .showNewFolder = false
314
383
}
315
384
}
316
385
}
0 commit comments