Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VSC-1478] Disable cmds for Codespaces and redirect Flash monitor to Web extension #1297

Merged
merged 7 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions l10n/bundle.l10n.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" has been updated": " ha sido actualizado",
"File project_description.json cannot be found.": "No se puede encontrar el archivo project_description.json.",
"Open a folder first.": "Primero abra una carpeta.",
"Selected command is not available in WebIDE": "El comando seleccionado no está disponible en WebIDE",
"Selected command is not available in Web": "El comando seleccionado no está disponible en Web",
"Use current folder: {workspace}": "Usar carpeta actual: {workspace}",
"Choose a container directory...": "Elija un directorio de contenedor...",
"Select a directory to use": "Seleccione un directorio para usar",
Expand Down Expand Up @@ -142,8 +142,8 @@
"This action will delete your project sdkconfig. Continue?": "Esta acción eliminará su proyecto sdkconfig. ",
"Saved changes in SDK Configuration editor": "Cambios guardados en el editor de configuración del SDK",
"Discarded changes in SDK Configuration editor": "Cambios descartados en el editor de configuración del SDK",
"Error encountered while adding dependency {dependency} to the component \"{component}\"": "Se encontró un error al agregar la dependencia {dependencia} al componente \"{componente}\"",
"Error encountered while creating project from example \"{example}\"": "Se encontró un error al crear un proyecto a partir del ejemplo \"{ejemplo}\"",
"Error encountered while adding dependency {dependency} to the component \"{component}\"": "Se encontró un error al agregar la dependencia {dependency} al componente \"{component}\"",
"Error encountered while creating project from example \"{example}\"": "Se encontró un error al crear un proyecto a partir del ejemplo \"{example}\"",
"Create ESP-IDF From Extension Templates": "Cree ESP-IDF a partir de plantillas de extensión",
"Install ESP-ADF": "Instalar ESP-ADF",
"Install ESP-MDF": "Instalar ESP-MDF",
Expand Down
2 changes: 1 addition & 1 deletion l10n/bundle.l10n.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" has been updated": " foi atualizado",
"File project_description.json cannot be found.": "O arquivo project_description.json não pode ser encontrado.",
"Open a folder first.": "Abra uma pasta primeiro.",
"Selected command is not available in WebIDE": "O comando selecionado não está disponível no WebIDE",
"Selected command is not available in Web": "O comando selecionado não está disponível no Web",
"Use current folder: {workspace}": "Use a pasta atual: {workspace}",
"Choose a container directory...": "Escolha um diretório de contêiner...",
"Select a directory to use": "Selecione um diretório para usar",
Expand Down
2 changes: 1 addition & 1 deletion l10n/bundle.l10n.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" has been updated": " был обновлен",
"File project_description.json cannot be found.": "Файл project_description.json не найден.",
"Open a folder first.": "Сначала откройте папку.",
"Selected command is not available in WebIDE": "Выбранная команда недоступна в WebIDE.",
"Selected command is not available in Web": "Выбранная команда недоступна в Web.",
"Use current folder: {workspace}": "Использовать текущую папку: {workspace}",
"Choose a container directory...": "Выберите каталог контейнера...",
"Select a directory to use": "Выберите каталог для использования",
Expand Down
2 changes: 1 addition & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" has been updated": " 已经升级",
"File project_description.json cannot be found.": "找不到文件project_description.json。",
"Open a folder first.": "先打开一个文件夹。",
"Selected command is not available in WebIDE": "所选命令在 WebIDE 中不可用",
"Selected command is not available in Web": "所选命令在 Web 中不可用",
"Use current folder: {workspace}": "使用当前文件夹:{workspace}",
"Choose a container directory...": "选择容器目录...",
"Select a directory to use": "选择要使用的目录",
Expand Down
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,8 @@
{
"command": "espIdf.selectPort",
"title": "%espIdf.selectPort.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.buildDevice",
Expand All @@ -1085,17 +1086,20 @@
{
"command": "espIdf.flashUart",
"title": "%espIdf.flashUart.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.flashDFU",
"title": "%espIdf.flashDFU.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.flashAndEncryptDevice",
"title": "%espIdf.flashAndEncryptDevice.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.monitorDevice",
Expand All @@ -1105,7 +1109,8 @@
{
"command": "espIdf.buildFlashMonitor",
"title": "%espIdf.buildFlashMonitor.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.pickAWorkspaceFolder",
Expand Down Expand Up @@ -1224,7 +1229,8 @@
{
"command": "espIdf.launchWSServerAndMonitor",
"category": "ESP-IDF",
"title": "%espIdf.launchWSServerAndMonitor.title%"
"title": "%espIdf.launchWSServerAndMonitor.title%",
"when": "!isWeb"
},
{
"command": "espIdf.searchInEspIdfDocs",
Expand Down Expand Up @@ -1285,12 +1291,14 @@
{
"command": "espIdf.jtag_flash",
"title": "%espIdf.jtag_flash.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.selectFlashMethodAndFlash",
"title": "%espIdf.selectFlashMethodAndFlash.title%",
"category": "ESP-IDF"
"category": "ESP-IDF",
"when": "!isWeb"
},
{
"command": "espIdf.fullClean",
Expand Down
5 changes: 5 additions & 0 deletions src/cmdTreeView/cmdStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export interface IDFCommandDescription {
tooltip: string;
}

export enum IDFWebCommandKeys {
Flash = "espIdfWeb.flash",
Monitor = "espIdfWeb.monitor"
}

export enum CommandKeys {
pickWorkspace = "espIdf.pickAWorkspaceFolder",
SelectCurrentIdfVersion = "espIdf.selectCurrentIdfVersion",
Expand Down
5 changes: 4 additions & 1 deletion src/espIdf/openOcd/openOcdManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export class OpenOCDManager extends EventEmitter {

private registerOpenOCDStatusBarItem() {
this.statusBar = vscode.window.createStatusBarItem(
CommandKeys.OpenOCD,
vscode.StatusBarAlignment.Right,
1000
);
Expand All @@ -303,7 +304,9 @@ export class OpenOCDManager extends EventEmitter {
}
this.chan = Buffer.alloc(0);
OutputChannel.init();
this.registerOpenOCDStatusBarItem();
if (vscode.env.uiKind !== vscode.UIKind.Web) {
this.registerOpenOCDStatusBarItem();
}
}

private sendToOutputChannel(data: Buffer) {
Expand Down
28 changes: 21 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ import {
createStatusBarItem,
statusBarItems,
} from "./statusBar";
import { CommandKeys, createCommandDictionary } from "./cmdTreeView/cmdStore";
import {
CommandKeys,
createCommandDictionary,
IDFWebCommandKeys,
} from "./cmdTreeView/cmdStore";

// Global variables shared by commands
let workspaceRoot: vscode.Uri;
Expand Down Expand Up @@ -208,7 +212,7 @@ let wsServer: WSServer;

const openFolderFirstMsg = vscode.l10n.t("Open a folder first.");
const cmdNotForWebIdeMsg = vscode.l10n.t(
"Selected command is not available in WebIDE"
"Selected command is not available in Web"
);
const openFolderCheck = [
PreCheck.isWorkspaceFolderOpen,
Expand Down Expand Up @@ -817,7 +821,7 @@ export async function activate(context: vscode.ExtensionContext) {
});

registerIDFCommand("espIdf.selectCurrentIdfVersion", () => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
PreCheck.perform([openFolderCheck], async () => {
const currentIdfSetup = await selectIdfSetup(
workspaceRoot,
statusBarItems["currentIdfVersion"]
Expand Down Expand Up @@ -2553,7 +2557,7 @@ export async function activate(context: vscode.ExtensionContext) {
});

registerIDFCommand("espIdf.debug", async () => {
PreCheck.perform([openFolderCheck], async () => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(
workspaceRoot
);
Expand Down Expand Up @@ -3701,7 +3705,12 @@ const flash = (
encryptPartition: boolean = false,
flashType?: ESP.FlashType
) => {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
PreCheck.perform([openFolderCheck], async () => {
// Re route to ESP-IDF Web extension if using Codespaces or Browser
if (vscode.env.uiKind === vscode.UIKind.Web) {
vscode.commands.executeCommand(IDFWebCommandKeys.Flash);
return;
}
const notificationMode = idfConf.readParameter(
"idf.notificationMode",
workspaceRoot
Expand Down Expand Up @@ -3904,7 +3913,7 @@ async function startFlashing(
}

function createIdfTerminal() {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
PreCheck.perform([openFolderCheck], async () => {
const modifiedEnv = await utils.appendIdfAndToolsToPath(workspaceRoot);
const espIdfTerminal = vscode.window.createTerminal({
name: "ESP-IDF Terminal",
Expand All @@ -3919,7 +3928,12 @@ function createIdfTerminal() {
}

function createMonitor() {
PreCheck.perform([webIdeCheck, openFolderCheck], async () => {
PreCheck.perform([openFolderCheck], async () => {
// Re route to ESP-IDF Web extension if using Codespaces or Browser
if (vscode.env.uiKind === vscode.UIKind.Web) {
vscode.commands.executeCommand(IDFWebCommandKeys.Monitor);
return;
}
const noReset = idfConf.readParameter(
"idf.monitorNoReset",
workspaceRoot
Expand Down
1 change: 1 addition & 0 deletions src/qemu/qemuManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class QemuManager extends EventEmitter {
private registerQemuStatusBarItem() {
if (!this._statusBarItem) {
this._statusBarItem = window.createStatusBarItem(
CommandKeys.QemuServer,
StatusBarAlignment.Right,
1005
);
Expand Down
96 changes: 51 additions & 45 deletions src/statusBar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*/

import {
l10n,
env,
StatusBarAlignment,
StatusBarItem,
TreeItemCheckboxState,
UIKind,
Uri,
window,
} from "vscode";
Expand Down Expand Up @@ -64,7 +65,6 @@ export async function createCmdsStatusBarItems(workspaceFolder: Uri) {
}
let currentIdfVersion = await getCurrentIdfSetup(workspaceFolder, false);


statusBarItems["workspace"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.pickWorkspace].iconId})`,
commandDictionary[CommandKeys.pickWorkspace].tooltip,
Expand All @@ -83,21 +83,25 @@ export async function createCmdsStatusBarItems(workspaceFolder: Uri) {
commandDictionary[CommandKeys.SelectCurrentIdfVersion].checkboxState
);

statusBarItems["flashType"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.SelectFlashType].iconId}) ${flashType}`,
commandDictionary[CommandKeys.SelectFlashType].tooltip,
CommandKeys.SelectFlashType,
101,
commandDictionary[CommandKeys.SelectFlashType].checkboxState
);
if (env.uiKind !== UIKind.Web) {
statusBarItems["flashType"] = createStatusBarItem(
`$(${
commandDictionary[CommandKeys.SelectFlashType].iconId
}) ${flashType}`,
commandDictionary[CommandKeys.SelectFlashType].tooltip,
CommandKeys.SelectFlashType,
101,
commandDictionary[CommandKeys.SelectFlashType].checkboxState
);

statusBarItems["port"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.SelectSerialPort].iconId}) ${port}`,
commandDictionary[CommandKeys.SelectSerialPort].tooltip,
CommandKeys.SelectSerialPort,
100,
commandDictionary[CommandKeys.SelectSerialPort].checkboxState
);
statusBarItems["port"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.SelectSerialPort].iconId}) ${port}`,
commandDictionary[CommandKeys.SelectSerialPort].tooltip,
CommandKeys.SelectSerialPort,
100,
commandDictionary[CommandKeys.SelectSerialPort].checkboxState
);
}

if (projectConf) {
statusBarItems["projectConf"] = createStatusBarItem(
Expand Down Expand Up @@ -141,34 +145,36 @@ export async function createCmdsStatusBarItems(workspaceFolder: Uri) {
95,
commandDictionary[CommandKeys.Build].checkboxState
);
statusBarItems["flash"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Flash].iconId})`,
commandDictionary[CommandKeys.Flash].tooltip,
CommandKeys.Flash,
94,
commandDictionary[CommandKeys.Flash].checkboxState
);
statusBarItems["monitor"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Monitor].iconId})`,
commandDictionary[CommandKeys.Monitor].tooltip,
CommandKeys.Monitor,
93,
commandDictionary[CommandKeys.Monitor].checkboxState
);
statusBarItems["debug"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Debug].iconId})`,
commandDictionary[CommandKeys.Debug].tooltip,
CommandKeys.Debug,
92,
commandDictionary[CommandKeys.Debug].checkboxState
);
statusBarItems["buildFlashMonitor"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.BuildFlashMonitor].iconId})`,
commandDictionary[CommandKeys.BuildFlashMonitor].tooltip,
CommandKeys.BuildFlashMonitor,
91,
commandDictionary[CommandKeys.BuildFlashMonitor].checkboxState
);
if (env.uiKind !== UIKind.Web) {
statusBarItems["flash"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Flash].iconId})`,
commandDictionary[CommandKeys.Flash].tooltip,
CommandKeys.Flash,
94,
commandDictionary[CommandKeys.Flash].checkboxState
);
statusBarItems["monitor"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Monitor].iconId})`,
commandDictionary[CommandKeys.Monitor].tooltip,
CommandKeys.Monitor,
93,
commandDictionary[CommandKeys.Monitor].checkboxState
);
statusBarItems["debug"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.Debug].iconId})`,
commandDictionary[CommandKeys.Debug].tooltip,
CommandKeys.Debug,
92,
commandDictionary[CommandKeys.Debug].checkboxState
);
statusBarItems["buildFlashMonitor"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.BuildFlashMonitor].iconId})`,
commandDictionary[CommandKeys.BuildFlashMonitor].tooltip,
CommandKeys.BuildFlashMonitor,
91,
commandDictionary[CommandKeys.BuildFlashMonitor].checkboxState
);
}
statusBarItems["terminal"] = createStatusBarItem(
`$(${commandDictionary[CommandKeys.IDFTerminal].iconId})`,
commandDictionary[CommandKeys.IDFTerminal].tooltip,
Expand All @@ -194,7 +200,7 @@ export function createStatusBarItem(
showItem: TreeItemCheckboxState
) {
const alignment: StatusBarAlignment = StatusBarAlignment.Left;
const statusBarItem = window.createStatusBarItem(alignment, priority);
const statusBarItem = window.createStatusBarItem(cmd, alignment, priority);
statusBarItem.text = icon;
statusBarItem.tooltip = tooltip;
statusBarItem.command = cmd;
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class PreCheck {
);
}
public static notUsingWebIde(): boolean {
if (vscode.env.uiKind === vscode.UIKind.Web) {
return false;
}
return process.env.WEB_IDE ? false : true;
}
public static openOCDVersionValidator(
Expand Down