From 4fccb70c194ccfdd87791b4f37de05f03413bc6e Mon Sep 17 00:00:00 2001 From: Noel Cothren Date: Thu, 5 Dec 2024 16:17:17 -0700 Subject: [PATCH 1/3] add confluent logo as webview icon --- resources/confluent-logo-dark.svg | 4 ++++ resources/confluent-logo-light.svg | 4 ++++ src/directConnect.ts | 8 +++++++- src/webview-cache.ts | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 resources/confluent-logo-dark.svg create mode 100644 resources/confluent-logo-light.svg diff --git a/resources/confluent-logo-dark.svg b/resources/confluent-logo-dark.svg new file mode 100644 index 000000000..b4011b892 --- /dev/null +++ b/resources/confluent-logo-dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/confluent-logo-light.svg b/resources/confluent-logo-light.svg new file mode 100644 index 000000000..d19da7efc --- /dev/null +++ b/resources/confluent-logo-light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/directConnect.ts b/src/directConnect.ts index 332b635c2..5072e45df 100644 --- a/src/directConnect.ts +++ b/src/directConnect.ts @@ -1,11 +1,12 @@ import { randomUUID } from "crypto"; -import { ViewColumn, window } from "vscode"; +import { ViewColumn, window, Uri } from "vscode"; import { KafkaClusterConfig, SchemaRegistryConfig } from "./clients/sidecar"; import { DirectConnectionManager } from "./directConnectManager"; import { WebviewPanelCache } from "./webview-cache"; import { handleWebviewMessage } from "./webview/comms/comms"; import { post } from "./webview/direct-connect-form"; import connectionFormTemplate from "./webview/direct-connect-form.html"; +import { getExtensionContext } from "./context/extension"; type MessageSender = OverloadUnion; type MessageResponse = Awaited< @@ -15,6 +16,7 @@ type MessageResponse = Awaited< const directConnectWebviewCache = new WebviewPanelCache(); export function openDirectConnectionForm(): void { + const context = getExtensionContext(); // Set up the webview, checking for existing form for this connection const [directConnectForm, formExists] = directConnectWebviewCache.findOrCreate( { id: randomUUID(), multiple: false, template: connectionFormTemplate }, // TODO change the UUID handling when we start allowing Edit @@ -24,6 +26,10 @@ export function openDirectConnectionForm(): void { { enableScripts: true, }, + { + light: Uri.joinPath(context.extensionUri, "resources/confluent-logo-dark.svg"), + dark: Uri.joinPath(context.extensionUri, "resources/confluent-logo-light.svg"), + }, ); if (formExists) { diff --git a/src/webview-cache.ts b/src/webview-cache.ts index 07e9ef618..43a0b7259 100644 --- a/src/webview-cache.ts +++ b/src/webview-cache.ts @@ -33,6 +33,18 @@ export class WebviewPanelCache { title: string, viewColumn: vscode.ViewColumn, options: vscode.WebviewOptions, + iconPath?: + | vscode.Uri + | { + /** + * The icon path for the light theme. + */ + light: vscode.Uri; + /** + * The icon path for the dark theme. + */ + dark: vscode.Uri; + }, ): [vscode.WebviewPanel, boolean] { const { id, multiple = false, template } = config; @@ -53,6 +65,10 @@ export class WebviewPanelCache { localResourceRoots: [staticRoot, ...(options.localResourceRoots ?? [])], }); + if (iconPath) { + panel.iconPath = iconPath; + } + // …initialize its template… panel.webview.html = template({ cspSource: panel.webview.cspSource, From 7d21f02a4d05b19f9015baa4b4ad3b19e9594513 Mon Sep 17 00:00:00 2001 From: Noel Cothren Date: Fri, 6 Dec 2024 11:37:44 -0700 Subject: [PATCH 2/3] use logo in all webviews --- src/directConnect.ts | 8 +------- src/webview-cache.ts | 19 ++++--------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/directConnect.ts b/src/directConnect.ts index 5072e45df..332b635c2 100644 --- a/src/directConnect.ts +++ b/src/directConnect.ts @@ -1,12 +1,11 @@ import { randomUUID } from "crypto"; -import { ViewColumn, window, Uri } from "vscode"; +import { ViewColumn, window } from "vscode"; import { KafkaClusterConfig, SchemaRegistryConfig } from "./clients/sidecar"; import { DirectConnectionManager } from "./directConnectManager"; import { WebviewPanelCache } from "./webview-cache"; import { handleWebviewMessage } from "./webview/comms/comms"; import { post } from "./webview/direct-connect-form"; import connectionFormTemplate from "./webview/direct-connect-form.html"; -import { getExtensionContext } from "./context/extension"; type MessageSender = OverloadUnion; type MessageResponse = Awaited< @@ -16,7 +15,6 @@ type MessageResponse = Awaited< const directConnectWebviewCache = new WebviewPanelCache(); export function openDirectConnectionForm(): void { - const context = getExtensionContext(); // Set up the webview, checking for existing form for this connection const [directConnectForm, formExists] = directConnectWebviewCache.findOrCreate( { id: randomUUID(), multiple: false, template: connectionFormTemplate }, // TODO change the UUID handling when we start allowing Edit @@ -26,10 +24,6 @@ export function openDirectConnectionForm(): void { { enableScripts: true, }, - { - light: Uri.joinPath(context.extensionUri, "resources/confluent-logo-dark.svg"), - dark: Uri.joinPath(context.extensionUri, "resources/confluent-logo-light.svg"), - }, ); if (formExists) { diff --git a/src/webview-cache.ts b/src/webview-cache.ts index 43a0b7259..81904b49d 100644 --- a/src/webview-cache.ts +++ b/src/webview-cache.ts @@ -33,18 +33,6 @@ export class WebviewPanelCache { title: string, viewColumn: vscode.ViewColumn, options: vscode.WebviewOptions, - iconPath?: - | vscode.Uri - | { - /** - * The icon path for the light theme. - */ - light: vscode.Uri; - /** - * The icon path for the dark theme. - */ - dark: vscode.Uri; - }, ): [vscode.WebviewPanel, boolean] { const { id, multiple = false, template } = config; @@ -65,9 +53,10 @@ export class WebviewPanelCache { localResourceRoots: [staticRoot, ...(options.localResourceRoots ?? [])], }); - if (iconPath) { - panel.iconPath = iconPath; - } + panel.iconPath = { + light: vscode.Uri.joinPath(context.extensionUri, "resources/confluent-logo-dark.svg"), + dark: vscode.Uri.joinPath(context.extensionUri, "resources/confluent-logo-light.svg"), + }; // …initialize its template… panel.webview.html = template({ From d7f4d6649d82737f744b8398ac998e0af1a033d9 Mon Sep 17 00:00:00 2001 From: Noel Cothren Date: Fri, 6 Dec 2024 11:40:18 -0700 Subject: [PATCH 3/3] remove duplicate light logo --- resources/confluent-logo-light.svg | 4 ---- src/webview-cache.ts | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 resources/confluent-logo-light.svg diff --git a/resources/confluent-logo-light.svg b/resources/confluent-logo-light.svg deleted file mode 100644 index d19da7efc..000000000 --- a/resources/confluent-logo-light.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/webview-cache.ts b/src/webview-cache.ts index 81904b49d..7f902cc6f 100644 --- a/src/webview-cache.ts +++ b/src/webview-cache.ts @@ -55,7 +55,7 @@ export class WebviewPanelCache { panel.iconPath = { light: vscode.Uri.joinPath(context.extensionUri, "resources/confluent-logo-dark.svg"), - dark: vscode.Uri.joinPath(context.extensionUri, "resources/confluent-logo-light.svg"), + dark: vscode.Uri.joinPath(context.extensionUri, "resources/confluent-logo.svg"), }; // …initialize its template…