From 1c57fbae25f45a1a1e12b564428a1ce112b4a643 Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Wed, 19 Jul 2023 10:12:37 +0100 Subject: [PATCH] fix: Persist entire IOptions through results view Signed-off-by: Gordon Smith --- ecl-sample/.vscode/launch.json | 2 +- src/ecl/eclWatchPanelView.ts | 35 +++++++++++++++++----------------- src/eclwatch.tsx | 16 ++++------------ src/eclwatch/WUDetails.tsx | 20 +++++++------------ src/eclwatch/WUResult.tsx | 35 ++++++++++------------------------ src/eclwatch/messages.ts | 24 ++++++++++++++--------- 6 files changed, 55 insertions(+), 77 deletions(-) diff --git a/ecl-sample/.vscode/launch.json b/ecl-sample/.vscode/launch.json index 439a0ebf..c581e419 100644 --- a/ecl-sample/.vscode/launch.json +++ b/ecl-sample/.vscode/launch.json @@ -26,7 +26,7 @@ "serverAddress": "play.hpccsystems.com", "port": 18010, "targetCluster": "thor", - "rejectUnauthorized": true, + "rejectUnauthorized": false, "resultLimit": 100, "timeoutSecs": 60, "user": "vscode_user", diff --git a/src/ecl/eclWatchPanelView.ts b/src/ecl/eclWatchPanelView.ts index 60ce3f13..ec144b18 100644 --- a/src/ecl/eclWatchPanelView.ts +++ b/src/ecl/eclWatchPanelView.ts @@ -1,22 +1,12 @@ import * as vscode from "vscode"; import { send } from "@hpcc-js/comms"; import { hashSum } from "@hpcc-js/util"; -import { LaunchProtocol } from "../debugger/launchRequestArguments"; +import { LaunchRequestArguments } from "../debugger/launchRequestArguments"; import { wuDetailsUrl, wuResultUrl } from "../hpccplatform/launchConfig"; import { sessionManager } from "../hpccplatform/session"; import type { Messages } from "../eclwatch/messages"; -interface PartialLaunchRequestArgumentss { - protocol: LaunchProtocol; - serverAddress: string; - port: number; - path: string; - user?: string; - password?: string; - rejectUnauthorized?: boolean; -} - -interface NavigateParams extends PartialLaunchRequestArgumentss { +interface NavigateParams extends LaunchRequestArguments { wuid: string; result?: number; show: boolean; @@ -111,7 +101,7 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider { command: "proxyResponse", id: message.id, response - }); + } as Messages); delete abortControllers[message.id]; }); break; @@ -130,9 +120,9 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider { } private _prevHash: string; - navigateTo(launchRequestArgs: PartialLaunchRequestArgumentss, wuid: string, result?: number, show = true) { - const { protocol, serverAddress, port, path, user, password, rejectUnauthorized } = launchRequestArgs; - this._currParams = { protocol, serverAddress, port, path, user, password, rejectUnauthorized, wuid, result, show }; + navigateTo(launchRequestArgs: LaunchRequestArguments, wuid: string, result?: number, show = true) { + const { protocol, serverAddress, port, path, user, password, rejectUnauthorized, name, type, targetCluster } = launchRequestArgs; + this._currParams = { protocol, serverAddress, port, path, user, password, rejectUnauthorized, name, type, targetCluster, wuid, result, show }; if (!this._webviewView) { this._initialParams = this._currParams; if (show) { @@ -143,7 +133,18 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider { if (this._prevHash !== hash) { this._prevHash = hash; this._webviewView.title = this._currParams?.wuid; - this._webviewView.webview.postMessage({ command: "navigate", data: this._currParams }); + this._webviewView.webview.postMessage({ + command: "navigate", + data: { + baseUrl: this._currParams.protocol + "://" + this._currParams.serverAddress + ":" + this._currParams.port + "/", + userID: this._currParams.user, + password: this._currParams.password, + rejectUnauthorized: this._currParams.rejectUnauthorized, + timeoutSecs: this._currParams.timeoutSecs, + wuid: this._currParams.wuid, + result: this._currParams.result + } + } as Messages); if (show) { this._webviewView.show(true); } diff --git a/src/eclwatch.tsx b/src/eclwatch.tsx index 817bd312..e15c0ab1 100644 --- a/src/eclwatch.tsx +++ b/src/eclwatch.tsx @@ -2,8 +2,7 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import { WUDetails } from "./eclwatch/WUDetails"; import { ThemeProvider } from "./eclwatch/themeGenerator"; -import { join } from "@hpcc-js/util"; -import { LoadedMessage, Messages, ProxyCancelMessage, ProxySendMessage, State, vscode } from "./eclwatch/messages"; +import { LoadedMessage, ProxyCancelMessage, ProxySendMessage, State, vscode } from "./eclwatch/messages"; import { hookSend } from "@hpcc-js/comms"; const bodyStyles = window.getComputedStyle(document.body); @@ -75,11 +74,8 @@ function render(state: State) { if (state) { vscode.setState(state); ReactDOM.render(, placeholder); } @@ -92,13 +88,9 @@ function rerender() { // Local debugging without VS Code if (document.location.protocol === "file:") { render({ - protocol: "https", - serverAddress: "play.hpccsystems.com", - port: "18010", - path: "", - user: "gosmith", + baseUrl: "https://play.hpccsystems.com:18010", + userID: "gosmith", password: "", - rejectUnauthorized: false, wuid: "W20210304-144316" }); } diff --git a/src/eclwatch/WUDetails.tsx b/src/eclwatch/WUDetails.tsx index d956d864..6a97ae88 100644 --- a/src/eclwatch/WUDetails.tsx +++ b/src/eclwatch/WUDetails.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { Pivot, PivotItem, IPivotStyles, Spinner, initializeIcons, MessageBar, MessageBarType, IStyleFunctionOrObject, IPivotStyleProps } from "@fluentui/react"; -import { Workunit, WUInfo, Result } from "@hpcc-js/comms"; +import { Workunit, WUInfo, Result, IOptions } from "@hpcc-js/comms"; import { WUIssues, WUResult } from "./WUResult"; import { HolyGrail } from "./HolyGrail"; @@ -30,21 +30,15 @@ const getTabId = (itemKey: string) => { }; export interface WUDetailsProps { - baseUrl: string; - user: string; - password: string; + opts: IOptions; wuid: string; sequence?: number; - rejectUnauthorized: boolean; } export const WUDetails: React.FunctionComponent = ({ - baseUrl, - user, - password, + opts, wuid, sequence, - rejectUnauthorized }) => { const pivotRef = React.useRef(null); @@ -80,7 +74,7 @@ export const WUDetails: React.FunctionComponent = ({ if (wuid) { setSpinnerMessage("Loading..."); update(false, [], []); - const wu = Workunit.attach({ baseUrl, userID: user, password, rejectUnauthorized }, wuid); + const wu = Workunit.attach(opts, wuid); wu.refresh().then(() => { if (!canceled) { if (wu.isComplete()) { @@ -107,11 +101,11 @@ export const WUDetails: React.FunctionComponent = ({ return () => { canceled = true; }; - }, [baseUrl, wuid]); + }, [opts.baseUrl, wuid]); React.useEffect(() => { setSelectedKey(sequence === undefined ? "" + 0 : "" + sequence); - }, [baseUrl, wuid, sequence]); + }, [opts.baseUrl, wuid, sequence]); const hasIssues = exceptions.length > 0; const hasResults = results.length > 0; @@ -151,7 +145,7 @@ export const WUDetails: React.FunctionComponent = ({ main={selected === "issues" ? : hasResults ? - + : undefined } />; diff --git a/src/eclwatch/WUResult.tsx b/src/eclwatch/WUResult.tsx index ad2031eb..93d0536e 100644 --- a/src/eclwatch/WUResult.tsx +++ b/src/eclwatch/WUResult.tsx @@ -217,13 +217,9 @@ export class WUResultTable extends Common { this.renderHtml(false); } - @publish(undefined, "string", "URL to WsWorkunits") - baseUrl: { (): string, (_: string): WUResultTable }; - @publish(undefined, "string", "Workunit ID") - user: { (): string, (_: string): WUResultTable }; - @publish(undefined, "string", "User ID") - password: { (): string, (_: string): WUResultTable }; - @publish(undefined, "string", "Password") + @publish(undefined, "object", "IOptions") + opts: { (): IOptions, (_: IOptions): WUResultTable }; + @publish(undefined, "string", "Wuid") wuid: { (): string, (_: string): WUResultTable }; @publish(undefined, "string", "Result Name") resultName: { (): string, (_: string): WUResultTable }; @@ -235,17 +231,12 @@ export class WUResultTable extends Common { logicalFile: { (): string, (_: string): WUResultTable }; calcResult(): Result | null { - const opts: IOptions = { - baseUrl: this.baseUrl(), - userID: this.user(), - password: this.password() - }; if (this.wuid() && this.resultName()) { - return Result.attach(opts, this.wuid(), this.resultName()); + return Result.attach(this.opts(), this.wuid(), this.resultName()); } else if (this.wuid() && this.sequence() !== undefined) { - return Result.attach(opts, this.wuid(), this.sequence()); + return Result.attach(this.opts(), this.wuid(), this.sequence()); } else if (this.logicalFile()) { - return Result.attachLogicalFile(opts, this.cluster(), this.logicalFile()); + return Result.attachLogicalFile(this.opts(), this.cluster(), this.logicalFile()); } return null; } @@ -311,7 +302,7 @@ export class WUResultTable extends Common { update(domNode, element) { super.update(domNode, element); const hash = hashSum({ - wsWorkunitsUrl: this.baseUrl(), + opts: hashSum(this.opts()), wuid: this.wuid(), resultName: this.resultName(), sequence: this.sequence(), @@ -402,17 +393,13 @@ export class WUResultTable extends Common { WUResultTable.prototype._class += " eclwatch_WUResultTable"; interface WUResultProps { - baseUrl: string; - user: string; - password: string; + opts: IOptions; wuid: string; sequence: number; } export const WUResult: React.FunctionComponent = ({ - baseUrl, - user, - password, + opts, wuid, sequence, }) => { @@ -422,9 +409,7 @@ export const WUResult: React.FunctionComponent = ({ ).current; table - .baseUrl(baseUrl) - .user(user) - .password(password) + .opts(opts) .wuid(wuid) .sequence(sequence) ; diff --git a/src/eclwatch/messages.ts b/src/eclwatch/messages.ts index dcea7d48..1b95c894 100644 --- a/src/eclwatch/messages.ts +++ b/src/eclwatch/messages.ts @@ -1,11 +1,6 @@ -export interface State { - protocol: string; - serverAddress: string; - port: string; - path: string; - user: string; - password: string; - rejectUnauthorized: boolean; +import type { IOptions } from "@hpcc-js/comms"; + +export interface State extends IOptions { wuid: string; result?: number; } @@ -24,6 +19,11 @@ export interface Message { callbackID?: string; } +export interface NavigateMessage extends Message { + command: "navigate"; + data: State; +} + export interface LoadedMessage extends Message { command: "loaded"; } @@ -41,9 +41,15 @@ export interface ProxySendMessage extends Message { } } +export interface ProxyResponseMessage extends Message { + command: "proxyResponse"; + id: number; + response: any; +} + export interface ProxyCancelMessage extends Message { command: "proxyCancel"; id: number; } -export type Messages = LoadedMessage | ProxySendMessage | ProxyCancelMessage; +export type Messages = NavigateMessage | LoadedMessage | ProxySendMessage | ProxyResponseMessage | ProxyCancelMessage;