Refactor dashboard notifications

pull/10616/head
Alex P 2018-03-22 19:57:32 -07:00
parent 72458308b6
commit 3da13afb5a
4 changed files with 12 additions and 12 deletions

View File

@ -13,8 +13,8 @@ import {errorThrown} from 'shared/actions/errors'
import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants'
import {
NOTIFY_DASHBOARD_DELETED,
NOTIFY_DASHBOARD_DELETE_FAILED,
notifyDashboardDeleted,
notifyDashboardDeleteFailed,
} from 'shared/copy/notifications'
import {
@ -261,12 +261,12 @@ export const deleteDashboardAsync = dashboard => async dispatch => {
dispatch(deleteDashboard(dashboard))
try {
await deleteDashboardAJAX(dashboard)
dispatch(notify(NOTIFY_DASHBOARD_DELETED(dashboard.name)))
dispatch(notify(notifyDashboardDeleted(dashboard.name)))
} catch (error) {
dispatch(
errorThrown(
error,
NOTIFY_DASHBOARD_DELETE_FAILED(dashboard.name, error.data.message)
notifyDashboardDeleteFailed(dashboard.name, error.data.message)
)
)
dispatch(deleteDashboardFailed(dashboard))

View File

@ -24,7 +24,7 @@ import generateTemplateVariableQuery from 'src/dashboards/utils/templateVariable
import {errorThrown as errorThrownAction} from 'shared/actions/errors'
import {notify as notifyAction} from 'shared/actions/notifications'
import {NOTIFY_TEMP_VAR_ALREADY_EXISTS} from 'shared/copy/notifications'
import {notifyTempVarAlreadyExists} from 'shared/copy/notifications'
const compact = values => uniq(values).filter(value => /\S/.test(value))
@ -147,7 +147,7 @@ class RowWrapper extends Component {
const tempVar = `\u003a${_tempVar}\u003a` // add ':'s
if (tempVarAlreadyExists(tempVar, id)) {
return notify(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar))
return notify(notifyTempVarAlreadyExists(_tempVar))
}
this.setState({

View File

@ -34,7 +34,7 @@ import {
} from 'shared/actions/app'
import {presentationButtonDispatcher} from 'shared/dispatchers'
import {DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants'
import {NOTIFY_DASHBOARD_NOT_FOUND} from 'shared/copy/notifications'
import {notifyDashboardNotFound} from 'shared/copy/notifications'
const FORMAT_INFLUXQL = 'influxql'
const defaultTimeRange = {
@ -91,7 +91,7 @@ class DashboardPage extends Component {
if (!dashboard) {
router.push(`/sources/${source.id}/dashboards`)
return notify(NOTIFY_DASHBOARD_NOT_FOUND(dashboardID))
return notify(notifyDashboardNotFound(dashboardID))
}
// Refresh and persists influxql generated template variable values.

View File

@ -360,25 +360,25 @@ export const NOTIFY_DATABASE_NAME_ALREADY_EXISTS = {
// Dashboard Notifications
// ----------------------------------------------------------------------------
export const NOTIFY_TEMP_VAR_ALREADY_EXISTS = tempVarName => ({
export const notifyTempVarAlreadyExists = tempVarName => ({
...defaultErrorNotification,
icon: 'cube',
message: `Variable '${tempVarName}' already exists. Please enter a new value.`,
})
export const NOTIFY_DASHBOARD_NOT_FOUND = dashboardID => ({
export const notifyDashboardNotFound = dashboardID => ({
...defaultErrorNotification,
icon: 'dash-h',
message: `Dashboard ${dashboardID} could not be found`,
})
export const NOTIFY_DASHBOARD_DELETED = name => ({
export const notifyDashboardDeleted = name => ({
...defaultSuccessNotification,
icon: 'dash-h',
message: `Dashboard ${name} deleted successfully.`,
})
export const NOTIFY_DASHBOARD_DELETE_FAILED = (name, errorMessage) =>
export const notifyDashboardDeleteFailed = (name, errorMessage) =>
`Failed to delete Dashboard ${name}: ${errorMessage}.`
// Rule Builder Notifications