refactor: use SplitPane and EntityList in Admin RBAC tabs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,10 @@ import { InlineEdit } from '../../../design-system/primitives/InlineEdit/InlineE
|
|||||||
import { MultiSelect } from '../../../design-system/composites/MultiSelect/MultiSelect'
|
import { MultiSelect } from '../../../design-system/composites/MultiSelect/MultiSelect'
|
||||||
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
||||||
import { AlertDialog } from '../../../design-system/composites/AlertDialog/AlertDialog'
|
import { AlertDialog } from '../../../design-system/composites/AlertDialog/AlertDialog'
|
||||||
|
import { SplitPane } from '../../../design-system/composites/SplitPane/SplitPane'
|
||||||
|
import { EntityList } from '../../../design-system/composites/EntityList/EntityList'
|
||||||
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
||||||
import { MOCK_GROUPS, MOCK_USERS, MOCK_ROLES, getChildGroups, type MockGroup } from './rbacMocks'
|
import { MOCK_GROUPS, MOCK_USERS, MOCK_ROLES, type MockGroup } from './rbacMocks'
|
||||||
import styles from './UserManagement.module.css'
|
import styles from './UserManagement.module.css'
|
||||||
|
|
||||||
export function GroupsTab() {
|
export function GroupsTab() {
|
||||||
@@ -83,21 +85,9 @@ export function GroupsTab() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.splitPane}>
|
<SplitPane
|
||||||
<div className={styles.listPane}>
|
list={
|
||||||
<div className={styles.listHeader}>
|
<>
|
||||||
<Input
|
|
||||||
placeholder="Search groups..."
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
onClear={() => setSearch('')}
|
|
||||||
className={styles.listHeaderSearch}
|
|
||||||
/>
|
|
||||||
<Button size="sm" variant="secondary" onClick={() => setCreating(true)}>
|
|
||||||
+ Add group
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{creating && (
|
{creating && (
|
||||||
<div className={styles.createForm}>
|
<div className={styles.createForm}>
|
||||||
<Input placeholder="Group name *" value={newName} onChange={(e) => setNewName(e.target.value)} />
|
<Input placeholder="Group name *" value={newName} onChange={(e) => setNewName(e.target.value)} />
|
||||||
@@ -114,21 +104,14 @@ export function GroupsTab() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={styles.entityList} role="listbox" aria-label="Groups">
|
<EntityList
|
||||||
{filtered.map((group) => {
|
items={filtered}
|
||||||
|
renderItem={(group) => {
|
||||||
const groupChildren = groups.filter((g) => g.parentId === group.id)
|
const groupChildren = groups.filter((g) => g.parentId === group.id)
|
||||||
const groupMembers = MOCK_USERS.filter((u) => u.directGroups.includes(group.id))
|
const groupMembers = MOCK_USERS.filter((u) => u.directGroups.includes(group.id))
|
||||||
const groupParent = group.parentId ? groups.find((g) => g.id === group.parentId) : null
|
const groupParent = group.parentId ? groups.find((g) => g.id === group.parentId) : null
|
||||||
return (
|
return (
|
||||||
<div
|
<>
|
||||||
key={group.id}
|
|
||||||
className={`${styles.entityItem} ${selectedId === group.id ? styles.entityItemSelected : ''}`}
|
|
||||||
onClick={() => setSelectedId(group.id)}
|
|
||||||
role="option"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-selected={selectedId === group.id}
|
|
||||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setSelectedId(group.id) } }}
|
|
||||||
>
|
|
||||||
<Avatar name={group.name} size="sm" />
|
<Avatar name={group.name} size="sm" />
|
||||||
<div className={styles.entityInfo}>
|
<div className={styles.entityInfo}>
|
||||||
<div className={styles.entityName}>{group.name}</div>
|
<div className={styles.entityName}>{group.name}</div>
|
||||||
@@ -140,17 +123,21 @@ export function GroupsTab() {
|
|||||||
{group.directRoles.map((r) => <Badge key={r} label={r} color="warning" />)}
|
{group.directRoles.map((r) => <Badge key={r} label={r} color="warning" />)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
)
|
)
|
||||||
})}
|
}}
|
||||||
{filtered.length === 0 && (
|
getItemId={(group) => group.id}
|
||||||
<div className={styles.emptySearch}>No groups match your search</div>
|
selectedId={selectedId ?? undefined}
|
||||||
)}
|
onSelect={setSelectedId}
|
||||||
</div>
|
searchPlaceholder="Search groups..."
|
||||||
</div>
|
onSearch={setSearch}
|
||||||
|
addLabel="+ Add group"
|
||||||
<div className={styles.detailPane}>
|
onAdd={() => setCreating(true)}
|
||||||
{selected ? (
|
emptyMessage="No groups match your search"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
detail={selected ? (
|
||||||
<>
|
<>
|
||||||
<div className={styles.detailHeader}>
|
<div className={styles.detailHeader}>
|
||||||
<Avatar name={selected.name} size="lg" />
|
<Avatar name={selected.name} size="lg" />
|
||||||
@@ -279,11 +266,9 @@ export function GroupsTab() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : null}
|
||||||
<div className={styles.emptyDetail}>Select a group to view details</div>
|
emptyMessage="Select a group to view details"
|
||||||
)}
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={deleteTarget !== null}
|
open={deleteTarget !== null}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { MonoText } from '../../../design-system/primitives/MonoText/MonoText'
|
|||||||
import { SectionHeader } from '../../../design-system/primitives/SectionHeader/SectionHeader'
|
import { SectionHeader } from '../../../design-system/primitives/SectionHeader/SectionHeader'
|
||||||
import { Tag } from '../../../design-system/primitives/Tag/Tag'
|
import { Tag } from '../../../design-system/primitives/Tag/Tag'
|
||||||
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
||||||
|
import { SplitPane } from '../../../design-system/composites/SplitPane/SplitPane'
|
||||||
|
import { EntityList } from '../../../design-system/composites/EntityList/EntityList'
|
||||||
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
||||||
import { MOCK_ROLES, MOCK_GROUPS, MOCK_USERS, getEffectiveRoles, type MockRole } from './rbacMocks'
|
import { MOCK_ROLES, MOCK_GROUPS, MOCK_USERS, getEffectiveRoles, type MockRole } from './rbacMocks'
|
||||||
import styles from './UserManagement.module.css'
|
import styles from './UserManagement.module.css'
|
||||||
@@ -79,21 +81,9 @@ export function RolesTab() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.splitPane}>
|
<SplitPane
|
||||||
<div className={styles.listPane}>
|
list={
|
||||||
<div className={styles.listHeader}>
|
<>
|
||||||
<Input
|
|
||||||
placeholder="Search roles..."
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
onClear={() => setSearch('')}
|
|
||||||
className={styles.listHeaderSearch}
|
|
||||||
/>
|
|
||||||
<Button size="sm" variant="secondary" onClick={() => setCreating(true)}>
|
|
||||||
+ Add role
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{creating && (
|
{creating && (
|
||||||
<div className={styles.createForm}>
|
<div className={styles.createForm}>
|
||||||
<Input placeholder="Role name *" value={newName} onChange={(e) => setNewName(e.target.value)} />
|
<Input placeholder="Role name *" value={newName} onChange={(e) => setNewName(e.target.value)} />
|
||||||
@@ -106,17 +96,10 @@ export function RolesTab() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={styles.entityList} role="listbox" aria-label="Roles">
|
<EntityList
|
||||||
{filtered.map((role) => (
|
items={filtered}
|
||||||
<div
|
renderItem={(role) => (
|
||||||
key={role.id}
|
<>
|
||||||
className={`${styles.entityItem} ${selectedId === role.id ? styles.entityItemSelected : ''}`}
|
|
||||||
onClick={() => setSelectedId(role.id)}
|
|
||||||
role="option"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-selected={selectedId === role.id}
|
|
||||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setSelectedId(role.id) } }}
|
|
||||||
>
|
|
||||||
<Avatar name={role.name} size="sm" />
|
<Avatar name={role.name} size="sm" />
|
||||||
<div className={styles.entityInfo}>
|
<div className={styles.entityInfo}>
|
||||||
<div className={styles.entityName}>
|
<div className={styles.entityName}>
|
||||||
@@ -133,16 +116,20 @@ export function RolesTab() {
|
|||||||
.map((u) => <Badge key={u.id} label={u.username} color="auto" />)}
|
.map((u) => <Badge key={u.id} label={u.username} color="auto" />)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
))}
|
|
||||||
{filtered.length === 0 && (
|
|
||||||
<div className={styles.emptySearch}>No roles match your search</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
getItemId={(role) => role.id}
|
||||||
</div>
|
selectedId={selectedId ?? undefined}
|
||||||
|
onSelect={setSelectedId}
|
||||||
<div className={styles.detailPane}>
|
searchPlaceholder="Search roles..."
|
||||||
{selected ? (
|
onSearch={setSearch}
|
||||||
|
addLabel="+ Add role"
|
||||||
|
onAdd={() => setCreating(true)}
|
||||||
|
emptyMessage="No roles match your search"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
detail={selected ? (
|
||||||
<>
|
<>
|
||||||
<div className={styles.detailHeader}>
|
<div className={styles.detailHeader}>
|
||||||
<Avatar name={selected.name} size="lg" />
|
<Avatar name={selected.name} size="lg" />
|
||||||
@@ -209,11 +196,9 @@ export function RolesTab() {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : null}
|
||||||
<div className={styles.emptyDetail}>Select a role to view details</div>
|
emptyMessage="Select a role to view details"
|
||||||
)}
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={deleteTarget !== null}
|
open={deleteTarget !== null}
|
||||||
|
|||||||
@@ -1,63 +1,3 @@
|
|||||||
.splitPane {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 52fr 48fr;
|
|
||||||
gap: 1px;
|
|
||||||
background: var(--border-subtle);
|
|
||||||
border: 1px solid var(--border-subtle);
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
min-height: 500px;
|
|
||||||
box-shadow: var(--shadow-card);
|
|
||||||
}
|
|
||||||
|
|
||||||
.listPane {
|
|
||||||
background: var(--bg-surface);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
border-radius: var(--radius-lg) 0 0 var(--radius-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailPane {
|
|
||||||
background: var(--bg-surface);
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.listHeader {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
border-bottom: 1px solid var(--border-subtle);
|
|
||||||
}
|
|
||||||
|
|
||||||
.listHeaderSearch {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entityList {
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entityItem {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.1s;
|
|
||||||
border-bottom: 1px solid var(--border-subtle);
|
|
||||||
}
|
|
||||||
|
|
||||||
.entityItem:hover {
|
|
||||||
background: var(--bg-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.entityItemSelected {
|
|
||||||
background: var(--bg-raised);
|
|
||||||
}
|
|
||||||
|
|
||||||
.entityInfo {
|
.entityInfo {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -140,16 +80,6 @@
|
|||||||
max-width: 240px;
|
max-width: 240px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emptyDetail {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
|
||||||
color: var(--text-faint);
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: var(--font-body);
|
|
||||||
}
|
|
||||||
|
|
||||||
.createForm {
|
.createForm {
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
border-bottom: 1px solid var(--border-subtle);
|
border-bottom: 1px solid var(--border-subtle);
|
||||||
@@ -190,14 +120,6 @@
|
|||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emptySearch {
|
|
||||||
padding: 32px;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--text-faint);
|
|
||||||
font-size: 12px;
|
|
||||||
font-family: var(--font-body);
|
|
||||||
}
|
|
||||||
|
|
||||||
.securitySection {
|
.securitySection {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { InfoCallout } from '../../../design-system/primitives/InfoCallout/InfoC
|
|||||||
import { MultiSelect } from '../../../design-system/composites/MultiSelect/MultiSelect'
|
import { MultiSelect } from '../../../design-system/composites/MultiSelect/MultiSelect'
|
||||||
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
import { ConfirmDialog } from '../../../design-system/composites/ConfirmDialog/ConfirmDialog'
|
||||||
import { AlertDialog } from '../../../design-system/composites/AlertDialog/AlertDialog'
|
import { AlertDialog } from '../../../design-system/composites/AlertDialog/AlertDialog'
|
||||||
|
import { SplitPane } from '../../../design-system/composites/SplitPane/SplitPane'
|
||||||
|
import { EntityList } from '../../../design-system/composites/EntityList/EntityList'
|
||||||
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
import { useToast } from '../../../design-system/composites/Toast/Toast'
|
||||||
import { MOCK_USERS, MOCK_GROUPS, MOCK_ROLES, getEffectiveRoles, type MockUser } from './rbacMocks'
|
import { MOCK_USERS, MOCK_GROUPS, MOCK_ROLES, getEffectiveRoles, type MockUser } from './rbacMocks'
|
||||||
import styles from './UserManagement.module.css'
|
import styles from './UserManagement.module.css'
|
||||||
@@ -97,21 +99,9 @@ export function UsersTab() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.splitPane}>
|
<SplitPane
|
||||||
<div className={styles.listPane}>
|
list={
|
||||||
<div className={styles.listHeader}>
|
<>
|
||||||
<Input
|
|
||||||
placeholder="Search users..."
|
|
||||||
value={search}
|
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
|
||||||
onClear={() => setSearch('')}
|
|
||||||
className={styles.listHeaderSearch}
|
|
||||||
/>
|
|
||||||
<Button size="sm" variant="secondary" onClick={() => setCreating(true)}>
|
|
||||||
+ Add user
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{creating && (
|
{creating && (
|
||||||
<div className={styles.createForm}>
|
<div className={styles.createForm}>
|
||||||
<RadioGroup name="provider" value={newProvider} onChange={(v) => setNewProvider(v as 'local' | 'oidc')} orientation="horizontal">
|
<RadioGroup name="provider" value={newProvider} onChange={(v) => setNewProvider(v as 'local' | 'oidc')} orientation="horizontal">
|
||||||
@@ -146,17 +136,10 @@ export function UsersTab() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={styles.entityList} role="listbox" aria-label="Users">
|
<EntityList
|
||||||
{filtered.map((user) => (
|
items={filtered}
|
||||||
<div
|
renderItem={(user) => (
|
||||||
key={user.id}
|
<>
|
||||||
className={`${styles.entityItem} ${selectedId === user.id ? styles.entityItemSelected : ''}`}
|
|
||||||
onClick={() => { setSelectedId(user.id); setResettingPassword(false) }}
|
|
||||||
role="option"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-selected={selectedId === user.id}
|
|
||||||
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setSelectedId(user.id); setResettingPassword(false) } }}
|
|
||||||
>
|
|
||||||
<Avatar name={user.displayName} size="sm" />
|
<Avatar name={user.displayName} size="sm" />
|
||||||
<div className={styles.entityInfo}>
|
<div className={styles.entityInfo}>
|
||||||
<div className={styles.entityName}>
|
<div className={styles.entityName}>
|
||||||
@@ -176,16 +159,20 @@ export function UsersTab() {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</>
|
||||||
))}
|
|
||||||
{filtered.length === 0 && (
|
|
||||||
<div className={styles.emptySearch}>No users match your search</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
getItemId={(user) => user.id}
|
||||||
</div>
|
selectedId={selectedId ?? undefined}
|
||||||
|
onSelect={(id) => { setSelectedId(id); setResettingPassword(false) }}
|
||||||
<div className={styles.detailPane}>
|
searchPlaceholder="Search users..."
|
||||||
{selected ? (
|
onSearch={setSearch}
|
||||||
|
addLabel="+ Add user"
|
||||||
|
onAdd={() => setCreating(true)}
|
||||||
|
emptyMessage="No users match your search"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
detail={selected ? (
|
||||||
<>
|
<>
|
||||||
<div className={styles.detailHeader}>
|
<div className={styles.detailHeader}>
|
||||||
<Avatar name={selected.displayName} size="lg" />
|
<Avatar name={selected.displayName} size="lg" />
|
||||||
@@ -346,11 +333,9 @@ export function UsersTab() {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : null}
|
||||||
<div className={styles.emptyDetail}>Select a user to view details</div>
|
emptyMessage="Select a user to view details"
|
||||||
)}
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={deleteTarget !== null}
|
open={deleteTarget !== null}
|
||||||
|
|||||||
Reference in New Issue
Block a user