Skip to content

fix: adjust popup pattern, add isSaving on popups, return promises#994

Open
tomrndom wants to merge 3 commits into
masterfrom
fix/popup-pattern-deviations
Open

fix: adjust popup pattern, add isSaving on popups, return promises#994
tomrndom wants to merge 3 commits into
masterfrom
fix/popup-pattern-deviations

Conversation

@tomrndom

@tomrndom tomrndom commented Jun 19, 2026

Copy link
Copy Markdown

ref: https://app.clickup.com/t/9014802374/86bag2zk7

…emove open prop, adjust tests

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Prevented duplicate submissions by disabling save/close interactions during in-progress saves across multiple dialogs.
    • Updated dialog closing behavior so some dialogs now only dismiss after a successful save, while others remain open until the relevant list refreshes.
    • Improved inventory-save error handling so failures are no longer silently swallowed.
  • Refactor

    • Standardized save flows and refreshed lists with the correct paging/sort/filter settings; pagination now resets when view options change.
  • Tests

    • Updated dialog mock behaviors to match the new async save/close flow.

…emove open prop, adjust tests

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbbcae84-a4d2-4aab-ac88-1e96ed0f1bfc

📥 Commits

Reviewing files that changed from the base of the PR and between 19a9c72 and 1344f0c.

📒 Files selected for processing (1)
  • src/actions/inventory-item-actions.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/actions/inventory-item-actions.js

📝 Walkthrough

Walkthrough

Across six popup/dialog components, isSaving state management is moved from parent list pages into the dialogs themselves. Each dialog now guards against duplicate submissions, disables close/escape UI while saving, self-closes after the save promise resolves, and drops the externally-controlled open prop. Parent list pages remove explicit post-save setOpen(false) calls and instead trigger list refreshes in .then() handlers. Action functions are updated to properly return promises, with savePageTemplate delegating list refresh responsibility to parent pages.

Changes

Dialog Save-State Internalization & Close-Responsibility Shift

Layer / File(s) Summary
Dialog components: internalize isSaving and self-close on success
src/pages/sponsorship-types/components/sponsorship-dialog.js, src/pages/sponsors-global/page-templates/page-template-popup/index.js, src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js, src/pages/sponsors/popup/add-sponsor-popup.js, src/pages/sponsors/popup/edit-tier-popup.js, src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/components/add-sponsor-page-template-popup/index.js, src/pages/sponsors-global/form-templates/form-template-popup.js
Each dialog adds a local isSaving state with re-entry guard, sets/clears isSaving around the async save call, calls onClose on success in .then(), and disables Escape-key closing plus close icon and submit button while saving. SponsorshipDialog drops its external isSaving prop. FormTemplatePopup switches from Promise.resolve + closePopup to direct onSave().then(onClose). AddSponsorDialog and EditTierDialog also drop their open prop from the component API and PropTypes.
Parent pages: remove open prop, switch to conditional rendering
src/pages/sponsors/sponsor-list-page.js, src/pages/sponsors/summit-sponsorship-list-page.js, src/pages/sponsorship-types/sponsorship-list-page.js
SponsorListPage removes open={showAddSponsorModal} from AddSponsorDialog and relies on conditional mounting. SummitSponsorshipListPage switches EditTierPopup to conditional rendering without an open prop. SponsorshipListPage removes its local isSaving state, its isSaving prop to SponsorshipDialog, and simplifies both handleClose and handleSave.
Parent save handlers: remove dialog-close calls, add list refreshes
src/pages/sponsors-global/form-templates/form-template-item-list-page.js, src/pages/sponsors-global/form-templates/form-template-list-page.js, src/pages/sponsors-global/inventory/inventory-list-page.js, src/pages/sponsors-global/page-templates/page-template-list-page.js, src/pages/sponsors/show-pages-list-page/index.js, src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js, src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js, src/pages/tags/tag-list-page.js
Explicit setOpen(false) / setOpenPopup(null) calls are removed from post-save callbacks across eight list/tab pages. Handlers now chain .then() to refresh the list with current filters and pagination. ShowPagesListPage additionally resets to DEFAULT_CURRENT_PAGE on per-page change and archive toggle.
Test mocks: chain onClose after onSave resolves
src/pages/sponsors/show-pages-list-page/__tests__/show-pages-list-page.test.js, src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js, src/pages/sponsorship-types/__tests__/sponsorship-list-page.test.js
Mock dialog "Save" buttons updated to call onClose after onSave(...) resolves via .then(onClose), matching the new async close contract in the dialog components.
Action functions: return promises and remove auto-refresh
src/actions/inventory-item-actions.js, src/actions/sponsor-actions.js, src/actions/page-template-actions.js
saveInventoryItem updates its promise handling to propagate errors instead of swallowing them. saveSummitSponsorship now returns the API request promise in both update (putRequest) and create (postRequest) branches. savePageTemplate removes automatic getPageTemplates refresh calls from both update and create success paths, moving the responsibility to parent pages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fntechgit/summit-admin#764: Both PRs modify src/actions/page-template-actions.js's savePageTemplate flow and its getPageTemplates refresh invocation.
  • fntechgit/summit-admin#841: Both PRs modify src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js around managed/customized page popup save handling and follow-up close/refresh behavior.
  • fntechgit/summit-admin#890: Both PRs modify src/pages/sponsorship-types/components/sponsorship-dialog.js and src/pages/sponsorship-types/sponsorship-list-page.js around internalization of isSaving state and popup closing/refresh wiring.

