Skip to content

Commit

Permalink
Use ISC icon for webviews (#1331)
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano authored Mar 13, 2024
1 parent 019a39d commit 0a446be
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 28 deletions.
9 changes: 2 additions & 7 deletions src/commands/documaticPreviewPanel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { classNameRegex } from "../utils";
import { clsLangId } from "../extension";
import { clsLangId, iscIcon } from "../extension";

/**
* The schema of the message that gets sent to the webview.
Expand Down Expand Up @@ -84,6 +84,7 @@ export class DocumaticPreviewPanel {
localResourceRoots: [webviewFolderUri],
}
);
panel.iconPath = iscIcon;

this.currentPanel = new DocumaticPreviewPanel(panel, webviewFolderUri, openEditor);
}
Expand All @@ -92,12 +93,6 @@ export class DocumaticPreviewPanel {
this._panel = panel;
this._editor = editor;

// Update the panel's icon
this._panel.iconPath = {
dark: vscode.Uri.joinPath(webviewFolderUri, "preview-dark.svg"),
light: vscode.Uri.joinPath(webviewFolderUri, "preview-light.svg"),
};

// Set the webview's initial content
this.setWebviewHtml(webviewFolderUri);

Expand Down
2 changes: 2 additions & 0 deletions src/commands/restDebugPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as httpsModule from "https";
import * as vscode from "vscode";
import { AtelierAPI } from "../api";
import { cspAppsForUri, outputChannel } from "../utils";
import { iscIcon } from "../extension";

interface WebviewMessage {
/** Whether this message was triggered by the user pressing the 'Start Debugging' button */
Expand Down Expand Up @@ -137,6 +138,7 @@ export class RESTDebugPanel {
localResourceRoots: [webviewFolderUri],
}
);
panel.iconPath = iscIcon;

