From a99d64ec0facd09a0c8a16328e29c3f534f79705 Mon Sep 17 00:00:00 2001 From: Zak Burke Date: Wed, 22 May 2024 16:53:15 -0400 Subject: [PATCH] STCOR-851 accept locale from stripes-config Allow `stripes.config.js` to set `config.locale` in order to override the default value, `en-US`. This allows a tenant to set the locale for pages that are displayed before authenticating, when the tenant's locale can be read from mod-configuration. The `stripes.config.js` value will be overwritten by the stored value from mod-configuration, if present. Refs STCOR-851 --- CHANGELOG.md | 3 ++- src/components/Root/Root.js | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3b4f004..199af1479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,8 @@ * Make branding optional. Refs STCOR-847. * Idle-session timeout and "Keep working?" modal. Refs STCOR-776. * Implement password validation for Login Page. Refs STCOR-741. -* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844.. +* Avoid deprecated `defaultProps` for functional components. Refs STCOR-844. +* Read locale from stripes-config before defaulting to `en-US`. Refs STCOR-851. ## [10.1.0](https://github.com/folio-org/stripes-core/tree/v10.1.0) (2024-03-12) [Full Changelog](https://github.com/folio-org/stripes-core/compare/v10.0.0...v10.1.0) diff --git a/src/components/Root/Root.js b/src/components/Root/Root.js index cddcaedae..393f6ed4b 100644 --- a/src/components/Root/Root.js +++ b/src/components/Root/Root.js @@ -85,8 +85,9 @@ class Root extends Component { } componentDidMount() { - const { okapi, store, locale, defaultTranslations } = this.props; + const { okapi, store, defaultTranslations } = this.props; if (this.withOkapi) checkOkapiSession(okapi.url, store, okapi.tenant); + const locale = this.props.config.locale ?? 'en-US'; // TODO: remove this after we load locale and translations at start from a public endpoint loadTranslations(store, locale, defaultTranslations); } @@ -122,7 +123,6 @@ class Root extends Component { render() { const { logger, store, epics, config, okapi, actionNames, token, isAuthenticated, disableAuth, currentUser, currentPerms, locale, defaultTranslations, timezone, currency, plugins, bindings, discovery, translations, history, serverDown } = this.props; - if (serverDown) { return
Error: server is down.
; } @@ -254,8 +254,6 @@ Root.propTypes = { Root.defaultProps = { history: createBrowserHistory(), - // TODO: remove after locale is accessible from a global config / public url - locale: 'en-US', timezone: 'UTC', currency: 'USD', okapiReady: false,