summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components')
-rw-r--r--opendc-web/opendc-web-ui/src/components/AppHeaderTools.js16
-rw-r--r--opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js7
2 files changed, 12 insertions, 11 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/AppHeaderTools.js b/opendc-web/opendc-web-ui/src/components/AppHeaderTools.js
index 02e5d265..3e58b209 100644
--- a/opendc-web/opendc-web-ui/src/components/AppHeaderTools.js
+++ b/opendc-web/opendc-web-ui/src/components/AppHeaderTools.js
@@ -39,7 +39,9 @@ import { useAuth } from '../auth'
import { GithubIcon, HelpIcon } from '@patternfly/react-icons'
function AppHeaderTools() {
- const auth = useAuth()
+ const { logout, user, isAuthenticated, isLoading } = useAuth()
+ const username = isAuthenticated || isLoading ? user?.name : 'Anonymous'
+ const avatar = isAuthenticated || isLoading ? user?.picture : '/img/avatar.svg'
const [isKebabDropdownOpen, setKebabDropdownOpen] = useState(false)
const kebabDropdownItems = [
@@ -56,7 +58,11 @@ function AppHeaderTools() {
const [isDropdownOpen, setDropdownOpen] = useState(false)
const userDropdownItems = [
<DropdownGroup key="group 2">
- <DropdownItem key="group 2 logout" onClick={() => auth.logout({ returnTo: window.location.origin })}>
+ <DropdownItem
+ key="group 2 logout"
+ isDisabled={!isAuthenticated}
+ onClick={() => logout({ returnTo: window.location.origin })}
+ >
Logout
</DropdownItem>
</DropdownGroup>,
@@ -105,7 +111,7 @@ function AppHeaderTools() {
isOpen={isDropdownOpen}
toggle={
<DropdownToggle onToggle={() => setDropdownOpen(!isDropdownOpen)}>
- {auth?.user?.name ?? (
+ {username ?? (
<Skeleton
fontSize="xs"
width="150px"
@@ -119,8 +125,8 @@ function AppHeaderTools() {
/>
</PageHeaderToolsItem>
</PageHeaderToolsGroup>
- {auth?.user?.picture ? (
- <Avatar src={auth.user.picture} alt="Avatar image" />
+ {avatar ? (
+ <Avatar src={avatar} alt="Avatar image" />
) : (
<Skeleton className="pf-c-avatar" shape="circle" width="2.25rem" screenreaderText="Loading avatar" />
)}
diff --git a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js b/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js
index 8897f2d0..18c3db3c 100644
--- a/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js
+++ b/opendc-web/opendc-web-ui/src/components/topologies/sidebar/rack/MachineComponent.js
@@ -5,12 +5,7 @@ import { Machine } from '../../../../shapes'
const UnitIcon = ({ id, type }) => (
// eslint-disable-next-line @next/next/no-img-element
- <img
- src={'/img/topology/' + id + '-icon.png'}
- alt={'Machine contains ' + type + ' units'}
- height={24}
- width={24}
- />
+ <img src={'/img/topology/' + id + '-icon.png'} alt={'Machine contains ' + type + ' units'} height={24} width={24} />
)
UnitIcon.propTypes = {