this._file = openEditor.document.uri;
this.currentPanel = new RESTDebugPanel(panel, webviewFolderUri, api, restWebApps);
Expand Down
3 changes: 2 additions & 1 deletion src/commands/studio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { AtelierAPI } from "../api";
import { config, filesystemSchemas } from "../extension";
import { config, filesystemSchemas, iscIcon } from "../extension";
import { outputChannel, outputConsole, getServerName } from "../utils";
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
import { ClassNode } from "../explorer/models/classNode";
Expand Down Expand Up @@ -157,6 +157,7 @@ export class StudioActions {
enableScripts: true,
}
);
panel.iconPath = iscIcon;
panel.webview.onDidReceiveMessage((message) => {
if (message.result && message.result === "done") {
answer = "1";
Expand Down
15 changes: 6 additions & 9 deletions src/commands/webSocketTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import WebSocket = require("ws");

import { AtelierAPI } from "../api";
import { connectionTarget, currentFile, outputChannel } from "../utils";
import { config, resolveConnectionSpec } from "../extension";
import { config, iscIcon, resolveConnectionSpec } from "../extension";

const keys = {
enter: "\r",
Expand Down Expand Up @@ -609,7 +609,6 @@ function reportError(msg: string, throwErrors = false) {

function terminalConfigForUri(
api: AtelierAPI,
extensionUri: vscode.Uri,
targetUri: vscode.Uri,
throwErrors = false
): vscode.ExtensionTerminalOptions | undefined {
Expand All @@ -635,7 +634,7 @@ function terminalConfigForUri(
: vscode.TerminalLocation.Panel,
pty: new WebSocketTerminal(api),
isTransient: true,
iconPath: vscode.Uri.joinPath(extensionUri, "images", "fileIcon.svg"),
iconPath: iscIcon,
};
}

Expand All @@ -659,7 +658,7 @@ async function workspaceUriForTerminal(throwErrors = false) {
return uri;
}

export async function launchWebSocketTerminal(extensionUri: vscode.Uri, targetUri?: vscode.Uri): Promise<void> {
export async function launchWebSocketTerminal(targetUri?: vscode.Uri): Promise<void> {
// Determine the server to connect to
if (targetUri) {
// Uri passed as command argument might be for a server we haven't yet resolve connection details such as password,
Expand All @@ -679,7 +678,7 @@ export async function launchWebSocketTerminal(extensionUri: vscode.Uri, targetUr
await api.serverInfo();

// Get the terminal configuration
const terminalOpts = terminalConfigForUri(api, extensionUri, targetUri);
const terminalOpts = terminalConfigForUri(api, targetUri);
if (terminalOpts) {
// Launch the terminal
const terminal = vscode.window.createTerminal(terminalOpts);
Expand All @@ -688,15 +687,13 @@ export async function launchWebSocketTerminal(extensionUri: vscode.Uri, targetUr
}

export class WebSocketTerminalProfileProvider implements vscode.TerminalProfileProvider {
constructor(private readonly _extensionUri: vscode.Uri) {}

async provideTerminalProfile(_token: vscode.CancellationToken): Promise<vscode.TerminalProfile> {
async provideTerminalProfile(): Promise<vscode.TerminalProfile> {
// Determine the server connection to use
const uri: vscode.Uri = await workspaceUriForTerminal(true);

if (uri) {
// Get the terminal configuration. Will throw if there's an error.
const terminalOpts = terminalConfigForUri(new AtelierAPI(uri), this._extensionUri, uri, true);
const terminalOpts = terminalConfigForUri(new AtelierAPI(uri), uri, true);
return new vscode.TerminalProfile(terminalOpts);
} else {
throw new Error("WebSocket Terminal requires a selected workspace folder.");
Expand Down
11 changes: 6 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export let panel: vscode.StatusBarItem;
export let posPanel: vscode.StatusBarItem;
export const terminals: vscode.Terminal[] = [];
export let xmlContentProvider: XmlContentProvider;
export let iscIcon: vscode.Uri;

import TelemetryReporter from "vscode-extension-telemetry";
import { CodeActionProvider } from "./providers/CodeActionProvider";
Expand Down Expand Up @@ -782,6 +783,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
// Show the proposed API prompt if required
proposedApiPrompt(proposed.length > 0);

iscIcon = vscode.Uri.joinPath(context.extensionUri, "images", "fileIcon.svg");

context.subscriptions.push(
reporter,
panel,
Expand Down Expand Up @@ -1298,22 +1301,20 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
}),
vscode.commands.registerCommand("vscode-objectscript.modifyWsFolder", modifyWsFolder),
vscode.commands.registerCommand("vscode-objectscript.openErrorLocation", openErrorLocation),
vscode.commands.registerCommand("vscode-objectscript.launchWebSocketTerminal", () =>
launchWebSocketTerminal(context.extensionUri)
),
vscode.commands.registerCommand("vscode-objectscript.launchWebSocketTerminal", () => launchWebSocketTerminal()),
vscode.commands.registerCommand(
"vscode-objectscript.intersystems-servermanager.webterminal",
(namespaceTreeItem) => {
const idArray = namespaceTreeItem.id.split(":");
const serverId = idArray[1];
const namespace = idArray[3];
const targetUri = vscode.Uri.from({ scheme: "isfs", authority: `${serverId}:${namespace}` });
launchWebSocketTerminal(context.extensionUri, targetUri);
launchWebSocketTerminal(targetUri);
}
),
vscode.window.registerTerminalProfileProvider(
"vscode-objectscript.webSocketTerminal",
new WebSocketTerminalProfileProvider(context.extensionUri)
new WebSocketTerminalProfileProvider()
),
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
// Show the proposed API prompt if required
Expand Down
3 changes: 0 additions & 3 deletions webview/preview-dark.svg

This file was deleted.

3 changes: 0 additions & 3 deletions webview/preview-light.svg

This file was deleted.

0 comments on commit 0a446be

Please sign in to comment.