From 3da13afb5ab09ba8c5087f41f07cc0203a23ea5c Mon Sep 17 00:00:00 2001 From: Alex P Date: Thu, 22 Mar 2018 19:57:32 -0700 Subject: [PATCH] Refactor dashboard notifications --- ui/src/dashboards/actions/index.js | 8 ++++---- ui/src/dashboards/components/template_variables/Row.js | 4 ++-- ui/src/dashboards/containers/DashboardPage.js | 4 ++-- ui/src/shared/copy/notifications.js | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index 2cafbd89b8..6a6d904a43 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -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)) diff --git a/ui/src/dashboards/components/template_variables/Row.js b/ui/src/dashboards/components/template_variables/Row.js index 7d6f28ad61..a3bf0a1590 100644 --- a/ui/src/dashboards/components/template_variables/Row.js +++ b/ui/src/dashboards/components/template_variables/Row.js @@ -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({ diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.js index 19b85e6a26..29516e202d 100644 --- a/ui/src/dashboards/containers/DashboardPage.js +++ b/ui/src/dashboards/containers/DashboardPage.js @@ -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. diff --git a/ui/src/shared/copy/notifications.js b/ui/src/shared/copy/notifications.js index b353261df7..fb6b3315c0 100644 --- a/ui/src/shared/copy/notifications.js +++ b/ui/src/shared/copy/notifications.js @@ -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