Skip to content

Commit 9ec9d92

Browse files
committed
RI-6242 add loader before initial sign in
1 parent ea6fdca commit 9ec9d92

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

redisinsight/ui/src/components/oauth/oauth-user-profile/OAuthUserProfile.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useEffect, useState } from 'react'
22

33
import { useDispatch, useSelector } from 'react-redux'
44
import { EuiIcon, EuiLink, EuiLoadingSpinner, EuiPopover, EuiText } from '@elastic/eui'
@@ -27,18 +27,33 @@ export interface Props {
2727
const OAuthUserProfile = (props: Props) => {
2828
const { source } = props
2929
const [selectingAccountId, setSelectingAccountId] = useState<number>()
30-
const { data } = useSelector(oauthCloudUserSelector)
30+
const { loading, error, data } = useSelector(oauthCloudUserSelector)
3131
const { server } = useSelector(appInfoSelector)
3232

3333
const [isProfileOpen, setIsProfileOpen] = useState(false)
3434
const [isImportLoading, setIsImportLoading] = useState(false)
35+
const [profileLoading, setProfileLoading] = useState(true)
3536

3637
const dispatch = useDispatch()
3738
const history = useHistory()
3839

40+
useEffect(() => {
41+
if (!loading && (error || data)) {
42+
setProfileLoading(false)
43+
}
44+
}, [data, loading, error])
45+
3946
if (!data) {
4047
if (server?.packageType === PackageType.Mas) return null
4148

49+
if (profileLoading) {
50+
return (
51+
<div className={styles.loadingContainer}>
52+
<EuiLoadingSpinner className={cx('infiniteMessage__icon', styles.loading)} size="l" />
53+
</div>
54+
)
55+
}
56+
4257
return (
4358
<div className={styles.wrapper}>
4459
<OAuthSignInButton source={source} />

redisinsight/ui/src/components/oauth/oauth-user-profile/styles.module.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,12 @@
135135
}
136136
}
137137
}
138+
139+
.loadingContainer {
140+
display: flex;
141+
align-items: center;
142+
143+
.loading {
144+
border-top-color: var(--euiColorGhost) !important;
145+
}
146+
}

0 commit comments

Comments
 (0)