Skip to content

Commit

Permalink
Merge branch 'main' into vizwebview
Browse files Browse the repository at this point in the history
  • Loading branch information
noklam authored Aug 22, 2024
2 parents d160119 + ed5efbc commit d1933f1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/common/commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { QuickPickItem, window } from 'vscode';
import * as fs from 'fs';
import { QuickPickItem, window } from 'vscode';
import * as vscode from 'vscode';

import { getWorkspaceFolders } from './vscodeapi';
import { LanguageClient, LanguageClientOptions, ServerOptions, State, integer } from 'vscode-languageclient/node';
export async function selectEnvironment() {
Expand Down Expand Up @@ -97,3 +98,4 @@ export async function executeServerDefinitionCommand(lsClient: LanguageClient |
});
}
}

23 changes: 23 additions & 0 deletions src/common/status_bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as vscode from 'vscode';
import {
getWorkspaceSettings,
} from './settings';
import { getProjectRoot } from './utilities';

export async function createStatusBar(commandName: string, serverId:string): Promise<vscode.StatusBarItem>{
// Create a status bar item
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
statusBarItem.command = commandName;
// https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration
const projectRoot = await getProjectRoot();
const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true);
let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings.

if (workspaceSetting.environment) {
environment = workspaceSetting.environment;
}

statusBarItem.text = `$(kedro-logo) ${environment}`;
statusBarItem.show();
return statusBarItem;
}
38 changes: 13 additions & 25 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { selectEnvironment, executeServerCommand, executeServerDefinitionCommand } from './common/commands';
import * as vscode from 'vscode';
import { selectEnvironment, executeServerCommand, executeServerDefinitionCommand } from './common/commands';
import { LanguageClient } from 'vscode-languageclient/node';
import { registerLogger, traceError, traceLog, traceVerbose } from './common/log/logging';
import {
Expand All @@ -12,15 +12,10 @@ import {
resolveInterpreter,
} from './common/python';
import { restartServer } from './common/server';
import {
checkIfConfigurationChanged,
getExtensionSettings,
getGlobalSettings,
getInterpreterFromSetting,
getWorkspaceSettings,
} from './common/settings';
import { checkIfConfigurationChanged, getInterpreterFromSetting } from './common/settings';
import { loadServerDefaults } from './common/setup';
import { getLSClientTraceLevel, getProjectRoot } from './common/utilities';
import { createStatusBar } from './common/status_bar';
import { getLSClientTraceLevel } from './common/utilities';
import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi';
import KedroVizPanel from './webview/vizWebView';
import { runKedroVizServer } from './webview/vizServer';
Expand All @@ -35,10 +30,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const serverName = serverInfo.name;
const serverId = serverInfo.module;

// Log Server information
traceLog(`Name: ${serverInfo.name}`);
traceLog(`Module: ${serverInfo.module}`);
traceVerbose(`Full Server Info: ${JSON.stringify(serverInfo)}`);

// List of commands
const CMD_RESTART_SERVER = `${serverId}.restart`;
const CMD_SELECT_ENV = `${serverId}.selectEnvironment`;

// Status Bar
const statusBarItem = await createStatusBar(CMD_SELECT_ENV, serverId);
context.subscriptions.push(statusBarItem);

// Setup logging
const outputChannel = createOutputChannel(serverName);
context.subscriptions.push(outputChannel, registerLogger(outputChannel));
Expand Down Expand Up @@ -108,22 +112,6 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
);
};

// Create a status bar item
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
statusBarItem.command = CMD_SELECT_ENV;
// https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration
const projectRoot = await getProjectRoot();
const workspaceSetting = await getWorkspaceSettings(serverId, projectRoot, true);
let environment = 'base'; // todo: Assume base, better to take this from server as it could be changed in project settings.

if (workspaceSetting.environment) {
environment = workspaceSetting.environment;
}

statusBarItem.text = `$(kedro-logo) ${environment}`;
statusBarItem.show();
context.subscriptions.push(statusBarItem);

context.subscriptions.push(
onDidChangePythonInterpreter(async () => {
await runServer();
Expand Down

0 comments on commit d1933f1

Please sign in to comment.