ENG-177: Add global message API ref for out-of-tree toast usage#7695
ENG-177: Add global message API ref for out-of-tree toast usage#7695gilluminate merged 5 commits intomainfrom
Conversation
Add a module-level ref that stores the themed Ant Design messageApi from FidesUIProvider, making it accessible outside the React component tree. Migrate the Redux RTK query error middleware from Chakra's createStandaloneToast to the new global message ref. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
- Accept null in setGlobalMessageApi for cleanup on provider unmount - Add useEffect cleanup to null out stale ref when FidesUIProvider unmounts - Remove setGlobalMessageApi from public exports (internal to fidesui) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR introduces a global message API ref pattern to allow Ant Design's Key changes:
One concern: The Confidence Score: 4/5
Important Files Changed
Last reviewed commit: "Clean up global mess..." |
- Add identity check before nulling the global ref on unmount to avoid clobbering a ref set by a different FidesUIProvider instance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kruulik
left a comment
There was a problem hiding this comment.
Makes sense and looks good!
Ticket ENG-177
Description Of Changes
Add a global message API ref pattern to
fidesuiso that code running outside the React component tree (e.g. Redux middleware) can access the themed Ant DesignmessageApi. This is PR 1 of 4 for the toast-to-Ant migration (ENG-177).globalMessageApi.tswithgetGlobalMessageApi/setGlobalMessageApihelpersFidesUIProviderto store the wrapped message API on mount viauseEffectfidesuicreateChakraStandaloneToastto the new global refCode Changes
clients/fidesui/src/lib/globalMessageApi.ts- New module-level ref for the Ant Design message APIclients/fidesui/src/FidesUIProvider.tsx- Set global ref via useEffect after wrapping the message APIclients/fidesui/src/index.ts- ExportgetGlobalMessageApiandsetGlobalMessageApiclients/admin-ui/src/app/middleware.ts- ReplacecreateChakraStandaloneToastwithgetGlobalMessageApi()?.error(...)Steps to Confirm
npm run devinclients/admin-ui/)console_onlymode, so RTK query errors should appear in the console (not as toasts) unless config is changederror_notification_modetotoastin the application config and trigger an API errorPre-Merge Checklist
CHANGELOG.mdupdated