Skip to content

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

TypeScript

feat(profile-ui): standardize table interactions

Josuéa305e1da0e7a
diff --git a/profile-ui/app/components/EditableList/index.tsx b/profile-ui/app/components/EditableList/index.tsx
deleted file mode 100644
index ba4b62d9e..000000000
--- a/profile-ui/app/components/EditableList/index.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { Button } from '@components/Button'
-import { TextInput } from '@components/TextInput'
-import type { EditableListProps } from './types'
-
-export function EditableList({ title, values, onChange, placeholder }: EditableListProps) {
- return (
- <section className="editable-list">
- <strong>{title}</strong>
- {values.map((value, idx) => (
- <div key={`${title}-${idx}`} className="inline-row">
- <TextInput
- className="fluid-control"
- value={value}
- onChange={event =>
- onChange(values.map((item, itemIdx) => (itemIdx === idx ? event.target.value : item)))
- }
- placeholder={placeholder}
- />
- <Button
- variant="ghost"
- onClick={() => onChange(values.filter((_, itemIdx) => itemIdx !== idx))}
- >
- Remove
- </Button>
- </div>
- ))}
- <Button variant="secondary" onClick={() => onChange([...values, ''])}>
- Add
- </Button>
- </section>
- )
-}
diff --git a/profile-ui/app/components/EditableList/types.ts b/profile-ui/app/components/EditableList/types.ts
deleted file mode 100644
index 701cf9472..000000000
--- a/profile-ui/app/components/EditableList/types.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export type EditableListProps = {
- title: string
- values: string[]
- onChange: (next: string[]) => void
- placeholder: string
-}
diff --git a/profile-ui/app/connected-accounts/page.tsx b/profile-ui/app/connected-accounts/page.tsx
index 449be2120..094f88844 100644
--- a/profile-ui/app/connected-accounts/page.tsx
+++ b/profile-ui/app/connected-accounts/page.tsx
@@ -1,6 +1,7 @@
'use client'
import { useEffect, useState } from 'react'
+import { RecordList, RecordListRow, RowActionMenu } from '@clerum/frontend-table-system'
import { AuthGate } from '@components/AuthGate'
import { Button } from '@components/Button'
import { ProfileBodySkeleton } from '@components/ProfileBodySkeleton'
@@ -81,11 +82,11 @@ function ConnectedAccountsContent() {
{accounts.length === 0 ? (
<div className="muted">No connected accounts.</div>
) : (
- <div className="stack">
+ <RecordList className="stack">
{accounts.map(a => {
const key = `${a.recipeName}/${a.oauthClientId}`
return (
- <div key={key} className="member-row">
+ <RecordListRow key={key} className="member-row">
<div className="member-summary">
<div>
<div>
@@ -96,18 +97,23 @@ function ConnectedAccountsContent() {
{a.background ? ' · background access' : ''}
</div>
</div>
- <Button
- variant="danger"
- disabled={busy === key}
- onClick={() => void revoke(a)}
- >
- {busy === key ? 'Revoking…' : 'Revoke'}
- </Button>
+ <RowActionMenu
+ ariaLabel={`Actions for ${a.recipeName}`}
+ actions={[
+ {
+ key: 'revoke',
+ label: busy === key ? 'Revoking…' : 'Revoke',
+ danger: true,
+ disabled: busy === key,
+ onSelect: () => void revoke(a),
+ },
+ ]}
+ />
</div>
- </div>
+ </RecordListRow>
)
})}
- </div>
+ </RecordList>
)}
</section>
)}
diff --git a/profile-ui/app/members/[userId]/page.tsx b/profile-ui/app/members/[userId]/page.tsx
index 3bb362a35..71c306b37 100644
--- a/profile-ui/app/members/[userId]/page.tsx
+++ b/profile-ui/app/members/[userId]/page.tsx
@@ -2,7 +2,7 @@
import { useEffect, useMemo, useState } from 'react'
import { useParams, useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, RowActionMenu } from '@clerum/frontend-table-system'
import { useAuth } from '@components/AuthContext'
import { AuthGate } from '@components/AuthGate'
import { Button } from '@components/Button'
@@ -265,46 +265,32 @@ export default function MemberDetailsPage() {
disabled
/>
</td>
- <td>
- <div className="row-actions">
- {!memberIsSelf ? (
- <button
- type="button"
- className="icon-button"
- onClick={() => {
- if (!team.canEdit) return
- setEditTeam(team)
- setEditRole(team.role)
- setEditError('')
- }}
- disabled={busy || !team.canEdit}
- title={
- team.canEdit
- ? `Edit ${team.name} permissions`
- : 'Only leaders can edit member permissions.'
- }
- aria-label={`Edit ${team.name} permissions`}
- >
- Edit
- </button>
- ) : null}
- {!memberIsSelf ? (
- <button
- type="button"
- className="icon-button icon-button--danger"
- onClick={() => void removeMemberFromTeam(team)}
- disabled={busy || !team.canDelete}
- title={
- team.canDelete
- ? `Remove from ${team.name}`
- : 'Only leaders can remove members from this team.'
- }
- aria-label={`Remove from ${team.name}`}
- >
- <IconTrash />
- </button>
- ) : null}
- </div>
+ <td className="eft-table__cell--actions">
+ {!memberIsSelf ? (
+ <RowActionMenu
+ ariaLabel={`Actions for team ${team.name}`}
+ actions={[
+ {
+ key: 'edit',
+ label: 'Edit permissions',
+ disabled: busy || !team.canEdit,
+ onSelect: () => {
+ if (!team.canEdit) return
+ setEditTeam(team)
+ setEditRole(team.role)
+ setEditError('')
+ },
+ },
+ {
+ key: 'remove',
+ label: 'Remove from team',
+ danger: true,
+ disabled: busy || !team.canDelete,
+ onSelect: () => void removeMemberFromTeam(team),
+ },
+ ]}
+ />
+ ) : null}
</td>
</tr>
)
diff --git a/profile-ui/app/members/invite/page.tsx b/profile-ui/app/members/invite/page.tsx
index 142464160..281b93ee3 100644
--- a/profile-ui/app/members/invite/page.tsx
+++ b/profile-ui/app/members/invite/page.tsx
@@ -2,7 +2,7 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import { DataTable, RowActionMenu } from '@clerum/frontend-table-system'
import { AuthGate } from '@components/AuthGate'
import { Button } from '@components/Button'
import { CreateFlowPanel } from '@components/CreateFlowPanel'
@@ -311,16 +311,19 @@ function PermissionTable({
aria-label={`Can delete members for ${team.name}`}
/>
</td>
- <td>
- <button
- type="button"
- className="icon-button icon-button--danger"
- onClick={() => onRemove(team)}
- disabled={busy}
- aria-label={`Remove ${team.name}`}
- >
- <IconTrash />
- </button>
+ <td className="eft-table__cell--actions">
+ <RowActionMenu
+ ariaLabel={`Actions for ${team.name}`}
+ actions={[
+ {
+ key: 'remove',
+ label: 'Remove team',
+ danger: true,
+ disabled: busy,
+ onSelect: () => onRemove(team),
+ },
+ ]}
+ />
</td>
</tr>
)
diff --git a/profile-ui/app/members/page.tsx b/profile-ui/app/members/page.tsx
index e041efbd4..0055d679f 100644
--- a/profile-ui/app/members/page.tsx
+++ b/profile-ui/app/members/page.tsx
@@ -2,7 +2,12 @@
import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
-import { DataTable } from '@clerum/frontend-table-system'
+import {
+ DataTable,
+ RowActionMenu,
+ TableHeaderCell,
+ useTableSort,
+} from '@clerum/frontend-table-system'
import { useAuth } from '@components/AuthContext'
import { AuthGate } from '@components/AuthGate'
import { Button } from '@components/Button'
@@ -38,6 +43,26 @@ export default function MembersPage() {
const [busy, setBusy] = useState(false)
const [error, setError] = useState('')
const currentUserId = authState.me?.id || ''
+ const invitationSort = useTableSort<ManagedPendingInvitation, 'email' | 'teams' | 'expires'>({
+ rows: invitations,
+ defaultKey: 'email' as const,
+ identity: invitation => invitation.id,
+ accessors: {
+ email: (invitation: ManagedPendingInvitation) => invitation.email,
+ teams: (invitation: ManagedPendingInvitation) => invitation.teams.length,
+ expires: (invitation: ManagedPendingInvitation) => new Date(invitation.expiresAt),
+ },
+ })
+ const memberSort = useTableSort<ManagedMember, 'name' | 'email' | 'teams'>({
+ rows: members,
+ defaultKey: 'name' as const,
+ identity: member => member.id,
+ accessors: {
+ name: (member: ManagedMember) => displayMemberName(member),
+ email: (member: ManagedMember) => member.email,
+ teams: (member: ManagedMember) => member.teams.length,
+ },
+ })
async function loadMembers(forceAccess = false) {
setState('loading')
@@ -174,47 +199,55 @@ export default function MembersPage() {
<DataTable className="eft-table members-table">
<thead>
<tr>
- <th>Email</th>
- <th>Teams</th>
- <th>Expires</th>
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'email' ? invitationSort.direction : null
+ }
+ label="Email"
+ onSort={() => invitationSort.sortBy('email')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'teams' ? invitationSort.direction : null
+ }
+ label="Teams"
+ onSort={() => invitationSort.sortBy('teams')}
+ />
+ <TableHeaderCell
+ activeDirection={
+ invitationSort.key === 'expires' ? invitationSort.direction : null
+ }
+ label="Expires"
+ onSort={() => invitationSort.sortBy('expires')}
+ />
<th></th>
</tr>
</thead>
<tbody>
- {invitations.map(invitation => (
+ {invitationSort.sortedRows.map(invitation => (
<tr key={invitation.id}>
<td>{invitation.email}</td>
<td>{invitation.teams.map(team => team.name).join(', ')}</td>
<td>{new Date(invitation.expiresAt).toLocaleString()}</td>
- <td>
- <div className="row-actions">
- <button
- type="button"
- className="icon-button"
- onClick={() => void resendInvitation(invitation)}
- disabled={busy || !invitation.canResend}
- title={
- invitation.canResend
- ? 'Resend invitation'
- : 'You can only resend invitations for teams you can invite to.'
- }
- >
- Resend
- </button>
- <button
- type="button"
- className="icon-button icon-button--danger"
- onClick={() => void cancelInvitation(invitation)}
- disabled={busy || !invitation.canCancel}
- title={
- invitation.canCancel
- ? 'Cancel invitation'
- : 'You can only cancel invitations for teams you can invite to.'
- }
- >
- Cancel
- </button>
- </div>
+ <td className="eft-table__cell--actions">
+ <RowActionMenu
+ ariaLabel={`Actions for invitation ${invitation.email}`}
+ actions={[
+ {
+ key: 'resend',
+ label: 'Resend invitation',
+ disabled: busy || !invitation.canResend,
+ onSelect: () => void resendInvitation(invitation),
+ },
+ {
+ key: 'cancel',
+ label: 'Cancel invitation',
+ danger: true,
+ disabled: busy || !invitation.canCancel,
+ onSelect: () => void cancelInvitation(invitation),
+ },
+ ]}
+ />
</td>
</tr>
))}
@@ -230,26 +263,41 @@ export default function MembersPage() {
<DataTable className="eft-table members-table">
<thead>
<tr>
- <th>Member</th>
- <th>Email</th>
- <th>Teams</th>
+ <TableHeaderCell
+ activeDirection={memberSort.key === 'name' ? memberSort.direction : null}
+ label="Member"
+ onSort={() => memberSort.sortBy('name')}
+ />
+ <TableHeaderCell
+ activeDirection={memberSort.key === 'email' ? memberSort.direction : null}
+ label="Email"
+ onSort={() => memberSort.sortBy('email')}
+ />
+ <TableHeaderCell
+ activeDirection={memberSort.key === 'teams' ? memberSort.direction : null}
+ label="Teams"
+ onSort={() => memberSort.sortBy('teams')}
+ />
<th></th>
</tr>
</thead>
<tbody>
- {members.map(member => {
+ {memberSort.sortedRows.map(member => {
const deleteAllowed = canDeleteMemberAccount(member, currentUserId)
return (
- <tr key={member.id}>
- <td>
- <button
- type="button"
- className="table-link"
- onClick={() => router.push(PROFILE_ROUTES.members.detail(member.id))}
- >
- {displayMemberName(member)}
- </button>
- </td>
+ <tr
+ className="eft-table__row--navigable"
+ key={member.id}
+ onClick={() => router.push(PROFILE_ROUTES.members.detail(member.id))}
+ onKeyDown={event => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault()
+ router.push(PROFILE_ROUTES.members.detail(member.id))
+ }
+ }}
+ tabIndex={0}
+ >
+ <td>{displayMemberName(member)}</td>
<td>
<span className="member-email">
<span>{member.email}</span>
@@ -265,19 +313,29 @@ export default function MembersPage() {
</span>
</td>
<td>{member.teams.length}</td>
- <td>
- <div className="row-actions">
- <button
- type="button"
- className="icon-button icon-button--danger"
- onClick={() => void deleteMemberAccount(member)}
- disabled={busy || !deleteAllowed}
- title={memberDeleteTooltip(member, currentUserId)}
- aria-label={`Delete ${displayMemberName(member)}`}
- >
- <IconTrash />
- </button>
- </div>
+ <td
+ className="eft-table__cell--actions"
+ onClick={event => event.stopPropagation()}
+ onKeyDown={event => event.stopPropagation()}
+ >
+ <RowActionMenu
+ ariaLabel={`Actions for ${displayMemberName(member)}`}
+ actions={[
+ {
+ key: 'view',
+ label: 'View details',
+ onSelect: () =>
+ router.push(PROFILE_ROUTES.members.detail(member.id)),
+ },
+ {
+ key: 'delete',
+ label: 'Delete member',
+ danger: true,
+ disabled: busy || !deleteAllowed,
+ onSelect: () => void deleteMemberAccount(member),
+ },
+ ]}
+ />
</td>
</tr>
)
diff --git a/profile-ui/app/settings/SettingsChannelSection.tsx b/profile-ui/app/settings/SettingsChannelSection.tsx
index dd760ad4b..69777622f 100644
--- a/profile-ui/app/settings/SettingsChannelSection.tsx
+++ b/profile-ui/app/settings/SettingsChannelSection.tsx
@@ -1,3 +1,4 @@
+import { RecordList, RecordListRow, RowActionMenu } from '@clerum/frontend-table-system'
import { Button } from '@components/Button'
import { TextInput } from '@components/TextInput'
import type {
@@ -36,10 +37,10 @@ export function SettingsChannelSection({
<h3 className="settings-subtitle">{section.title}</h3>
<p className="settings-help">{section.description}</p>
</div>
- <div className="settings-channel-rows">
+ <RecordList className="settings-channel-rows">
{!hasValues && <div className="small muted">No values added.</div>}
{readonlyValues.map(row => (
- <div className="settings-channel-readonly-row" key={row.id}>
+ <RecordListRow className="settings-channel-readonly-row" key={row.id}>
<div className="settings-channel-readonly-content">
<div className="settings-channel-readonly-value">{row.value}</div>
<div className="settings-channel-readonly-caption">{row.caption}</div>
@@ -53,10 +54,10 @@ export function SettingsChannelSection({
{row.actionLabel}
</Button>
)}
- </div>
+ </RecordListRow>
))}
{rows.map(row => (
- <div className="settings-channel-row" key={row.id}>
+ <RecordListRow className="settings-channel-row" key={row.id}>
<TextInput
className="fluid-control"
value={row.value}
@@ -65,19 +66,24 @@ export function SettingsChannelSection({
aria-label={section.title}
disabled={disabled}
/>
- <Button
- variant="ghost"
- onClick={() => void onRemove(section.key, row.id)}
- disabled={disabled}
- >
- Remove
- </Button>
- </div>
+ <RowActionMenu
+ ariaLabel={`Actions for ${row.value || section.title}`}
+ actions={[
+ {
+ key: 'remove',
+ label: 'Remove',
+ danger: true,
+ disabled,
+ onSelect: () => void onRemove(section.key, row.id),
+ },
+ ]}
+ />
+ </RecordListRow>
))}
<Button variant="secondary" onClick={() => onAdd(section.key)} disabled={disabled}>
{section.addLabel}
</Button>
- </div>
+ </RecordList>
</div>
)
}
diff --git a/profile-ui/app/settings/TelegramVerificationPanel.tsx b/profile-ui/app/settings/TelegramVerificationPanel.tsx
index 25bc75c2e..870c9ed8b 100644
--- a/profile-ui/app/settings/TelegramVerificationPanel.tsx
+++ b/profile-ui/app/settings/TelegramVerificationPanel.tsx
@@ -1,6 +1,7 @@
'use client'
import { useEffect, useMemo, useState } from 'react'
+import { RecordList, RecordListRow, RowActionMenu } from '@clerum/frontend-table-system'
import { Button } from '@components/Button'
import { CheckboxField } from '@components/CheckboxField'
import { FormField } from '@components/FormField'
@@ -211,9 +212,9 @@ export function TelegramVerificationPanel({
)}
{accounts.length > 0 ? (
- <div className="settings-target-list">
+ <RecordList className="settings-target-list">
{accounts.map(account => (
- <div className="settings-target-row" key={account.id}>
+ <RecordListRow className="settings-target-row" key={account.id}>
<div>
<div className="settings-target-title">{approvalAccountDisplayName(account)}</div>
<div className="settings-target-meta">
@@ -223,35 +224,27 @@ export function TelegramVerificationPanel({
))}
</div>
</div>
- <div className="settings-target-actions">
- <Button
- variant="secondary"
- className="cu-btn--icon cu-btn--toolbar"
- onClick={() => openDisplayNameModal(account)}
- disabled={disabled}
- aria-label={`Edit ${approvalAccountDisplayName(account)} display name`}
- title={`Edit ${approvalAccountDisplayName(account)} display name`}
- >
- <IconPencil />
- </Button>
- <Button
- variant="secondary"
- className="cu-btn--icon cu-btn--danger-icon"
- onClick={() => onRemoveAccount(account.id, Boolean(account.disabledAt))}
- disabled={disabled}
- aria-label={
- account.disabledAt
- ? `Remove ${approvalAccountDisplayName(account)} record`
- : `Delete ${approvalAccountDisplayName(account)} connection`
- }
- title={account.disabledAt ? 'Remove record' : 'Delete connection'}
- >
- <IconTrash />
- </Button>
- </div>
- </div>
+ <RowActionMenu
+ ariaLabel={`Actions for ${approvalAccountDisplayName(account)}`}
+ actions={[
+ {
+ key: 'edit',
+ label: 'Edit display name',
+ disabled,
+ onSelect: () => openDisplayNameModal(account),
+ },
+ {
+ key: 'delete',
+ label: account.disabledAt ? 'Remove record' : 'Delete connection',
+ danger: true,
+ disabled,
+ onSelect: () => onRemoveAccount(account.id, Boolean(account.disabledAt)),
+ },
+ ]}
+ />
+ </RecordListRow>
))}
- </div>
+ </RecordList>
) : null}
{modalOpen ? (
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 043c25052..385694665 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.126",
+ "version": "0.1.127",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.126",
+ "version": "0.1.127",
"dependencies": {
"@clerum/desktop-app-links": "file:../packages/desktop-app-links",
"@clerum/frontend-table-system": "file:../packages/frontend-table-system",
diff --git a/profile-ui/package.json b/profile-ui/package.json
index af5bf5274..66cf3f57a 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.126",
+ "version": "0.1.127",
"private": true,
"scripts": {
"dev": "next dev",