Replace data write errorThrown with notify

Moving to copy as well
pull/10616/head
Alex P 2018-03-22 21:42:01 -07:00
parent 2155217a60
commit 0e0ef31020
2 changed files with 10 additions and 4 deletions

View File

@ -1,17 +1,18 @@
import {writeLineProtocol as writeLineProtocolAJAX} from 'src/data_explorer/apis'
import {errorThrown} from 'shared/actions/errors'
import {notify} from 'shared/actions/notifications'
import {notifyDataWritten} from 'shared/copy/notifications'
import {
notifyDataWritten,
notifyDataWriteFailed,
} from 'shared/copy/notifications'
export const writeLineProtocolAsync = (source, db, data) => async dispatch => {
try {
await writeLineProtocolAJAX(source, db, data)
dispatch(notify(notifyDataWritten()))
} catch (response) {
const errorMessage = `Write failed: ${response.data.error}`
dispatch(errorThrown(response, errorMessage))
dispatch(notify(notifyDataWriteFailed(response.data.error)))
throw response
}
}

View File

@ -50,6 +50,11 @@ export const notifyDataWritten = () => ({
message: 'Data was written successfully.',
})
export const notifyDataWriteFailed = errorMessage => ({
...defaultErrorNotification,
message: `Data write failed: ${errorMessage}`,
})
export const notifySessionTimedOut = () => ({
type: 'primary',
icon: 'triangle',