Skip to content
Merged
Show file tree
Hide file tree
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
124 changes: 0 additions & 124 deletions .github/workflows/agent-deep-modeling.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,4 @@ jobs:
with:
persist-credentials: false
- uses: ./.github/actions/pnpm-setup
- run: pnpm --filter @liam-hq/db supabase:start
- run: cp .env.template .env
- name: Make scripts executable
run: chmod +x ./scripts/extract-supabase-anon-key.sh ./scripts/extract-supabase-service-key.sh
- run: ./scripts/extract-supabase-anon-key.sh
- run: ./scripts/extract-supabase-service-key.sh
- run: pnpm test
- run: pnpm --filter @liam-hq/db supabase:gen
- name: Check for diff in generated types and schema.sql
env:
# check two files.
GENERATED_FILES: "frontend/internal-packages/db/supabase/database.types.ts frontend/internal-packages/db/supabase/schemas/schema.sql"
run: |
if ! git diff HEAD --ignore-space-at-eol --exit-code ${{ env.GENERATED_FILES }}; then
echo "Generated types and schema.sql differ from committed files."
exit 1
else
echo "Generated types and schema.sql are up-to-date."
exit 0
fi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Table } from '@dlh/erd-viewer-schema'
import { useStore } from '@xyflow/react'
import { type FC, useCallback, useEffect, useRef } from 'react'
import { useVersionOrThrow } from '../../../../../../../providers'
import {
Expand All @@ -18,6 +19,8 @@ import { Indexes } from './Indexes'
import { RelatedTables } from './RelatedTables'
import styles from './TableDetail.module.css'

const MIN_ZOOM_FOR_COLUMN_FOCUS = 1.5

type Props = {
table: Table
}
Expand All @@ -34,9 +37,28 @@ export const TableDetail: FC<Props> = ({ table }) => {
showMode: 'TABLE_NAME',
})

const { getNodes, getEdges, setNodes, setEdges, fitView } =
const { getNodes, getEdges, setNodes, setEdges, fitView, setCenter } =
useCustomReactflow()
const { version } = useVersionOrThrow()
const zoomLevel = useStore((store) => store.transform[2])

const handleColumnClick = useCallback(
(_columnName: string) => {
const mainPaneNodes = getNodes()
const tableNode = mainPaneNodes.find((node) => node.id === table.name)

if (tableNode) {
const targetZoom = Math.max(zoomLevel, MIN_ZOOM_FOR_COLUMN_FOCUS)
const nodeX =
tableNode.position.x + (tableNode.measured?.width ?? 0) / 2
const nodeY =
tableNode.position.y + (tableNode.measured?.height ?? 0) / 2

setCenter(nodeX, nodeY, { zoom: targetZoom, duration: 300 })
}
},
[getNodes, table.name, zoomLevel, setCenter],
)

const handleOpenMainPane = useCallback(async () => {
const visibleNodeIds: string[] = nodes.map((node) => node.id)
Expand Down Expand Up @@ -96,7 +118,7 @@ export const TableDetail: FC<Props> = ({ table }) => {
<Head table={table} />
<div className={styles.body}>
{table.comment && <Comment table={table} />}
<Columns table={table} />
<Columns table={table} onColumnClick={handleColumnClick} />
<Indexes tableId={table.name} indexes={table.indexes} />
<Constraints table={table} />
<div className={styles.relatedTables}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,30 @@ export const TableDetailDrawerRoot: FC<PropsWithChildren> = ({ children }) => {
}
}

// Also stop propagation on click events to prevent ReactFlow from
// triggering fitView when clicking outside the drawer to close it
const handleClickOutsideClick = (event: MouseEvent) => {
if (!(event.target instanceof Element)) {
return
}

if (
drawerRef.current &&
!drawerRef.current.contains(event.target) &&
open
) {
event.stopPropagation()
}
}

if (open) {
document.addEventListener('mousedown', handleClickOutside, true)
document.addEventListener('click', handleClickOutsideClick, true)
}

return () => {
document.removeEventListener('mousedown', handleClickOutside, true)
document.removeEventListener('click', handleClickOutsideClick, true)
}
}, [open, handleClose])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { highlightNodesAndEdges } from '../../utils'
type SelectTableParams = {
tableId: string
displayArea: DisplayArea
skipFitView?: boolean
}

export const useTableSelection = () => {
Expand All @@ -16,7 +17,11 @@ export const useTableSelection = () => {
useCustomReactflow()

const selectTable = useCallback(
async ({ tableId, displayArea }: SelectTableParams) => {
async ({
tableId,
displayArea,
skipFitView = false,
}: SelectTableParams) => {
setActiveTableName(tableId)

const { nodes, edges } = highlightNodesAndEdges(getNodes(), getEdges(), {
Expand All @@ -26,7 +31,7 @@ export const useTableSelection = () => {
setNodes(nodes)
setEdges(edges)

if (displayArea === 'main') {
if (displayArea === 'main' && !skipFitView) {
await fitView({
maxZoom: 1,
duration: 300,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Props = PropsWithChildren & UserEditingProviderValue
export const UserEditingProvider: FC<Props> = ({
children,
showDiff: initialShowDiff = false,
defaultShowMode = 'TABLE_NAME',
defaultShowMode = 'KEY_ONLY',
}) => {
const [activeTableName, _setActiveTableName] = useQueryState(
'active',
Expand Down
Loading