|
@ -14,6 +14,8 @@ import { BridgeSyncConsumer } from 'bridge/BridgeSyncContext' |
|
|
import CounterValues from 'helpers/countervalues' |
|
|
import CounterValues from 'helpers/countervalues' |
|
|
|
|
|
|
|
|
import { Rotating } from 'components/base/Spinner' |
|
|
import { Rotating } from 'components/base/Spinner' |
|
|
|
|
|
import Tooltip from 'components/base/Tooltip' |
|
|
|
|
|
import TranslatedError from 'components/TranslatedError' |
|
|
import Box from 'components/base/Box' |
|
|
import Box from 'components/base/Box' |
|
|
import IconRefresh from 'icons/Refresh' |
|
|
import IconRefresh from 'icons/Refresh' |
|
|
import IconExclamationCircle from 'icons/ExclamationCircle' |
|
|
import IconExclamationCircle from 'icons/ExclamationCircle' |
|
@ -28,6 +30,7 @@ type Props = { |
|
|
// FIXME: eslint should see that it is used in static method
|
|
|
// FIXME: eslint should see that it is used in static method
|
|
|
isGlobalSyncStatePending: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
isGlobalSyncStatePending: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
|
|
|
|
|
|
|
|
|
error: ?Error, |
|
|
isPending: boolean, |
|
|
isPending: boolean, |
|
|
isError: boolean, |
|
|
isError: boolean, |
|
|
t: T, |
|
|
t: T, |
|
@ -75,12 +78,12 @@ class ActivityIndicatorInner extends PureComponent<Props, State> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
render() { |
|
|
render() { |
|
|
const { isPending, isError, t } = this.props |
|
|
const { isPending, isError, error, t } = this.props |
|
|
const { hasClicked, isFirstSync } = this.state |
|
|
const { hasClicked, isFirstSync } = this.state |
|
|
const isDisabled = isError || (isPending && (isFirstSync || hasClicked)) |
|
|
const isDisabled = isError || (isPending && (isFirstSync || hasClicked)) |
|
|
const isRotating = isPending && (hasClicked || isFirstSync) |
|
|
const isRotating = isPending && (hasClicked || isFirstSync) |
|
|
|
|
|
|
|
|
return ( |
|
|
const content = ( |
|
|
<ItemContainer disabled={isDisabled} onClick={isDisabled ? undefined : this.handleRefresh}> |
|
|
<ItemContainer disabled={isDisabled} onClick={isDisabled ? undefined : this.handleRefresh}> |
|
|
<Rotating |
|
|
<Rotating |
|
|
size={16} |
|
|
size={16} |
|
@ -123,6 +126,23 @@ class ActivityIndicatorInner extends PureComponent<Props, State> { |
|
|
</Box> |
|
|
</Box> |
|
|
</ItemContainer> |
|
|
</ItemContainer> |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if (error) { |
|
|
|
|
|
return ( |
|
|
|
|
|
<Tooltip |
|
|
|
|
|
tooltipBg="alertRed" |
|
|
|
|
|
render={() => ( |
|
|
|
|
|
<Box fontSize={4} p={2} style={{ maxWidth: 250 }}> |
|
|
|
|
|
<TranslatedError error={error} /> |
|
|
|
|
|
</Box> |
|
|
|
|
|
)} |
|
|
|
|
|
> |
|
|
|
|
|
{content} |
|
|
|
|
|
</Tooltip> |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return content |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -132,13 +152,14 @@ const ActivityIndicator = ({ globalSyncState, t }: { globalSyncState: AsyncState |
|
|
<CounterValues.PollingConsumer> |
|
|
<CounterValues.PollingConsumer> |
|
|
{cvPolling => { |
|
|
{cvPolling => { |
|
|
const isPending = cvPolling.pending || globalSyncState.pending |
|
|
const isPending = cvPolling.pending || globalSyncState.pending |
|
|
const isError = cvPolling.error || globalSyncState.error |
|
|
const isError = !isPending && (cvPolling.error || globalSyncState.error) |
|
|
return ( |
|
|
return ( |
|
|
<ActivityIndicatorInner |
|
|
<ActivityIndicatorInner |
|
|
t={t} |
|
|
t={t} |
|
|
isPending={isPending} |
|
|
isPending={isPending} |
|
|
isGlobalSyncStatePending={globalSyncState.pending} |
|
|
isGlobalSyncStatePending={globalSyncState.pending} |
|
|
isError={!!isError && !isPending} |
|
|
isError={!!isError} |
|
|
|
|
|
error={isError ? globalSyncState.error : null} |
|
|
cvPoll={cvPolling.poll} |
|
|
cvPoll={cvPolling.poll} |
|
|
setSyncBehavior={setSyncBehavior} |
|
|
setSyncBehavior={setSyncBehavior} |
|
|
/> |
|
|
/> |
|
|