import { useState } from 'react'; import type { CurrentUser } from '@reforger-panel/shared'; import { useConfiguration, usePrimaryServer } from '../api/hooks.js'; import { formatRelativeTime } from '../lib/format.js'; import { Card, EmptyState, PageHeader, SegmentedControl, Spinner } from '../components/ui.js'; import { ConfigKeyEditor } from '../components/config/key-editor.js'; import { ConfigRawEditor } from '../components/config/raw-editor.js'; import { PerformanceForm } from '../components/performance-form.js'; import { StartupVarsCard } from '../components/startup-vars-card.js'; import { SchedulesCard } from '../components/schedules-card.js'; import { ConfigSummaryRows } from '../components/widgets.js'; type Tab = 'settings' | 'keys' | 'raw' | 'startup' | 'schedules'; export function ConfigurationPage({ user }: { user: CurrentUser }) { const server = usePrimaryServer(); if (!server) return ; return ; } function ConfigurationBody({ slug, user }: { slug: string; user: CurrentUser }) { const canEdit = user.capabilities.includes('config.edit'); const [tab, setTab] = useState('settings'); const { data: config } = useConfiguration(slug); return (
Edits are written straight to the server’s config.json, verified by reading it back, and rejected if the file changed since this page loaded. {config && ` Read ${formatRelativeTime(config.fetchedAt)}.`} } /> value={tab} onChange={setTab} options={[ { value: 'settings', label: 'Settings', icon: 'sliders' }, { value: 'keys', label: 'All keys', icon: 'search' }, { value: 'raw', label: 'Raw JSON', icon: 'terminal' }, { value: 'startup', label: 'Startup variables', icon: 'server' }, { value: 'schedules', label: 'Restarts', icon: 'restart' }, ]} /> {tab === 'settings' && (
{config ? : }
)} {tab === 'keys' && ( )} {tab === 'raw' && ( )} {tab === 'startup' && (canEdit ? ( ) : ( ))} {tab === 'schedules' && }
); }