Skip to content

feat: add quick-create product modal to product list#3296

Open
kzamanbd wants to merge 9 commits into
developfrom
feature/quick-create-product-modal
Open

feat: add quick-create product modal to product list#3296
kzamanbd wants to merge 9 commits into
developfrom
feature/quick-create-product-modal

Conversation

@kzamanbd

@kzamanbd kzamanbd commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title

Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

Summary

  • New Features

    • Added an inline “Add new product” quick-create modal directly from the product list, with schema-driven fields and “Create & Continue” confirmation.
    • Quick-create is controlled by Dokan options and is bypassed when the legacy editor is preferred; users return to the full editor when disabled.
    • Product data refreshes after a successful creation.
  • Bug Fixes

    • Improved modal reliability: confirmation is disabled until initialization completes and the form is valid; errors show a toast and keep the modal open for retry.
  • Style

    • Adjusted quick-create image sizing for the modal editor layout.
  • Tests

    • Extended end-to-end coverage for both enabled and disabled quick-create scenarios.

kzamanbd added 2 commits June 29, 2026 20:32
Add a lightweight "Add new product" modal on the React product list that
reuses the product-editor FormSchema. It fetches the schema, renders an
essential field subset (name, image, price, category, short description)
via DataForm, creates a simple draft through the shared product-editor
store, then refetches the list in place — no navigation.

- src/dashboard/product-editor/QuickCreateModal.tsx: new modal component
- src/dashboard/products/ProductList.tsx: open the modal when One Page
  Product Creation is enabled, else navigate to the full create page
- includes/Assets.php: localize is_quick_create_enabled flag
- docs: implementation plan
The @dokan import path already resolves via the typescript resolver
(tsconfig paths), so the duplicate alias map in .eslintrc is unnecessary.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f06b3000-77f2-4d17-9cd3-a21019232f75

📥 Commits

Reviewing files that changed from the base of the PR and between 70cf211 and 2931182.

📒 Files selected for processing (3)
  • src/dashboard/product-editor/QuickCreateModal.tsx
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • tests/pw/tests/e2e/new-products/newProductsPage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • src/dashboard/product-editor/QuickCreateModal.tsx

📝 Walkthrough

Walkthrough

Adds a quick-create product modal, localizes its enablement from product options, and wires the product list to open it or fall back to the full editor. Playwright coverage checks both paths.

Changes

Quick Create Modal Feature

Layer / File(s) Summary
QuickCreateModal component
src/dashboard/product-editor/QuickCreateModal.tsx, src/dashboard/product-editor/index.scss
Adds the quick-create modal, schema-driven field subset, initialization loading, store wiring, save flow, and modal-specific image sizing.
Product list entry point and flag
.eslintrc, includes/Assets.php, src/dashboard/products/ProductList.tsx
Removes the ESLint alias resolver entry, localizes is_quick_create_enabled, and opens or mounts the quick-create modal from the product list.
New product end-to-end coverage
tests/pw/tests/e2e/new-products/newProductsPage.ts, tests/pw/tests/e2e/new-products/newProducts.spec.ts
Adds quick-create selectors and tests both modal opening and fallback navigation to the full create editor.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • getdokan/dokan#3299: Both changes modify the new-products Playwright suite and the “Add new product” flow.

Suggested labels: Test Automation

