refactor(onboarding): converge setup wizard onto canonical settings#3262
Open
mrabbani wants to merge 5 commits into
Open
refactor(onboarding): converge setup wizard onto canonical settings#3262mrabbani wants to merge 5 commits into
mrabbani wants to merge 5 commits into
Conversation
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.
Contributor
|
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:
✨ 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 |
63a4b26 to
5469523
Compare
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.
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
SettingsSchemarendered by the shared@wedevs/plugin-uiOnboarding component.Depends on the plugin-ui Onboarding component: getdokan/plugin-ui#101.
Backend
Steps/*Step.php) declares canonical field ids viaget_field_ids()instead of a bespokeFactoryfield tree.AbstractStep::populate()harvests those fields fromSettingsRegistry::get_schema()and re-parents them under a page+section subtree (hide_save).AbstractStep::save()writes a whitelisted slice into the singledokan_admin_settingsoption viaSettingsRepository::update(). Legacy options (dokan_selling,dokan_withdraw,dokan_appearance) stay in sync through the existing read-overlay (BridgeBootstrap) — no direct legacy write, nooption_dispatcher.update_itemaccepts a flat{ values: { id: value } }body, normalizes plugin-ui dot-path keys to the leaf id, sanitizes withwc_clean, and delegates to the step.includes/Admin/OnboardingSetup/Components/(ComponentFactory + Page/Section/Field/Fields/*).Frontend
setup-guide/index.tsxrenders<Onboarding>(vertical stepper,hookPrefix="dokan"), fetching each step's schema over REST and reusingregisterSettingsFieldsfor Dokan custom variants.StepSettings.tsx,Elements/*,components/*, and thesettingsDependencyParser/Applicatorutils.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, thehide_vendor_infotrio →store_page_vendor_info_visibility. Droppedskrill(no longer a withdraw method in the schema).Behaviour notes
{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 phpcsclean on all changed source filesnpm run lint:jsclean;npm run buildsucceeds (Onboarding import resolves)StepConvergenceTest,AdminSetupGuideControllerTest; retargetedSettingsElementTestto in-file doublesdokan_admin_settings+ legacydokan_sellingreflects via overlayFollow-up (not in this PR)
validate_field_value()/sanitize_field_value()so the two admin-only write paths can't diverge (current path iswc_clean+ id-whitelist — safe, but skips enum/type validation).