support for accesses in visualizer (#799)

This commit is contained in:
Michael Quigley 2024-12-05 16:05:57 -05:00
parent 8582077990
commit 87116b3ab1
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 40 additions and 1 deletions

17
ui100/src/AccessNode.tsx Normal file
View File

@ -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;

View File

@ -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([]);

View File

@ -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!
});
});
}
}
});