@@ -21,7 +21,7 @@ import {
2121 DatabaseItem ,
2222 DatabaseManager ,
2323} from "./local-databases" ;
24- import { commandRunner , ProgressCallback , withProgress } from "./commandRunner" ;
24+ import { ProgressCallback , withProgress } from "./commandRunner" ;
2525import {
2626 isLikelyDatabaseRoot ,
2727 isLikelyDbLanguageFolder ,
@@ -38,8 +38,8 @@ import { asError, asyncFilter, getErrorMessage } from "./pure/helpers-pure";
3838import { QueryRunner } from "./queryRunner" ;
3939import { isCanary } from "./config" ;
4040import { App } from "./common/app" ;
41- import { Credentials } from "./common/authentication" ;
4241import { redactableError } from "./pure/errors" ;
42+ import { LocalDatabasesCommands } from "./common/commands" ;
4343
4444enum SortOrder {
4545 NameAsc = "NameAsc" ,
@@ -206,108 +206,34 @@ export class DatabaseUI extends DisposableObject {
206206 ) ;
207207 }
208208
209- init ( ) {
210- void extLogger . log ( "Registering database panel commands." ) ;
211- this . push (
212- commandRunner (
213- "codeQL.setCurrentDatabase" ,
214- this . handleSetCurrentDatabase . bind ( this ) ,
215- ) ,
216- ) ;
217- this . push (
218- commandRunner (
219- "codeQL.setDefaultTourDatabase" ,
209+ public getCommands ( ) : LocalDatabasesCommands {
210+ return {
211+ "codeQL.setCurrentDatabase" : this . handleSetCurrentDatabase . bind ( this ) ,
212+ "codeQL.setDefaultTourDatabase" :
220213 this . handleSetDefaultTourDatabase . bind ( this ) ,
221- ) ,
222- ) ;
223- this . push (
224- commandRunner (
225- "codeQL.upgradeCurrentDatabase" ,
214+ "codeQL.upgradeCurrentDatabase" :
226215 this . handleUpgradeCurrentDatabase . bind ( this ) ,
227- ) ,
228- ) ;
229- this . push (
230- commandRunner ( "codeQL.clearCache" , this . handleClearCache . bind ( this ) ) ,
231- ) ;
232-
233- this . push (
234- commandRunner (
235- "codeQLDatabases.chooseDatabaseFolder" ,
216+ "codeQL.clearCache" : this . handleClearCache . bind ( this ) ,
217+ "codeQLDatabases.chooseDatabaseFolder" :
236218 this . handleChooseDatabaseFolder . bind ( this ) ,
237- ) ,
238- ) ;
239- this . push (
240- commandRunner (
241- "codeQLDatabases.chooseDatabaseArchive" ,
219+ "codeQLDatabases.chooseDatabaseArchive" :
242220 this . handleChooseDatabaseArchive . bind ( this ) ,
243- ) ,
244- ) ;
245- this . push (
246- commandRunner (
247- "codeQLDatabases.chooseDatabaseInternet" ,
221+ "codeQLDatabases.chooseDatabaseInternet" :
248222 this . handleChooseDatabaseInternet . bind ( this ) ,
249- ) ,
250- ) ;
251- this . push (
252- commandRunner ( "codeQLDatabases.chooseDatabaseGithub" , async ( ) => {
253- const credentials = isCanary ( ) ? this . app . credentials : undefined ;
254- await this . handleChooseDatabaseGithub ( credentials ) ;
255- } ) ,
256- ) ;
257- this . push (
258- commandRunner (
259- "codeQLDatabases.setCurrentDatabase" ,
223+ "codeQLDatabases.chooseDatabaseGithub" :
224+ this . handleChooseDatabaseGithub . bind ( this ) ,
225+ "codeQLDatabases.setCurrentDatabase" :
260226 this . handleMakeCurrentDatabase . bind ( this ) ,
261- ) ,
262- ) ;
263- this . push (
264- commandRunner (
265- "codeQLDatabases.sortByName" ,
266- this . handleSortByName . bind ( this ) ,
267- ) ,
268- ) ;
269- this . push (
270- commandRunner (
271- "codeQLDatabases.sortByDateAdded" ,
272- this . handleSortByDateAdded . bind ( this ) ,
273- ) ,
274- ) ;
275- this . push (
276- commandRunner (
277- "codeQLDatabases.removeDatabase" ,
278- this . handleRemoveDatabase . bind ( this ) ,
279- ) ,
280- ) ;
281- this . push (
282- commandRunner (
283- "codeQLDatabases.upgradeDatabase" ,
284- this . handleUpgradeDatabase . bind ( this ) ,
285- ) ,
286- ) ;
287- this . push (
288- commandRunner (
289- "codeQLDatabases.renameDatabase" ,
290- this . handleRenameDatabase . bind ( this ) ,
291- ) ,
292- ) ;
293- this . push (
294- commandRunner (
295- "codeQLDatabases.openDatabaseFolder" ,
296- this . handleOpenFolder . bind ( this ) ,
297- ) ,
298- ) ;
299- this . push (
300- commandRunner (
301- "codeQLDatabases.addDatabaseSource" ,
302- this . handleAddSource . bind ( this ) ,
303- ) ,
304- ) ;
305- this . push (
306- commandRunner (
307- "codeQLDatabases.removeOrphanedDatabases" ,
227+ "codeQLDatabases.sortByName" : this . handleSortByName . bind ( this ) ,
228+ "codeQLDatabases.sortByDateAdded" : this . handleSortByDateAdded . bind ( this ) ,
229+ "codeQLDatabases.removeDatabase" : this . handleRemoveDatabase . bind ( this ) ,
230+ "codeQLDatabases.upgradeDatabase" : this . handleUpgradeDatabase . bind ( this ) ,
231+ "codeQLDatabases.renameDatabase" : this . handleRenameDatabase . bind ( this ) ,
232+ "codeQLDatabases.openDatabaseFolder" : this . handleOpenFolder . bind ( this ) ,
233+ "codeQLDatabases.addDatabaseSource" : this . handleAddSource . bind ( this ) ,
234+ "codeQLDatabases.removeOrphanedDatabases" :
308235 this . handleRemoveOrphanedDatabases . bind ( this ) ,
309- ) ,
310- ) ;
236+ } ;
311237 }
312238
313239 private async handleMakeCurrentDatabase (
@@ -505,12 +431,10 @@ export class DatabaseUI extends DisposableObject {
505431 ) ;
506432 }
507433
508- private async handleChooseDatabaseInternet ( ) : Promise <
509- DatabaseItem | undefined
510- > {
434+ private async handleChooseDatabaseInternet ( ) : Promise < void > {
511435 return withProgress (
512436 async ( progress , token ) => {
513- return await this . chooseDatabaseInternet ( progress , token ) ;
437+ await this . chooseDatabaseInternet ( progress , token ) ;
514438 } ,
515439 {
516440 title : "Adding database from URL" ,
@@ -519,10 +443,11 @@ export class DatabaseUI extends DisposableObject {
519443 }
520444
521445 public async chooseDatabaseGithub (
522- credentials : Credentials | undefined ,
523446 progress : ProgressCallback ,
524447 token : CancellationToken ,
525448 ) : Promise < DatabaseItem | undefined > {
449+ const credentials = isCanary ( ) ? this . app . credentials : undefined ;
450+
526451 return await promptImportGithubDatabase (
527452 this . databaseManager ,
528453 this . storagePath ,
@@ -533,12 +458,10 @@ export class DatabaseUI extends DisposableObject {
533458 ) ;
534459 }
535460
536- private async handleChooseDatabaseGithub (
537- credentials : Credentials | undefined ,
538- ) : Promise < DatabaseItem | undefined > {
461+ private async handleChooseDatabaseGithub ( ) : Promise < void > {
539462 return withProgress (
540463 async ( progress , token ) => {
541- return await this . chooseDatabaseGithub ( credentials , progress , token ) ;
464+ await this . chooseDatabaseGithub ( progress , token ) ;
542465 } ,
543466 {
544467 title : "Adding database from GitHub" ,
0 commit comments