Merge pull request #2195 from github/koesie10/move-database-commands
Move remaining local database commands to databases UI
This commit is contained in:
@@ -78,27 +78,42 @@ export type QueryHistoryCommands = {
|
|||||||
|
|
||||||
// Commands used for the local databases panel
|
// Commands used for the local databases panel
|
||||||
export type LocalDatabasesCommands = {
|
export type LocalDatabasesCommands = {
|
||||||
"codeQL.setCurrentDatabase": (uri: Uri) => Promise<void>;
|
// Command palette commands
|
||||||
"codeQL.setDefaultTourDatabase": () => Promise<void>;
|
"codeQL.chooseDatabaseFolder": () => Promise<void>;
|
||||||
|
"codeQL.chooseDatabaseArchive": () => Promise<void>;
|
||||||
|
"codeQL.chooseDatabaseInternet": () => Promise<void>;
|
||||||
|
"codeQL.chooseDatabaseGithub": () => Promise<void>;
|
||||||
"codeQL.upgradeCurrentDatabase": () => Promise<void>;
|
"codeQL.upgradeCurrentDatabase": () => Promise<void>;
|
||||||
"codeQL.clearCache": () => Promise<void>;
|
"codeQL.clearCache": () => Promise<void>;
|
||||||
|
|
||||||
|
// Explorer context menu
|
||||||
|
"codeQL.setCurrentDatabase": (uri: Uri) => Promise<void>;
|
||||||
|
|
||||||
|
// Database panel view title commands
|
||||||
"codeQLDatabases.chooseDatabaseFolder": () => Promise<void>;
|
"codeQLDatabases.chooseDatabaseFolder": () => Promise<void>;
|
||||||
"codeQLDatabases.chooseDatabaseArchive": () => Promise<void>;
|
"codeQLDatabases.chooseDatabaseArchive": () => Promise<void>;
|
||||||
"codeQLDatabases.chooseDatabaseInternet": () => Promise<void>;
|
"codeQLDatabases.chooseDatabaseInternet": () => Promise<void>;
|
||||||
"codeQLDatabases.chooseDatabaseGithub": () => Promise<void>;
|
"codeQLDatabases.chooseDatabaseGithub": () => Promise<void>;
|
||||||
|
"codeQLDatabases.sortByName": () => Promise<void>;
|
||||||
|
"codeQLDatabases.sortByDateAdded": () => Promise<void>;
|
||||||
|
|
||||||
|
// Database panel context menu
|
||||||
"codeQLDatabases.setCurrentDatabase": (
|
"codeQLDatabases.setCurrentDatabase": (
|
||||||
databaseItem: DatabaseItem,
|
databaseItem: DatabaseItem,
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
"codeQLDatabases.sortByName": () => Promise<void>;
|
|
||||||
"codeQLDatabases.sortByDateAdded": () => Promise<void>;
|
|
||||||
"codeQLDatabases.removeOrphanedDatabases": () => Promise<void>;
|
|
||||||
|
|
||||||
|
// Database panel selection commands
|
||||||
"codeQLDatabases.removeDatabase": SelectionCommandFunction<DatabaseItem>;
|
"codeQLDatabases.removeDatabase": SelectionCommandFunction<DatabaseItem>;
|
||||||
"codeQLDatabases.upgradeDatabase": SelectionCommandFunction<DatabaseItem>;
|
"codeQLDatabases.upgradeDatabase": SelectionCommandFunction<DatabaseItem>;
|
||||||
"codeQLDatabases.renameDatabase": SelectionCommandFunction<DatabaseItem>;
|
"codeQLDatabases.renameDatabase": SelectionCommandFunction<DatabaseItem>;
|
||||||
"codeQLDatabases.openDatabaseFolder": SelectionCommandFunction<DatabaseItem>;
|
"codeQLDatabases.openDatabaseFolder": SelectionCommandFunction<DatabaseItem>;
|
||||||
"codeQLDatabases.addDatabaseSource": SelectionCommandFunction<DatabaseItem>;
|
"codeQLDatabases.addDatabaseSource": SelectionCommandFunction<DatabaseItem>;
|
||||||
|
|
||||||
|
// Codespace template commands
|
||||||
|
"codeQL.setDefaultTourDatabase": () => Promise<void>;
|
||||||
|
|
||||||
|
// Internal commands
|
||||||
|
"codeQLDatabases.removeOrphanedDatabases": () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Commands tied to variant analysis
|
// Commands tied to variant analysis
|
||||||
|
|||||||
@@ -951,49 +951,6 @@ async function activateWithInstalledDistribution(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.subscriptions.push(
|
|
||||||
commandRunnerWithProgress(
|
|
||||||
"codeQL.chooseDatabaseFolder",
|
|
||||||
(progress: ProgressCallback, token: CancellationToken) =>
|
|
||||||
databaseUI.chooseDatabaseFolder(progress, token),
|
|
||||||
{
|
|
||||||
title: "Choose a Database from a Folder",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
ctx.subscriptions.push(
|
|
||||||
commandRunnerWithProgress(
|
|
||||||
"codeQL.chooseDatabaseArchive",
|
|
||||||
(progress: ProgressCallback, token: CancellationToken) =>
|
|
||||||
databaseUI.chooseDatabaseArchive(progress, token),
|
|
||||||
{
|
|
||||||
title: "Choose a Database from an Archive",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
ctx.subscriptions.push(
|
|
||||||
commandRunnerWithProgress(
|
|
||||||
"codeQL.chooseDatabaseGithub",
|
|
||||||
async (progress: ProgressCallback, token: CancellationToken) => {
|
|
||||||
await databaseUI.chooseDatabaseGithub(progress, token);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Adding database from GitHub",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
ctx.subscriptions.push(
|
|
||||||
commandRunnerWithProgress(
|
|
||||||
"codeQL.chooseDatabaseInternet",
|
|
||||||
(progress: ProgressCallback, token: CancellationToken) =>
|
|
||||||
databaseUI.chooseDatabaseInternet(progress, token),
|
|
||||||
|
|
||||||
{
|
|
||||||
title: "Adding database from URL",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
ctx.subscriptions.push(
|
ctx.subscriptions.push(
|
||||||
commandRunner("codeQL.copyVersion", async () => {
|
commandRunner("codeQL.copyVersion", async () => {
|
||||||
const text = `CodeQL extension version: ${
|
const text = `CodeQL extension version: ${
|
||||||
|
|||||||
@@ -208,6 +208,13 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
|
|
||||||
public getCommands(): LocalDatabasesCommands {
|
public getCommands(): LocalDatabasesCommands {
|
||||||
return {
|
return {
|
||||||
|
"codeQL.chooseDatabaseFolder":
|
||||||
|
this.handleChooseDatabaseFolderFromPalette.bind(this),
|
||||||
|
"codeQL.chooseDatabaseArchive":
|
||||||
|
this.handleChooseDatabaseArchiveFromPalette.bind(this),
|
||||||
|
"codeQL.chooseDatabaseInternet":
|
||||||
|
this.handleChooseDatabaseInternet.bind(this),
|
||||||
|
"codeQL.chooseDatabaseGithub": this.handleChooseDatabaseGithub.bind(this),
|
||||||
"codeQL.setCurrentDatabase": this.handleSetCurrentDatabase.bind(this),
|
"codeQL.setCurrentDatabase": this.handleSetCurrentDatabase.bind(this),
|
||||||
"codeQL.setDefaultTourDatabase":
|
"codeQL.setDefaultTourDatabase":
|
||||||
this.handleSetDefaultTourDatabase.bind(this),
|
this.handleSetDefaultTourDatabase.bind(this),
|
||||||
@@ -242,7 +249,7 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
|
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async chooseDatabaseFolder(
|
private async chooseDatabaseFolder(
|
||||||
progress: ProgressCallback,
|
progress: ProgressCallback,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -268,6 +275,17 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async handleChooseDatabaseFolderFromPalette(): Promise<void> {
|
||||||
|
return withProgress(
|
||||||
|
async (progress, token) => {
|
||||||
|
await this.chooseDatabaseFolder(progress, token);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Choose a Database from a Folder",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private async handleSetDefaultTourDatabase(): Promise<void> {
|
private async handleSetDefaultTourDatabase(): Promise<void> {
|
||||||
return withProgress(
|
return withProgress(
|
||||||
async (progress, token) => {
|
async (progress, token) => {
|
||||||
@@ -392,7 +410,7 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async chooseDatabaseArchive(
|
private async chooseDatabaseArchive(
|
||||||
progress: ProgressCallback,
|
progress: ProgressCallback,
|
||||||
token: CancellationToken,
|
token: CancellationToken,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
@@ -418,23 +436,27 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async chooseDatabaseInternet(
|
private async handleChooseDatabaseArchiveFromPalette(): Promise<void> {
|
||||||
progress: ProgressCallback,
|
return withProgress(
|
||||||
token: CancellationToken,
|
async (progress, token) => {
|
||||||
): Promise<DatabaseItem | undefined> {
|
await this.chooseDatabaseArchive(progress, token);
|
||||||
return await promptImportInternetDatabase(
|
},
|
||||||
this.databaseManager,
|
{
|
||||||
this.storagePath,
|
title: "Choose a Database from an Archive",
|
||||||
progress,
|
},
|
||||||
token,
|
|
||||||
this.queryServer?.cliServer,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleChooseDatabaseInternet(): Promise<void> {
|
private async handleChooseDatabaseInternet(): Promise<void> {
|
||||||
return withProgress(
|
return withProgress(
|
||||||
async (progress, token) => {
|
async (progress, token) => {
|
||||||
await this.chooseDatabaseInternet(progress, token);
|
await promptImportInternetDatabase(
|
||||||
|
this.databaseManager,
|
||||||
|
this.storagePath,
|
||||||
|
progress,
|
||||||
|
token,
|
||||||
|
this.queryServer?.cliServer,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Adding database from URL",
|
title: "Adding database from URL",
|
||||||
@@ -442,26 +464,19 @@ export class DatabaseUI extends DisposableObject {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async chooseDatabaseGithub(
|
|
||||||
progress: ProgressCallback,
|
|
||||||
token: CancellationToken,
|
|
||||||
): Promise<DatabaseItem | undefined> {
|
|
||||||
const credentials = isCanary() ? this.app.credentials : undefined;
|
|
||||||
|
|
||||||
return await promptImportGithubDatabase(
|
|
||||||
this.databaseManager,
|
|
||||||
this.storagePath,
|
|
||||||
credentials,
|
|
||||||
progress,
|
|
||||||
token,
|
|
||||||
this.queryServer?.cliServer,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async handleChooseDatabaseGithub(): Promise<void> {
|
private async handleChooseDatabaseGithub(): Promise<void> {
|
||||||
return withProgress(
|
return withProgress(
|
||||||
async (progress, token) => {
|
async (progress, token) => {
|
||||||
await this.chooseDatabaseGithub(progress, token);
|
const credentials = isCanary() ? this.app.credentials : undefined;
|
||||||
|
|
||||||
|
await promptImportGithubDatabase(
|
||||||
|
this.databaseManager,
|
||||||
|
this.storagePath,
|
||||||
|
credentials,
|
||||||
|
progress,
|
||||||
|
token,
|
||||||
|
this.queryServer?.cliServer,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Adding database from GitHub",
|
title: "Adding database from GitHub",
|
||||||
|
|||||||
Reference in New Issue
Block a user