Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(control-ui): standardize gfs access records

Josuéfd11967fcde4
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 79df71a8f..faddd53ba 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -13365,34 +13365,6 @@ button.cu-gfs-tree__button:focus-visible,
flex: 0 0 var(--cu-space-2);
}
-.cu-gfs-existing-access__item > .cu-btn {
- flex: 0 0 auto;
- white-space: nowrap;
-}
-
-.cu-gfs-existing-access__revoke.cu-btn {
- min-width: 1.5rem;
- min-height: 1.5rem;
- padding: 0;
- border: 0;
- border-radius: 999px;
- background: transparent;
- color: var(--cu-danger);
- font-size: 0.9rem;
- font-weight: 700;
- line-height: 1;
-}
-
-.cu-gfs-existing-access__revoke.cu-btn:hover:not(:disabled) {
- border-color: transparent;
- background: transparent;
- color: var(--cu-danger-hover);
-}
-
-.cu-gfs-existing-access__revoke.cu-btn:focus-visible {
- border-color: transparent;
-}
-
.cu-gfs-existing-access__error {
display: flex;
align-items: center;
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsx
index a18729195..55cf06cb0 100644
--- a/control-ui/components/GfsGrantPanel.tsx
+++ b/control-ui/components/GfsGrantPanel.tsx
@@ -1,6 +1,7 @@
'use client'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { RecordList, RecordListRow, RowActionMenu } from '@clerum/frontend-components'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { GfsPermissionDropdown } from '@components/GfsPermissionDropdown'
import { GFS_PERMISSION_LABELS } from '@components/GfsPermissionDropdown/constants'
@@ -314,19 +315,36 @@ export function GfsGrantPanel({
return () => onCreateShareActionChange(null, true)
}, [canCreateShare, canSubmit, onCreateShareActionChange])
- function subjectLabel(item: GfsExistingAccessItem): string {
- if (item.subject.type === 'operator') return 'Operator'
- const option = bulkSubjectOptions.find(
- candidate =>
- candidate.subject.type === item.subject.type && candidate.subject.id === item.subject.id
- )
- if (option) return option.label
- const typeLabel =
- item.subject.type === 'host'
- ? 'Agent or workflow'
- : item.subject.type.charAt(0).toUpperCase() + item.subject.type.slice(1)
- return item.subject.id ? `${typeLabel} · ${item.subject.id}` : typeLabel
- }
+ const subjectLabel = useCallback(
+ (item: GfsExistingAccessItem): string => {
+ if (item.subject.type === 'operator') return 'Operator'
+ const option = bulkSubjectOptions.find(
+ candidate =>
+ candidate.subject.type === item.subject.type && candidate.subject.id === item.subject.id
+ )
+ if (option) return option.label
+ const typeLabel =
+ item.subject.type === 'host'
+ ? 'Agent or workflow'
+ : item.subject.type.charAt(0).toUpperCase() + item.subject.type.slice(1)
+ return item.subject.id ? `${typeLabel} · ${item.subject.id}` : typeLabel
+ },
+ [bulkSubjectOptions]
+ )
+
+ const sortedExistingAccess = useMemo(
+ () =>
+ [...existingAccess].sort(
+ (left, right) =>
+ subjectLabel(left).localeCompare(subjectLabel(right), undefined, {
+ numeric: true,
+ sensitivity: 'base',
+ }) ||
+ left.kind.localeCompare(right.kind) ||
+ left.id.localeCompare(right.id)
+ ),
+ [existingAccess, subjectLabel]
+ )
async function revokeAccess(item: GfsExistingAccessItem) {
const label = subjectLabel(item)
@@ -435,13 +453,13 @@ export function GfsGrantPanel({
) : existingAccess.length === 0 ? (
<p className="cu-gfs-existing-access__empty">No direct grants or shares yet.</p>
) : (
- <ul className="cu-gfs-existing-access__list" aria-label="Resource access">
- {existingAccess.map(item => {
+ <RecordList className="cu-gfs-existing-access__list" aria-label="Resource access">
+ {sortedExistingAccess.map(item => {
const label = subjectLabel(item)
const coversDescendants =
item.kind === 'grant' ? item.inherit : item.includeDescendants
return (
- <li
+ <RecordListRow
className="cu-gfs-existing-access__item"
data-testid={`gfs-access-row-${item.kind}-${item.id}`}
key={`${item.kind}:${item.id}`}
@@ -468,22 +486,22 @@ export function GfsGrantPanel({
</span>
) : null}
</span>
- <Button
- aria-label={`Remove ${item.kind} access for ${label}`}
- className="cu-gfs-existing-access__revoke"
- data-testid={`gfs-revoke-${item.kind}-${item.id}`}
- title={`Remove ${item.kind} access for ${label}`}
- size="sm"
- disabled={actionPending}
- onClick={() => void revokeAccess(item)}
- variant="ghost"
- >
- X
- </Button>
- </li>
+ <RowActionMenu
+ actions={[
+ {
+ key: 'remove',
+ label: 'Remove access',
+ danger: true,
+ disabled: actionPending,
+ onSelect: () => void revokeAccess(item),
+ },
+ ]}
+ ariaLabel={`Actions for ${label}`}
+ />
+ </RecordListRow>
)
})}
- </ul>
+ </RecordList>
)}
</section>
{confirmDialog}
diff --git a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
index 2bef23b65..ba91845aa 100644
--- a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
+++ b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
@@ -184,15 +184,8 @@ describe('GfsGrantPanel bulk access', () => {
expect(within(existing).getByText('Direct grant · user')).toBeTruthy()
expect(within(existing).getByText('Read')).toBeTruthy()
expect(within(existing).getByText('Write')).toBeTruthy()
- expect(within(existing).getByText('X')).toBeTruthy()
- expect(
- within(existing).getByRole('button', { name: 'Remove grant access for Ada Lovelace' })
- .className
- ).toContain('cu-gfs-existing-access__revoke')
-
- fireEvent.click(
- within(existing).getByRole('button', { name: 'Remove grant access for Ada Lovelace' })
- )
+ fireEvent.click(within(existing).getByRole('button', { name: 'Actions for Ada Lovelace' }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove access' }))
const dialog = await screen.findByRole('alertdialog')
fireEvent.click(within(dialog).getByRole('button', { name: 'Remove access' }))
@@ -206,6 +199,38 @@ describe('GfsGrantPanel bulk access', () => {
expect(mockGetGfsShares).toHaveBeenCalledTimes(2)
})
+ it('sorts access records by visible principal identity', async () => {
+ mockGetGfsGrants.mockResolvedValue({
+ items: [
+ {
+ id: '77777777-7777-7777-7777-777777777777',
+ drive: 'main',
+ resourceId: resource.resourceId,
+ subject: { type: 'operator' },
+ permissions: ['read'],
+ inherit: false,
+ },
+ {
+ id: '33333333-3333-3333-3333-333333333333',
+ drive: 'main',
+ resourceId: resource.resourceId,
+ subject: userSubject,
+ permissions: ['read'],
+ inherit: false,
+ },
+ ],
+ })
+ renderPanel()
+
+ const list = await screen.findByRole('list', { name: 'Resource access' })
+ await waitFor(() => expect(within(list).getByText('Ada Lovelace')).toBeTruthy())
+ expect(
+ within(list)
+ .getAllByRole('listitem')
+ .map(row => row.textContent)
+ ).toEqual([expect.stringContaining('Ada Lovelace'), expect.stringContaining('Operator')])
+ })
+
it('self-heals a row that another admin already revoked without hiding other errors', async () => {
mockGetGfsGrants
.mockResolvedValueOnce({
@@ -229,9 +254,8 @@ describe('GfsGrantPanel bulk access', () => {
)
renderPanel()
const existing = await screen.findByRole('region', { name: 'Who has access' })
- fireEvent.click(
- within(existing).getByRole('button', { name: 'Remove grant access for Ada Lovelace' })
- )
+ fireEvent.click(within(existing).getByRole('button', { name: 'Actions for Ada Lovelace' }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove access' }))
const dialog = await screen.findByRole('alertdialog')
fireEvent.click(within(dialog).getByRole('button', { name: 'Remove access' }))
@@ -264,9 +288,8 @@ describe('GfsGrantPanel bulk access', () => {
)
renderPanel()
const existing = await screen.findByRole('region', { name: 'Who has access' })
- fireEvent.click(
- within(existing).getByRole('button', { name: 'Remove grant access for Ada Lovelace' })
- )
+ fireEvent.click(within(existing).getByRole('button', { name: 'Actions for Ada Lovelace' }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove access' }))
const dialog = await screen.findByRole('alertdialog')
fireEvent.click(within(dialog).getByRole('button', { name: 'Remove access' }))
diff --git a/control-ui/e2e/support/gfs-bulk-operator-journey.test.ts b/control-ui/e2e/support/gfs-bulk-operator-journey.test.ts
index 008a8acd7..79fc0d649 100644
--- a/control-ui/e2e/support/gfs-bulk-operator-journey.test.ts
+++ b/control-ui/e2e/support/gfs-bulk-operator-journey.test.ts
@@ -211,9 +211,8 @@ export async function exerciseGfsBulkOperatorJourney(page: Page): Promise<void>
response.request().method() === 'DELETE' &&
response.url().includes('/control-api/api/v1/gfs/grants/')
)
- await existingAccess
- .getByRole('button', { name: `Remove grant access for ${E2E_TEST_NAME}` })
- .click()
+ await existingAccess.getByRole('button', { name: `Actions for ${E2E_TEST_NAME}` }).click()
+ await page.getByRole('menuitem', { name: 'Remove access' }).click()
const confirmation = page.getByRole('alertdialog')
await expect(confirmation).toContainText('Remove access?')
await confirmation.getByRole('button', { name: 'Remove access' }).click()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 7f7a85fba..87cb0732e 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.550",
+ "version": "0.1.551",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.550",
+ "version": "0.1.551",
"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.json
index d2902e0c8..f2d1e4c6e 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.550",
+ "version": "0.1.551",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",