From fb22c5958317ad2badd6ab9c9d5095dfafa54f64 Mon Sep 17 00:00:00 2001 From: MFA-X-AI Date: Thu, 5 Sep 2024 02:07:23 +0900 Subject: [PATCH] trigger remote run config fetch on config.ini save --- src/XircuitsFactory.ts | 3 +++ src/XircuitsWidget.tsx | 3 +++ src/commands/CommandIDs.tsx | 3 ++- src/components/XircuitsBodyWidget.tsx | 4 +++- src/index.tsx | 14 ++++++++++++-- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/XircuitsFactory.ts b/src/XircuitsFactory.ts index 7bdd8d0c..0c52d4aa 100644 --- a/src/XircuitsFactory.ts +++ b/src/XircuitsFactory.ts @@ -37,6 +37,7 @@ export class XircuitsFactory extends ABCWidgetFactory { commands: any; serviceManager: ServiceManager; fetchComponentsSignal: Signal; + fetchRemoteRunConfigSignal: Signal; saveXircuitSignal: Signal; compileXircuitSignal: Signal; runXircuitSignal: Signal; @@ -55,6 +56,7 @@ export class XircuitsFactory extends ABCWidgetFactory { this.commands = options.commands; this.serviceManager = options.serviceManager; this.fetchComponentsSignal = new Signal(this); + this.fetchRemoteRunConfigSignal = new Signal(this); this.saveXircuitSignal = new Signal(this); this.compileXircuitSignal = new Signal(this); this.runXircuitSignal = new Signal(this); @@ -76,6 +78,7 @@ export class XircuitsFactory extends ABCWidgetFactory { context: context, serviceManager: this.serviceManager, fetchComponentsSignal: this.fetchComponentsSignal, + fetchRemoteRunConfigSignal: this.fetchRemoteRunConfigSignal, saveXircuitSignal: this.saveXircuitSignal, compileXircuitSignal: this.compileXircuitSignal, runXircuitSignal: this.runXircuitSignal, diff --git a/src/XircuitsWidget.tsx b/src/XircuitsWidget.tsx index efae8349..04e334d0 100644 --- a/src/XircuitsWidget.tsx +++ b/src/XircuitsWidget.tsx @@ -18,6 +18,7 @@ export class XircuitsPanel extends ReactWidget { xircuitsApp: XircuitsApplication; serviceManager: ServiceManager; fetchComponentsSignal: Signal; + fetchRemoteRunConfigSignal: Signal; saveXircuitSignal: Signal; compileXircuitSignal: Signal; runXircuitSignal: Signal; @@ -38,6 +39,7 @@ export class XircuitsPanel extends ReactWidget { this.context = options.context; this.serviceManager = options.serviceManager; this.fetchComponentsSignal = options.fetchComponentsSignal; + this.fetchRemoteRunConfigSignal = options.fetchRemoteRunConfigSignal; this.saveXircuitSignal = options.saveXircuitSignal; this.compileXircuitSignal = options.compileXircuitSignal; this.runXircuitSignal = options.runXircuitSignal; @@ -89,6 +91,7 @@ export class XircuitsPanel extends ReactWidget { widgetId={this.parent?.id} serviceManager={this.serviceManager} fetchComponentsSignal={this.fetchComponentsSignal} + fetchRemoteRunConfigSignal={this.fetchRemoteRunConfigSignal} saveXircuitSignal={this.saveXircuitSignal} compileXircuitSignal={this.compileXircuitSignal} runXircuitSignal={this.runXircuitSignal} diff --git a/src/commands/CommandIDs.tsx b/src/commands/CommandIDs.tsx index bb6ba790..474883b1 100644 --- a/src/commands/CommandIDs.tsx +++ b/src/commands/CommandIDs.tsx @@ -37,5 +37,6 @@ export const commandIDs = { refreshComponentList: "xircuits-sidebar:refresh-component-list", toggleDisplayNodesInLibrary: "xircuits-sidebar:toggle-display-nodes-in-library", helpOpenResource: "xircuits-help:open-resource", - openXircuitsConfiguration: "xircuits-config:open-config" + openXircuitsConfiguration: "xircuits-config:open-config", + fetchRemoteRunConfig: "xircuits-config:fetch-remote-config" }; \ No newline at end of file diff --git a/src/components/XircuitsBodyWidget.tsx b/src/components/XircuitsBodyWidget.tsx index d3b98eb1..a7774b01 100644 --- a/src/components/XircuitsBodyWidget.tsx +++ b/src/components/XircuitsBodyWidget.tsx @@ -44,6 +44,7 @@ export interface BodyWidgetProps { widgetId?: string; serviceManager: ServiceManager; fetchComponentsSignal: Signal; + fetchRemoteRunConfigSignal: Signal; saveXircuitSignal: Signal; compileXircuitSignal: Signal; runXircuitSignal: Signal; @@ -81,6 +82,7 @@ export const BodyWidget: FC = ({ commands, widgetId, fetchComponentsSignal, + fetchRemoteRunConfigSignal, saveXircuitSignal, compileXircuitSignal, runXircuitSignal, @@ -859,6 +861,7 @@ export const BodyWidget: FC = ({ [saveXircuitSignal, handleSaveClick], [compileXircuitSignal, handleCompileClick], [runXircuitSignal, handleRunClick], + [fetchRemoteRunConfigSignal, getRemoteRunTypeFromConfig], [lockNodeSignal, handleLockClick], [triggerLoadingAnimationSignal, triggerLoadingAnimation], [reloadAllNodesSignal, handleReloadAll], @@ -878,7 +881,6 @@ export const BodyWidget: FC = ({ runTypeXircuitSignal.connect((_, args) => { runType = args["runType"]; setRunType(runType) - // console.log(runType) }); }, [runTypeXircuitSignal]) diff --git a/src/index.tsx b/src/index.tsx index 760c2845..03073a63 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -176,14 +176,16 @@ const xircuits: JupyterFrontEndPlugin = { {label: "Run Xircuits", icon: runIcon, execute: emitSignal(widgetFactory.runXircuitSignal)}], [commandIDs.compileXircuit, {execute: emitSignal(widgetFactory.compileXircuitSignal)}], - [commandIDs.lockXircuit, + [commandIDs.fetchRemoteRunConfig, + {execute: emitSignal(widgetFactory.fetchRemoteRunConfigSignal)}], + [commandIDs.lockXircuit, {execute: emitSignal(widgetFactory.lockNodeSignal)}], [commandIDs.triggerLoadingAnimation, {execute: emitSignal(widgetFactory.triggerLoadingAnimationSignal)}], [commandIDs.reloadAllNodes, {execute: emitSignal(widgetFactory.reloadAllNodesSignal)}], [commandIDs.toggleAllLinkAnimation, - {execute: emitSignal(widgetFactory.toggleAllLinkAnimationSignal)}], + {execute: emitSignal(widgetFactory.toggleAllLinkAnimationSignal)}] ] signalConnections.forEach(([cmdId, def]) => app.commands.addCommand(cmdId, def)) @@ -288,6 +290,14 @@ const xircuits: JupyterFrontEndPlugin = { } }); } + + if (context.path.endsWith('config.ini')) { + context.fileChanged.connect(async () => { + if(context.path.startsWith(".xircuits/")){ + await app.commands.execute(commandIDs.fetchRemoteRunConfig); + } + }); + } }); let outputPanel: OutputPanel;