-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: never render HeaderBar without runtime provider (#587)
* fix: never render HeaderBar without runtime provider * style: formatting * fix: log locale initialization in useEffect, add emoji to log * fix: short-circuit the system info fetch if no url provided * style: sort propTypes
- Loading branch information
Showing
7 changed files
with
74 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { HeaderBar } from '@dhis2/ui' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { useCurrentUserLocale } from '../utils/useLocale.js' | ||
import { Alerts } from './Alerts.js' | ||
import { LoadingMask } from './LoadingMask.js' | ||
import { styles } from './styles/AppWrapper.style.js' | ||
|
||
export const AppWrapper = ({ appName, children }) => { | ||
const { loading } = useCurrentUserLocale() | ||
|
||
if (loading) { | ||
return <LoadingMask /> | ||
} | ||
|
||
return ( | ||
<div className="app-shell-adapter"> | ||
<style jsx>{styles}</style> | ||
<HeaderBar appName={appName} /> | ||
<div className="app-shell-app">{children}</div> | ||
<Alerts /> | ||
</div> | ||
) | ||
} | ||
|
||
AppWrapper.propTypes = { | ||
appName: PropTypes.string.isRequired, | ||
children: PropTypes.node, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
import { HeaderBar } from '@dhis2/ui' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
import { Alerts } from './components/Alerts' | ||
import { AuthBoundary } from './components/AuthBoundary' | ||
import { FatalErrorBoundary } from './components/FatalErrorBoundary' | ||
import { ServerVersionProvider } from './components/ServerVersionProvider' | ||
import { styles } from './styles.js' | ||
import { AppWrapper } from './components/AppWrapper.js' | ||
import { FatalErrorBoundary } from './components/FatalErrorBoundary.js' | ||
import { ServerVersionProvider } from './components/ServerVersionProvider.js' | ||
|
||
const App = ({ url, apiVersion, appName, children }) => ( | ||
const AppAdapter = ({ url, apiVersion, appName, children }) => ( | ||
<FatalErrorBoundary> | ||
<ServerVersionProvider url={url} apiVersion={apiVersion}> | ||
<div className="app-shell-adapter"> | ||
<style jsx>{styles}</style> | ||
<HeaderBar appName={appName} /> | ||
<AuthBoundary url={url}> | ||
<div className="app-shell-app">{children}</div> | ||
</AuthBoundary> | ||
<Alerts /> | ||
</div> | ||
<AppWrapper appName={appName}>{children}</AppWrapper> | ||
</ServerVersionProvider> | ||
</FatalErrorBoundary> | ||
) | ||
|
||
App.propTypes = { | ||
AppAdapter.propTypes = { | ||
appName: PropTypes.string.isRequired, | ||
url: PropTypes.string.isRequired, | ||
apiVersion: PropTypes.number, | ||
children: PropTypes.element, | ||
url: PropTypes.string, | ||
} | ||
|
||
export default App | ||
export default AppAdapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters