|
| 1 | +# Settings Schema Migration Plan |
| 2 | + |
| 3 | +## Context |
| 4 | + |
| 5 | +Non-universal base fields (query_port, admin_password, auto_restart, etc.) are hardcoded in the server edit panel and create dialog. The `settingsSchema` feature was WIP but never committed. The `GameSettingsRenderer` component, `ReforgerScenarioPicker`, `SettingsSchemaTest`, and TS types exist as untracked files. The tracked file modifications (interface, handlers, controller) were lost and need to be recreated. |
| 6 | + |
| 7 | +## What's Done |
| 8 | + |
| 9 | +1. `GameHandler.php` interface — PHPDoc types added, `settingsSchema()` method declared |
| 10 | + |
| 11 | +## Remaining Steps |
| 12 | + |
| 13 | +### Backend (PHP) |
| 14 | + |
| 15 | +2. **Arma3Handler** — implement `settingsSchema()` returning 4 sections: |
| 16 | + - Server Rules (`showOnCreate: true`, `createLabel: 'Arma 3 Options'`): verify_signatures, allowed_file_patching, battle_eye, von_enabled, persistent, auto_restart |
| 17 | + - Difficulty Settings (`collapsible: true`, `source: 'difficulty_settings'`, `layout: 'columns'`, 3 groups): 23 fields (10 toggles, 10 segmented, 2 number + separator) |
| 18 | + - Network Settings (`collapsible: true`, `source: 'network_settings'`, `layout: 'rows'`, 2 presets — "Reset to Default" and "Apply High Performance"): 11 fields (8 number, 3 text/decimal) |
| 19 | + - Advanced (`advanced: true`): additional_params (`source: 'server'`), additional_server_options |
| 20 | + |
| 21 | +3. **ReforgerHandler** — implement `settingsSchema()` returning 1 section: |
| 22 | + - Reforger Settings (`source: 'reforger_settings'`): scenario_id (`type: 'custom'`, `component: 'scenario-picker'`), third_person_view_enabled, battle_eye (`source: 'server'`), cross_platform, max_fps |
| 23 | + |
| 24 | +4. **DayZHandler** — implement `settingsSchema()` returning empty array `[]` |
| 25 | + |
| 26 | +5. **ServerController::index()** — add `'settingsSchema' => $handler->settingsSchema()` to the `gameTypes` Inertia prop |
| 27 | + |
| 28 | +### Frontend (TypeScript/React) |
| 29 | + |
| 30 | +6. **server-edit-panel.tsx** — rewrite to use `GameSettingsRenderer` + `buildEditDataFromSchema`: |
| 31 | + - Keep hardcoded: name, port (with auto-sync to query_port if exists in data), max_players, description, game_install_id, active_preset_id, backup section |
| 32 | + - Schema-driven via renderer: all game-specific sections + connection fields (query_port, password, admin_password) |
| 33 | + - Advanced accordion: render `getAdvancedFields()` from schema only, remove hardcoded additional_params/additional_server_options |
| 34 | + - Remove imports of `DifficultySettingsSection`, `NetworkSettingsSection` |
| 35 | + - Replace `EditData` type with `Record<string, unknown>` |
| 36 | + |
| 37 | +7. **create-server-dialog.tsx** — rewrite to use `GameSettingsRenderer` + `getSchemaDefaults`: |
| 38 | + - Keep hardcoded: game_type, name, port (with auto-sync), max_players, game_install_id, active_preset_id |
| 39 | + - Schema-driven: `showOnCreate` sections (Server Rules for Arma 3) |
| 40 | + - Remove hardcoded Arma 3 toggles, additional_params, additional_server_options |
| 41 | + - Use `getSchemaDefaults(gt.settingsSchema, true)` for form defaults |
| 42 | + |
| 43 | +8. **servers/index.tsx** — pass `settingsSchema` from `gameTypes` to `ServerCard` |
| 44 | + |
| 45 | +9. **server-card.tsx** — accept and pass `settingsSchema` to `ServerEditPanel` |
| 46 | + |
| 47 | +### Testing & Cleanup |
| 48 | + |
| 49 | +10. Update `SettingsSchemaTest.php` — adjust section counts if Connection fields are added as new sections (currently tests expect Arma3: 4, Reforger: 1, DayZ: 0). Add assertions for connection/advanced fields with `source: 'server'`. |
| 50 | + |
| 51 | +11. Run Pint: `vendor/bin/pint --dirty --format agent` |
| 52 | + |
| 53 | +12. Run affected tests: `php artisan test --compact tests/Feature/GameHandlers/SettingsSchemaTest.php` |
| 54 | + |
| 55 | +13. Run full test suite: `php artisan test --compact` |
| 56 | + |
| 57 | +## Design Decisions (Confirmed) |
| 58 | + |
| 59 | +- `additional_params`: removed from create dialog, lives in advanced section only |
| 60 | +- Port auto-sync: kept — port onChange checks if `query_port` exists in form data and sets `port + 1` |
| 61 | +- `description`: stays hardcoded (universal field), edit-only (not on create dialog) |
| 62 | +- Connection fields (query_port, password, admin_password): schema-driven with `source: 'server'`, in a section with `showOnCreate: true` |
| 63 | +- `auto_restart`: only in Arma 3 Server Rules section (only game with crash detection strings) |
| 64 | + |
| 65 | +## Key Files |
| 66 | + |
| 67 | +### Surviving WIP (untracked, not lost) |
| 68 | + |
| 69 | +- `resources/js/components/servers/game-settings-renderer.tsx` (698 lines) |
| 70 | +- `resources/js/components/servers/reforger-scenario-picker.tsx` (163 lines) |
| 71 | +- `tests/Feature/GameHandlers/SettingsSchemaTest.php` (495 lines) |
| 72 | +- `app/Contracts/SupportsReforgerMods.php` (9 lines) |
| 73 | +- `resources/js/types/game.ts` — TS schema types already committed |
| 74 | + |
| 75 | +### Files to modify |
| 76 | + |
| 77 | +- `app/Contracts/GameHandler.php` (done) |
| 78 | +- `app/GameHandlers/Arma3Handler.php` |
| 79 | +- `app/GameHandlers/ReforgerHandler.php` |
| 80 | +- `app/GameHandlers/DayZHandler.php` |
| 81 | +- `app/Http/Controllers/ServerController.php` |
| 82 | +- `resources/js/components/servers/server-edit-panel.tsx` |
| 83 | +- `resources/js/components/servers/create-server-dialog.tsx` |
| 84 | +- `resources/js/pages/servers/index.tsx` |
| 85 | +- `resources/js/components/servers/server-card.tsx` |
| 86 | + |
| 87 | +### Files to eventually remove (replaced by schema renderer) |
| 88 | + |
| 89 | +- `resources/js/components/servers/difficulty-settings-section.tsx` |
| 90 | +- `resources/js/components/servers/network-settings-section.tsx` |
0 commit comments