Move all progress reporting into extension packs file

This commit is contained in:
Koen Vlaswinkel
2023-04-12 10:13:08 +02:00
parent 035456cd31
commit cdb6e8a3d3
2 changed files with 26 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ import { join } from "path";
import { App } from "../common/app";
import { showAndLogErrorMessage } from "../helpers";
import { withProgress } from "../progress";
import { pickExtensionPack, pickModelFile } from "./extension-packs";
import { pickExtensionPackModelFile } from "./extension-packs";
export class DataExtensionsEditorModule {
private readonly queryStorageDir: string;
@@ -67,19 +67,10 @@ export class DataExtensionsEditorModule {
return;
}
const extensionPackPath = await pickExtensionPack(
const modelFile = await pickExtensionPackModelFile(
this.cliServer,
progress,
);
if (!extensionPackPath) {
return;
}
const modelFile = await pickModelFile(
this.cliServer,
progress,
extensionPackPath,
);
if (!modelFile) {
return;
}

View File

@@ -4,14 +4,33 @@ import { CodeQLCliServer } from "../cli";
import { getOnDiskWorkspaceFolders, showAndLogErrorMessage } from "../helpers";
import { ProgressCallback } from "../progress";
export async function pickExtensionPack(
const maxStep = 3;
export async function pickExtensionPackModelFile(
cliServer: CodeQLCliServer,
progress: ProgressCallback,
): Promise<string | undefined> {
const extensionPackPath = await pickExtensionPack(cliServer, progress);
if (!extensionPackPath) {
return;
}
const modelFile = await pickModelFile(cliServer, progress, extensionPackPath);
if (!modelFile) {
return;
}
return modelFile;
}
async function pickExtensionPack(
cliServer: CodeQLCliServer,
progress: ProgressCallback,
): Promise<string | undefined> {
progress({
message: "Resolving extension packs...",
step: 1,
maxStep: 3,
maxStep,
});
// Get all existing extension packs in the workspace
@@ -25,7 +44,7 @@ export async function pickExtensionPack(
progress({
message: "Choosing extension pack...",
step: 2,
maxStep: 3,
maxStep,
});
const extensionPackOption = await window.showQuickPick(options, {
@@ -53,7 +72,7 @@ export async function pickExtensionPack(
return extensionPackPaths[0];
}
export async function pickModelFile(
async function pickModelFile(
cliServer: CodeQLCliServer,
progress: ProgressCallback,
extensionPackPath: string,
@@ -84,7 +103,7 @@ export async function pickModelFile(
progress({
message: "Choosing model file...",
step: 3,
maxStep: 3,
maxStep,
});
const fileOption = await window.showQuickPick(fileOptions, {