Skip to content

Commit 22e0dac

Browse files
alenakhineikaRhys Howell
andauthored
VSCODE-86: Playgrounds and connections explorers update (#162)
* Add playgrounds panel in mongodb view * feat: add playgrounds tree * refactor: fix package json after rebase * refactor: trees without extra roots * refactor: root of connections tree should check for element * refactor: clear cache if connections changed * build: resolve merge conflicts * feat: show root path * feat: show a welcome view if playgrounds list is empty * refactor: clean up names and comments * test: debug current workspace on windows * test: use path with dirname * test: cut string instead of path resolve * test: check excluding folders and files specified in extension settings * feat: fetch new folders and files to exclude after refreshing * refactor: remove unused command from package.json * refactor: use separate commands for refreshing playgrounds from tree and command palette Co-authored-by: Rhys Howell <rhys@[email protected]>
1 parent 2936c05 commit 22e0dac

23 files changed

+828
-307
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ If you use Terraform to manage your infrastructure, MongoDB for VS Code helps yo
4747
- `mdb.show`: Show or hide the MongoDB view.
4848
- `mdb.defaultLimit`: The number of documents to fetch when viewing documents from a collection.
4949
- `mdb.confirmRunAll`: Show a confirmation message before running commands in a playground.
50+
- `mdb.excludeFromPlaygroundsSearch`: Exclude files and folders while searching for playground in the the current workspace.
5051
- `mdb.connectionSaving.hideOptionToChooseWhereToSaveNewConnections`: When a connection is added, a prompt is shown that let's the user decide where the new connection should be saved. When this setting is checked, the prompt is not shown and the default connection saving location setting is used.
5152
- `mdb.connectionSaving.defaultConnectionSavingLocation`: When the setting that hides the option to choose where to save new connections is checked, this setting sets if and where new connections are saved.
5253
- `mdb.useDefaultTemplateForPlayground`: Choose whether to use the default template for playground files or to start with an empty playground editor.

images/dark/file-light.svg

Lines changed: 4 additions & 0 deletions
Loading

images/light/file-light.svg

Lines changed: 4 additions & 0 deletions
Loading

package.json

Lines changed: 116 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
"onCommand:mdb.removeConnection",
7272
"onCommand:mdb.openMongoDBShell",
7373
"onView:mongoDB",
74+
"onView:mongoDBConnectionExplorer",
75+
"onView:mongoDBPlaygroundsExplorer",
7476
"onLanguage:json",
7577
"onLanguage:mongodb"
7678
],
@@ -87,16 +89,25 @@
8789
"views": {
8890
"mongoDB": [
8991
{
90-
"id": "mongoDB",
91-
"name": "MongoDB",
92-
"when": "config.mdb.show == true"
92+
"id": "mongoDBConnectionExplorer",
93+
"name": "Connections",
94+
"when": "config.mdb.showMongoDBConnectionExplorer == true"
95+
},
96+
{
97+
"id": "mongoDBPlaygroundsExplorer",
98+
"name": "Playgrounds",
99+
"when": "config.mdb.showMongoDBPlaygrounds == true"
93100
}
94101
]
95102
},
96103
"viewsWelcome": [
97104
{
98-
"view": "mongoDB",
105+
"view": "mongoDBConnectionExplorer",
99106
"contents": "No connections found.\n[Add Connection](command:mdb.connect)"
107+
},
108+
{
109+
"view": "mongoDBPlaygroundsExplorer",
110+
"contents": "No '.mongodb' playground files found in the workspace.\n[Create New Playground](command:mdb.createNewPlaygroundFromPlaygroundExplorer)"
100111
}
101112
],
102113
"languages": [
@@ -168,10 +179,22 @@
168179
"command": "mdb.createPlayground",
169180
"title": "MongoDB: Create MongoDB Playground"
170181
},
182+
{
183+
"command": "mdb.refreshPlaygrounds",
184+
"title": "MongoDB: Refresh Playgrounds List"
185+
},
186+
{
187+
"command": "mdb.refreshPlaygroundsFromTreeView",
188+
"title": "Refresh"
189+
},
171190
{
172191
"command": "mdb.createNewPlaygroundFromViewAction",
173192
"title": "Create MongoDB Playground"
174193
},
194+
{
195+
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
196+
"title": "Create MongoDB Playground"
197+
},
175198
{
176199
"command": "mdb.changeActiveConnection",
177200
"title": "MongoDB: Change Active Connection"
@@ -236,6 +259,10 @@
236259
"dark": "images/dark/search-regular.svg"
237260
}
238261
},
262+
{
263+
"command": "mdb.openPlaygroundFromTreeItem",
264+
"title": "Open Playground"
265+
},
239266
{
240267
"command": "mdb.connectToConnectionTreeItem",
241268
"title": "Connect"
@@ -317,176 +344,170 @@
317344
"view/title": [
318345
{
319346
"command": "mdb.createNewPlaygroundFromViewAction",
320-
"when": "view == mongoDB"
347+
"when": "view == mongoDBPlaygroundsExplorer"
348+
},
349+
{
350+
"command": "mdb.refreshPlaygroundsFromTreeView",
351+
"when": "view == mongoDBPlaygroundsExplorer"
321352
},
322353
{
323354
"command": "mdb.addConnection",
324-
"when": "view == mongoDB"
355+
"when": "view == mongoDBConnectionExplorer"
325356
},
326357
{
327358
"command": "mdb.addConnectionWithURI",
328-
"when": "view == mongoDB"
359+
"when": "view == mongoDBConnectionExplorer"
329360
}
330361
],
331362
"view/item/context": [
332-
{
333-
"command": "mdb.addConnection",
334-
"when": "view == mongoDB && viewItem == mdbConnectionsTreeItem",
335-
"group": "inline"
336-
},
337-
{
338-
"command": "mdb.addConnection",
339-
"when": "view == mongoDB && viewItem == mdbConnectionsTreeItem"
340-
},
341-
{
342-
"command": "mdb.addConnectionWithURI",
343-
"when": "view == mongoDB && viewItem == mdbConnectionsTreeItem"
344-
},
345363
{
346364
"command": "mdb.addDatabase",
347-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
365+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
348366
"group": "inline"
349367
},
350368
{
351369
"command": "mdb.addDatabase",
352-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
370+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
353371
"group": "1@1"
354372
},
355373
{
356374
"command": "mdb.refreshConnection",
357-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
375+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
358376
"group": "1@2"
359377
},
360378
{
361379
"command": "mdb.treeViewOpenMongoDBShell",
362-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
380+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
363381
"group": "2@1"
364382
},
365383
{
366384
"command": "mdb.renameConnection",
367-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
385+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
368386
"group": "3@1"
369387
},
370388
{
371389
"command": "mdb.copyConnectionString",
372-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
390+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
373391
"group": "4@1"
374392
},
375393
{
376394
"command": "mdb.disconnectFromConnectionTreeItem",
377-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
395+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
378396
"group": "5@1"
379397
},
380398
{
381399
"command": "mdb.treeItemRemoveConnection",
382-
"when": "view == mongoDB && viewItem == connectedConnectionTreeItem",
400+
"when": "view == mongoDBConnectionExplorer && viewItem == connectedConnectionTreeItem",
383401
"group": "5@2"
384402
},
403+
{
404+
"command": "mdb.openPlaygroundFromTreeItem",
405+
"when": "view == mongoDBPlaygroundsExplorer && viewItem == playgroundsTreeItem",
406+
"group": "1@1"
407+
},
385408
{
386409
"command": "mdb.connectToConnectionTreeItem",
387-
"when": "view == mongoDB && viewItem == disconnectedConnectionTreeItem",
410+
"when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem",
388411
"group": "1@1"
389412
},
390413
{
391414
"command": "mdb.renameConnection",
392-
"when": "view == mongoDB && viewItem == disconnectedConnectionTreeItem",
415+
"when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem",
393416
"group": "2@1"
394417
},
395418
{
396419
"command": "mdb.copyConnectionString",
397-
"when": "view == mongoDB && viewItem == disconnectedConnectionTreeItem",
420+
"when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem",
398421
"group": "3@1"
399422
},
400423
{
401424
"command": "mdb.treeItemRemoveConnection",
402-
"when": "view == mongoDB && viewItem == disconnectedConnectionTreeItem",
425+
"when": "view == mongoDBConnectionExplorer && viewItem == disconnectedConnectionTreeItem",
403426
"group": "4@1"
404427
},
405428
{
406429
"command": "mdb.addCollection",
407-
"when": "view == mongoDB && viewItem == databaseTreeItem",
430+
"when": "view == mongoDBConnectionExplorer && viewItem == databaseTreeItem",
408431
"group": "inline"
409432
},
410433
{
411434
"command": "mdb.addCollection",
412-
"when": "view == mongoDB && viewItem == databaseTreeItem",
435+
"when": "view == mongoDBConnectionExplorer && viewItem == databaseTreeItem",
413436
"group": "1@1"
414437
},
415438
{
416439
"command": "mdb.refreshDatabase",
417-
"when": "view == mongoDB && viewItem == databaseTreeItem",
440+
"when": "view == mongoDBConnectionExplorer && viewItem == databaseTreeItem",
418441
"group": "1@2"
419442
},
420443
{
421444
"command": "mdb.copyDatabaseName",
422-
"when": "view == mongoDB && viewItem == databaseTreeItem",
445+
"when": "view == mongoDBConnectionExplorer && viewItem == databaseTreeItem",
423446
"group": "2@1"
424447
},
425448
{
426449
"command": "mdb.dropDatabase",
427-
"when": "view == mongoDB && viewItem == databaseTreeItem",
450+
"when": "view == mongoDBConnectionExplorer && viewItem == databaseTreeItem",
428451
"group": "3@1"
429452
},
430453
{
431454
"command": "mdb.viewCollectionDocuments",
432-
"when": "view == mongoDB && viewItem == collectionTreeItem",
455+
"when": "view == mongoDBConnectionExplorer && viewItem == collectionTreeItem",
433456
"group": "1@1"
434457
},
435458
{
436459
"command": "mdb.refreshCollection",
437-
"when": "view == mongoDB && viewItem == collectionTreeItem",
460+
"when": "view == mongoDBConnectionExplorer && viewItem == collectionTreeItem",
438461
"group": "1@2"
439462
},
440463
{
441464
"command": "mdb.copyCollectionName",
442-
"when": "view == mongoDB && viewItem == collectionTreeItem",
465+
"when": "view == mongoDBConnectionExplorer && viewItem == collectionTreeItem",
443466
"group": "2@1"
444467
},
445468
{
446469
"command": "mdb.dropCollection",
447-
"when": "view == mongoDB && viewItem == collectionTreeItem",
470+
"when": "view == mongoDBConnectionExplorer && viewItem == collectionTreeItem",
448471
"group": "3@1"
449472
},
450473
{
451474
"command": "mdb.searchForDocuments",
452-
"when": "view == mongoDB && viewItem == documentListTreeItem",
475+
"when": "view == mongoDBConnectionExplorer && viewItem == documentListTreeItem",
453476
"group": "inline"
454477
},
455478
{
456479
"command": "mdb.viewCollectionDocuments",
457-
"when": "view == mongoDB && viewItem == documentListTreeItem",
458-
"group": "1@1"
480+
"when": "view == mongoDBConnectionExplorer && viewItem == documentListTreeItem"
459481
},
460482
{
461483
"command": "mdb.refreshDocumentList",
462-
"when": "view == mongoDB && viewItem == documentListTreeItem",
463-
"group": "1@2"
484+
"when": "view == mongoDBConnectionExplorer && viewItem == documentListTreeItem"
464485
},
465486
{
466487
"command": "mdb.searchForDocuments",
467-
"when": "view == mongoDB && viewItem == documentListTreeItem",
488+
"when": "view == mongoDBConnectionExplorer && viewItem == documentListTreeItem",
468489
"group": "2@1"
469490
},
470491
{
471492
"command": "mdb.refreshSchema",
472-
"when": "view == mongoDB && viewItem == schemaTreeItem"
493+
"when": "view == mongoDBConnectionExplorer && viewItem == schemaTreeItem"
473494
},
474495
{
475496
"command": "mdb.copySchemaFieldName",
476-
"when": "view == mongoDB && viewItem == fieldTreeItem"
497+
"when": "view == mongoDBConnectionExplorer && viewItem == fieldTreeItem"
477498
},
478499
{
479500
"command": "mdb.createIndexFromTreeView",
480-
"when": "view == mongoDB && viewItem == indexListTreeItem",
501+
"when": "view == mongoDBConnectionExplorer && viewItem == indexListTreeItem",
481502
"group": "inline"
482503
},
483504
{
484505
"command": "mdb.refreshIndexes",
485-
"when": "view == mongoDB && viewItem == indexListTreeItem"
506+
"when": "view == mongoDBConnectionExplorer && viewItem == indexListTreeItem"
486507
},
487508
{
488509
"command": "mdb.createIndexFromTreeView",
489-
"when": "view == mongoDB && viewItem == indexListTreeItem"
510+
"when": "view == mongoDBConnectionExplorer && viewItem == indexListTreeItem"
490511
}
491512
],
492513
"editor/title": [
@@ -497,6 +518,10 @@
497518
}
498519
],
499520
"commandPalette": [
521+
{
522+
"command": "mdb.refreshPlaygroundsFromTreeView",
523+
"when": "false"
524+
},
500525
{
501526
"command": "mdb.searchForDocuments",
502527
"when": "false"
@@ -513,6 +538,10 @@
513538
"command": "mdb.createNewPlaygroundFromViewAction",
514539
"when": "false"
515540
},
541+
{
542+
"command": "mdb.createNewPlaygroundFromPlaygroundExplorer",
543+
"when": "false"
544+
},
516545
{
517546
"command": "mdb.changeActiveConnection",
518547
"when": "false"
@@ -533,6 +562,10 @@
533562
"command": "mdb.addDatabase",
534563
"when": "false"
535564
},
565+
{
566+
"command": "mdb.openPlaygroundFromTreeItem",
567+
"when": "false"
568+
},
536569
{
537570
"command": "mdb.connectToConnectionTreeItem",
538571
"when": "false"
@@ -659,10 +692,38 @@
659692
"default": "mongo",
660693
"description": "The MongoDB shell to use."
661694
},
662-
"mdb.show": {
695+
"mdb.showMongoDBConnectionExplorer": {
696+
"type": "boolean",
697+
"default": true,
698+
"description": "Show or hide the MongoDB connections view."
699+
},
700+
"mdb.showMongoDBPlaygrounds": {
663701
"type": "boolean",
664702
"default": true,
665-
"description": "Show or hide the MongoDB view."
703+
"description": "Show or hide the MongoDB playgrounds view."
704+
},
705+
"mdb.excludeFromPlaygroundsSearch": {
706+
"type": "array",
707+
"items": {
708+
"type": "string"
709+
},
710+
"description": "Files and folders to exclude while searching for playground in the the current workspace.",
711+
"default": [
712+
"**/.!(todo|todos|task|tasks)/**",
713+
"**/_output/**",
714+
"**/bower_components/**",
715+
"**/build/**",
716+
"**/dist/**",
717+
"**/node_modules/**",
718+
"**/out/**",
719+
"**/output/**",
720+
"**/release/**",
721+
"**/releases/**",
722+
"**/static/**",
723+
"**/target/**",
724+
"**/third_party/**",
725+
"**/vendor/**"
726+
]
666727
},
667728
"mdb.defaultLimit": {
668729
"type": "number",
@@ -723,6 +784,7 @@
723784
"debug": "^4.1.1",
724785
"dotenv": "^8.2.0",
725786
"encoding": "^0.1.12",
787+
"micromatch": "^4.0.2",
726788
"mongodb-cloud-info": "^1.1.2",
727789
"mongodb-connection-model": "^16.1.4",
728790
"mongodb-data-service": "^16.8.1",

0 commit comments

Comments
 (0)