|
1 |
| -import React, { useState } from 'react' |
| 1 | +import React, { useEffect, useState } from 'react' |
2 | 2 |
|
3 | 3 | import { useDispatch, useSelector } from 'react-redux'
|
4 | 4 | import { EuiIcon, EuiLink, EuiLoadingSpinner, EuiPopover, EuiText } from '@elastic/eui'
|
@@ -27,18 +27,33 @@ export interface Props {
|
27 | 27 | const OAuthUserProfile = (props: Props) => {
|
28 | 28 | const { source } = props
|
29 | 29 | const [selectingAccountId, setSelectingAccountId] = useState<number>()
|
30 |
| - const { data } = useSelector(oauthCloudUserSelector) |
| 30 | + const { loading, error, data } = useSelector(oauthCloudUserSelector) |
31 | 31 | const { server } = useSelector(appInfoSelector)
|
32 | 32 |
|
33 | 33 | const [isProfileOpen, setIsProfileOpen] = useState(false)
|
34 | 34 | const [isImportLoading, setIsImportLoading] = useState(false)
|
| 35 | + const [profileLoading, setProfileLoading] = useState(true) |
35 | 36 |
|
36 | 37 | const dispatch = useDispatch()
|
37 | 38 | const history = useHistory()
|
38 | 39 |
|
| 40 | + useEffect(() => { |
| 41 | + if (!loading && (error || data)) { |
| 42 | + setProfileLoading(false) |
| 43 | + } |
| 44 | + }, [data, loading, error]) |
| 45 | + |
39 | 46 | if (!data) {
|
40 | 47 | if (server?.packageType === PackageType.Mas) return null
|
41 | 48 |
|
| 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 | + |
42 | 57 | return (
|
43 | 58 | <div className={styles.wrapper}>
|
44 | 59 | <OAuthSignInButton source={source} />
|
|
0 commit comments