Skip to content

Commit

Permalink
fix: expose baseurl to loginappwrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Apr 25, 2024
1 parent 3e24d35 commit 8330626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions adapter/src/components/ServerVersionProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const ServerVersionProvider = ({
parentAlertsAdd,
showAlertsInPlugin,
loginApp,
setLoginBaseUrl,

Check failure on line 21 in adapter/src/components/ServerVersionProvider.js

View workflow job for this annotation

GitHub Actions / lint

'setLoginBaseUrl' is missing in props validation
children,
}) => {
const offlineInterface = useOfflineInterface()
Expand Down Expand Up @@ -149,6 +150,10 @@ export const ServerVersionProvider = ({
}
}, [appName, baseUrl, loginApp])

useEffect(() => {
setLoginBaseUrl(baseUrl)
}, [setLoginBaseUrl, baseUrl])

useEffect(() => {
if (pwaEnabled) {
offlineInterface.ready.then(() => {
Expand Down
10 changes: 7 additions & 3 deletions adapter/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { checkForSWUpdateAndReload } from '@dhis2/pwa'
import PropTypes from 'prop-types'
import React from 'react'
import React, { useState } from 'react'
import { AppWrapper } from './components/AppWrapper.js'
import { ErrorBoundary } from './components/ErrorBoundary.js'
import { LoginAppWrapper } from './components/LoginAppWrapper.js'
import { LoginAppWrapper } from './components/LoginAppWrapper.js'
import { OfflineInterfaceProvider } from './components/OfflineInterfaceContext.js'
import { PWALoadingBoundary } from './components/PWALoadingBoundary.js'
import { ServerVersionProvider } from './components/ServerVersionProvider.js'
Expand All @@ -24,6 +23,7 @@ const AppAdapter = ({
loginApp,
children,
}) => {
const [loginBaseUrl, setLoginBaseUrl] = useState(url)
if (loginApp) {
return (
<ErrorBoundary
Expand All @@ -43,8 +43,11 @@ const AppAdapter = ({
pwaEnabled={pwaEnabled}
loginApp={loginApp}
plugin={false}
setLoginBaseUrl={setLoginBaseUrl}
>
<LoginAppWrapper url={url}>{children}</LoginAppWrapper>
<LoginAppWrapper url={loginBaseUrl}>
{children}
</LoginAppWrapper>
</ServerVersionProvider>
</ErrorBoundary>
)
Expand All @@ -66,6 +69,7 @@ const AppAdapter = ({
plugin={plugin}
parentAlertsAdd={parentAlertsAdd}
showAlertsInPlugin={showAlertsInPlugin}
setLoginBaseUrl={() => {}}
>
<AppWrapper
plugin={plugin}
Expand Down

0 comments on commit 8330626

Please sign in to comment.