Migrate settings page to plugin-ui schema-driven components#65
Migrate settings page to plugin-ui schema-driven components#65mrabbani wants to merge 4 commits intotest/dashboardfrom
Conversation
…onents Replace the hand-rolled React settings UI with the schema-driven <Settings> component from @wedevs/plugin-ui, backed by BaseSettingsRESTController from wedevs/wp-kit. Preserves full backward compatibility with the existing texty_settings wp_option structure and gateway credential validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces SMS metrics tracking, a schema-driven settings API, and a complete dashboard UI redesign. New API endpoints expose metrics and settings; gateways now return structured responses with reference IDs; SMS data is persisted via a new SmsStat model backed by a database table; and the frontend gains a Dashboard page with metrics visualization and a refactored Settings interface. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant Dashboard
participant MetricsAPI
participant SmsStat
participant Database as DB
Browser->>Dashboard: Load /dashboard
Dashboard->>MetricsAPI: GET /texty/v1/metrics
MetricsAPI->>SmsStat: get_sent_sms_between_dates(12 months)
SmsStat->>Database: Query SMS records
Database-->>SmsStat: Return SMS records
SmsStat-->>MetricsAPI: Aggregate by month
MetricsAPI->>SmsStat: get_successful_sent_sms_between_dates(30 days)
SmsStat->>Database: Query sent SMS
Database-->>SmsStat: Return records
SmsStat-->>MetricsAPI: Calculate delivery rate
MetricsAPI->>MetricsAPI: Build response (volume_chart, delivery_rate, usage)
MetricsAPI-->>Dashboard: Return metrics JSON
Dashboard->>Dashboard: Render StatCards, VolumeChart
Dashboard-->>Browser: Display dashboard UI
sequenceDiagram
participant Browser
participant SettingsPage
participant SettingsAPI
participant Gateways as Gateway Validators
Browser->>SettingsPage: Load /settings
SettingsPage->>SettingsAPI: GET /texty/v1/settings/schema
SettingsAPI-->>SettingsPage: Return schema (multi-gateway config)
SettingsPage->>Browser: Render Settings form
Browser->>SettingsPage: User fills form & saves
SettingsPage->>SettingsAPI: POST /texty/v1/settings (values)
SettingsAPI->>Gateways: validate_gateway_credentials(nested config)
Gateways-->>SettingsAPI: Validation results
SettingsAPI->>SettingsAPI: Persist validated settings
SettingsAPI-->>SettingsPage: Success/error response
SettingsPage->>Browser: Show toast (success or error)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r sorting - Add `texty_settings_schema` filter in get_settings_schema() to allow third-party plugins to register gateway sections and fields - Add `order()` method to GatewayInterface (default 10, Fake returns 99) - Add `priority` prop to all gateway sections in schema - Sort gateway dropdown options by order, then alphabetically Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove order() from GatewayInterface and default-10 gateways. Only Fake overrides it (returns 99). get_gateway_options() already falls back to 10 via method_exists() check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ensures the gateway selector section always appears above gateway credential sections (priority 10) regardless of sort order. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
<Settings>component from@wedevs/plugin-uiSettingsControllerextendingBaseSettingsRESTControllerfromwedevs/wp-kitwith flat-to-nested value conversion and gateway credential validationtexty_settingswp_option structureChanges
includes/Api/SettingsController.php(new) — Schema-driven REST controller withget_field_path()override for root-level fields,create_item()override for flat-to-nested value conversion, and gatewayvalidate()integrationsrc/pages/SettingsPage.js(new) — React settings page using<Settings>component withrenderSaveButtonincludes/Api.php— Register newSettingsControllerendpointsrc/App.js— Route/settingsto newSettingsPageBackward Compatibility
texty_settingsoption key inwp_optionsgatewayat root, credentials under gateway key)texty/v1/settings) preserved$gateway->validate()send(),get_settings()) continue working unchangedTest plan
texty_settingsoption structure in DB matches old formattexty()->settings()->get('twilio')returns correct values after saveGET/POST texty/v1/settings) still works🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
User Interface