Pass errorMessages directly from TimeSeries, and change if limit error
parent
2551aadd79
commit
6bd1518fd0
|
@ -87,10 +87,10 @@ class RefreshingView extends PureComponent<Props, State> {
|
||||||
key={manualRefresh}
|
key={manualRefresh}
|
||||||
variables={this.variableAssignments}
|
variables={this.variableAssignments}
|
||||||
>
|
>
|
||||||
{({tables, loading, error, isInitialFetch}) => {
|
{({tables, loading, errorMessage, isInitialFetch}) => {
|
||||||
return (
|
return (
|
||||||
<EmptyQueryView
|
<EmptyQueryView
|
||||||
errorMessage={error ? error.message : null}
|
errorMessage={errorMessage}
|
||||||
tables={tables}
|
tables={tables}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
isInitialFetch={isInitialFetch}
|
isInitialFetch={isInitialFetch}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {checkQueryResult} from 'src/shared/utils/checkQueryResult'
|
||||||
// Constants
|
// Constants
|
||||||
import {RATE_LIMIT_ERROR_STATUS} from 'src/cloud/constants/index'
|
import {RATE_LIMIT_ERROR_STATUS} from 'src/cloud/constants/index'
|
||||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||||
|
import {RATE_LIMIT_ERROR_TEXT} from 'src/cloud/constants'
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import {notify as notifyAction} from 'src/shared/actions/notifications'
|
import {notify as notifyAction} from 'src/shared/actions/notifications'
|
||||||
|
@ -32,7 +33,7 @@ interface QueriesState {
|
||||||
tables: FluxTable[]
|
tables: FluxTable[]
|
||||||
files: string[] | null
|
files: string[] | null
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
error: Error | null
|
errorMessage: string
|
||||||
isInitialFetch: boolean
|
isInitialFetch: boolean
|
||||||
duration: number
|
duration: number
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ interface State {
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
tables: FluxTable[]
|
tables: FluxTable[]
|
||||||
files: string[] | null
|
files: string[] | null
|
||||||
error: Error | null
|
errorMessage: string
|
||||||
fetchCount: number
|
fetchCount: number
|
||||||
duration: number
|
duration: number
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,7 @@ const defaultState = (): State => ({
|
||||||
tables: [],
|
tables: [],
|
||||||
files: null,
|
files: null,
|
||||||
fetchCount: 0,
|
fetchCount: 0,
|
||||||
error: null,
|
errorMessage: '',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -97,13 +98,20 @@ class TimeSeries extends Component<Props & WithRouterProps, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {tables, files, loading, error, fetchCount, duration} = this.state
|
const {
|
||||||
|
tables,
|
||||||
|
files,
|
||||||
|
loading,
|
||||||
|
errorMessage,
|
||||||
|
fetchCount,
|
||||||
|
duration,
|
||||||
|
} = this.state
|
||||||
|
|
||||||
return this.props.children({
|
return this.props.children({
|
||||||
tables,
|
tables,
|
||||||
files,
|
files,
|
||||||
loading,
|
loading,
|
||||||
error,
|
errorMessage,
|
||||||
duration,
|
duration,
|
||||||
isInitialFetch: fetchCount === 1,
|
isInitialFetch: fetchCount === 1,
|
||||||
})
|
})
|
||||||
|
@ -127,7 +135,7 @@ class TimeSeries extends Component<Props & WithRouterProps, State> {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: RemoteDataState.Loading,
|
loading: RemoteDataState.Loading,
|
||||||
fetchCount: this.state.fetchCount + 1,
|
fetchCount: this.state.fetchCount + 1,
|
||||||
error: null,
|
errorMessage: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -161,12 +169,15 @@ class TimeSeries extends Component<Props & WithRouterProps, State> {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let errorMessage = get(error, 'message', '')
|
||||||
|
|
||||||
if (get(error, 'xhr.status') === RATE_LIMIT_ERROR_STATUS) {
|
if (get(error, 'xhr.status') === RATE_LIMIT_ERROR_STATUS) {
|
||||||
notify(readLimitReached())
|
notify(readLimitReached())
|
||||||
|
errorMessage = RATE_LIMIT_ERROR_TEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
error,
|
errorMessage,
|
||||||
loading: RemoteDataState.Error,
|
loading: RemoteDataState.Error,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue