@@ -15,6 +15,7 @@ import 'mongo_databases_view.dart';
1515import 'mongo_documents_view.dart' ;
1616import 'mongo_document_editor.dart' ;
1717import 'mongo_indexes_view.dart' ;
18+ import 'mongo_query_workspace.dart' ;
1819import 'mongo_stats_view.dart' ;
1920
2021// ─── Navigation path model ──────────────────────────────────────────────────
@@ -34,6 +35,7 @@ enum _Level {
3435 stats,
3536 aggregation,
3637 indexes,
38+ queryConsole,
3739}
3840
3941// ─── Main explorer widget ───────────────────────────────────────────────────
@@ -64,6 +66,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
6466 bool _showStats = false ;
6567 bool _showAggregation = false ;
6668 bool _showIndexes = false ;
69+ bool _showQueryConsole = false ;
6770
6871 /// Bumped when the user taps Refresh in the breadcrumb bar (reload active view).
6972 int _refreshToken = 0 ;
@@ -169,6 +172,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
169172 _selectedDocument = null ;
170173 _showAggregation = false ;
171174 _showIndexes = false ;
175+ _showQueryConsole = false ;
172176 });
173177 }
174178
@@ -179,6 +183,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
179183 _selectedDocument = null ;
180184 _showAggregation = false ;
181185 _showIndexes = false ;
186+ _showQueryConsole = false ;
182187 });
183188 }
184189
@@ -187,6 +192,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
187192 _selectedDocument = doc;
188193 _showAggregation = false ;
189194 _showIndexes = false ;
195+ _showQueryConsole = false ;
190196 });
191197 }
192198
@@ -197,6 +203,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
197203 _selectedDocument = null ;
198204 _showAggregation = false ;
199205 _showIndexes = false ;
206+ _showQueryConsole = false ;
200207 });
201208 }
202209
@@ -206,6 +213,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
206213 _selectedDocument = null ;
207214 _showAggregation = false ;
208215 _showIndexes = false ;
216+ _showQueryConsole = false ;
209217 });
210218 }
211219
@@ -214,6 +222,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
214222 _selectedDocument = null ;
215223 _showAggregation = false ;
216224 _showIndexes = false ;
225+ _showQueryConsole = false ;
217226 });
218227 }
219228
@@ -233,7 +242,9 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
233242 final id = _selectedDocument! ['_id' ]? .toString () ?? 'Document' ;
234243 list.add (_Crumb (id, _Level .document));
235244 }
236- if (_showIndexes) {
245+ if (_showQueryConsole) {
246+ list.add (const _Crumb ('MQL Console' , _Level .queryConsole));
247+ } else if (_showIndexes) {
237248 list.add (const _Crumb ('Indexes' , _Level .indexes));
238249 } else if (_showAggregation) {
239250 list.add (const _Crumb ('Aggregation' , _Level .aggregation));
@@ -248,7 +259,8 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
248259 crumb.level != _Level .document &&
249260 crumb.level != _Level .stats &&
250261 crumb.level != _Level .aggregation &&
251- crumb.level != _Level .indexes;
262+ crumb.level != _Level .indexes &&
263+ crumb.level != _Level .queryConsole;
252264 if (leavesDocument) {
253265 if (! await confirmDiscardUnsavedWorkIfNeeded (context)) return ;
254266 if (! mounted) return ;
@@ -262,6 +274,9 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
262274 if (_showIndexes && crumb.level != _Level .indexes) {
263275 setState (() => _showIndexes = false );
264276 }
277+ if (_showQueryConsole && crumb.level != _Level .queryConsole) {
278+ setState (() => _showQueryConsole = false );
279+ }
265280 switch (crumb.level) {
266281 case _Level .databases:
267282 _navigateToDatabases ();
@@ -277,6 +292,8 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
277292 break ;
278293 case _Level .indexes:
279294 break ;
295+ case _Level .queryConsole:
296+ break ;
280297 }
281298 }
282299
@@ -428,6 +445,17 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
428445 );
429446 }
430447
448+ // Query Console workspace
449+ if (_showQueryConsole && _selectedDatabase != null ) {
450+ return MongoQueryWorkspace (
451+ key: ValueKey ('mql_${_selectedDatabase }_$_selectedCollection ' ),
452+ connection: conn,
453+ database: _selectedDatabase! ,
454+ initialCollection: _selectedCollection,
455+ onBack: () => setState (() => _showQueryConsole = false ),
456+ );
457+ }
458+
431459 // Documents list
432460 if (_selectedCollection != null && _selectedDatabase != null ) {
433461 return MongoDocumentsView (
@@ -439,6 +467,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
439467 onDocumentTap: _navigateToDocument,
440468 onOpenAggregation: () => setState (() => _showAggregation = true ),
441469 onOpenIndexes: () => setState (() => _showIndexes = true ),
470+ onOpenQueryConsole: () => setState (() => _showQueryConsole = true ),
442471 );
443472 }
444473
@@ -450,6 +479,7 @@ class _MongoExplorerViewState extends material.State<MongoExplorerView> {
450479 database: _selectedDatabase! ,
451480 refreshToken: _refreshToken,
452481 onCollectionTap: _navigateToCollection,
482+ onOpenQueryConsole: () => setState (() => _showQueryConsole = true ),
453483 );
454484 }
455485
0 commit comments