refactor(decnet_web/Config): extract types

Foundation for the Config split. UserEntry / ConfigData move out
of the page so the upcoming hook + tab extractions can import
without reaching back through Config.tsx. New ConfigTab union and
FormMsg type for the inline success/error chip pattern that
repeats across every admin form on the page.

- New Config/types.ts (UserEntry, ConfigData, ConfigTab, FormMsg)
- Config.tsx loses the inline interfaces and the `as any` cast on
  setActiveTab in the tab-switcher.
This commit is contained in:
2026-05-09 05:19:50 -04:00
parent 6ba12cc571
commit 209efd1a74
2 changed files with 30 additions and 16 deletions

View File

@@ -6,25 +6,12 @@ import RuleStateControls from './RuleStateControls';
import './Dashboard.css';
import './Config.css';
interface UserEntry {
uuid: string;
username: string;
role: string;
must_change_password: boolean;
}
interface ConfigData {
role: string;
deployment_limit: number;
global_mutation_interval: string;
users?: UserEntry[];
developer_mode?: boolean;
}
import type { ConfigData, ConfigTab } from './Config/types';
const Config: React.FC = () => {
const [config, setConfig] = useState<ConfigData | null>(null);
const [loading, setLoading] = useState(true);
const [activeTab, setActiveTab] = useState<'limits' | 'users' | 'globals' | 'appearance' | 'workers' | 'ttp'>('limits');
const [activeTab, setActiveTab] = useState<ConfigTab>('limits');
const [accent, setAccent] = useState<'matrix' | 'violet'>(() => {
try {
const raw = localStorage.getItem('decnet_tweaks');
@@ -256,7 +243,7 @@ const Config: React.FC = () => {
<button
key={tab.key}
className={`config-tab ${activeTab === tab.key ? 'active' : ''}`}
onClick={() => setActiveTab(tab.key as any)}
onClick={() => setActiveTab(tab.key as ConfigTab)}
>
{tab.icon}
{tab.label}

View File

@@ -0,0 +1,27 @@
/** Wire + UI types for the Config page surface. */
export interface UserEntry {
uuid: string;
username: string;
role: string;
must_change_password: boolean;
}
export interface ConfigData {
role: string;
deployment_limit: number;
global_mutation_interval: string;
users?: UserEntry[];
developer_mode?: boolean;
}
/** Inline success/error chip surfaced under each form section. */
export type FormMsg = { type: 'success' | 'error'; text: string };
export type ConfigTab =
| 'limits'
| 'users'
| 'globals'
| 'appearance'
| 'workers'
| 'ttp';