Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(frontend): converge actions cell behavior
Josué3bfa3993eba1
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex 1060c33a5..2e231b9f6 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -24,15 +24,7 @@ import {IconVideo,} from '@components/Sidebar/icons'import { useToast } from '@components/Toast'-import {- IconChevronRight,- IconDownload,- IconPaperclip,- IconPencil,- IconShare,- IconUpload,- IconX,-} from '@components/icons'+import { IconChevronRight, IconPaperclip, IconUpload, IconX } from '@components/icons'import { Button, Field, TextInput } from '@components/ui'import { apiGet, apiSend, gfsDownload, isSilentApiError } from '@lib/api'import { isGfsDocumentFile } from '@lib/gfsDocumentFile'@@ -1335,42 +1327,6 @@ export function GfsBrowser(): React.JSX.Element {{child.kind === 'directory' ? '—' : formatBytes(child.bytes)}</span><span className="cu-gfs-list__actions">- <Button- className="cu-gfs-list__row-action"- icon- size="sm"- variant="ghost"- title={`Share ${child.name}`}- aria-label={`Share ${child.name}`}- onClick={() => openManage(child)}- >- <IconShare width={16} height={16} />- </Button>- {child.kind !== 'directory' ? (- <Button- className="cu-gfs-list__download cu-gfs-list__row-action"- icon- size="sm"- variant="ghost"- title={`Download ${child.name}`}- aria-label={`Download ${child.name}`}- disabled={downloadingIds.has(child.resourceId)}- onClick={() => void downloadFile(child)}- >- <IconDownload width={18} height={18} />- </Button>- ) : null}- <Button- className="cu-gfs-list__row-action"- icon- size="sm"- variant="ghost"- title={`Rename ${child.name}`}- aria-label={`Rename ${child.name}`}- onClick={() => openRowRename(child)}- >- <IconPencil width={16} height={16} />- </Button><GfsResourceMenuresourceName={child.name}resourceUri={child.gfsUri}diff --git a/control-ui/components/__tests__/FrontendComponents.test.tsx b/control-ui/components/__tests__/FrontendComponents.test.tsxindex f9d0bf9ee..fb2c09303 100644--- a/control-ui/components/__tests__/FrontendComponents.test.tsx+++ b/control-ui/components/__tests__/FrontendComponents.test.tsx@@ -500,6 +500,51 @@ describe('shared frontend components', () => {expect(screen.queryByRole('menu')).not.toBeInTheDocument()})+ it('opens a class-A action menu from the whole cell without adding a tab stop', () => {+ const onNavigate = vi.fn()+ render(+ <table>+ <tbody>+ <tr onClick={onNavigate}>+ <td data-testid="action-cell">+ <RowActionMenu+ ariaLabel="Actions for Alpha"+ actions={[{ key: 'view', label: 'View', onSelect: vi.fn() }]}+ />+ </td>+ </tr>+ </tbody>+ </table>+ )++ const cell = screen.getByTestId('action-cell')+ expect(cell).not.toHaveAttribute('tabindex')+ fireEvent.click(cell)+ expect(screen.getByRole('menu')).toBeInTheDocument()+ expect(onNavigate).not.toHaveBeenCalled()+ expect(screen.getAllByRole('button')).toHaveLength(1)+ })++ it('does not widen a mixed-control action cell', () => {+ render(+ <table>+ <tbody>+ <tr>+ <td data-testid="mixed-cell">+ <button type="button">Pin</button>+ <RowActionMenu+ ariaLabel="Actions for Alpha"+ actions={[{ key: 'view', label: 'View', onSelect: vi.fn() }]}+ />+ </td>+ </tr>+ </tbody>+ </table>+ )+ fireEvent.click(screen.getByTestId('mixed-cell'))+ expect(screen.queryByRole('menu')).not.toBeInTheDocument()+ })+it('disables the trigger when every row action is unavailable', () => {const onDelete = vi.fn()render(diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsxindex 19f65d596..ec113992a 100644--- a/control-ui/components/__tests__/GfsBrowser.test.tsx+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx@@ -1101,7 +1101,8 @@ describe('GfsBrowser', () => {mockApiSend.mockRejectedValueOnce(new Error('stale resource version'))renderBrowser()- fireEvent.click(await screen.findByRole('button', { name: 'Rename archive' }))+ await openResourceMenu('archive')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))const renameDialog = await screen.findByRole('dialog', { name: 'Rename folder' })fireEvent.change(within(renameDialog).getByLabelText('New name'), {target: { value: 'renamed-archive' },@@ -1115,7 +1116,8 @@ describe('GfsBrowser', () => {fireEvent.click(within(renameDialog).getByRole('button', { name: 'Cancel' }))expect(screen.queryByRole('dialog', { name: 'Rename folder' })).toBeNull()- fireEvent.click(screen.getByRole('button', { name: 'Rename archive' }))+ await openResourceMenu('archive')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))expect(await screen.findByLabelText('New name')).toHaveValue('archive')})@@ -1146,12 +1148,13 @@ describe('GfsBrowser', () => {const currentResources = await screen.findByRole('list', { name: 'Current folder resources' })const reportRow = within(currentResources).getByText('report.md').closest('li')expect(reportRow).toBeTruthy()- fireEvent.click(within(reportRow!).getByRole('button', { name: 'Download report.md' }))+ await openResourceMenu('report.md')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Download' }))await waitFor(() => expect(mockGfsDownload).toHaveBeenCalledWith('r2', 'report.md'))})- it('shows share and rename row actions beside download', async () => {+ it('converges every resource action into one row menu trigger', async () => {mockApiGet.mockResolvedValueOnce({items: [child('report.md', 'file', 2)],nextCursor: null,@@ -1161,22 +1164,20 @@ describe('GfsBrowser', () => {const currentResources = await screen.findByRole('list', { name: 'Current folder resources' })const reportRow = within(currentResources).getByText('report.md').closest('li')expect(reportRow).toBeTruthy()- expect(within(reportRow!).getByRole('button', { name: 'Share report.md' })).toBeTruthy()- expect(within(reportRow!).getByRole('button', { name: 'Download report.md' })).toBeTruthy()- expect(within(reportRow!).getByRole('button', { name: 'Rename report.md' })).toBeTruthy()expect(Array.from(reportRow!.querySelectorAll('.cu-gfs-list__actions button')).map(button =>button.getAttribute('aria-label'))- ).toEqual([- 'Share report.md',- 'Download report.md',- 'Rename report.md',- 'Actions for report.md',- ])+ ).toEqual(['Actions for report.md'])+ await openResourceMenu('report.md')+ expect(screen.getByRole('menuitem', { name: 'Share' })).toBeVisible()+ expect(screen.getByRole('menuitem', { name: 'Download' })).toBeVisible()+ expect(screen.getByRole('menuitem', { name: 'Rename' })).toBeVisible()+ expect(screen.getByRole('menuitem', { name: 'Move to…' })).toBeVisible()+ expect(screen.getByRole('menuitem', { name: 'Delete' })).toBeVisible()})- it('shows share and rename actions on both folder and file rows', async () => {+ it('uses one action trigger on both folder and file rows', async () => {mockApiGet.mockResolvedValueOnce({items: [child('archive', 'directory', 1), child('report.md', 'file', 2)],nextCursor: null,@@ -1189,13 +1190,12 @@ describe('GfsBrowser', () => {expect(folderRow).not.toBeNull()expect(fileRow).not.toBeNull()- expect(within(folderRow!).getByRole('button', { name: 'Share archive' })).toBeTruthy()- expect(within(folderRow!).getByRole('button', { name: 'Rename archive' })).toBeTruthy()+ expect(within(folderRow!).getAllByRole('button')).toHaveLength(2)+ expect(within(folderRow!).getByRole('button', { name: 'Actions for archive' })).toBeTruthy()expect(within(folderRow!).queryByRole('button', { name: 'Download archive' })).toBeNull()- expect(within(fileRow!).getByRole('button', { name: 'Share report.md' })).toBeTruthy()- expect(within(fileRow!).getByRole('button', { name: 'Download report.md' })).toBeTruthy()- expect(within(fileRow!).getByRole('button', { name: 'Rename report.md' })).toBeTruthy()+ expect(within(fileRow!).getAllByRole('button')).toHaveLength(2)+ expect(within(fileRow!).getByRole('button', { name: 'Actions for report.md' })).toBeTruthy()})it('surfaces download failures through the toast stack', async () => {@@ -1206,7 +1206,8 @@ describe('GfsBrowser', () => {mockGfsDownload.mockRejectedValueOnce(new Error('download unavailable'))renderBrowser()- fireEvent.click(await screen.findByRole('button', { name: 'Download report.md' }))+ await openResourceMenu('report.md')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Download' }))expect(await screen.findByRole('status')).toHaveTextContent('download unavailable')})diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex fcf0ca3c0..fe326d8aa 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.616",+ "version": "0.1.617","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.616",+ "version": "0.1.617","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 89e22815e..bef45a63c 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.616",+ "version": "0.1.617","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/packages/frontend-components/src/table/row-actions.tsx b/packages/frontend-components/src/table/row-actions.tsxindex 7db195e0f..97474db23 100644--- a/packages/frontend-components/src/table/row-actions.tsx+++ b/packages/frontend-components/src/table/row-actions.tsx@@ -41,6 +41,30 @@ export function RowActionMenu({if (triggerDisabled && open) close()}, [close, open, triggerDisabled])+ useEffect(() => {+ const trigger = triggerRef.current+ const cell = trigger?.closest('td')+ if (!trigger || !cell) return+ const otherInteractive = Array.from(+ cell.querySelectorAll<HTMLElement>('button, a, input, select, textarea, [tabindex]')+ ).some(element => element !== trigger && !trigger.contains(element))+ if (otherInteractive) return++ const openFromCell = (event: MouseEvent) => {+ const target = event.target as Node+ if (trigger.contains(target)) return+ event.preventDefault()+ event.stopPropagation()+ trigger.click()+ }+ cell.classList.add('eft-table__cell--menu-target')+ cell.addEventListener('click', openFromCell)+ return () => {+ cell.removeEventListener('click', openFromCell)+ cell.classList.remove('eft-table__cell--menu-target')+ }+ }, [])+useEffect(() => {if (!open) returnconst onPointer = (event: MouseEvent) => {diff --git a/packages/frontend-components/styles.css b/packages/frontend-components/styles.cssindex 9a1be9737..84a275205 100644--- a/packages/frontend-components/styles.css+++ b/packages/frontend-components/styles.css@@ -518,6 +518,9 @@text-align: right;width: 3.5rem;}+.eft-table__cell--menu-target {+ cursor: pointer;+}.eft-table__cell--fixed {white-space: nowrap;width: 1%;