0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/apps/portal/src/AppContext.js
Cathy Sarisky 1196688b0e
🌐 Improved i18n support for Portal error messages (#21190)
no ref

Expose (some) Portal error strings for translations

💩This is a somewhat hacky (but test-passing and individual inspection
passing) solution to the way Portal handles errors. Or rather, the
half-dozen ways Portal handles errors.

Passing 't' around with context and state, and occasionally recreating
it from the site object. Yes, I am also somewhat horrified, but a better
implementation will need a major rewrite of Portal.

Addresses errors in both the popover React app and in the
data-attributes.

There are probably more. Since Portal exposes raw API responses in some
places, it's hard to enumerate everything that /might/ end up being
client-facing, but at least I've gotten the ones that I've commonly
seen.

Improvements very welcome.
2024-10-03 13:35:23 +00:00

18 lines
338 B
JavaScript

// Ref: https://reactjs.org/docs/context.html
import React from 'react';
const AppContext = React.createContext({
site: {},
member: {},
action: '',
lastPage: '',
brandColor: '',
pageData: {},
onAction: (action, data) => {
return {action, data};
},
t: () => {}
});
export default AppContext;