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

Update flowchart on Kedro/LSP server restart #99

Merged
merged 1 commit into from
Sep 10, 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
8 changes: 8 additions & 0 deletions src/common/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import * as fs from 'fs-extra';
import * as path from 'path';
import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient/node';
import { LogLevel, Uri, WorkspaceFolder } from 'vscode';
import { Trace } from 'vscode-jsonrpc/node';
import { getWorkspaceFolders } from './vscodeapi';
import { callPythonScript } from './callPythonScript';
import { EXTENSION_ROOT_DIR } from './constants';
import { traceError, traceLog } from './log/logging';
import { executeGetProjectDataCommand } from './commands';
import KedroVizPanel from '../webview/vizWebView';

function logLevelToTrace(logLevel: LogLevel): Trace {
switch (logLevel) {
Expand Down Expand Up @@ -90,3 +93,8 @@ export async function installDependenciesIfNeeded(context: vscode.ExtensionConte
}
}
}

export async function updateKedroVizPanel(lsClient: LanguageClient | undefined): Promise<void> {
const projectData = await executeGetProjectDataCommand(lsClient);
KedroVizPanel.currentPanel?.updateData(projectData);
}
10 changes: 7 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { restartServer } from './common/server';
import { checkIfConfigurationChanged, getInterpreterFromSetting } from './common/settings';
import { loadServerDefaults } from './common/setup';
import { createStatusBar } from './common/status_bar';
import { getLSClientTraceLevel, installDependenciesIfNeeded } from './common/utilities';
import { getLSClientTraceLevel, installDependenciesIfNeeded, updateKedroVizPanel } from './common/utilities';
import { createOutputChannel, onDidChangeConfiguration, registerCommand } from './common/vscodeapi';
import KedroVizPanel from './webview/vizWebView';

Expand Down Expand Up @@ -71,8 +71,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
context.subscriptions.push(
registerCommand(CMD_RUN_KEDRO_VIZ, async () => {
KedroVizPanel.createOrShow(context.extensionUri);
const projectData = await executeGetProjectDataCommand(lsClient);
KedroVizPanel.currentPanel?.updateData(projectData);
updateKedroVizPanel(lsClient);
}),
);

Expand Down Expand Up @@ -126,6 +125,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}),
registerCommand(CMD_RESTART_SERVER, async () => {
await runServer();

// If KedroVizPanel is open, update the data on server restart
if (KedroVizPanel.currentPanel) {
updateKedroVizPanel(lsClient);
}
}),
registerCommand(CMD_SELECT_ENV, async () => {
const result = await selectEnvironment();
Expand Down