Skip to content

Commit

Permalink
feat(adapter): don't render headerbar for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi authored and KaiVandivier committed Aug 23, 2022
1 parent 9fea158 commit 4ac6d54
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
5 changes: 3 additions & 2 deletions adapter/src/components/AppWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LoadingMask } from './LoadingMask.js'
import PWAUpdateManager from './PWAUpdateManager.js'
import { styles } from './styles/AppWrapper.style.js'

export const AppWrapper = ({ appName, children, offlineInterface }) => {
export const AppWrapper = ({ appName, children, offlineInterface, plugin }) => {
const { loading: localeLoading } = useCurrentUserLocale()
const { loading: latestUserLoading } = useVerifyLatestUser()

Expand All @@ -20,7 +20,7 @@ export const AppWrapper = ({ appName, children, offlineInterface }) => {
return (
<div className="app-shell-adapter">
<style jsx>{styles}</style>
<HeaderBar appName={appName} />
{!plugin && <HeaderBar appName={appName} />}
<div className="app-shell-app">
<ErrorBoundary onRetry={() => window.location.reload()}>
{children}
Expand All @@ -36,4 +36,5 @@ AppWrapper.propTypes = {
appName: PropTypes.string.isRequired,
offlineInterface: PropTypes.object.isRequired,
children: PropTypes.node,
plugin: PropTypes.bool,
}
16 changes: 14 additions & 2 deletions adapter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ import { ServerVersionProvider } from './components/ServerVersionProvider.js'

const offlineInterface = new OfflineInterface()

const AppAdapter = ({ url, apiVersion, appName, pwaEnabled, children }) => (
const AppAdapter = ({
url,
apiVersion,
appName,
pwaEnabled,
plugin,
children,
}) => (
<ErrorBoundary fullscreen onRetry={checkForSWUpdateAndReload}>
<ServerVersionProvider
url={url}
apiVersion={apiVersion}
pwaEnabled={pwaEnabled}
offlineInterface={offlineInterface}
>
<AppWrapper appName={appName} offlineInterface={offlineInterface}>
<AppWrapper
appName={appName}
offlineInterface={offlineInterface}
plugin={plugin}
>
{children}
</AppWrapper>
</ServerVersionProvider>
Expand All @@ -26,6 +37,7 @@ AppAdapter.propTypes = {
appName: PropTypes.string.isRequired,
apiVersion: PropTypes.number,
children: PropTypes.element,
plugin: PropTypes.bool,
pwaEnabled: PropTypes.bool,
url: PropTypes.string,
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = ({ env: webpackEnv, paths }) => {
process.env.PUBLIC_URL
)

const shellEnv = getShellEnv({})
const shellEnv = getShellEnv({ plugin: 'true' })

// "style" loader turns CSS into JS modules that inject <style> tags.
// "css" loader resolves paths in CSS and adds assets as dependencies.
Expand Down
1 change: 1 addition & 0 deletions shell/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const appConfig = {
appName: process.env.REACT_APP_DHIS2_APP_NAME || '',
apiVersion: parseInt(process.env.REACT_APP_DHIS2_API_VERSION),
pwaEnabled: process.env.REACT_APP_DHIS2_APP_PWA_ENABLED === 'true',
plugin: process.env.REACT_APP_DHIS2_APP_PLUGIN === 'true',
}

const App = () => (
Expand Down

0 comments on commit 4ac6d54

Please sign in to comment.