plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
473 stars 642 forks source link

Redux state for the `statusmessage` cookie #4355

Open JeffersonBledsoe opened 1 year ago

JeffersonBledsoe commented 1 year ago

Is your feature request related to a problem? Please describe. Some Plone responses set a statusmessage cookie. This cookie is the 'raw' value as base64 to be used by products.statusmessage which does a little bit of parsing to split apart the message and status type. It would be nice to encapsulate the logic that is normally done in classic in Volto too and provide the status messages in an easier to use format for any potential Volto users.

Describe the solution you'd like

Describe alternatives you've considered

Additional context Whilst plone.restapi doesn't currently use status messages (see plone/plone.restapi#584), some addons still provide useful information via IStatusMessage.

tiberiuichim commented 1 year ago

I guess that would require some type of cookie watcher, like https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/cookies/onChanged ?

JeffersonBledsoe commented 1 year ago

I guess that would require some type of cookie watcher, like https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/cookies/onChanged ?

Yep. We would probably use useCookies(['statusmessage']) from react-cookie or something similar to handle this as Safari support isn't there and I'm not sure on the state of polyfills for the API. The Cookies Store API looks like a similar situation.