Suggested reviewers: MdAsifHossainNadim, shohan0120, mrabbani

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is mostly the untouched template and leaves required sections like changes, testing, changelog, and before/after empty. Fill in the template with a concrete change summary, related PRs, testing steps, changelog details, and before/after context.
Linked Issues check ⚠️ Warning The changes do not clearly satisfy #5791: they still reference a fixed QUICK_CREATE_FIELDS subset and show no Product Form Manager help-text update. Drive popup fields from Product Form Manager required/visible fields, always include title, drop fixed field subsets, and update the admin help text.
Out of Scope Changes check ⚠️ Warning The .eslintrc resolver cleanup is unrelated to the quick-create product modal work and looks like an out-of-scope config change. Remove the ESLint config edit unless it is required by the feature and explain the need in the PR description.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a quick-create product modal to the product list.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/quick-create-product-modal

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/dashboard/product-editor/QuickCreateModal.tsx`:
- Around line 122-153: QuickCreateModal is bypassing the product-editor hook
contract by calling updateProduct and saveProduct directly, so add-ons never see
dokan_product_editor_field_changed or dokan_product_editor_after_save. Update
the modal to go through the same hook-driven flow used by useProductEditor, or
explicitly fire the same field-changed and after-save hooks from
handleConfirm/onChange after the corresponding actions. Keep the existing
NEW_PRODUCT_ID flow, but make sure the quick-create path triggers the same
extension points as the standard editor.

In `@src/dashboard/products/ProductList.tsx`:
- Around line 969-978: The QuickCreateModal stays mounted across open/close
cycles, so its local init state can preserve a transient schema-load failure and
keep quick-create stuck. Update ProductList’s QuickCreateModal usage so the
modal is unmounted when closed (using the existing isQuickCreateOpen state) and
make sure the onCreated flow also closes the overlay before refreshing via
fetchProducts and fetchStatusCounts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d16a204e-b2de-4ab4-8fa5-ea7f44c0c474

📥 Commits

Reviewing files that changed from the base of the PR and between 1d70241 and 83b531f.

📒 Files selected for processing (4)
  • .eslintrc
  • includes/Assets.php
  • src/dashboard/product-editor/QuickCreateModal.tsx
  • src/dashboard/products/ProductList.tsx
💤 Files with no reviewable changes (1)
  • .eslintrc

Comment thread src/dashboard/product-editor/QuickCreateModal.tsx
Comment thread src/dashboard/products/ProductList.tsx Outdated
kzamanbd added 2 commits June 30, 2026 08:51
Arrange the quick-create form as a row: a fixed 200px image/gallery
column beside the name/price fields. RowLayout styles are keyed by the
direct child id and only honor flex, so pin the image_gallery column
rather than image_id.

Scope a 200px image box to the modal via a .quick-create-product-editor
compound selector so the full product editor keeps its 232px box.
The schedule date fields were keyed as sale_price_dates_from/to, which
have no matching schema field, so DataForm rendered nothing when Create
Schedule for Discount was checked. Use the real ids date_on_sale_from /
date_on_sale_to so their dependency-driven visibility works.
@kzamanbd kzamanbd changed the title Feature/quick create product modal feat: add quick-create product modal to product list Jun 30, 2026
@kzamanbd kzamanbd self-assigned this Jun 30, 2026
@kzamanbd kzamanbd added Needs: Testing This requires further testing Needs: Dev Review It requires a developer review and approval labels Jun 30, 2026
Address CodeRabbit review on the quick-create modal:

- Fire `dokan_product_editor_field_changed` and `dokan_product_editor_after_save`
  from the modal so add-ons wired to the editor hook contract also see
  quick-create edits and post-save persistence.
- Mount QuickCreateModal only while open and close it on success, so a
  transient schema-load failure resets on the next open instead of leaving
  quick-create stuck until a full page reload.

Update the React products list E2E coverage for the quick-create default:

- "Add new product" now opens the quick-create modal when
  one_step_product_create is on (the Lite default) — assert the modal instead
  of the create route.
- Add an off-path test that disables one_step_product_create and verifies the
  button routes to the full React create editor, restoring the option after.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/pw/tests/e2e/new-products/newProducts.spec.ts`:
- Around line 113-120: The route check in the quick-create modal test is too
loose because `page.url()` containing `#/products` also matches
`#/products/create`. Tighten the assertion in `newProducts.spec.ts` within
`vendor can open the quick-create product modal (React)` to verify the exact
list route (or a more specific list-route pattern) after
`products.clickAddNewProduct()`, while keeping the existing modal visibility
checks for `products.quickCreateModalTitle` and
`products.quickCreateConfirmButton`.

In `@tests/pw/tests/e2e/new-products/newProductsPage.ts`:
- Around line 177-180: `clickAddNewProduct()` is masking failures by swallowing
the quick-create modal wait error; update this method to let the
`quickCreateModalTitle.waitFor(...)` failure propagate instead of catching it,
so the method only succeeds when the modal actually appears. Keep the existing
synchronization flow in `clickAddNewProduct()` and `addNewProductButton`, but
remove the silent fallback so broken clicks are detected reliably.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe61ee74-c0d2-43e6-9bd0-a9ae4334265f

📥 Commits

Reviewing files that changed from the base of the PR and between 83b531f and 5dd8bbb.

📒 Files selected for processing (5)
  • src/dashboard/product-editor/QuickCreateModal.tsx
  • src/dashboard/product-editor/index.scss
  • src/dashboard/products/ProductList.tsx
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • tests/pw/tests/e2e/new-products/newProductsPage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/dashboard/products/ProductList.tsx
  • src/dashboard/product-editor/QuickCreateModal.tsx

Comment thread tests/pw/tests/e2e/new-products/newProducts.spec.ts
Comment thread tests/pw/tests/e2e/new-products/newProductsPage.ts
@dev-shahed

Copy link
Copy Markdown
Member

These tooltips have no content on hover:
image

There must be showing something relatable related to the component..

@dev-shahed dev-shahed added Merge Conflict QA In Progress and removed Needs: Testing This requires further testing labels Jul 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/pw/tests/e2e/new-products/newProductsPage.ts (1)

178-181: 🩺 Stability & Availability | 🟡 Minor

Don't swallow the modal wait failure here.

clickAddNewProduct() is documented as synchronizing on the quick-create modal, but the .catch(() => undefined) on line 181 makes it succeed even when the modal never opens, hiding broken clicks and weakening failure detection.

