Skip to content

Commit fabb273

Browse files
committed
improvement(tables): move preview navigation into header
1 parent cb225b6 commit fabb273

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/reference-row-preview.test.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ vi.mock('@/lib/table/column-types', () => ({
2929
}))
3030

3131
vi.mock('@sim/emcn/icons', () => ({
32+
ArrowRight: () => null,
3233
Loader: () => null,
3334
}))
3435

@@ -125,11 +126,18 @@ describe('ReferenceRowPreview', () => {
125126
expect(container.textContent).toContain('Acme')
126127
expect(container.textContent).toContain('Enterprise')
127128
expect(container.textContent).not.toContain('Open in sub view')
128-
const goToTableLink = Array.from(container.querySelectorAll('a')).find(
129-
(link) => link.textContent === 'Go to table'
130-
)
129+
const goToTableLink = container.querySelector('a[aria-label="Go to table"]')
131130
expect(goToTableLink?.getAttribute('href')).toBe('/workspace/workspace-1/tables/table-accounts')
131+
expect(goToTableLink?.getAttribute('title')).toBe('Go to table')
132+
expect(goToTableLink?.className).toContain('size-[20px]')
133+
expect(goToTableLink?.className).toContain('hover-hover:bg-[var(--surface-active)]')
132134
expect(goToTableLink?.parentElement?.className).toContain('h-9')
135+
expect(goToTableLink?.parentElement?.className).toContain('gap-1.5')
136+
expect(goToTableLink?.previousElementSibling?.textContent).toBe('Accounts')
137+
expect(goToTableLink?.textContent).toBe('')
138+
const previewShell = container.querySelector<HTMLElement>('tbody > tr > td > div > div')
139+
expect(previewShell?.lastElementChild?.className).toContain('h-9')
140+
expect(previewShell?.lastElementChild?.querySelector('a')).toBeNull()
133141
const previewCell = container.querySelector('tbody > tr > td')
134142
expect(previewCell?.className).toContain('overflow-clip')
135143
expect(previewCell?.className).toContain('border-r')

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/reference-row-preview.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { memo, type ReactNode, useLayoutEffect, useMemo, useRef } from 'react'
44
import { buttonVariants } from '@sim/emcn'
5-
import { Loader } from '@sim/emcn/icons'
5+
import { ArrowRight, Loader } from '@sim/emcn/icons'
66
import { noop } from '@sim/utils/helpers'
77
import Link from 'next/link'
88
import { columnTypeById } from '@/lib/table/column-types'
@@ -188,6 +188,14 @@ export const ReferenceRowPreview = memo(function ReferenceRowPreview({
188188
<div className='flex h-9 shrink-0 items-center gap-1.5 px-3 text-[var(--text-primary)] text-small'>
189189
<ReferenceIcon className='size-[14px] text-[var(--text-icon)]' />
190190
<span className='font-medium'>{table?.name ?? 'Referenced table'}</span>
191+
<Link
192+
href={`/workspace/${workspaceId}/tables/${referenceTableId}`}
193+
aria-label='Go to table'
194+
title='Go to table'
195+
className={buttonVariants({ variant: 'quiet', size: 'icon' })}
196+
>
197+
<ArrowRight className='size-[14px]' />
198+
</Link>
191199
</div>
192200

193201
<div
@@ -197,14 +205,7 @@ export const ReferenceRowPreview = memo(function ReferenceRowPreview({
197205
{content}
198206
</div>
199207

200-
<div className='flex h-9 shrink-0 items-center bg-[var(--bg)] px-3'>
201-
<Link
202-
href={`/workspace/${workspaceId}/tables/${referenceTableId}`}
203-
className={buttonVariants({ variant: 'default', size: 'sm' })}
204-
>
205-
Go to table
206-
</Link>
207-
</div>
208+
<div aria-hidden className='h-9 shrink-0 bg-[var(--bg)]' />
208209
</div>
209210
</div>
210211
</td>

0 commit comments

Comments
 (0)