Skip to content

Commit

Permalink
update progress windows with idf notificationMode
Browse files Browse the repository at this point in the history
  • Loading branch information
brianignacio5 committed Jan 26, 2024
1 parent 2d58ef0 commit 26a76f4
Show file tree
Hide file tree
Showing 17 changed files with 463 additions and 62 deletions.
16 changes: 11 additions & 5 deletions src/checkExtensionSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ import {
isCurrentInstallValid,
} from "./setup/setupInit";
import { Logger } from "./logger/logger";
import { readParameter } from "./idfConfiguration";
import { NotificationMode, readParameter } from "./idfConfiguration";
import { useIdfSetupSettings } from "./setup/setupValidation/espIdfSetup";
import { getIdfMd5sum } from "./setup/espIdfJson";
import { getEspIdfFromCMake } from "./utils";
import { IdfSetup } from "./views/setup/types";

export async function checkExtensionSettings(
extensionPath: string,
Expand All @@ -40,10 +37,19 @@ export async function checkExtensionSettings(
vscode.commands.executeCommand("espIdf.welcome.start");
return;
}
const notificationMode = readParameter(
"idf.notificationMode",
workspace
) as string;
const ProgressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? vscode.ProgressLocation.Notification
: vscode.ProgressLocation.Window;
await vscode.window.withProgress(
{
cancellable: false,
location: vscode.ProgressLocation.Notification,
location: ProgressLocation,
title: "ESP-IDF: Loading initial configuration...",
},
async (
Expand Down
20 changes: 18 additions & 2 deletions src/common/abstractCloning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,18 @@ export class AbstractCloning {
Logger.infoNotify(`${resultingPath} already exist.`);
return;
}
const notificationMode = idfConf.readParameter(
"idf.notificationMode"
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
location: progressLocation,
title: this.name,
},
async (
Expand Down Expand Up @@ -368,10 +376,18 @@ export class AbstractCloning {
public async getSubmodules(repoRootDir: string) {
const repoName = /[^/]*$/.exec(repoRootDir)[0];
OutputChannel.appendLine(`Downloading ${repoName} submodules`);
const notificationMode = idfConf.readParameter(
"idf.notificationMode"
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
location: progressLocation,
title: `Checking out ${repoName} submodules`,
},
async (
Expand Down
17 changes: 13 additions & 4 deletions src/component-manager/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { join } from "path";
import { Disposable, Uri, ViewColumn, WebviewPanel, window } from "vscode";
import { ESP } from "../config";
import { readParameter } from "../idfConfiguration";
import { NotificationMode, readParameter } from "../idfConfiguration";
import { addDependency, createProject } from "./utils";
import * as vscode from "vscode";

Expand Down Expand Up @@ -87,7 +87,7 @@ export class ComponentManagerUIPanel {
this.extensionPath = extensionPath;
this.panel.onDidDispose(() => this.dispose(), null, this.disposable);
this.panel.webview.onDidReceiveMessage(
async (message) => this.onMessage(message),
async (message) => this.onMessage(message, workspaceRoot),
null,
this.disposable
);
Expand All @@ -97,7 +97,7 @@ export class ComponentManagerUIPanel {
this.panel.webview.html = this.initWebView(url);
}

private async onMessage(message: IMessage) {
private async onMessage(message: IMessage, workspaceUri: Uri) {
switch (message.message) {
case "install":
if (!message.dependency) return;
Expand All @@ -117,9 +117,18 @@ export class ComponentManagerUIPanel {
if (!selectedFolder) {
return;
}
const notificationMode = readParameter(
"idf.notificationMode",
workspaceUri
) as string;
const ProgressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? vscode.ProgressLocation.Notification
: vscode.ProgressLocation.Window;
await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
location: ProgressLocation,
title: "ESP-IDF: Creating project...",
cancellable: false,
},
Expand Down
13 changes: 11 additions & 2 deletions src/coverage/configureProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import { extensionContext, getConfigValueFromSDKConfig, getEspIdfFromCMake } from "../utils";
import { readParameter } from "../idfConfiguration";
import { NotificationMode, readParameter } from "../idfConfiguration";
import { ConfserverProcess } from "../espIdf/menuconfig/confServerProcess";
import {
env,
Expand Down Expand Up @@ -81,10 +81,19 @@ export async function configureProjectWithGcov(workspacePath: Uri) {
if (response !== "Start") {
return;
}
const notificationMode = readParameter(
"idf.notificationMode",
workspacePath
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
location: progressLocation,
title: "ESP-IDF: Configuring coverage",
},
async (
Expand Down
16 changes: 14 additions & 2 deletions src/espIdf/menuconfig/MenuconfigPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Logger } from "../../logger/logger";
import { getWebViewFavicon } from "../../utils";
import { ConfserverProcess } from "./confServerProcess";
import { Menu } from "./Menu";
import { NotificationMode, readParameter } from "../../idfConfiguration";

const locDic = new LocDictionary(__filename);

Expand Down Expand Up @@ -136,7 +137,9 @@ export class MenuConfigPanel {
this.panel.webview.onDidReceiveMessage(async (message) => {
switch (message.command) {
case "updateValue":
ConfserverProcess.setUpdatedValue(JSON.parse(message.updated_value) as Menu);
ConfserverProcess.setUpdatedValue(
JSON.parse(message.updated_value) as Menu
);
break;
case "setDefault":
const changesNotSavedMessage = locDic.localize(
Expand All @@ -153,10 +156,19 @@ export class MenuConfigPanel {
{ title: noMsg, isCloseAffordance: true }
);
if (selected.title === yesMsg) {
const notificationMode = readParameter(
"idf.notificationMode",
this.curWorkspaceFolder
) as string;
const ProgressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? vscode.ProgressLocation.Notification
: vscode.ProgressLocation.Window;
vscode.window.withProgress(
{
cancellable: true,
location: vscode.ProgressLocation.Notification,
location: ProgressLocation,
title: "ESP-IDF: SDK Configuration editor",
},
async (
Expand Down
13 changes: 11 additions & 2 deletions src/espIdf/partition-table/partitionFlasher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { basename, join } from "path";
import { Progress, ProgressLocation, Uri, window } from "vscode";
import { readParameter } from "../../idfConfiguration";
import { NotificationMode, readParameter } from "../../idfConfiguration";
import { Logger } from "../../logger/logger";
import { appendIdfAndToolsToPath, spawn } from "../../utils";
import { OutputChannel } from "../../logger/outputChannel";
Expand All @@ -28,10 +28,19 @@ export async function flashBinaryToPartition(
binPath: string,
workspaceFolder: Uri
) {
const notificationMode = readParameter(
"idf.notificationMode",
workspaceFolder
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: false,
location: ProgressLocation.Notification,
location: progressLocation,
title: "ESP-IDF: Flashing binary to device",
},
async (progress: Progress<{ message: string; increment: number }>) => {
Expand Down
22 changes: 19 additions & 3 deletions src/espIdf/setTarget/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
ProgressLocation,
window,
} from "vscode";
import { readParameter, writeParameter } from "../../idfConfiguration";
import {
NotificationMode,
readParameter,
writeParameter,
} from "../../idfConfiguration";
import { Logger } from "../../logger/logger";
import { OutputChannel } from "../../logger/outputChannel";
import { getBoards, getOpenOcdScripts } from "../openOcd/boardConfiguration";
Expand All @@ -38,10 +42,19 @@ export async function setIdfTarget(placeHolderMsg: string) {
return;
}

const notificationMode = readParameter(
"idf.notificationMode",
workspaceFolder
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: false,
location: ProgressLocation.Notification,
location: progressLocation,
title: "ESP-IDF: Setting device target...",
},
async (progress: Progress<{ message: string; increment: number }>) => {
Expand Down Expand Up @@ -86,7 +99,10 @@ export async function setIdfTarget(placeHolderMsg: string) {
workspaceFolder.uri
);
const openOcdScriptsPath = getOpenOcdScripts(workspaceFolder.uri);
const boards = await getBoards(selectedTarget.target, openOcdScriptsPath);
const boards = await getBoards(
selectedTarget.target,
openOcdScriptsPath
);
const choices = boards.map((b) => {
return {
description: `${b.description} (${b.configFiles})`,
Expand Down
12 changes: 10 additions & 2 deletions src/espIdf/tracing/system-view/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,25 @@ import { AppTraceArchiveItems } from "../tree/appTraceArchiveTreeDataProvider";
import { window, ProgressLocation } from "vscode";
import { Logger } from "../../../logger/logger";
import { SystemViewPanel } from "./panel";
import { readJsonSync } from "fs-extra";
import { SysviewTraceProc } from "../tools/sysviewTraceProc";
import { NotificationMode, readParameter } from "../../../idfConfiguration";

export class SystemViewResultParser {
public static parseWithProgress(
trace: AppTraceArchiveItems,
extensionPath: string
) {
const notificationMode = readParameter(
"idf.notificationMode"
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
window.withProgress(
{
location: ProgressLocation.Notification,
location: progressLocation,
cancellable: false,
title:
"ESP-IDF: Processing your tracing file to generate System View Report",
Expand Down
34 changes: 29 additions & 5 deletions src/espMatter/espMatterDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,24 @@ export class EspMatterCloning extends AbstractCloning {
);
}

public async initEsp32PlatformSubmodules(espMatterDir: string) {
public async initEsp32PlatformSubmodules(
espMatterDir: string,
workspace: Uri
) {
OutputChannel.appendLine("Downloading Matter ESP32 platform submodules");
const notificationMode = readParameter(
"idf.notificationMode",
workspace
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
location: progressLocation,
title: "ESP-IDF: Installing ESP-Matter",
},
async (
Expand Down Expand Up @@ -254,10 +266,19 @@ export async function installPythonReqs(
confToolsPath ||
process.env.IDF_TOOLS_PATH ||
join(containerPath, ".espressif");
const notificationMode = readParameter(
"idf.notificationMode",
workspace
) as string;
const progressLocation =
notificationMode === NotificationMode.All ||
notificationMode === NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
await window.withProgress(
{
cancellable: true,
location: ProgressLocation.Notification,
location: progressLocation,
title: "ESP-IDF: Installing ESP-Matter",
},
async (
Expand All @@ -283,7 +304,7 @@ export async function installPythonReqs(
export async function getEspMatter(workspace?: Uri) {
const gitPath =
(await readParameter("idf.gitPath", workspace)) || "/usr/bin/git";
let espMatterPath;
let espMatterPath: string;
const espMatterInstaller = new EspMatterCloning(gitPath, workspace);
const installAllSubmodules = await window.showQuickPick(
[
Expand Down Expand Up @@ -312,7 +333,10 @@ export async function getEspMatter(workspace?: Uri) {
);
espMatterPath = readParameter("idf.espMatterPath", workspace);
await espMatterInstaller.getSubmodules(espMatterPath);
await espMatterInstaller.initEsp32PlatformSubmodules(espMatterPath);
await espMatterInstaller.initEsp32PlatformSubmodules(
espMatterPath,
workspace
);
await espMatterInstaller.startBootstrap(true);
}
await TaskManager.runTasks();
Expand Down
Loading

0 comments on commit 26a76f4

Please sign in to comment.