🔧 Proposed fix
-        await this.quickCreateModalTitle.waitFor({ state: 'visible', timeout: 15000 }).catch(() => undefined);
+        await this.quickCreateModalTitle.waitFor({ state: 'visible', timeout: 15000 });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/pw/tests/e2e/new-products/newProductsPage.ts` around lines 178 - 181,
Remove the `.catch(() => undefined)` from `clickAddNewProduct()` so
`quickCreateModalTitle.waitFor()` propagates failures when the modal does not
appear, preserving the method’s synchronization guarantee.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/pw/tests/e2e/new-products/newProductsPage.ts`:
- Around line 184-188: Remove the `.catch(() => undefined)` from
`openSeededProduct()` so `page.waitForURL()` propagates navigation timeout
failures; keep the existing URL pattern and timeout unchanged.

---

Duplicate comments:
In `@tests/pw/tests/e2e/new-products/newProductsPage.ts`:
- Around line 178-181: Remove the `.catch(() => undefined)` from
`clickAddNewProduct()` so `quickCreateModalTitle.waitFor()` propagates failures
when the modal does not appear, preserving the method’s synchronization
guarantee.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f06b3000-77f2-4d17-9cd3-a21019232f75

📥 Commits

Reviewing files that changed from the base of the PR and between 70cf211 and 2931182.

📒 Files selected for processing (3)
  • src/dashboard/product-editor/QuickCreateModal.tsx
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • tests/pw/tests/e2e/new-products/newProductsPage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • src/dashboard/product-editor/QuickCreateModal.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/pw/tests/e2e/new-products/newProductsPage.ts (1)

178-181: 🩺 Stability & Availability | 🟡 Minor

Don't swallow the modal wait failure here.

clickAddNewProduct() is documented as synchronizing on the quick-create modal, but the .catch(() => undefined) on line 181 makes it succeed even when the modal never opens, hiding broken clicks and weakening failure detection.

🔧 Proposed fix
-        await this.quickCreateModalTitle.waitFor({ state: 'visible', timeout: 15000 }).catch(() => undefined);
+        await this.quickCreateModalTitle.waitFor({ state: 'visible', timeout: 15000 });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/pw/tests/e2e/new-products/newProductsPage.ts` around lines 178 - 181,
Remove the `.catch(() => undefined)` from `clickAddNewProduct()` so
`quickCreateModalTitle.waitFor()` propagates failures when the modal does not
appear, preserving the method’s synchronization guarantee.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/pw/tests/e2e/new-products/newProductsPage.ts`:
- Around line 184-188: Remove the `.catch(() => undefined)` from
`openSeededProduct()` so `page.waitForURL()` propagates navigation timeout
failures; keep the existing URL pattern and timeout unchanged.

---

Duplicate comments:
In `@tests/pw/tests/e2e/new-products/newProductsPage.ts`:
- Around line 178-181: Remove the `.catch(() => undefined)` from
`clickAddNewProduct()` so `quickCreateModalTitle.waitFor()` propagates failures
when the modal does not appear, preserving the method’s synchronization
guarantee.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f06b3000-77f2-4d17-9cd3-a21019232f75

📥 Commits

Reviewing files that changed from the base of the PR and between 70cf211 and 2931182.

📒 Files selected for processing (3)
  • src/dashboard/product-editor/QuickCreateModal.tsx
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • tests/pw/tests/e2e/new-products/newProductsPage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/pw/tests/e2e/new-products/newProducts.spec.ts
  • src/dashboard/product-editor/QuickCreateModal.tsx
🛑 Comments failed to post (1)
tests/pw/tests/e2e/new-products/newProductsPage.ts (1)

184-188: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Don't swallow the navigation wait failure in openSeededProduct().

The .catch(() => undefined) on the waitForURL call means the method succeeds even when navigation to the product editor never happens. Downstream locator failures from a broken navigation will be harder to debug than a clear timeout here.

🔧 Proposed fix
-        await this.page.waitForURL(/#\/?products\/\d+\/edit/, { timeout: 15000 }).catch(() => undefined);
+        await this.page.waitForURL(/#\/?products\/\d+\/edit/, { timeout: 15000 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    async openSeededProduct(): Promise<void> {
        await this.seededProductLink.waitFor({ state: 'visible', timeout: 10000 });
        await this.seededProductLink.click();
        await this.page.waitForURL(/#\/?products\/\d+\/edit/, { timeout: 15000 });
    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/pw/tests/e2e/new-products/newProductsPage.ts` around lines 184 - 188,
Remove the `.catch(() => undefined)` from `openSeededProduct()` so
`page.waitForURL()` propagates navigation timeout failures; keep the existing
URL pattern and timeout unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merge Conflict Needs: Dev Review It requires a developer review and approval QA In Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants