Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dash): add connector types legend #835

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -76,10 +76,10 @@ const edgeTypes = {
const LOCAL_STORAGE_KEY = 'nitric-local-dash-arch-options'

interface ArchOptions {
horizonal: boolean
isHorizontal: boolean
}

const defaultOptions: ArchOptions = { horizonal: false }
const defaultOptions: ArchOptions = { isHorizontal: false }

const getOptions = (): ArchOptions => {
try {
@@ -96,7 +96,7 @@ const setOptions = (options: ArchOptions) => {
}

function ReactFlowLayout() {
const [horizonal, setHorizonal] = useState(getOptions().horizonal)
const [isHorizontal, setIsHorizontal] = useState(getOptions().isHorizontal)
const { fitView } = useReactFlow()
const { data } = useWebSocket()
const [nodes, setNodes, onNodesChange] = useNodesState([])
@@ -112,12 +112,16 @@ function ReactFlowLayout() {

const { nodes, edges } = generateArchitectureData(data)

const layouted = getLayoutedElements(nodes, edges, horizonal ? 'LR' : 'TB')
const layouted = getLayoutedElements(
nodes,
edges,
isHorizontal ? 'LR' : 'TB',
)

setNodes([...layouted.nodes])
setEdges([...layouted.edges])

setOptions({ horizonal })
setOptions({ isHorizontal })

window.requestAnimationFrame(() => {
setTimeout(
@@ -130,7 +134,7 @@ function ReactFlowLayout() {
100, // ensure the diagram is 100% ready before re-fitting
)
})
}, [data, horizonal])
}, [data, isHorizontal])

return (
<AppLayout
@@ -167,15 +171,28 @@ function ReactFlowLayout() {
<Switch
id="horizontal-mode"
aria-label="Toggle Horizontal Mode"
checked={horizonal}
onCheckedChange={setHorizonal}
checked={isHorizontal}
onCheckedChange={setIsHorizontal}
/>
<Label htmlFor="horizontal-mode">Horizontal</Label>
</div>
<ExportButton projectName={data.projectName} />
</div>
</Panel>
)}
<Panel position="bottom-left" className="flex flex-col gap-y-1">
<div className="rounded-md border bg-white p-2">
<div className="mb-2 text-center text-xs font-semibold">
Connector Types
</div>
<div className="grid grid-cols-2 items-center gap-x-4 gap-y-2 text-xs font-semibold">
<span className="h-1 border-b-2 border-dashed border-black" />
<span>Triggers</span>
<span className="h-1 border-b-2 border-black" />
<span>Dependencies</span>
</div>
</div>
</Panel>
</ReactFlow>
</div>
</div>