Home / Function/ getLayoutedElementsViaLocalStorage() — supabase Function Reference

getLayoutedElementsViaLocalStorage() — supabase Function Reference

Architecture documentation for the getLayoutedElementsViaLocalStorage() function in Schemas.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  1e123e3a_d836_584b_bf4a_e372fc253ab3["getLayoutedElementsViaLocalStorage()"]
  c873669a_f88c_bb16_2076_ffa1fc0fc1a7["getGraphDataFromTables()"]
  c873669a_f88c_bb16_2076_ffa1fc0fc1a7 -->|calls| 1e123e3a_d836_584b_bf4a_e372fc253ab3
  style 1e123e3a_d836_584b_bf4a_e372fc253ab3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Database/Schemas/Schemas.utils.ts lines 202–234

const getLayoutedElementsViaLocalStorage = (
  nodes: Node[],
  edges: Edge[],
  positions: { [key: string]: { x: number; y: number } }
) => {
  // [Joshen] Potentially look into auto fitting new nodes?
  // https://github.com/xyflow/xyflow/issues/1113

  const nodesWithNoSavedPositons = nodes.filter((n) => !(n.id in positions))
  let newNodeCount = 0
  let basePosition = {
    x: 0,
    y: -(NODE_SEP + TABLE_NODE_ROW_HEIGHT + nodesWithNoSavedPositons.length * 10),
  }

  nodes.forEach((node) => {
    const existingPosition = positions?.[node.id]

    node.targetPosition = Position.Left
    node.sourcePosition = Position.Right

    if (existingPosition) {
      node.position = existingPosition
    } else {
      node.position = {
        x: basePosition.x + newNodeCount * 10,
        y: basePosition.y + newNodeCount * 10,
      }
      newNodeCount += 1
    }
  })
  return { nodes, edges }
}

Subdomains

Frequently Asked Questions

What does getLayoutedElementsViaLocalStorage() do?
getLayoutedElementsViaLocalStorage() is a function in the supabase codebase.
What calls getLayoutedElementsViaLocalStorage()?
getLayoutedElementsViaLocalStorage() is called by 1 function(s): getGraphDataFromTables.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free