Suggested reviewers

  • smarcet

Poem

🐰 Hop hop, the dialogs now know when they're done,
No more parent pages closing things on the run!
isSaving lives inside, a local little flag,
Escape and X are locked while the save does drag.
The lists refresh after, neat and precise —
Self-managing popups: oh, isn't that nice! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main changes: adjusting the popup pattern, adding isSaving state management to popups, and ensuring promise returns across multiple files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/popup-pattern-deviations

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js (1)

1-1: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Missing useState import causes ReferenceError.

Line 48 uses useState but it is not imported from React on line 1. This will throw a runtime error when the component renders.

🐛 Proposed fix to add the missing import
-import React from "react";
+import React, { useState } from "react";

Also applies to: 48-49

🤖 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 `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js` at line
1, The component uses the useState hook on lines 48-49 but it is not imported in
the React import statement on line 1. Add useState to the destructured import
from React by updating the import statement to include useState alongside React,
so that the useState hook is available when the component renders.
🤖 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/pages/sponsors-global/inventory/inventory-list-page.js`:
- Around line 249-259: The `handleInventorySave` function relies on the promise
returned by `saveInventoryItem` to determine when the save operation is truly
complete and whether it succeeded or failed, but the `saveInventoryItem`
function in src/actions/inventory-item-actions.js (around lines 205-300) is
currently swallowing errors and resolving prematurely before nested image and
metadata saves finish. Fix this by ensuring the `saveInventoryItem` function
waits for all nested save operations (image saves and metadata saves) to
complete before resolving, and properly rejects the returned promise if any part
of the save process fails, so that the promise chain accurately reflects the
true completion status and allows error handling in downstream code like
dialog-close logic to respond correctly.

In `@src/pages/sponsors-global/page-templates/page-template-list-page.js`:
- Around line 117-128: The handleSavePageTemplate function does not return a
promise, causing runtime failures when the popup contract attempts to chain
.then on the result. Add a return statement before the savePageTemplate promise
chain to ensure the entire promise returned from
savePageTemplate(entity).then(...) is returned from the handler, allowing
callers to properly chain .then(onClose) on the result.
- Around line 118-127: The savePageTemplate call in the
page-template-list-page.js file has a redundant .then() chain that invokes
getPageTemplates again, causing duplicate requests. Since savePageTemplate
already dispatches getPageTemplates internally, remove the entire .then() block
that calls getPageTemplates with the term, DEFAULT_CURRENT_PAGE, perPage, order,
orderDir, and showArchived parameters. Simply call savePageTemplate(entity)
without the chained getPageTemplates invocation to let the internal dispatch
handle the refresh with the appropriate state values.

In `@src/pages/sponsors/summit-sponsorship-list-page.js`:
- Around line 99-101: The saveSummitSponsorship thunk in
src/actions/sponsor-actions.js does not return the promise from the API request
(putRequest or postRequest), causing the .then() chain in
summit-sponsorship-list-page.js to execute prematurely. Modify the
saveSummitSponsorship function to return the actual promise from the
putRequest/postRequest call so that getSummitSponsorships is only invoked after
the API write completes, preventing the popup from closing before persistence
finishes.

---

Outside diff comments:
In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js`:
- Line 1: The component uses the useState hook on lines 48-49 but it is not
imported in the React import statement on line 1. Add useState to the
destructured import from React by updating the import statement to include
useState alongside React, so that the useState hook is available when the
component renders.
🪄 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: 7a8515e5-6d59-4f49-a419-d75f0973d2c7

