Skip to content

refactor(onboarding): converge setup wizard onto canonical settings#3262

Open
mrabbani wants to merge 5 commits into
refactor/simplify-settings-to-flat-arrayfrom
refactor/onboarding-settings-convergence
Open

refactor(onboarding): converge setup wizard onto canonical settings#3262
mrabbani wants to merge 5 commits into
refactor/simplify-settings-to-flat-arrayfrom
refactor/onboarding-settings-convergence

Conversation

@mrabbani

Copy link
Copy Markdown
Member

Summary

Converges the admin Setup Wizard onto the new flat-array settings system, deleting the parallel schema/renderer/storage stack it used to maintain. The wizard is now a curated view over the canonical SettingsSchema rendered by the shared @wedevs/plugin-ui Onboarding component.

Depends on the plugin-ui Onboarding component: getdokan/plugin-ui#101.

Backend

  • Each step (Steps/*Step.php) declares canonical field ids via get_field_ids() instead of a bespoke Factory field tree.
  • AbstractStep::populate() harvests those fields from SettingsRegistry::get_schema() and re-parents them under a page+section subtree (hide_save).
  • AbstractStep::save() writes a whitelisted slice into the single dokan_admin_settings option via SettingsRepository::update(). Legacy options (dokan_selling, dokan_withdraw, dokan_appearance) stay in sync through the existing read-overlay (BridgeBootstrap) — no direct legacy write, no option_dispatcher.
  • REST update_item accepts a flat { values: { id: value } } body, normalizes plugin-ui dot-path keys to the leaf id, sanitizes with wc_clean, and delegates to the step.
  • Deleted includes/Admin/OnboardingSetup/Components/ (ComponentFactory + Page/Section/Field/Fields/*).

Frontend

  • setup-guide/index.tsx renders <Onboarding> (vertical stepper, hookPrefix="dokan"), fetching each step's schema over REST and reusing registerSettingsFields for Dokan custom variants.
  • Deleted the bespoke renderer: StepSettings.tsx, Elements/*, components/*, and the settingsDependencyParser/Applicator utils.

Canonical id remapping

tax_fee_recipient → product_tax_fee_recipient, order_status_change → vendor_can_change_order_status, new_seller_enable_selling → vendor_auto_enable_selling, withdraw_limit → minimum_withdraw_limit, paypal/bank → paypal_withdraw/bank_transfer_withdraw, the hide_vendor_info trio → store_page_vendor_info_visibility. Dropped skrill (no longer a withdraw method in the schema).

Behaviour notes

  • Completion flags are preserved at the existing keys ({storage_key}_completed) — no reset for already-onboarded installs.
  • AdminSetupGuide::settings() now injects only the step list; per-step schema is fetched lazily over REST.

Test Plan

  • php -l + composer phpcs clean on all changed source files
  • npm run lint:js clean; npm run build succeeds (Onboarding import resolves)
  • New PHPUnit: StepConvergenceTest, AdminSetupGuideControllerTest; retargeted SettingsElementTest to in-file doubles
  • Live E2E (Lite+Pro): all 4 steps render canonical fields; in-step dependencies work (Fixed↔Category Based); UI save → dokan_admin_settings + legacy dokan_selling reflects via overlay
  • CI PHPUnit (runs Lite-only)

Follow-up (not in this PR)

  • Route the wizard write path through the settings page's schema-aware validate_field_value()/sanitize_field_value() so the two admin-only write paths can't diverge (current path is wc_clean + id-whitelist — safe, but skips enum/type validation).

mrabbani added 5 commits June 10, 2026 11:40
Steps now declare canonical SettingsSchema field ids via get_field_ids()
instead of bespoke Factory field trees. AbstractStep harvests those fields
from SettingsRegistry (populate) and saves their values into the single
dokan_admin_settings option via SettingsRepository (save), whitelisting to
declared ids. Legacy options stay in sync through the settings read-overlay,
so option_dispatcher and per-step value storage are gone. Completion flags
are preserved at the existing keys.

- StepInterface: replace settings()/option_dispatcher()/get_settings_options()
  with get_field_ids() + get_title()
- AbstractStep: override populate()/save(); drop dispatch/listen; no-op
  describe_settings()
- Basic/Commission/Withdraw/Appearance: declare canonical ids (tax->product_tax,
  order_status_change->vendor_can_change_order_status, withdraw_limit->
  minimum_withdraw_limit, hide_vendor_info trio->store_page_vendor_info_visibility;
  drop non-existent skrill method)
- AdminSetupGuide::settings(): inject only the step list (schema fetched lazily)
update_item now reads a flat { values: { id: value } } body, normalizes
plugin-ui dot-path keys to the canonical leaf id, sanitizes with wc_clean,
and delegates to the step (which whitelists to its declared field ids).
Drops the tree-walking parse_settings_data helper.
The Components/ tree (ComponentFactory, Page/Section/Field/Fields/*) was a
parallel copy of the settings element system that steps no longer use — they
harvest the canonical schema instead. Retarget SettingsElementTest to in-file
doubles so it no longer depends on the deleted concrete elements.
…nent

Replace the bespoke setup-guide renderer (StepSettings + Elements/* +
components/* + the settings dependency parser/applicator) with the shared
@wedevs/plugin-ui Onboarding stepper. The wizard now fetches each step's
canonical schema over REST, renders fields through the same FieldRenderer as
the settings page (reusing registerSettingsFields for Dokan custom variants),
and saves a flat { values } payload per step. onComplete marks setup done and
redirects to the dashboard.
The wizard rewrite dropped the exported Step type that AdminSetupBanner
imports; restore it (the step-meta shape) so the banner's import resolves.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: daf80bde-09ae-4769-a935-07d16c359f12

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/onboarding-settings-convergence

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mrabbani mrabbani force-pushed the refactor/onboarding-settings-convergence branch from 63a4b26 to 5469523 Compare June 10, 2026 09:06
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