Improve error message copy for read, write, asset limits
parent
268229d31c
commit
c8a345b35d
|
@ -7,7 +7,7 @@ import {client} from 'src/utils/api'
|
|||
import {RemoteDataState, AppState, Bucket} from 'src/types'
|
||||
|
||||
// Utils
|
||||
import {isLimitError, extractMessage} from 'src/cloud/utils/limits'
|
||||
import {isLimitError} from 'src/cloud/utils/limits'
|
||||
|
||||
// Actions
|
||||
import {notify} from 'src/shared/actions/notifications'
|
||||
|
@ -118,8 +118,7 @@ export const createBucket = (bucket: Bucket) => async (
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(resourceLimitReached('buckets', message)))
|
||||
dispatch(notify(resourceLimitReached('buckets')))
|
||||
} else {
|
||||
dispatch(notify(bucketCreateFailed()))
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import {notify} from 'src/shared/actions/notifications'
|
|||
|
||||
// Constants
|
||||
import {
|
||||
readWriteLimitReached,
|
||||
readLimitReached,
|
||||
resourceLimitReached,
|
||||
} from 'src/shared/copy/notifications'
|
||||
|
||||
|
@ -142,10 +142,9 @@ export const getReadWriteLimits = () => async (
|
|||
const limits = await getReadWriteLimitsAJAX(org.id)
|
||||
|
||||
const isReadLimited = limits.read.status === LimitStatus.EXCEEDED
|
||||
const isWriteLimited = limits.write.status === LimitStatus.EXCEEDED
|
||||
|
||||
if (isReadLimited || isWriteLimited) {
|
||||
dispatch(notify(readWriteLimitReached(isReadLimited, isWriteLimited)))
|
||||
if (isReadLimited) {
|
||||
dispatch(notify(readLimitReached()))
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@ export const isLimitError = error => {
|
|||
return get(error, 'response.status', '') === RATE_LIMIT_ERROR_STATUS
|
||||
}
|
||||
|
||||
export const extractMessage = error => {
|
||||
return get(error, 'response.data.message', '')
|
||||
}
|
||||
|
||||
export const extractBucketLimits = (limits: LimitsState) => {
|
||||
return get(limits, 'buckets.limitStatus')
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ import {client} from 'src/utils/api'
|
|||
import {exportVariables} from 'src/variables/utils/exportVariables'
|
||||
import {getSaveableView} from 'src/timeMachine/selectors'
|
||||
import {incrementCloneName} from 'src/utils/naming'
|
||||
import {extractMessage, isLimitError} from 'src/cloud/utils/limits'
|
||||
import {isLimitError} from 'src/cloud/utils/limits'
|
||||
|
||||
// Constants
|
||||
import * as copy from 'src/shared/copy/notifications'
|
||||
|
@ -235,8 +235,7 @@ export const createDashboard = () => async (
|
|||
console.error(error)
|
||||
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards')))
|
||||
} else {
|
||||
dispatch(notify(copy.dashboardCreateFailed()))
|
||||
}
|
||||
|
@ -264,8 +263,7 @@ export const cloneDashboard = (dashboard: Dashboard) => async (
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards')))
|
||||
} else {
|
||||
dispatch(notify(copy.dashboardCreateFailed()))
|
||||
}
|
||||
|
@ -310,8 +308,7 @@ export const createDashboardFromTemplate = (
|
|||
dispatch(checkDashboardLimits())
|
||||
} catch (error) {
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('dashboards')))
|
||||
} else {
|
||||
dispatch(notify(copy.importDashboardFailed(error)))
|
||||
}
|
||||
|
|
|
@ -556,12 +556,11 @@ export const writeLineProtocolAction = (
|
|||
dispatch(setLPStatus(RemoteDataState.Done))
|
||||
} catch (error) {
|
||||
const errorMessage = _.get(error, 'response.data.message', '')
|
||||
console.error(errorMessage || error)
|
||||
dispatch(setLPStatus(RemoteDataState.Error, errorMessage))
|
||||
|
||||
console.error(errorMessage || error)
|
||||
|
||||
if (error.response.status === RATE_LIMIT_ERROR_STATUS) {
|
||||
dispatch(notify(writeLimitReached(errorMessage)))
|
||||
dispatch(notify(writeLimitReached()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import {checkQueryResult} from 'src/shared/utils/checkQueryResult'
|
|||
|
||||
// Constants
|
||||
import {RATE_LIMIT_ERROR_STATUS} from 'src/shared/constants/errors'
|
||||
import {queryLimitReached} from 'src/shared/copy/notifications'
|
||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||
|
||||
// Actions
|
||||
import {notify as notifyAction} from 'src/shared/actions/notifications'
|
||||
|
@ -162,7 +162,7 @@ class TimeSeries extends Component<Props & WithRouterProps, State> {
|
|||
}
|
||||
|
||||
if (get(error, 'xhr.status') === RATE_LIMIT_ERROR_STATUS) {
|
||||
notify(queryLimitReached())
|
||||
notify(readLimitReached())
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
|
|
@ -950,43 +950,20 @@ export const deleteBucketFailed = (): Notification => ({
|
|||
})
|
||||
|
||||
// Limits
|
||||
export const writeLimitReached = (errorMessage: string): Notification => ({
|
||||
export const writeLimitReached = (): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: `You have reached a write limit on this resource: ${errorMessage}.`,
|
||||
message: `It looks like you have exceeded the write rate limits allowed as part of your plan. If you would like to increase your write rate limits, reach out to cloudbeta@influxdata.com.`,
|
||||
duration: INFINITE,
|
||||
})
|
||||
|
||||
export const readWriteLimitReached = (
|
||||
isReadLimited: boolean,
|
||||
isWriteLimited: boolean
|
||||
): Notification => {
|
||||
let limitText = ''
|
||||
if (isReadLimited && isWriteLimited) {
|
||||
limitText = 'read and write'
|
||||
} else if (isReadLimited) {
|
||||
limitText = 'read'
|
||||
} else if (isWriteLimited) {
|
||||
limitText = 'write'
|
||||
}
|
||||
|
||||
return {
|
||||
...defaultErrorNotification,
|
||||
message: `You have reached a ${limitText} limit on this resource. Some operations may not be permitted at this time.`,
|
||||
duration: INFINITE,
|
||||
}
|
||||
}
|
||||
|
||||
export const queryLimitReached = (): Notification => ({
|
||||
export const readLimitReached = (): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'You have reached a query limit.',
|
||||
message: `It looks like you have exceeded the query limits allowed as part of your plan. Try reducing the number of cells on your dashboard. If you would like to increase your query limits, reach out to cloudbeta@influxdata.com.`,
|
||||
duration: INFINITE,
|
||||
})
|
||||
|
||||
export const resourceLimitReached = (
|
||||
resourceName: string,
|
||||
message?: string
|
||||
): Notification => ({
|
||||
export const resourceLimitReached = (resourceName: string): Notification => ({
|
||||
...defaultErrorNotification,
|
||||
message: `You have created the maximum number of ${resourceName} allowed on this account, some operations may not be permitted. ${message}`,
|
||||
message: `Oops. It looks like you have reached the maximum number of ${resourceName} allowed as part of your plan. If you would like to upgrade and remove this restriction, reach out to cloudbeta@influxdata.com.`,
|
||||
duration: INFINITE,
|
||||
})
|
||||
|
|
|
@ -45,7 +45,7 @@ import {getErrorMessage} from 'src/utils/api'
|
|||
import {insertPreambleInScript} from 'src/shared/utils/insertPreambleInScript'
|
||||
import {TaskOptionKeys, TaskSchedule} from 'src/utils/taskOptionsToFluxScript'
|
||||
import {taskToTemplate} from 'src/shared/utils/resourceToTemplate'
|
||||
import {isLimitError, extractMessage} from 'src/cloud/utils/limits'
|
||||
import {isLimitError} from 'src/cloud/utils/limits'
|
||||
import {checkTaskLimits} from 'src/cloud/actions/limits'
|
||||
|
||||
export type Action =
|
||||
|
@ -333,8 +333,7 @@ export const cloneTask = (task: Task, _) => async dispatch => {
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('tasks', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('tasks')))
|
||||
} else {
|
||||
const message = getErrorMessage(error)
|
||||
dispatch(notify(taskCloneFailed(task.name, message)))
|
||||
|
@ -433,8 +432,7 @@ export const saveNewScript = (script: string, preamble: string) => async (
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('tasks', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('tasks')))
|
||||
} else {
|
||||
const message = getErrorMessage(error)
|
||||
dispatch(notify(taskNotCreated(message)))
|
||||
|
@ -548,8 +546,7 @@ export const createTaskFromTemplate = (template: ITaskTemplate) => async (
|
|||
dispatch(checkTaskLimits())
|
||||
} catch (error) {
|
||||
if (isLimitError(error)) {
|
||||
const message = extractMessage(error)
|
||||
dispatch(notify(copy.resourceLimitReached('tasks', message)))
|
||||
dispatch(notify(copy.resourceLimitReached('tasks')))
|
||||
} else {
|
||||
dispatch(notify(importTaskFailed(error)))
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import {refreshVariableValues, selectValue} from 'src/variables/actions'
|
|||
import {notify} from 'src/shared/actions/notifications'
|
||||
|
||||
// Constants
|
||||
import {queryLimitReached} from 'src/shared/copy/notifications'
|
||||
import {readLimitReached} from 'src/shared/copy/notifications'
|
||||
import {RATE_LIMIT_ERROR_STATUS} from 'src/shared/constants/errors'
|
||||
|
||||
// Utils
|
||||
|
@ -130,7 +130,7 @@ export const executeQueries = () => async (dispatch, getState: GetState) => {
|
|||
}
|
||||
|
||||
if (get(e, 'xhr.status') === RATE_LIMIT_ERROR_STATUS) {
|
||||
dispatch(notify(queryLimitReached()))
|
||||
dispatch(notify(readLimitReached()))
|
||||
}
|
||||
|
||||
console.error(e)
|
||||
|
|
Loading…
Reference in New Issue