📥 Commits

Reviewing files that changed from the base of the PR and between 23217a9 and 9de307d.

📒 Files selected for processing (21)
  • src/pages/sponsors-global/form-templates/form-template-item-list-page.js
  • src/pages/sponsors-global/form-templates/form-template-list-page.js
  • src/pages/sponsors-global/form-templates/form-template-popup.js
  • src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
  • src/pages/sponsors-global/inventory/inventory-list-page.js
  • src/pages/sponsors-global/page-templates/page-template-list-page.js
  • src/pages/sponsors-global/page-templates/page-template-popup/index.js
  • src/pages/sponsors/popup/add-sponsor-popup.js
  • src/pages/sponsors/popup/edit-tier-popup.js
  • src/pages/sponsors/show-pages-list-page/__tests__/show-pages-list-page.test.js
  • src/pages/sponsors/show-pages-list-page/index.js
  • src/pages/sponsors/sponsor-list-page.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/__tests__/sponsor-pages-tab.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/components/add-sponsor-page-template-popup/index.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-pages-tab/index.js
  • src/pages/sponsors/summit-sponsorship-list-page.js
  • src/pages/sponsorship-types/__tests__/sponsorship-list-page.test.js
  • src/pages/sponsorship-types/components/sponsorship-dialog.js
  • src/pages/sponsorship-types/sponsorship-list-page.js
  • src/pages/tags/tag-list-page.js

Comment thread src/pages/sponsors-global/inventory/inventory-list-page.js
Comment thread src/pages/sponsors-global/page-templates/page-template-list-page.js Outdated
Comment thread src/pages/sponsors-global/page-templates/page-template-list-page.js
Comment thread src/pages/sponsors/summit-sponsorship-list-page.js
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/actions/inventory-item-actions.js`:
- Around line 236-250: The stopLoading() dispatch call inside the inner
.finally() block (after Promise.all) only executes when the putRequest succeeds.
If the putRequest fails, the outer catch block rethrows the error without ever
clearing the loading state. Move the stopLoading() call from the inner
.finally() block to an outer .finally() block at the end of the entire promise
chain, so it executes regardless of whether the putRequest or subsequent
Promise.all operations succeed or fail.
🪄 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: 506f0181-cdcb-423b-a046-3729b1f92efb

📥 Commits

Reviewing files that changed from the base of the PR and between 9de307d and 19a9c72.

📒 Files selected for processing (4)
  • src/actions/inventory-item-actions.js
  • src/actions/page-template-actions.js
  • src/actions/sponsor-actions.js
  • src/pages/sponsors-global/page-templates/page-template-list-page.js
💤 Files with no reviewable changes (1)
  • src/actions/page-template-actions.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/sponsors-global/page-templates/page-template-list-page.js

Comment thread src/actions/inventory-item-actions.js Outdated
Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@tomrndom tomrndom requested a review from smarcet June 19, 2026 21:22
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