Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
refactor(control-ui): extract the access picker modal into a shared component
Andy Pavia6088fcd20cc3
diff --git a/control-ui/components/HostAccessTab/index.tsx b/control-ui/components/HostAccessTab/index.tsxindex 710a76626..66edcf4ef 100644--- a/control-ui/components/HostAccessTab/index.tsx+++ b/control-ui/components/HostAccessTab/index.tsx@@ -3,7 +3,7 @@import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useRouter } from 'next/navigation'import { useConfirmDialog } from '@components/ConfirmDialog'-import { SelectionDropdown } from '@components/SelectionDropdown'+import { SelectionModal } from '@components/SelectionModal'import { TabBar } from '@components/TabBar'import { useToast } from '@components/Toast'import { IconX } from '@components/icons'@@ -404,7 +404,7 @@ export function HostAccessTab({ hostName }: HostAccessTabProps) {</div>{showAddUser ? (- <AccessGrantModal+ <SelectionModalbusy={busy}emptyLabel="No available members."id="agent-member-picker"@@ -427,7 +427,7 @@ export function HostAccessTab({ hostName }: HostAccessTabProps) {) : null}{showAddTeam ? (- <AccessGrantModal+ <SelectionModalbusy={busy}emptyLabel="No available teams."id="agent-team-picker"@@ -453,115 +453,3 @@ export function HostAccessTab({ hostName }: HostAccessTabProps) {</section>)}--type AccessGrantModalProps = {- busy: boolean- emptyLabel: string- id: string- label: string- onChange: (next: string[]) => void- onClose: () => void- onConfirm: () => Promise<void>- options: { value: string; label: string; description?: string; badge?: string }[]- placeholder: string- searchPlaceholder: string- selectionLabel: string- submitLabel: string- title: string- titleId: string- value: string[]-}--function AccessGrantModal({- busy,- emptyLabel,- id,- label,- onChange,- onClose,- onConfirm,- options,- placeholder,- searchPlaceholder,- selectionLabel,- submitLabel,- title,- titleId,- value,-}: AccessGrantModalProps) {- return (- <div- style={{- position: 'fixed',- inset: 0,- background: 'var(--cu-overlay)',- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- zIndex: 1000,- padding: '1rem',- }}- role="presentation"- onClick={e => {- if (e.target === e.currentTarget && !busy) onClose()- }}- >- <div- className="cu-modal-panel cu-modal-panel--selection"- role="dialog"- aria-labelledby={titleId}- onClick={e => e.stopPropagation()}- >- <div className="cu-modal-panel__head">- <strong id={titleId} style={{ fontSize: '1rem', lineHeight: 1.35 }}>- {title}- </strong>- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--ghost"- onClick={onClose}- disabled={busy}- aria-label="Close"- >- <IconX width={18} height={18} />- </button>- </div>-- <div className="cu-field">- <label htmlFor={id}>{label}</label>- <SelectionDropdown- emptyLabel={emptyLabel}- id={id}- inline- disabled={busy}- onChange={onChange}- options={options}- placeholder={placeholder}- searchPlaceholder={searchPlaceholder}- selectionLabel={selectionLabel}- value={value}- />- </div>-- <div className="cu-modal-panel__foot">- <button- type="button"- className="cu-btn cu-btn--ghost cu-btn--sm"- onClick={onClose}- disabled={busy}- >- Cancel- </button>- <button- type="button"- className="cu-btn cu-btn--primary"- onClick={() => void onConfirm()}- disabled={busy || value.length === 0}- >- {submitLabel}- </button>- </div>- </div>- </div>- )-}diff --git a/control-ui/components/SelectionModal/index.tsx b/control-ui/components/SelectionModal/index.tsxnew file mode 100644index 000000000..59df76600--- /dev/null+++ b/control-ui/components/SelectionModal/index.tsx@@ -0,0 +1,106 @@+'use client'++import React from 'react'+import { SelectionDropdown } from '@components/SelectionDropdown'+import { IconX } from '@components/icons'+import type { SelectionModalProps } from './types'++/**+ * "Pick some things from a list, then confirm" overlay — the Add member / Add+ * team / Add hook flow on the agent detail tabs. Extracted from HostAccessTab+ * so every one of those surfaces is literally the same control rather than a+ * near-copy that drifts.+ */+export function SelectionModal({+ busy,+ emptyLabel,+ id,+ label,+ onChange,+ onClose,+ onConfirm,+ options,+ placeholder,+ searchPlaceholder,+ selectionLabel,+ submitLabel,+ title,+ titleId,+ value,+}: SelectionModalProps) {+ return (+ <div+ style={{+ position: 'fixed',+ inset: 0,+ background: 'var(--cu-overlay)',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ zIndex: 1000,+ padding: '1rem',+ }}+ role="presentation"+ onClick={e => {+ if (e.target === e.currentTarget && !busy) onClose()+ }}+ >+ <div+ className="cu-modal-panel cu-modal-panel--selection"+ role="dialog"+ aria-labelledby={titleId}+ onClick={e => e.stopPropagation()}+ >+ <div className="cu-modal-panel__head">+ <strong id={titleId} style={{ fontSize: '1rem', lineHeight: 1.35 }}>+ {title}+ </strong>+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--ghost"+ onClick={onClose}+ disabled={busy}+ aria-label="Close"+ >+ <IconX width={18} height={18} />+ </button>+ </div>++ <div className="cu-field">+ <label htmlFor={id}>{label}</label>+ <SelectionDropdown+ emptyLabel={emptyLabel}+ id={id}+ inline+ disabled={busy}+ onChange={onChange}+ options={options}+ placeholder={placeholder}+ searchPlaceholder={searchPlaceholder}+ selectionLabel={selectionLabel}+ value={value}+ />+ </div>++ <div className="cu-modal-panel__foot">+ <button+ type="button"+ className="cu-btn cu-btn--ghost cu-btn--sm"+ onClick={onClose}+ disabled={busy}+ >+ Cancel+ </button>+ <button+ type="button"+ className="cu-btn cu-btn--primary"+ onClick={() => void onConfirm()}+ disabled={busy || value.length === 0}+ >+ {submitLabel}+ </button>+ </div>+ </div>+ </div>+ )+}diff --git a/control-ui/components/SelectionModal/types.ts b/control-ui/components/SelectionModal/types.tsnew file mode 100644index 000000000..9f386375c--- /dev/null+++ b/control-ui/components/SelectionModal/types.ts@@ -0,0 +1,24 @@+export type SelectionModalOption = {+ value: string+ label: string+ description?: string+ badge?: string+}++export type SelectionModalProps = {+ busy: boolean+ emptyLabel: string+ id: string+ label: string+ onChange: (next: string[]) => void+ onClose: () => void+ onConfirm: () => Promise<void>+ options: SelectionModalOption[]+ placeholder: string+ searchPlaceholder: string+ selectionLabel: string+ submitLabel: string+ title: string+ titleId: string+ value: string[]+}