feat(visualizer): adds enums support to the visualizer#339
feat(visualizer): adds enums support to the visualizer#339Rudra-Sankha-Sinhamahapatra wants to merge 19 commits intomainfrom
Conversation
|
This PR was not deployed automatically as @Rudra-Sankha-Sinhamahapatra does not have access to the Railway project. In order to get automatic PR deploys, please add @Rudra-Sankha-Sinhamahapatra to your workspace on Railway. |
There was a problem hiding this comment.
Pull request overview
Adds enum visualization support to the database visualizer so enum-typed columns can display their enum type and link to enum “nodes” in the graph (Issue #338).
Changes:
- Fetch enums data alongside tables/columns/constraints in the visualizer route.
- Extend graph generation to create enum nodes and enum-related edges.
- Update the React Flow node renderer to display enum nodes differently and hide the enum “anchor” row.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| apps/desktop/src/routes/_protected/database/$id/visualizer/index.tsx | Loads enums query data and passes it into layout generation. |
| apps/desktop/src/routes/_protected/database/$id/visualizer/-lib.ts | Adds enum nodes + edges and uses enums to alter column type display. |
| apps/desktop/src/entities/connection/components/react-flow-node.tsx | Renders enum nodes with a different icon/label and filters out the enum anchor row. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (columns && enums && schema) { | ||
| const schemaEnums = enums.filter(e => e.schema === schema) | ||
|
|
||
| columns.forEach((c) => { | ||
| const enumDef = c.enum | ||
| ? schemaEnums.find((e) => { | ||
| if (e.metadata?.table) { | ||
| return e.metadata.table === c.table && e.metadata.column === c.id | ||
| } | ||
|
|
||
| return e.id === c.enum || e.name === c.enum | ||
| }) |
There was a problem hiding this comment.
getEdges iterates over all columns passed in, but it does not filter by schema. Since Visualizer passes columns from all schemas, this can create enum edges from tables in other schemas to enums in the currently selected schema (and potentially reference non-existent nodes). Filter constraints/columns to the current schema (and ideally to schemaTables) before building edges.
Description of Changes
Added enums support to the visualizer
so that enum field type shows on row and added enums card on visualizer
Closes #338 (If applicable, delete this line if not)
Checklist
Notes to reviewer
Need to verify edgecases though
one enum with two tables
two different enums with same name for different tables