feat: Phase 1 — Config UI Schema system with per-field widget routing
- Backend: add Arma3ConfigGenerator.get_ui_schema() with widget hints per field - Backend: add ServerService.get_config_schema() and GET /config/schema endpoint - Frontend: add FieldSchema/ConfigSchema types + useServerConfigSchema hook - Frontend: new TagListEditor component for dynamic string-list editing - Frontend: ConfigEditor now routes each field to correct widget (text/number/password/textarea/select/toggle/tag-list) - Frontend: password fields have show/hide toggle; toggles render as checkbox; tag-list uses TagListEditor - Tests: 8 new tests covering hook and TagListEditor; all 136 tests green
This commit is contained in:
@@ -115,6 +115,21 @@ export interface Mod {
|
||||
path: string;
|
||||
size_bytes: number;
|
||||
enabled: boolean;
|
||||
display_name: string | null;
|
||||
workshop_id: string | null;
|
||||
}
|
||||
|
||||
export interface FieldSchema {
|
||||
widget: "text" | "number" | "password" | "textarea" | "select" | "toggle" | "tag-list";
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
min?: number;
|
||||
max?: number;
|
||||
options?: string[];
|
||||
}
|
||||
|
||||
export interface ConfigSchema {
|
||||
[section: string]: { [field: string]: FieldSchema };
|
||||
}
|
||||
|
||||
export interface ModsResponse {
|
||||
@@ -125,6 +140,19 @@ export interface ModsResponse {
|
||||
|
||||
// ── Query Hooks ────────────────────────────────────────────────────────
|
||||
|
||||
export function useServerConfigSchema(serverId: number) {
|
||||
return useQuery({
|
||||
queryKey: ["servers", serverId, "config", "schema"],
|
||||
queryFn: async () => {
|
||||
const res = await apiClient.get<{ success: boolean; data: ConfigSchema }>(
|
||||
`/api/servers/${serverId}/config/schema`,
|
||||
);
|
||||
return res.data.data;
|
||||
},
|
||||
enabled: serverId > 0,
|
||||
});
|
||||
}
|
||||
|
||||
export function useServerConfig(serverId: number) {
|
||||
return useQuery({
|
||||
queryKey: ["servers", serverId, "config"],
|
||||
|
||||
Reference in New Issue
Block a user