feat(settings): admin settings page (Settings → SlyTranslate) + REST backend#12
Closed
slydlake wants to merge 1 commit into
Closed
feat(settings): admin settings page (Settings → SlyTranslate) + REST backend#12slydlake wants to merge 1 commit into
slydlake wants to merge 1 commit into
Conversation
…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>
1 task
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements phases 1+2 of
plan/settings-ui-plan.md(Stand 2026-06-12, Basis v1.10.0).Why
The plugin had no admin settings page at all — global settings were only reachable via the MCP
configureability,/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→ reuseAI_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→ wrapsConfigurationService::probe_string_table_concurrency()(previously unreachable without MCP).manage_options, nonce viawp_rest(api-fetch).Phase 2 — settings page (Einstellungen → SlyTranslate)
SettingsPageclass:add_options_page(no top-level menu), assets enqueued only on its own screen.@wordpress/components(assets/settings-page.js), matching the existing asset style:get-available-models+ refresh buttonauto_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
SettingsPageTest(menu registration, asset gating, route registration +manage_optionspermission, payload enrichment, flat + enveloped POST bodies)HookRegistrationTestupdated for the new hooks;add_options_pagestub addedcomposer test:unit);php -l+node --checkcleanNote: 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