Skip to content

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

TypeScript

fix(frontend): r1-b2 complete record table sorting

Josué328619839b6a
diff --git a/control-ui/app/outputs/page.tsx b/control-ui/app/outputs/page.tsx
index 10069a8a3..2cc9959bc 100644
--- a/control-ui/app/outputs/page.tsx
+++ b/control-ui/app/outputs/page.tsx
@@ -2,7 +2,7 @@
import React, { useEffect, useMemo, useState } from 'react'
import { useParams } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, TableHeaderCell, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import { AuthGate } from '../../components/AuthGate'
import { DashboardLayout } from '../../components/DashboardLayout'
@@ -118,6 +118,39 @@ function OutputsPageContent() {
.includes(normalizedSearch)
)
}, [chatArtifacts, normalizedSearch])
+ const workflowSort = useTableSort<
+ WorkflowOutputRow,
+ 'file' | 'format' | 'recipe' | 'run' | 'completed'
+ >({
+ rows: filteredWorkflowOutputs,
+ defaultKey: 'completed',
+ defaultDirection: 'desc',
+ identity: output =>
+ `${output.namespace}/${output.recipeName}/${output.runId}/${output.fileName}`,
+ accessors: {
+ file: output => output.fileName,
+ format: output => output.format,
+ recipe: output => `${output.namespace}/${output.recipeName}`,
+ run: output => output.runId,
+ completed: output => output.completedAt,
+ },
+ })
+ const artifactSort = useTableSort<
+ ChatArtifactOutputRow,
+ 'file' | 'format' | 'size' | 'host' | 'created'
+ >({
+ rows: filteredChatArtifacts,
+ defaultKey: 'created',
+ defaultDirection: 'desc',
+ identity: artifact => `${artifact.hostRef}/${artifact.fileName}/${artifact.createdAt}`,
+ accessors: {
+ file: artifact => artifact.fileName,
+ format: artifact => artifact.format,
+ size: artifact => artifact.sizeBytes,
+ host: artifact => artifact.hostRef,
+ created: artifact => artifact.createdAt,
+ },
+ })
const FORMAT_COLORS: Record<string, string> = {
pdf: '#ef4444',
@@ -218,13 +251,27 @@ function OutputsPageContent() {
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- {['File', 'Format', 'Recipe', 'Run', 'Completed', 'Action'].map(h => (
- <th key={h}>{h}</th>
+ {(
+ [
+ ['file', 'File'],
+ ['format', 'Format'],
+ ['recipe', 'Recipe'],
+ ['run', 'Run'],
+ ['completed', 'Completed'],
+ ] as const
+ ).map(([key, label]) => (
+ <TableHeaderCell
+ activeDirection={workflowSort.key === key ? workflowSort.direction : null}
+ key={key}
+ label={label}
+ onSort={() => workflowSort.sortBy(key)}
+ />
))}
+ <TableHeaderCell label="Action" />
</tr>
</thead>
<tbody>
- {filteredWorkflowOutputs.map(output => (
+ {workflowSort.sortedRows.map(output => (
<tr
key={`${output.namespace}-${output.recipeName}-${output.runId}-${output.fileName}`}
>
@@ -304,13 +351,29 @@ function OutputsPageContent() {
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- {['File', 'Format', 'Size', 'Host', 'Created', 'Action'].map(h => (
- <th key={h}>{h}</th>
+ {(
+ [
+ ['file', 'File'],
+ ['format', 'Format'],
+ ['size', 'Size'],
+ ['host', 'Host'],
+ ['created', 'Created'],
+ ] as const
+ ).map(([key, label]) => (
+ <TableHeaderCell
+ activeDirection={
+ artifactSort.key === key ? artifactSort.direction : null
+ }
+ key={key}
+ label={label}
+ onSort={() => artifactSort.sortBy(key)}
+ />
))}
+ <TableHeaderCell label="Action" />
</tr>
</thead>
<tbody>
- {filteredChatArtifacts.map(artifact => (
+ {artifactSort.sortedRows.map(artifact => (
<tr key={`${artifact.hostRef}-${artifact.fileName}-${artifact.createdAt}`}>
<td style={{ fontFamily: 'monospace', fontSize: 13 }}>
{artifact.fileName}
diff --git a/control-ui/app/shared-filesystems/page.tsx b/control-ui/app/shared-filesystems/page.tsx
index 884f6a5a7..1055406d7 100644
--- a/control-ui/app/shared-filesystems/page.tsx
+++ b/control-ui/app/shared-filesystems/page.tsx
@@ -2,7 +2,7 @@
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable, RowActionMenu } from '@clerum/frontend-table-system'
+import { DataTable, RowActionMenu, useTableSort } from '@clerum/frontend-table-system'
import { DashboardLayout } from '@components/DashboardLayout'
import { SectionSearchInput } from '@components/SectionSearchInput'
import { IconSharedFiles } from '@components/Sidebar/icons'
@@ -151,6 +151,36 @@ export default function SharedFileSystemsPage() {
return [name, phase, storageClass].join(' ').toLowerCase().includes(normalizedSearch)
})
: items
+ const fileSystemSort = useTableSort<
+ SharedFileSystemResource,
+ 'name' | 'phase' | 'capacity' | 'storage-class' | 'mounted-by-contexts'
+ >({
+ rows: filteredItems,
+ defaultKey: 'name',
+ identity: item => item.metadata?.name,
+ accessors: {
+ name: item => item.metadata?.name,
+ phase: item => item.status?.phase,
+ capacity: item => item.status?.capacity || item.spec?.size,
+ 'storage-class': item => item.status?.storageClassName || item.spec?.storageClassName,
+ 'mounted-by-contexts': item =>
+ (item.status?.mountedByContexts || [])
+ .map(context => `${context.namespace}/${context.name}`)
+ .join(', '),
+ },
+ })
+ const columns = SHARED_FILE_SYSTEM_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: fileSystemSort.key === column.key ? fileSystemSort.direction : null,
+ onSort: () =>
+ fileSystemSort.sortBy(
+ column.key as 'name' | 'phase' | 'capacity' | 'storage-class' | 'mounted-by-contexts'
+ ),
+ }
+ )
const isInitialLoad = loading && items.length === 0
return (
@@ -216,13 +246,13 @@ export default function SharedFileSystemsPage() {
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={SHARED_FILE_SYSTEM_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
{isInitialLoad ? (
- <SkeletonTableRows columns={SHARED_FILE_SYSTEM_COLUMNS.length} rows={5} />
+ <SkeletonTableRows columns={columns.length} rows={5} />
) : (
- filteredItems.map(item => {
+ fileSystemSort.sortedRows.map(item => {
const name = item.metadata?.name || ''
const isDeleting = deletingNames.has(name)
const status = item.status || {}
diff --git a/control-ui/components/CodexSubscriptionHub/index.tsx b/control-ui/components/CodexSubscriptionHub/index.tsx
index f44e19271..3991b284e 100644
--- a/control-ui/components/CodexSubscriptionHub/index.tsx
+++ b/control-ui/components/CodexSubscriptionHub/index.tsx
@@ -1,7 +1,7 @@
'use client'
import React, { useCallback, useEffect, useMemo, useState } from 'react'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, TableHeaderCell, useTableSort } from '@clerum/frontend-table-system'
import {
type CodexSubscriptionConnectionView,
createCodexSubscriptionConnection,
@@ -99,6 +99,15 @@ export function CodexSubscriptionHub() {
[grantLabel(row), row.connectionKey, row.status].join(' ').toLowerCase().includes(q)
)
}, [connections, searchQuery])
+ const subscriptionSort = useTableSort<CodexSubscriptionConnectionView, 'name' | 'status'>({
+ rows: filtered,
+ defaultKey: 'name',
+ identity: row => row.connectionKey,
+ accessors: {
+ name: grantLabel,
+ status: row => statusLabel(mapConnectionStatus(row.status)),
+ },
+ })
async function handleCreate() {
const displayName = createName.trim()
@@ -360,8 +369,8 @@ export function CodexSubscriptionHub() {
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th>Status</th>
+ <TableHeaderCell label="Name" />
+ <TableHeaderCell label="Status" />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
@@ -393,13 +402,25 @@ export function CodexSubscriptionHub() {
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th>Status</th>
+ <TableHeaderCell
+ activeDirection={
+ subscriptionSort.key === 'name' ? subscriptionSort.direction : null
+ }
+ label="Name"
+ onSort={() => subscriptionSort.sortBy('name')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ subscriptionSort.key === 'status' ? subscriptionSort.direction : null
+ }
+ label="Status"
+ onSort={() => subscriptionSort.sortBy('status')}
+ />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
<tbody>
- {filtered.map(row => {
+ {subscriptionSort.sortedRows.map(row => {
const mapped = mapConnectionStatus(row.status)
return (
<tr key={row.connectionKey}>
diff --git a/control-ui/components/CommunicationChannelsTable.tsx b/control-ui/components/CommunicationChannelsTable.tsx
index 503e2fe80..e780fc6bd 100644
--- a/control-ui/components/CommunicationChannelsTable.tsx
+++ b/control-ui/components/CommunicationChannelsTable.tsx
@@ -1,7 +1,7 @@
'use client'
import React, { useMemo, useState } from 'react'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import {
COMMUNICATION_CHANNEL_PROVIDERS,
type CommunicationChannelProvider,
@@ -131,6 +131,30 @@ export function CommunicationChannelsTable({
.includes(normalizedSearch)
})
}, [normalizedSearch, rows])
+ const channelSort = useTableSort<(typeof filteredRows)[number], 'name' | 'agent' | 'type'>({
+ rows: filteredRows,
+ defaultKey: 'name',
+ identity: row => row.key,
+ accessors: {
+ name: row => row.item.metadata?.name,
+ agent: row => row.item.spec?.hostRef,
+ type: row =>
+ COMMUNICATION_CHANNEL_PROVIDERS.filter(provider =>
+ configuredProviders(row.item).has(provider)
+ )
+ .map(communicationChannelProviderLabel)
+ .join(', '),
+ },
+ })
+ const columns = COMMUNICATION_CHANNEL_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: channelSort.key === column.key ? channelSort.direction : null,
+ onSort: () => channelSort.sortBy(column.key as 'name' | 'agent' | 'type'),
+ }
+ )
async function deleteRow(item: CommunicationChannelItem) {
const name = item.metadata?.name
@@ -217,10 +241,10 @@ export function CommunicationChannelsTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={COMMUNICATION_CHANNEL_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={COMMUNICATION_CHANNEL_COLUMNS.length} rows={3} />
+ <SkeletonTableRows columns={columns.length} rows={3} />
</tbody>
</DataTable>
</div>
@@ -232,10 +256,10 @@ export function CommunicationChannelsTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={COMMUNICATION_CHANNEL_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {filteredRows.map(({ key, item }) => {
+ {channelSort.sortedRows.map(({ key, item }) => {
const name = item.metadata?.name || '-'
const spec = item.spec || {}
const configuredProviderTypes = configuredProviders(item)
diff --git a/control-ui/components/ControlAdminsPanel/index.tsx b/control-ui/components/ControlAdminsPanel/index.tsx
index 6b4d9ab45..3ab993309 100644
--- a/control-ui/components/ControlAdminsPanel/index.tsx
+++ b/control-ui/components/ControlAdminsPanel/index.tsx
@@ -2,7 +2,7 @@
import { useEffect, useMemo, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, TableHeaderCell, useTableSort } from '@clerum/frontend-table-system'
import { useAuth } from '@components/AuthContext'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { RowActionsMenu } from '@components/RowActionsMenu'
@@ -123,6 +123,35 @@ export function ControlAdminsPanel({
.some(value => value.toLowerCase().includes(normalizedSearch))
)
}, [admins, normalizedSearch])
+ const invitationSort = useTableSort<
+ ControlAdminInvitationItem,
+ 'email' | 'status' | 'expires' | 'created'
+ >({
+ rows: filteredInvitations,
+ defaultKey: 'email',
+ identity: invitation => invitation.id,
+ accessors: {
+ email: invitation => invitation.email,
+ status: invitation => invitation.status,
+ expires: invitation => invitation.expiresAt,
+ created: invitation => invitation.createdAt,
+ },
+ })
+ const adminSort = useTableSort<
+ ControlAdminListItem,
+ 'username' | 'email' | 'status' | 'gfs' | 'lastLogin'
+ >({
+ rows: filteredAdmins,
+ defaultKey: 'username',
+ identity: admin => admin.id,
+ accessors: {
+ username: admin => admin.username,
+ email: admin => admin.email,
+ status: admin => formatAdminStatus(admin.status),
+ gfs: admin => admin.gfsOperatorLink?.status,
+ lastLogin: admin => admin.lastLoginAt,
+ },
+ })
async function handleCancelInvitation(invitation: ControlAdminInvitationItem) {
const shouldCancel = await confirm({
@@ -331,10 +360,32 @@ export function ControlAdminsPanel({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Pending invitation</th>
- <th>Status</th>
- <th>Expires</th>
- <th>Created</th>
+ <TableHeaderCell
+ activeDirection={invitationSort.key === 'email' ? invitationSort.direction : null}
+ label="Pending invitation"
+ onSort={() => invitationSort.sortBy('email')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'status' ? invitationSort.direction : null
+ }
+ label="Status"
+ onSort={() => invitationSort.sortBy('status')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'expires' ? invitationSort.direction : null
+ }
+ label="Expires"
+ onSort={() => invitationSort.sortBy('expires')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'created' ? invitationSort.direction : null
+ }
+ label="Created"
+ onSort={() => invitationSort.sortBy('created')}
+ />
<th aria-label="Actions" />
</tr>
</thead>
@@ -342,7 +393,7 @@ export function ControlAdminsPanel({
{loading ? (
<SkeletonTableRows columns={5} rows={2} />
) : (
- filteredInvitations.map(invitation => (
+ invitationSort.sortedRows.map(invitation => (
<tr key={invitation.id}>
<td>{invitation.email}</td>
<td>{invitation.status}</td>
@@ -376,11 +427,31 @@ export function ControlAdminsPanel({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Username</th>
- <th>Email</th>
- <th>Status</th>
- <th>Desktop GFS access</th>
- <th>Last sign-in</th>
+ <TableHeaderCell
+ activeDirection={adminSort.key === 'username' ? adminSort.direction : null}
+ label="Username"
+ onSort={() => adminSort.sortBy('username')}
+ />
+ <TableHeaderCell
+ activeDirection={adminSort.key === 'email' ? adminSort.direction : null}
+ label="Email"
+ onSort={() => adminSort.sortBy('email')}
+ />
+ <TableHeaderCell
+ activeDirection={adminSort.key === 'status' ? adminSort.direction : null}
+ label="Status"
+ onSort={() => adminSort.sortBy('status')}
+ />
+ <TableHeaderCell
+ activeDirection={adminSort.key === 'gfs' ? adminSort.direction : null}
+ label="Desktop GFS access"
+ onSort={() => adminSort.sortBy('gfs')}
+ />
+ <TableHeaderCell
+ activeDirection={adminSort.key === 'lastLogin' ? adminSort.direction : null}
+ label="Last sign-in"
+ onSort={() => adminSort.sortBy('lastLogin')}
+ />
<th aria-label="Actions" />
</tr>
</thead>
@@ -388,7 +459,7 @@ export function ControlAdminsPanel({
{loading ? (
<SkeletonTableRows columns={6} rows={5} />
) : filteredAdmins.length > 0 ? (
- filteredAdmins.map(admin => {
+ adminSort.sortedRows.map(admin => {
const currentAdmin = isCurrentAdmin(admin)
const label = admin.email ? `${admin.username} (${admin.email})` : admin.username
const memberCreationUnavailable = !admin.email || admin.passwordPending
diff --git a/control-ui/components/GuardrailHooksTable.tsx b/control-ui/components/GuardrailHooksTable.tsx
index 7401e732a..1b153de6f 100644
--- a/control-ui/components/GuardrailHooksTable.tsx
+++ b/control-ui/components/GuardrailHooksTable.tsx
@@ -2,7 +2,7 @@
import React, { useMemo, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import { RowActionsMenu } from '@components/RowActionsMenu'
import { CONTROL_ROUTES } from '@constants/routes'
import type { LlmHookStatus } from '../lib/api'
@@ -116,6 +116,32 @@ export function GuardrailHooksTable({
.includes(normalizedSearch)
})
}, [normalizedSearch, rows])
+ const hookSort = useTableSort<
+ (typeof filteredRows)[number],
+ 'name' | 'lifecycle' | 'order' | 'failMode' | 'status'
+ >({
+ rows: filteredRows,
+ defaultKey: 'name',
+ identity: row => row.key,
+ accessors: {
+ name: row => row.name,
+ lifecycle: row => ((row.item.spec || {}) as LlmHookSpecView).lifecyclePoints?.join(', '),
+ order: row => ((row.item.spec || {}) as LlmHookSpecView).order,
+ failMode: row => ((row.item.spec || {}) as LlmHookSpecView).failMode,
+ status: row =>
+ row.item.status?.conditions?.find(condition => condition.type === 'Ready')?.status,
+ },
+ })
+ const columns = HOOK_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: hookSort.key === column.key ? hookSort.direction : null,
+ onSort: () =>
+ hookSort.sortBy(column.key as 'name' | 'lifecycle' | 'order' | 'failMode' | 'status'),
+ }
+ )
React.useEffect(() => {
if (!onRefresh) return
@@ -182,10 +208,10 @@ export function GuardrailHooksTable({
<div className="eft-table-viewport cu-table-wrap cu-guardrails-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band cu-guardrails-table">
<thead>
- <TableHeaderRow columns={HOOK_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={HOOK_COLUMNS.length} rows={5} />
+ <SkeletonTableRows columns={columns.length} rows={5} />
</tbody>
</DataTable>
</div>
@@ -197,10 +223,10 @@ export function GuardrailHooksTable({
<div className="eft-table-viewport cu-table-wrap cu-guardrails-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band cu-guardrails-table">
<thead>
- <TableHeaderRow columns={HOOK_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {filteredRows.map(({ key, name, item }) => {
+ {hookSort.sortedRows.map(({ key, name, item }) => {
const spec = (item.spec || {}) as LlmHookSpecView
const lifecycle = (spec.lifecyclePoints || []).join(', ')
return (
diff --git a/control-ui/components/LlmPriceTable.tsx b/control-ui/components/LlmPriceTable.tsx
index c4d9cfebd..1a47e6fb2 100644
--- a/control-ui/components/LlmPriceTable.tsx
+++ b/control-ui/components/LlmPriceTable.tsx
@@ -1,7 +1,7 @@
'use client'
import React, { useMemo, useState } from 'react'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import type { LlmModelPrice, UnpricedModel } from '@lib/api'
import { getProviderDisplayLabel } from '@lib/llm'
import type { LlmPriceTableProps } from './LlmPriceTable.types'
@@ -97,6 +97,59 @@ export function LlmPriceTable({
)
}, [missingPriceItems, normalizedSearch])
+ type PriceSortKey =
+ | 'provider'
+ | 'model'
+ | 'input'
+ | 'output'
+ | 'cacheRead'
+ | 'cacheWrite'
+ | 'currency'
+ | 'enabled'
+ const priceSort = useTableSort<LlmModelPrice, PriceSortKey>({
+ rows: filteredPrices,
+ defaultKey: 'provider',
+ identity: price => price.id,
+ accessors: {
+ provider: price => getProviderDisplayLabel(price.provider),
+ model: price => price.model,
+ input: price => price.input_token_price,
+ output: price => price.output_token_price,
+ cacheRead: price => price.cache_read_token_price,
+ cacheWrite: price => price.cache_write_token_price,
+ currency: price => price.currency,
+ enabled: price => price.enabled,
+ },
+ })
+ const missingSort = useTableSort<UnpricedModel, PriceSortKey>({
+ rows: filteredMissingPriceItems,
+ defaultKey: 'provider',
+ identity: item => `${item.provider ?? ''}/${item.model}`,
+ accessors: {
+ provider: item => (item.provider ? getProviderDisplayLabel(item.provider) : 'Any provider'),
+ model: item => item.model,
+ input: () => null,
+ output: () => null,
+ cacheRead: () => null,
+ cacheWrite: () => null,
+ currency: () => null,
+ enabled: () => false,
+ },
+ })
+ const columns = PRICE_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: priceSort.key === column.key ? priceSort.direction : null,
+ onSort: () => {
+ const key = column.key as PriceSortKey
+ priceSort.sortBy(key)
+ missingSort.sortBy(key)
+ },
+ }
+ )
+
const visibleRowCount = filteredPrices.length + filteredMissingPriceItems.length
const isInitialLoad = Boolean(loading) && items.length === 0
@@ -143,10 +196,10 @@ export function LlmPriceTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={PRICE_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={PRICE_COLUMNS.length} rows={4} />
+ <SkeletonTableRows columns={columns.length} rows={4} />
</tbody>
</DataTable>
</div>
@@ -160,10 +213,10 @@ export function LlmPriceTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={PRICE_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {filteredPrices.map((price: LlmModelPrice) => {
+ {priceSort.sortedRows.map((price: LlmModelPrice) => {
const isUnpriced = unpricedItems.some(
item =>
item.model === price.model &&
@@ -229,7 +282,7 @@ export function LlmPriceTable({
</tr>
)
})}
- {filteredMissingPriceItems.map((item: UnpricedModel) => {
+ {missingSort.sortedRows.map((item: UnpricedModel) => {
const label = item.provider
? `${getProviderDisplayLabel(item.provider)}/${item.model}`
: item.model
diff --git a/control-ui/components/MarketplaceOrgImages/index.tsx b/control-ui/components/MarketplaceOrgImages/index.tsx
index caeaafc99..22e5a7bf9 100644
--- a/control-ui/components/MarketplaceOrgImages/index.tsx
+++ b/control-ui/components/MarketplaceOrgImages/index.tsx
@@ -1,7 +1,7 @@
'use client'
import { useCallback, useEffect, useState } from 'react'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import { type OrgImage, listOrgImages } from '../../lib/api'
import { RetryBanner } from '../PublisherView/RetryBanner'
@@ -64,6 +64,21 @@ export function MarketplaceOrgImages({ orgScope }: { orgScope: string }) {
: [{ name: img.name, tag: '<tag>' }]
)
: []
+ const imageSort = useTableSort<(typeof rows)[number], 'image' | 'tag' | 'coordinate'>({
+ rows,
+ defaultKey: 'image',
+ identity: row => `${row.name}:${row.tag}`,
+ accessors: {
+ image: row => row.name,
+ tag: row => row.tag,
+ coordinate: row => buildImageCoordinate(DEFAULT_REGISTRY_HOST, orgScope, row.name, row.tag),
+ },
+ })
+ const columns = COLUMNS.map(column => ({
+ ...column,
+ activeDirection: imageSort.key === column.key ? imageSort.direction : null,
+ onSort: () => imageSort.sortBy(column.key as 'image' | 'tag' | 'coordinate'),
+ }))
return (
<section>
@@ -111,10 +126,10 @@ export function MarketplaceOrgImages({ orgScope }: { orgScope: string }) {
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table">
<thead>
- <TableHeaderRow columns={COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {rows.map(r => (
+ {imageSort.sortedRows.map(r => (
<tr key={`${r.name}:${r.tag}`}>
<td>
<code>{r.name}</code>
diff --git a/control-ui/components/McpServerTable.tsx b/control-ui/components/McpServerTable.tsx
index 87ccf7fc5..cf7b064b9 100644
--- a/control-ui/components/McpServerTable.tsx
+++ b/control-ui/components/McpServerTable.tsx
@@ -166,7 +166,7 @@ export function McpServerTable({
loading,
}: McpServerTableProps) {
const [searchQuery, setSearchQuery] = useState('')
- const [sortKey, setSortKey] = useState<ConnectorSortKey | null>(null)
+ const [sortKey, setSortKey] = useState<ConnectorSortKey>('name')
const [sortDirection, setSortDirection] = useState<SortDirection>('asc')
const [serverKeyAddingContexts, setServerKeyAddingContexts] = useState<string | null>(null)
const [serverKeyViewingAccess, setServerKeyViewingAccess] = useState<string | null>(null)
@@ -217,8 +217,6 @@ export function McpServerTable({
.toLowerCase()
.includes(normalizedSearch)
})
- if (!sortKey) return matchingRows
-
const direction = sortDirection === 'asc' ? 1 : -1
return [...matchingRows].sort((left, right) => {
const leftAccess = accessByConnectorKey?.[left.key]
@@ -309,28 +307,13 @@ export function McpServerTable({
setSortDirection('asc')
}
- function renderSortHeader(key: ConnectorSortKey, label: string) {
- const isActive = sortKey === key
- const indicator = isActive ? (sortDirection === 'asc' ? '↑' : '↓') : ''
- const nextDirection = isActive && sortDirection === 'asc' ? 'descending' : 'ascending'
- return (
- <button
- type="button"
- className={`cu-table__sort-link${isActive ? ' is-active' : ''}`}
- onClick={() => toggleSort(key)}
- aria-label={`Sort by ${label.toLowerCase()} ${nextDirection}`}
- aria-pressed={isActive}
- >
- {label} {indicator}
- </button>
- )
- }
-
const columns = CONNECTOR_COLUMNS.map(column => {
if (column.key !== 'actions') {
+ const key = column.key as ConnectorSortKey
return {
...column,
- label: renderSortHeader(column.key as ConnectorSortKey, column.label as string),
+ activeDirection: sortKey === key ? sortDirection : null,
+ onSort: () => toggleSort(key),
}
}
return column
diff --git a/control-ui/components/PublisherView/GrantedToMe.tsx b/control-ui/components/PublisherView/GrantedToMe.tsx
index 6ab8b2219..c7b3a98df 100644
--- a/control-ui/components/PublisherView/GrantedToMe.tsx
+++ b/control-ui/components/PublisherView/GrantedToMe.tsx
@@ -1,7 +1,7 @@
'use client'
import Link from 'next/link'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import type { GrantedToMeItem } from '../../lib/api'
import type { InboundGrantsStatus } from '../../lib/hooks/useInboundGrants'
@@ -36,6 +36,21 @@ export function GrantedToMe({
grants: GrantedToMeItem[]
reload: () => void
}) {
+ const grantSort = useTableSort<GrantedToMeItem, 'plugin' | 'owner' | 'since'>({
+ rows: grants,
+ defaultKey: 'plugin',
+ identity: grant => `${grant.ownerOrg}/${grant.pluginName}`,
+ accessors: {
+ plugin: grant => grant.pluginName,
+ owner: grant => grant.ownerOrg,
+ since: grant => grant.createdAt,
+ },
+ })
+ const columns = COLUMNS.map(column => ({
+ ...column,
+ activeDirection: grantSort.key === column.key ? grantSort.direction : null,
+ onSort: () => grantSort.sortBy(column.key as 'plugin' | 'owner' | 'since'),
+ }))
if (status === 'loading') {
return <SectionLoadingSkeleton label="Loading shared plugins" rows={3} />
}
@@ -59,10 +74,10 @@ export function GrantedToMe({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table">
<thead>
- <TableHeaderRow columns={COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {grants.map(g => (
+ {grantSort.sortedRows.map(g => (
<tr key={`${g.ownerOrg}/${g.pluginName}`}>
<td>
<code>{g.pluginName}</code>
diff --git a/control-ui/components/PublisherView/OwnedEntries.tsx b/control-ui/components/PublisherView/OwnedEntries.tsx
index 72ffab9f7..3c71fe7cd 100644
--- a/control-ui/components/PublisherView/OwnedEntries.tsx
+++ b/control-ui/components/PublisherView/OwnedEntries.tsx
@@ -2,7 +2,7 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import { useRouter, useSearchParams } from 'next/navigation'
-import { DataTable, TableRow } from '@clerum/frontend-table-system'
+import { DataTable, TableRow, useTableSort } from '@clerum/frontend-table-system'
import { MARKETPLACE_ENTRY_TYPE_LABELS } from '@constants/marketplaceEntryTypes'
import { CONTROL_ROUTES } from '@constants/routes'
import {
@@ -39,20 +39,6 @@ function entryKey(e: OwnedRegistryEntry): string {
return `${e.name}@${e.version}`
}
-// Descending semver-ish sort so the latest version leads each group. Falls back
-// to a reverse lexical compare when a segment isn't numeric.
-function compareVersionDesc(a: string, b: string): number {
- const pa = a.split('.')
- const pb = b.split('.')
- for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
- const x = Number.parseInt(pa[i] ?? '0', 10)
- const y = Number.parseInt(pb[i] ?? '0', 10)
- if (Number.isNaN(x) || Number.isNaN(y)) return b.localeCompare(a)
- if (x !== y) return y - x
- }
- return b.localeCompare(a)
-}
-
// The registry's owned-entries payload carries `serverMode` but not `entry_type`
// (mcp-servers always have a serverMode; recipes don't). Prefer an explicit
// entry_type if the registry ever starts sending it, else infer from serverMode.
@@ -175,14 +161,30 @@ export function OwnedEntries({
// cross-org sharing does to this org's private entries, so a `?type=` filter
// that happens to hide them all must not make it disappear.
const hasPrivateEntries = entries.some(e => e.visibility === 'private')
- const sortedEntries = useMemo(
- () =>
- [...visibleEntries].sort(
- (left, right) =>
- left.name.localeCompare(right.name, undefined, { sensitivity: 'base' }) ||
- compareVersionDesc(left.version, right.version)
- ),
- [visibleEntries]
+ const entrySort = useTableSort<
+ OwnedRegistryEntry,
+ 'name' | 'type' | 'version' | 'visibility' | 'status'
+ >({
+ rows: visibleEntries,
+ defaultKey: 'name',
+ identity: entryKey,
+ accessors: {
+ name: entry => entry.name,
+ type: entry => entryTypeLabel(entry),
+ version: entry => entry.version,
+ visibility: entry => entry.visibility,
+ status: entry => entry.status,
+ },
+ })
+ const columns = COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: entrySort.key === column.key ? entrySort.direction : null,
+ onSort: () =>
+ entrySort.sortBy(column.key as 'name' | 'type' | 'version' | 'visibility' | 'status'),
+ }
)
return (
@@ -227,10 +229,10 @@ export function OwnedEntries({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table">
<thead>
- <TableHeaderRow columns={COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {sortedEntries.map(e => {
+ {entrySort.sortedRows.map(e => {
const isPrivate = e.visibility === 'private'
const detailRoute = CONTROL_ROUTES.marketplace.entry(e.name, e.version)
const rowActions: RowActionMenuItem[] = [
diff --git a/control-ui/components/RecipesTab.tsx b/control-ui/components/RecipesTab.tsx
index c696c40ca..d39463250 100644
--- a/control-ui/components/RecipesTab.tsx
+++ b/control-ui/components/RecipesTab.tsx
@@ -2,7 +2,7 @@
import { useMemo, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import { DEFAULT_WORKFLOW_RECIPE_NAMESPACE } from '@constants/workflowRecipes'
import type { WorkflowRecipeResource } from '../lib/api'
@@ -57,6 +57,22 @@ export function RecipesTab({ items, loading, error, onInstall, onRefresh }: Prop
.includes(normalizedSearch)
})
}, [items, normalizedSearch])
+ const recipeSort = useTableSort<WorkflowRecipeResource, 'name' | 'phase' | 'created'>({
+ rows: filteredItems,
+ defaultKey: 'name',
+ identity: item =>
+ `${item.metadata?.namespace ?? DEFAULT_WORKFLOW_RECIPE_NAMESPACE}/${item.metadata?.name ?? ''}`,
+ accessors: {
+ name: item => item.metadata?.name,
+ phase: item => normalizeRecipePhase(item.status?.phase),
+ created: item => item.metadata?.creationTimestamp,
+ },
+ })
+ const columns = RECIPE_COLUMNS.map(column => ({
+ ...column,
+ activeDirection: recipeSort.key === column.key ? recipeSort.direction : null,
+ onSort: () => recipeSort.sortBy(column.key as 'name' | 'phase' | 'created'),
+ }))
const isInitialLoad = loading && items.length === 0
function detailHref(name: string, namespace: string): string {
@@ -116,10 +132,10 @@ export function RecipesTab({ items, loading, error, onInstall, onRefresh }: Prop
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band cu-installed-plugins-table">
<thead>
- <TableHeaderRow columns={RECIPE_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={RECIPE_COLUMNS.length} rows={4} />
+ <SkeletonTableRows columns={columns.length} rows={4} />
</tbody>
</DataTable>
</div>
@@ -131,10 +147,10 @@ export function RecipesTab({ items, loading, error, onInstall, onRefresh }: Prop
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band cu-installed-plugins-table">
<thead>
- <TableHeaderRow columns={RECIPE_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {filteredItems.map(item => {
+ {recipeSort.sortedRows.map(item => {
const name = item.metadata?.name ?? '(unnamed)'
const namespace = item.metadata?.namespace ?? DEFAULT_WORKFLOW_RECIPE_NAMESPACE
const key = `${namespace}/${name}`
diff --git a/control-ui/components/RegistryApiKeysPanel.tsx b/control-ui/components/RegistryApiKeysPanel.tsx
index 5c9416f16..b58f5130d 100644
--- a/control-ui/components/RegistryApiKeysPanel.tsx
+++ b/control-ui/components/RegistryApiKeysPanel.tsx
@@ -2,7 +2,7 @@
import { useCallback, useEffect, useState } from 'react'
import Link from 'next/link'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import {
type CreateRegistryApiKeyInput,
@@ -70,6 +70,43 @@ export default function RegistryApiKeysPanel({ embedded = false }: RegistryApiKe
const [connectionMode, setConnectionMode] = useState<'self-hosted' | 'managed' | 'unknown'>(
'unknown'
)
+ const keySort = useTableSort<
+ RegistryApiKey,
+ 'prefix' | 'description' | 'scopes' | 'created_by' | 'created' | 'expires' | 'last_used'
+ >({
+ rows: view.kind === 'ready' ? view.keys : [],
+ defaultKey: 'created',
+ defaultDirection: 'desc',
+ identity: key => key.id,
+ accessors: {
+ prefix: key => key.key_prefix,
+ description: key => key.description,
+ scopes: key => key.scopes.join(', '),
+ created_by: key => key.created_by_username,
+ created: key => key.created_at,
+ expires: key => key.expires_at,
+ last_used: key => key.last_used_at,
+ },
+ })
+ const columns = API_KEYS_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: keySort.key === column.key ? keySort.direction : null,
+ onSort: () =>
+ keySort.sortBy(
+ column.key as
+ | 'prefix'
+ | 'description'
+ | 'scopes'
+ | 'created_by'
+ | 'created'
+ | 'expires'
+ | 'last_used'
+ ),
+ }
+ )
const load = useCallback(async () => {
try {
@@ -203,10 +240,10 @@ export default function RegistryApiKeysPanel({ embedded = false }: RegistryApiKe
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table">
<thead>
- <TableHeaderRow columns={API_KEYS_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {view.keys.map(k => (
+ {keySort.sortedRows.map(k => (
<tr key={k.id}>
<td>
<code>{k.key_prefix}</code>
diff --git a/control-ui/components/RegistryCatalog.tsx b/control-ui/components/RegistryCatalog.tsx
index 40aa5acfa..72e69f769 100644
--- a/control-ui/components/RegistryCatalog.tsx
+++ b/control-ui/components/RegistryCatalog.tsx
@@ -58,7 +58,7 @@ export default function RegistryCatalog() {
const [error, setError] = useState<string | null>(null)
const [search, setSearch] = useState('')
const [categoryFilter, setCategoryFilter] = useState('all')
- const [sortKey, setSortKey] = useState<CatalogSortKey | null>(null)
+ const [sortKey, setSortKey] = useState<CatalogSortKey>('name')
const [sortDirection, setSortDirection] = useState<SortDirection>('asc')
const [removeTarget, setRemoveTarget] = useState<RegistryEntry | null>(null)
const [removing, setRemoving] = useState(false)
@@ -85,7 +85,11 @@ export default function RegistryCatalog() {
column.key === 'quality' ||
column.key === 'version'
) {
- return { ...column, label: renderSortHeader(column.key, column.label as string) }
+ return {
+ ...column,
+ activeDirection: sortKey === column.key ? sortDirection : null,
+ onSort: () => toggleSort(column.key as CatalogSortKey),
+ }
}
return column
})
@@ -155,8 +159,6 @@ export default function RegistryCatalog() {
entry.tags.some(tag => tag.toLowerCase().includes(query))
)
})
- if (!sortKey) return visibleEntries
-
const direction = sortDirection === 'asc' ? 1 : -1
return [...visibleEntries].sort((left, right) => {
const comparison =
@@ -188,30 +190,7 @@ export default function RegistryCatalog() {
return
}
setSortKey(key)
- setSortDirection(key === 'version' ? 'desc' : 'asc')
- }
-
- function renderSortHeader(key: CatalogSortKey, label: string) {
- const isActive = sortKey === key
- const indicator = isActive ? (sortDirection === 'asc' ? '↑' : '↓') : ''
- const nextDirection = isActive
- ? sortDirection === 'asc'
- ? 'descending'
- : 'ascending'
- : key === 'version'
- ? 'descending'
- : 'ascending'
- return (
- <button
- type="button"
- className={`cu-table__sort-link${isActive ? ' is-active' : ''}`}
- onClick={() => toggleSort(key)}
- aria-label={`Sort by ${label.toLowerCase()} ${nextDirection}`}
- aria-pressed={isActive}
- >
- {label} {indicator}
- </button>
- )
+ setSortDirection('asc')
}
function isEntryInstalled(entry: RegistryEntry): boolean {
diff --git a/control-ui/components/SecretsTable.tsx b/control-ui/components/SecretsTable.tsx
index fd1c9d52d..4a24bdb71 100644
--- a/control-ui/components/SecretsTable.tsx
+++ b/control-ui/components/SecretsTable.tsx
@@ -2,7 +2,7 @@
import React, { useEffect, useMemo, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, TableHeaderCell, useTableSort } from '@clerum/frontend-table-system'
import { CONTROL_ROUTES } from '@constants/routes'
import {
type RecipeSecretItem,
@@ -162,6 +162,38 @@ export function SecretsTable({
.includes(normalizedRecipeSearch)
)
}, [recipeRows, normalizedRecipeSearch])
+ const llmSort = useTableSort<string, 'name' | 'providers'>({
+ rows: filteredRows,
+ defaultKey: 'name',
+ identity: name => name,
+ accessors: {
+ name: name => name,
+ providers: name =>
+ getProvidersWithCompleteCredentials(keysByName.get(name) ?? [])
+ .map(getProviderLabel)
+ .join(', '),
+ },
+ })
+ const mcpSort = useTableSort<McpSecretRow, 'name' | 'servers' | 'registry'>({
+ rows: filteredMcpRows,
+ defaultKey: 'name',
+ identity: row => row.name,
+ accessors: {
+ name: row => row.name,
+ servers: row => row.servers.join(', '),
+ registry: row => row.registryEntries.join(', '),
+ },
+ })
+ const recipeSort = useTableSort<RecipeSecretRow, 'name' | 'keys' | 'recipes'>({
+ rows: filteredRecipeRows,
+ defaultKey: 'name',
+ identity: row => `${row.namespace}/${row.name}`,
+ accessors: {
+ name: row => `${row.namespace}/${row.name}`,
+ keys: row => row.keys.join(', '),
+ recipes: row => row.recipes.join(', '),
+ },
+ })
function openUpdate(name: string) {
setEditingName(name)
@@ -494,8 +526,8 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th>Providers</th>
+ <TableHeaderCell label="Name" />
+ <TableHeaderCell label="Providers" />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
@@ -531,13 +563,21 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th>Providers</th>
+ <TableHeaderCell
+ activeDirection={llmSort.key === 'name' ? llmSort.direction : null}
+ label="Name"
+ onSort={() => llmSort.sortBy('name')}
+ />
+ <TableHeaderCell
+ activeDirection={llmSort.key === 'providers' ? llmSort.direction : null}
+ label="Providers"
+ onSort={() => llmSort.sortBy('providers')}
+ />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
<tbody>
- {filteredRows.map(name => {
+ {llmSort.sortedRows.map(name => {
const providers = getProvidersWithCompleteCredentials(keysByName.get(name) ?? [])
return (
<tr key={name}>
@@ -592,9 +632,9 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th style={{ width: '36%' }}>Attached connectors</th>
- <th style={{ width: '34%' }}>Marketplace Source</th>
+ <TableHeaderCell label="Name" />
+ <TableHeaderCell label="Attached connectors" style={{ width: '36%' }} />
+ <TableHeaderCell label="Marketplace Source" style={{ width: '34%' }} />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
@@ -629,14 +669,28 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th style={{ width: '36%' }}>Attached connectors</th>
- <th style={{ width: '34%' }}>Marketplace Source</th>
+ <TableHeaderCell
+ activeDirection={mcpSort.key === 'name' ? mcpSort.direction : null}
+ label="Name"
+ onSort={() => mcpSort.sortBy('name')}
+ />
+ <TableHeaderCell
+ activeDirection={mcpSort.key === 'servers' ? mcpSort.direction : null}
+ label="Attached connectors"
+ onSort={() => mcpSort.sortBy('servers')}
+ style={{ width: '36%' }}
+ />
+ <TableHeaderCell
+ activeDirection={mcpSort.key === 'registry' ? mcpSort.direction : null}
+ label="Marketplace Source"
+ onSort={() => mcpSort.sortBy('registry')}
+ style={{ width: '34%' }}
+ />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
<tbody>
- {filteredMcpRows.map(row => (
+ {mcpSort.sortedRows.map(row => (
<tr key={row.name}>
<td>{row.name}</td>
<td style={{ color: 'var(--cu-text-soft)', fontSize: '0.8125rem' }}>
@@ -680,9 +734,9 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th style={{ width: '32%' }}>Keys</th>
- <th style={{ width: '32%' }}>Used by recipes</th>
+ <TableHeaderCell label="Name" />
+ <TableHeaderCell label="Keys" style={{ width: '32%' }} />
+ <TableHeaderCell label="Used by recipes" style={{ width: '32%' }} />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
@@ -723,14 +777,28 @@ export function SecretsTable({
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
<tr>
- <th>Name</th>
- <th style={{ width: '32%' }}>Keys</th>
- <th style={{ width: '32%' }}>Used by recipes</th>
+ <TableHeaderCell
+ activeDirection={recipeSort.key === 'name' ? recipeSort.direction : null}
+ label="Name"
+ onSort={() => recipeSort.sortBy('name')}
+ />
+ <TableHeaderCell
+ activeDirection={recipeSort.key === 'keys' ? recipeSort.direction : null}
+ label="Keys"
+ onSort={() => recipeSort.sortBy('keys')}
+ style={{ width: '32%' }}
+ />
+ <TableHeaderCell
+ activeDirection={recipeSort.key === 'recipes' ? recipeSort.direction : null}
+ label="Used by recipes"
+ onSort={() => recipeSort.sortBy('recipes')}
+ style={{ width: '32%' }}
+ />
<th style={{ width: '8rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
</thead>
<tbody>
- {filteredRecipeRows.map(row => (
+ {recipeSort.sortedRows.map(row => (
<tr key={`${row.status}:${row.namespace}:${row.name}`}>
<td>
<div style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem' }}>
diff --git a/control-ui/components/TokenBudgetTable.tsx b/control-ui/components/TokenBudgetTable.tsx
index 5acf680db..22288cd14 100644
--- a/control-ui/components/TokenBudgetTable.tsx
+++ b/control-ui/components/TokenBudgetTable.tsx
@@ -1,7 +1,7 @@
'use client'
import React, { useMemo, useState } from 'react'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, useTableSort } from '@clerum/frontend-table-system'
import type { TokenBudget } from '@lib/api'
import {
budgetProgressPercent,
@@ -64,6 +64,46 @@ export function TokenBudgetTable({
.includes(normalizedSearch)
})
}, [items, lookups, normalizedSearch])
+ const budgetSort = useTableSort<
+ TokenBudget,
+ 'name' | 'scope' | 'unit' | 'period' | 'progress' | 'enforcement' | 'enabled'
+ >({
+ rows: filteredItems,
+ defaultKey: 'name',
+ identity: budget => budget.id,
+ accessors: {
+ name: budget => budget.name,
+ scope: budget =>
+ formatBudgetScope(budget.scope, lookups)
+ .map(segment => `${segment.label} ${segment.values.join(' ')}`)
+ .join(' '),
+ unit: budget => budget.unit,
+ period: budget => budget.period,
+ progress: budget =>
+ budget.limit_amount > 0 ? (budget.spent ?? 0) / budget.limit_amount : (budget.spent ?? 0),
+ enforcement: budget => budget.enforcement,
+ enabled: budget => budget.enabled,
+ },
+ })
+ const columns = BUDGET_COLUMNS.map(column =>
+ column.key === 'actions'
+ ? column
+ : {
+ ...column,
+ activeDirection: budgetSort.key === column.key ? budgetSort.direction : null,
+ onSort: () =>
+ budgetSort.sortBy(
+ column.key as
+ | 'name'
+ | 'scope'
+ | 'unit'
+ | 'period'
+ | 'progress'
+ | 'enforcement'
+ | 'enabled'
+ ),
+ }
+ )
const isInitialLoad = Boolean(loading) && items.length === 0
@@ -110,10 +150,10 @@ export function TokenBudgetTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={BUDGET_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- <SkeletonTableRows columns={BUDGET_COLUMNS.length} rows={4} />
+ <SkeletonTableRows columns={columns.length} rows={4} />
</tbody>
</DataTable>
</div>
@@ -127,10 +167,10 @@ export function TokenBudgetTable({
<div className="eft-table-viewport cu-table-wrap">
<DataTable className="eft-table cu-table cu-table--header-band">
<thead>
- <TableHeaderRow columns={BUDGET_COLUMNS} />
+ <TableHeaderRow columns={columns} />
</thead>
<tbody>
- {filteredItems.map((budget: TokenBudget) => (
+ {budgetSort.sortedRows.map((budget: TokenBudget) => (
<BudgetRow
key={budget.id}
budget={budget}
diff --git a/control-ui/components/__tests__/FrontendTableSystem.test.tsx b/control-ui/components/__tests__/FrontendTableSystem.test.tsx
index bd30d1265..2d6889291 100644
--- a/control-ui/components/__tests__/FrontendTableSystem.test.tsx
+++ b/control-ui/components/__tests__/FrontendTableSystem.test.tsx
@@ -22,7 +22,7 @@ describe('shared frontend table system', () => {
)
expect(screen.getByRole('columnheader')).toHaveAttribute('aria-sort', 'ascending')
- fireEvent.click(screen.getByRole('button', { name: 'Name' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by Name descending' }))
expect(onSort).toHaveBeenCalledOnce()
})
diff --git a/control-ui/components/__tests__/McpServerTable.test.tsx b/control-ui/components/__tests__/McpServerTable.test.tsx
index 463b29536..957ed7fe5 100644
--- a/control-ui/components/__tests__/McpServerTable.test.tsx
+++ b/control-ui/components/__tests__/McpServerTable.test.tsx
@@ -188,15 +188,18 @@ describe('McpServerTable — column sorting', () => {
element => element.textContent
)
- fireEvent.click(screen.getByRole('button', { name: 'Sort by name ascending' }))
expect(listedNames()).toEqual([
'alpha-server',
'bravo-server',
'charlie-server',
'zebra-server',
])
+ expect(screen.getByRole('columnheader', { name: 'Name' })).toHaveAttribute(
+ 'aria-sort',
+ 'ascending'
+ )
- fireEvent.click(screen.getByRole('button', { name: 'Sort by enabled ascending' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by Enabled ascending' }))
expect(listedNames()).toEqual([
'alpha-server',
'charlie-server',
@@ -204,7 +207,7 @@ describe('McpServerTable — column sorting', () => {
'zebra-server',
])
- fireEvent.click(screen.getByRole('button', { name: 'Sort by status ascending' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by Status ascending' }))
expect(listedNames()).toEqual([
'charlie-server',
'bravo-server',
diff --git a/control-ui/components/__tests__/RegistryCatalog.test.tsx b/control-ui/components/__tests__/RegistryCatalog.test.tsx
index 99e4d2be4..a4d7dc427 100644
--- a/control-ui/components/__tests__/RegistryCatalog.test.tsx
+++ b/control-ui/components/__tests__/RegistryCatalog.test.tsx
@@ -226,14 +226,17 @@ describe('RegistryCatalog tabs and columns', () => {
element => element.textContent
)
- fireEvent.click(screen.getByRole('button', { name: 'Sort by name ascending' }))
expect(listedNames()).toEqual(['alpha-search', 'brave-search', 'zebra-search'])
+ expect(screen.getByRole('columnheader', { name: 'Name' })).toHaveAttribute(
+ 'aria-sort',
+ 'ascending'
+ )
- fireEvent.click(screen.getByRole('button', { name: 'Sort by version descending' }))
- expect(listedNames()).toEqual(['alpha-search', 'zebra-search', 'brave-search'])
-
- fireEvent.click(screen.getByRole('button', { name: 'Sort by version ascending' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by Version ascending' }))
expect(listedNames()).toEqual(['brave-search', 'zebra-search', 'alpha-search'])
+
+ fireEvent.click(screen.getByRole('button', { name: 'Sort by Version descending' }))
+ expect(listedNames()).toEqual(['alpha-search', 'zebra-search', 'brave-search'])
})
})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 5c845c54f..baecef5b5 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.483",
+ "version": "0.1.484",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.483",
+ "version": "0.1.484",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-table-system": "file:../packages/frontend-table-system",
diff --git a/control-ui/package.json b/control-ui/package.json
index 05b818eed..f47200c93 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.483",
+ "version": "0.1.484",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/packages/frontend-table-system/src/index.tsx b/packages/frontend-table-system/src/index.tsx
index ffa73782e..490035742 100644
--- a/packages/frontend-table-system/src/index.tsx
+++ b/packages/frontend-table-system/src/index.tsx
@@ -183,6 +183,8 @@ export function TableHeaderCell({
: onSort
? 'none'
: undefined
+ const nextDirection = activeDirection === 'asc' ? 'descending' : 'ascending'
+ const accessibleSortLabel = String(sortLabel ?? label)
return (
<th
{...props}
@@ -194,7 +196,7 @@ export function TableHeaderCell({
<span className="eft-table__sort-group">
{label}
<button
- aria-label={`Sort by ${String(sortLabel)}`}
+ aria-label={`Sort by ${accessibleSortLabel} ${nextDirection}`}
className="eft-table__sort eft-table__sort--icon"
onClick={onSort}
type="button"
@@ -205,7 +207,12 @@ export function TableHeaderCell({
</button>
</span>
) : onSort ? (
- <button className="eft-table__sort" onClick={onSort} type="button">
+ <button
+ aria-label={`Sort by ${accessibleSortLabel} ${nextDirection}`}
+ className="eft-table__sort"
+ onClick={onSort}
+ type="button"
+ >
<span>{label}</span>
<span aria-hidden="true" className="eft-table__sort-indicator">
{activeDirection === 'asc' ? '↑' : activeDirection === 'desc' ? '↓' : '↕'}
diff --git a/scripts/style-rules/rules.test.mjs b/scripts/style-rules/rules.test.mjs
index 7fb4451b8..86ccb00d9 100644
--- a/scripts/style-rules/rules.test.mjs
+++ b/scripts/style-rules/rules.test.mjs
@@ -72,3 +72,31 @@ test('shared table colors resolve through tokens declared by both web apps', ()
assert.match(controlCss, /:root\[data-theme='light'\][\s\S]*--cu-surface-hover\s*:/)
assert.doesNotMatch(sharedCss, /--eft-[^:]+:[^;]*#[0-9a-f]{3,8}/i)
})
+
+test('ordinary web record tables keep an explicit sorting model', () => {
+ const ordinaryRecordTables = [
+ 'control-ui/app/outputs/page.tsx',
+ 'control-ui/app/shared-filesystems/page.tsx',
+ 'control-ui/components/CodexSubscriptionHub/index.tsx',
+ 'control-ui/components/CommunicationChannelsTable.tsx',
+ 'control-ui/components/ControlAdminsPanel/index.tsx',
+ 'control-ui/components/GuardrailHooksTable.tsx',
+ 'control-ui/components/LlmPriceTable.tsx',
+ 'control-ui/components/MarketplaceOrgImages/index.tsx',
+ 'control-ui/components/McpServerTable.tsx',
+ 'control-ui/components/PublisherView/GrantedToMe.tsx',
+ 'control-ui/components/PublisherView/OwnedEntries.tsx',
+ 'control-ui/components/RecipesTab.tsx',
+ 'control-ui/components/RegistryApiKeysPanel.tsx',
+ 'control-ui/components/RegistryCatalog.tsx',
+ 'control-ui/components/SecretsTable.tsx',
+ 'control-ui/components/TokenBudgetTable.tsx',
+ 'profile-ui/app/members/page.tsx',
+ ]
+
+ for (const file of ordinaryRecordTables) {
+ const source = readFileSync(file, 'utf8')
+ assert.match(source, /useTableSort|sortKey/, `${file} must declare its sorting model`)
+ assert.match(source, /onSort/, `${file} must expose sortable headers`)
+ }
+})