Skip to content

Commit

Permalink
fix: Moves code in useEffect into main body of component #673
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomjinx authored and tadayosi committed Nov 21, 2023
1 parent 3ff43cc commit 1f54014
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/hawtio/src/ui/login/HawtioLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useUser } from '@hawtiosrc/auth/hooks'
import { DEFAULT_APP_NAME, DEFAULT_LOGIN_TITLE, useHawtconfig, usePlugins } from '@hawtiosrc/core'
import { backgroundImages, hawtioLogo } from '@hawtiosrc/img'
import { ListItem, ListVariant, LoginFooterItem, LoginPage } from '@patternfly/react-core'
import React, { useEffect } from 'react'
import React from 'react'
import { useNavigate } from 'react-router-dom'
import { HawtioNotification } from '../notification'
import { HawtioLoadingPage } from '../page/HawtioLoadingPage'
Expand All @@ -16,17 +16,15 @@ export const HawtioLogin: React.FunctionComponent = () => {
const { hawtconfig, hawtconfigLoaded } = useHawtconfig()
const { plugins, pluginsLoaded } = usePlugins()

useEffect(() => {
if (isLogin) {
navigate('/')
}
}, [isLogin, navigate])

if (!userLoaded || !hawtconfigLoaded || !pluginsLoaded) {
log.debug('Loading:', 'user =', userLoaded, ', hawtconfig =', hawtconfigLoaded, ', pluginsLoaded =', pluginsLoaded)
return <HawtioLoadingPage />
}

if (isLogin) {
navigate('/')
}

let loginForm = <HawtioLoginForm />
const loginPlugins = plugins.filter(plugin => plugin.isLogin)
log.debug('Discovered Login Plugins:', loginPlugins.length)
Expand Down

0 comments on commit 1f54014

Please sign in to comment.