Connect With Non-Terminal Widgets (#304)

- Adds connection buttons for previews
- Makes it possible for graphs and previews to connect on backend
(without a terminal open to connection)
- Changes the wsh install message
This commit is contained in:
Sylvie Crowe
2024-09-02 12:34:49 -07:00
committed by GitHub
parent 63cfe1d279
commit 226bc4ee6f
7 changed files with 99 additions and 10 deletions
+10 -1
View File
@@ -353,12 +353,21 @@ const ChangeConnectionBlockModal = React.memo(
}) => {
const [connSelected, setConnSelected] = React.useState("");
const changeConnModalOpen = jotai.useAtomValue(changeConnModalAtom);
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", blockId));
const changeConnection = React.useCallback(
async (connName: string) => {
const oldCwd = blockData?.meta?.file ?? "";
let newCwd: string;
if (oldCwd == "") {
newCwd = "";
} else {
newCwd = "~";
}
await WshServer.SetMetaCommand({
oref: WOS.makeORef("block", blockId),
meta: { connection: connName },
meta: { connection: connName, file: newCwd },
});
await services.BlockService.EnsureConnection(blockId).catch((e) => console.log(e));
await WshServer.ControllerRestartCommand({ blockid: blockId });
},
[blockId]
+3
View File
@@ -7,6 +7,9 @@ import * as WOS from "./wos";
// blockservice.BlockService (block)
class BlockServiceType {
EnsureConnection(arg2: string): Promise<void> {
return WOS.callBackendService("block", "EnsureConnection", Array.from(arguments))
}
GetControllerStatus(arg2: string): Promise<BlockControllerRuntimeStatus> {
return WOS.callBackendService("block", "GetControllerStatus", Array.from(arguments))
}
+2
View File
@@ -52,6 +52,7 @@ export class PreviewModel implements ViewModel {
previewTextRef: React.RefObject<HTMLDivElement>;
editMode: jotai.Atom<boolean>;
canPreview: jotai.PrimitiveAtom<boolean>;
manageConnection: jotai.Atom<boolean>;
fileName: jotai.Atom<string>;
connection: jotai.Atom<string>;
@@ -81,6 +82,7 @@ export class PreviewModel implements ViewModel {
this.ceReadOnly = jotai.atom(true);
this.canPreview = jotai.atom(false);
this.openFileModal = jotai.atom(false);
this.manageConnection = jotai.atom(true);
this.blockAtom = WOS.getWaveObjectAtom<Block>(`block:${blockId}`);
this.viewIcon = jotai.atom((get) => {
let blockData = get(this.blockAtom);