Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire up some more
Browse files Browse the repository at this point in the history
oleavr committed Sep 11, 2024
1 parent 8df90b4 commit 96dde25
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ui/tracer/src/App.tsx
Original file line number Diff line number Diff line change
@@ -7,17 +7,19 @@ import useWebSocket from "react-use-websocket";

function App() {
const [handlers, setHandlers] = useState<Handler[]>([]);
const [selectedScope, setSelectedScope] = useState("");
const [selectedHandler, setSelectedHandler] = useState(-1);
const [handlerCode, setHandlerCode] = useState("");
const { sendJsonMessage, lastJsonMessage } = useWebSocket<TracerMessage>("ws://localhost:1337" /* window.location.origin */);

const scopes = handlers.reduce((result, { scope }) => result.add(scope), new Set<string>());
const handlerNodes: TreeNodeInfo[] = Array.from(scopes).map(scope => {
const isExpanded = scope === selectedScope;
return {
id: scope,
label: labelFromScope(scope),
isExpanded: true,
icon: "folder-open",
isExpanded,
icon: isExpanded ? "folder-open" : "folder-close",
childNodes: handlers
.filter(h => h.scope === scope)
.map(({ id, display_name }) => {
@@ -32,8 +34,12 @@ function App() {
});

function onNodeClick(node: TreeNodeInfo) {
setSelectedHandler(node.id as number);
sendJsonMessage({ type: "load-handler", id: node.id });
if (typeof node.id === "string") {
setSelectedScope((selectedScope !== node.id) ? node.id : "");
} else {
setSelectedHandler(node.id as number);
sendJsonMessage({ type: "load-handler", id: node.id });
}
}

const editorOptions: Monaco.editor.IStandaloneEditorConstructionOptions = {

0 comments on commit 96dde25

Please sign in to comment.