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:
@@ -6,25 +6,12 @@ import RuleStateControls from './RuleStateControls';
|
|||||||
import './Dashboard.css';
|
import './Dashboard.css';
|
||||||
import './Config.css';
|
import './Config.css';
|
||||||
|
|
||||||
interface UserEntry {
|
import type { ConfigData, ConfigTab } from './Config/types';
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Config: React.FC = () => {
|
const Config: React.FC = () => {
|
||||||
const [config, setConfig] = useState<ConfigData | null>(null);
|
const [config, setConfig] = useState<ConfigData | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
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'>(() => {
|
const [accent, setAccent] = useState<'matrix' | 'violet'>(() => {
|
||||||
try {
|
try {
|
||||||
const raw = localStorage.getItem('decnet_tweaks');
|
const raw = localStorage.getItem('decnet_tweaks');
|
||||||
@@ -256,7 +243,7 @@ const Config: React.FC = () => {
|
|||||||
<button
|
<button
|
||||||
key={tab.key}
|
key={tab.key}
|
||||||
className={`config-tab ${activeTab === tab.key ? 'active' : ''}`}
|
className={`config-tab ${activeTab === tab.key ? 'active' : ''}`}
|
||||||
onClick={() => setActiveTab(tab.key as any)}
|
onClick={() => setActiveTab(tab.key as ConfigTab)}
|
||||||
>
|
>
|
||||||
{tab.icon}
|
{tab.icon}
|
||||||
{tab.label}
|
{tab.label}
|
||||||
|
|||||||
27
decnet_web/src/components/Config/types.ts
Normal file
27
decnet_web/src/components/Config/types.ts
Normal 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';
|
||||||
Reference in New Issue
Block a user