Skip to content

Commit 3ca1c49

Browse files
msivasubramaniaandgolovin
authored andcommitted
moved onDidChangeActiveColorTheme into webview instead of using vscode command
Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
1 parent 55fe540 commit 3ca1c49

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@
286286
"onCommand:clusters.openshift.deployment.openConsole",
287287
"onCommand:clusters.openshift.imagestream.openConsole",
288288
"onCommand:openshift.componentTypesView.registry.openInView",
289-
"onCommand:openshift.componentTypesView.registry.setTheme",
290289
"onWalkthrough:openshiftWalkthrough"
291290
],
292291
"contributes": {

src/extension.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {
1111
StatusBarAlignment,
1212
StatusBarItem,
1313
env,
14-
QuickPickItemKind,
15-
ColorTheme,
16-
ColorThemeKind
14+
QuickPickItemKind
1715
} from 'vscode';
1816
import path = require('path');
1917
import { startTelemetry } from './telemetry';
@@ -32,7 +30,6 @@ import { ComponentsTreeDataProvider } from './componentsView';
3230

3331
import fsx = require('fs-extra');
3432

35-
3633
// eslint-disable-next-line @typescript-eslint/no-empty-function
3734
// this method is called when your extension is deactivated
3835
export function deactivate(): void {
@@ -90,14 +87,6 @@ export async function activate(extensionContext: ExtensionContext): Promise<any>
9087
];
9188
disposable.forEach((value) => extensionContext.subscriptions.push(value));
9289

93-
let themeKind:ColorThemeKind = window.activeColorTheme.kind;
94-
window.onDidChangeActiveColorTheme((editor: ColorTheme) => {
95-
if (themeKind !== editor.kind) {
96-
themeKind = editor?.kind;
97-
void commands.executeCommand('openshift.componentTypesView.registry.setTheme', themeKind);
98-
}
99-
});
100-
10190
function statusBarFunctions() {
10291
return commands.registerCommand('openshift.openStatusBar', async () => {
10392
const selection = await window.showQuickPick(

src/webview/devfile-registry/registryViewLoader.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ import { Registry } from '../../odo/componentType';
1414

1515
let panel: vscode.WebviewPanel;
1616

17+
let themeKind: vscode.ColorThemeKind = vscode.window.activeColorTheme.kind;
18+
vscode.window.onDidChangeActiveColorTheme((editor: vscode.ColorTheme) => {
19+
if (themeKind !== editor.kind) {
20+
themeKind = editor.kind;
21+
if (panel) {
22+
panel.webview.postMessage({ action: 'setTheme', themeValue: themeKind });
23+
}
24+
}
25+
});
26+
1727
async function devfileRegistryViewerMessageListener(event: any): Promise<any> {
1828
let starterProject = event.selectedProject;
1929
switch (event?.action) {
@@ -118,13 +128,6 @@ export default class RegistryViewLoader {
118128
await RegistryViewLoader.loadView(`Devfile Registry - ${context.name}`, context.url);
119129
}
120130

121-
@vsCommand('openshift.componentTypesView.registry.setTheme')
122-
static async setTheme(kind: vscode.ColorThemeKind): Promise<void> {
123-
if (panel) {
124-
panel.webview.postMessage({ action: 'setTheme', themeValue: kind });
125-
}
126-
}
127-
128131
@vsCommand('openshift.componentTypesView.registry.closeView')
129132
static async closeRegistryInWebview(): Promise<void> {
130133
panel?.dispose();
@@ -156,7 +159,7 @@ function getAllComponents(eventActionName: string, url?: string, error?: string)
156159
action: eventActionName,
157160
compDescriptions: Array.from(componentDescriptions),
158161
registries: registries,
159-
themeValue: vscode.window.activeColorTheme.kind,
162+
themeValue: themeKind,
160163
errorMessage: error
161164
}
162165
);

0 commit comments

Comments
 (0)