Skip to content

feat(settings): admin settings page (Settings → SlyTranslate) + REST backend#12

Closed
slydlake wants to merge 1 commit into
feat/acf-meta-key-filtersfrom
feat/settings-ui
Closed

feat(settings): admin settings page (Settings → SlyTranslate) + REST backend#12
slydlake wants to merge 1 commit into
feat/acf-meta-key-filtersfrom
feat/settings-ui

Conversation

@slydlake

Copy link
Copy Markdown
Contributor

Implements phases 1+2 of plan/settings-ui-plan.md (Stand 2026-06-12, Basis v1.10.0).

Stacked on feat/acf-meta-key-filters (the v1.10.0 base the plan references) so the diff contains only the settings-UI work. Retarget to main after the ACF PR merges.

Why

The plugin had no admin settings page at all — global settings were only reachable via the MCP configure ability, /wp/v2/settings, or PHP filters. For site owners without an MCP client the plugin was effectively unconfigurable.

Phase 1 — REST endpoints (no second config path)

  • GET/POST ai-translate/v1/settings → reuse AI_Translate::execute_configure(), so validation (incl. SSRF guard) and the direct-API probe side effects stay identical to MCP. The payload is enriched with status-line facts: detected language plugin, AI-client availability, default prompt template, learned context windows.
  • POST ai-translate/v1/settings/probe-concurrency → wraps ConfigurationService::probe_string_table_concurrency() (previously unreachable without MCP).
  • All routes gated on manage_options, nonce via wp_rest (api-fetch).

Phase 2 — settings page (Einstellungen → SlyTranslate)

  • SettingsPage class: add_options_page (no top-level menu), assets enqueued only on its own screen.
  • Build-free React app on @wordpress/components (assets/settings-page.js), matching the existing asset style:
    • Status line: language plugin ✓/✗, SEO plugin, AI client, effective model, direct-API kwargs probe status
    • Model: dropdown from get-available-models + refresh button
    • Translation: site-wide prompt addon
    • Meta fields: effective lists (read-only, with SEO source) + the two free-text "additional keys" fields
    • Advanced (collapsed): prompt template + reset-to-default, context-window override with learned values, direct API URL, string-table concurrency slider + "Test concurrency" with result table (only for string-table adapters), transport diagnostics
  • Explicit save button, posts only changed fields (one request, snackbar on success).
  • Per plan not in the UI: auto_translate_new (dead switch), force_direct_api (deprecated), learned/internal options as editable fields.

Out of scope (per plan)

Phase 3 (meta-key exclusion checkboxes — needs describe_effective_meta_keys() from the ACF plan) and phase 4 (glossary/automation sections) — the page structure accommodates them.

Tests

  • New SettingsPageTest (menu registration, asset gating, route registration + manage_options permission, payload enrichment, flat + enveloped POST bodies)
  • HookRegistrationTest updated for the new hooks; add_options_page stub added
  • 482 unit tests pass (composer test:unit); php -l + node --check clean

Note: changelog/readme entries intentionally left out to avoid conflicts with the in-flight v1.11.0 work — add them at release time.

🤖 Generated with Claude Code

…backend

Implements phases 1+2 of plan/settings-ui-plan.md. The plugin previously
had no admin settings page at all — global settings were reachable only
via the MCP configure ability, /wp/v2/settings, or PHP filters.

Phase 1 — REST endpoints (thin wrappers, no second config path):
- GET/POST ai-translate/v1/settings reuse AI_Translate::execute_configure()
  so validation and the direct-API probe side effects stay identical to
  the MCP ability; the payload is enriched with the environment facts the
  status line needs (language plugin, AI client, default prompt template,
  learned context windows).
- POST ai-translate/v1/settings/probe-concurrency wraps
  ConfigurationService::probe_string_table_concurrency().
- All routes gated on manage_options.

Phase 2 — settings page:
- SettingsPage registers an options page (no top-level menu) and enqueues
  assets/settings-page.js only on its own screen.
- React app on @wordpress/components: status line, model dropdown with
  refresh, site-wide prompt addon, meta-key extra fields with effective
  lists, collapsed Advanced section (prompt template + reset, context
  window override with learned values, direct API URL with probe status,
  string-table concurrency slider + probe — shown only for string-table
  adapters — and transport diagnostics).
- Explicit save button posts only changed fields; auto_translate_new
  (dead switch) and force_direct_api (deprecated) stay out of the UI per
  plan.

Tests: SettingsPageTest (menu, asset gating, route registration,
permissions, payload enrichment, flat + enveloped POST bodies),
HookRegistrationTest updated for the new hooks, add_options_page stub
added. 482 unit tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@slydlake

Copy link
Copy Markdown
Contributor Author

Closing without merging: the settings page implemented here (Phase 1-2 of settings-ui-plan.md) is superseded by the more complete settings page shipped in #14 (v1.11.0), which covers phases 1-4 (status row, model picker, glossary editor, meta-field exclusion list, automation toggles, advanced section). #14 rewrites SettingsPage.php/settings-page.js from scratch on top of this branch's base, so merging this PR first would only add churn.

@slydlake slydlake closed this Jun 13, 2026
@slydlake slydlake deleted the feat/settings-ui branch June 13, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant