Skip to content

Conversation

@DJJones66
Copy link
Contributor

🚀 Enhancement: Safe Auto-Save Before Publish in Page Management Dialog

Summary

This PR introduces a critical UX improvement to the Plugin Studio's Page Management Dialog by ensuring that pages are auto-saved before publishing. It also adds real-time feedback to users, preventing unintentional publishing of stale or unsaved data. This change affects both the dialog behavior and toolbar layout, and addresses reliability and workflow clarity.


✅ Key Changes

🧠 PageManagementDialog (PageManagementDialog.tsx)

  • Auto-Save on Publish

    • When a user clicks "Publish" for the current working page, the dialog:

      • Auto-saves the current layout and module data
      • Cancels publish if save fails
      • Provides a clear error message
  • User Feedback

    • Displayed status chip "Saving before publish..." during the process
    • Publish/unpublish buttons are disabled while auto-save is in progress
    • Tooltip updated to reflect pending save status

🧩 Adapter Improvements (PageManagementDialogAdapter.tsx)

  • Wrapped publishPage() in logic to:

    • Automatically invoke savePage() for the current page before publishing
    • Catch save errors and prevent a broken publish attempt
  • Added console tracing to improve debuggability

🧰 GridToolbar (GridToolbar.tsx)

  • Toolbar Simplification

    • Moved PageSelector outside conditional blocks so it’s always rendered, even when no page exists
    • Removed redundant "Create Page" button (it’s now handled inside PageSelector)
    • Improved message shown when no page is selected ("Use the + button to create a new page")

🛠 usePages Hook Fix

  • Added null-check fallback for currentPage.layouts and currentPage.modules to avoid reference errors when saving.

🔁 PluginStudioAdapter Refactor

  • Fixed potential infinite render loop caused by module state comparison:

    • Added isUpdatingModulesRef safeguard flag to prevent recursion
    • Removed convertedPageData from useEffect dependency array

🧪 Benefits

  • ✅ Ensures publishing only happens with saved changes, eliminating user error
  • 🧘 Prevents data loss or confusion due to stale module/layout state
  • 💬 Improves user feedback with tooltips, chips, and error messaging
  • 🔁 Resolves long-standing save-loop edge case in Plugin Studio adapter
  • 🧼 Refactors and simplifies the Grid Toolbar UX

@DJJones66 DJJones66 merged commit b705382 into main Aug 15, 2025
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.

2 participants