Skip to content

Commit

Permalink
support for accesses in visualizer (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Dec 5, 2024
1 parent 8582077 commit 87116b3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ui100/src/AccessNode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Handle, Position} from "@xyflow/react";
import {Grid2} from "@mui/material";
import AccessIcon from "@mui/icons-material/Lan";

const AccessNode = ({ data }) => {
return (
<>
<Handle type="target" position={Position.Top} />
<Grid2 container sx={{ flexGrow: 1, p: 1 }} alignItems="center">
<Grid2 display="flex"><AccessIcon sx={{ fontSize: 15, mr: 0.5 }}/></Grid2>
<Grid2 display="flex">{data.label}</Grid2>
</Grid2>
</>
);
}

export default AccessNode;
8 changes: 7 additions & 1 deletion ui100/src/Visualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ import {stratify, tree} from "d3-hierarchy";
import ShareNode from "./ShareNode.tsx";
import EnvironmentNode from "./EnvironmentNode.tsx";
import AccountNode from "../AccountNode.tsx";
import AccessNode from "./AccessNode.tsx";

interface VisualizerProps {
overview: VisualOverview;
}

const nodeTypes = { account: AccountNode, environment: EnvironmentNode, share: ShareNode };
const nodeTypes = {
access: AccessNode,
account: AccountNode,
environment: EnvironmentNode,
share: ShareNode
};

const Visualizer = ({ overview }: VisualizerProps) => {
const [nodes, setNodes, onNodesChange] = useNodesState([]);
Expand Down
16 changes: 16 additions & 0 deletions ui100/src/model/visualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ const buildVisualizerGraph = (overview: Overview): VisualOverview => {
});
});
}
if(env.frontends) {
envNode.data.empty = false;
env.frontends.forEach(acc => {
out.nodes.push({
id: acc.token!,
position: { x: 0, y: 0 },
data: { label: acc.token! },
type: "access",
});
out.edges.push({
id: env.environment?.zId + "-" + acc.token!,
source: env.environment?.zId!,
target: acc.token!
});
});
}
}
});

Expand Down

0 comments on commit 87116b3

Please sign in to comment.