Refactor notifications to be functions

pull/3042/head
Alex P 2018-03-22 20:44:19 -07:00
parent d41089279b
commit 1a4b7b8dd6
10 changed files with 111 additions and 116 deletions

View File

@ -26,29 +26,29 @@ import {
notifyDBUserCreationFailed, notifyDBUserCreationFailed,
notifyDBUserDeleted, notifyDBUserDeleted,
notifyDBUserDeleteFailed, notifyDBUserDeleteFailed,
NOTIFY_DB_USER_PERMISSIONS_UPDATED, notifyDBUserPermissionsUpdated,
notifyDBUserPermissionsUpdateFailed, notifyDBUserPermissionsUpdateFailed,
NOTIFY_DB_USER_ROLES_UPDATED, notifyDBUserRolesUpdated,
notifyDBUserRolesUpdateFailed, notifyDBUserRolesUpdateFailed,
NOTIFY_DB_USER_PASSWORD_UPDATED, notifyDBUserPasswordUpdated,
notifyDBUserPasswordUpdateFailed, notifyDBUserPasswordUpdateFailed,
NOTIFY_DATABASE_CREATED, notifyDatabaseCreated,
notifyDBCreationFailed, notifyDBCreationFailed,
notifyDBDeleted, notifyDBDeleted,
notifyDBDeleteFailed, notifyDBDeleteFailed,
NOTIFY_ROLE_CREATED, notifyRoleCreated,
notifyRoleCreationFailed, notifyRoleCreationFailed,
notifyRoleDeleted, notifyRoleDeleted,
notifyRoleDeleteFailed, notifyRoleDeleteFailed,
NOTIFY_ROLE_USERS_UPDATED, notifyRoleUsersUpdated,
notifyRoleUsersUpdateFailed, notifyRoleUsersUpdateFailed,
NOTIFY_ROLE_PERMISSIONS_UPDATED, notifyRolePermissionsUpdated,
notifyRolePermissionsUpdateFailed, notifyRolePermissionsUpdateFailed,
NOTIFY_RETENTION_POLICY_CREATED, notifyRetentionPolicyCreated,
notifyRetentionPolicyCreationFailed, notifyRetentionPolicyCreationFailed,
notifyRetentionPolicyDeleted, notifyRetentionPolicyDeleted,
notifyRetentionPolicyDeleteFailed, notifyRetentionPolicyDeleteFailed,
NOTIFY_RETENTION_POLICY_UPDATED, notifyRetentionPolicyUpdated,
notifyRetentionPolicyUpdateFailed, notifyRetentionPolicyUpdateFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
@ -319,7 +319,7 @@ export const createUserAsync = (url, user) => async dispatch => {
export const createRoleAsync = (url, role) => async dispatch => { export const createRoleAsync = (url, role) => async dispatch => {
try { try {
const {data} = await createRoleAJAX(url, role) const {data} = await createRoleAJAX(url, role)
dispatch(notify(NOTIFY_ROLE_CREATED)) dispatch(notify(notifyRoleCreated()))
dispatch(syncRole(role, data)) dispatch(syncRole(role, data))
} catch (error) { } catch (error) {
dispatch(errorThrown(error, notifyRoleCreationFailed(error.data.message))) dispatch(errorThrown(error, notifyRoleCreationFailed(error.data.message)))
@ -332,7 +332,7 @@ export const createDatabaseAsync = (url, database) => async dispatch => {
try { try {
const {data} = await createDatabaseAJAX(url, database) const {data} = await createDatabaseAJAX(url, database)
dispatch(syncDatabase(database, data)) dispatch(syncDatabase(database, data))
dispatch(notify(NOTIFY_DATABASE_CREATED)) dispatch(notify(notifyDatabaseCreated()))
} catch (error) { } catch (error) {
dispatch(errorThrown(error, notifyDBCreationFailed(error.data.message))) dispatch(errorThrown(error, notifyDBCreationFailed(error.data.message)))
// undo optimistic update // undo optimistic update
@ -349,7 +349,7 @@ export const createRetentionPolicyAsync = (
database.links.retentionPolicies, database.links.retentionPolicies,
retentionPolicy retentionPolicy
) )
dispatch(notify(NOTIFY_RETENTION_POLICY_CREATED)) dispatch(notify(notifyRetentionPolicyCreated()))
dispatch(syncRetentionPolicy(database, retentionPolicy, data)) dispatch(syncRetentionPolicy(database, retentionPolicy, data))
} catch (error) { } catch (error) {
dispatch( dispatch(
@ -372,7 +372,7 @@ export const updateRetentionPolicyAsync = (
dispatch(editRetentionPolicyRequested(database, oldRP, newRP)) dispatch(editRetentionPolicyRequested(database, oldRP, newRP))
const {data} = await updateRetentionPolicyAJAX(oldRP.links.self, newRP) const {data} = await updateRetentionPolicyAJAX(oldRP.links.self, newRP)
dispatch(editRetentionPolicyCompleted(database, oldRP, data)) dispatch(editRetentionPolicyCompleted(database, oldRP, data))
dispatch(notify(NOTIFY_RETENTION_POLICY_UPDATED)) dispatch(notify(notifyRetentionPolicyUpdated()))
} catch (error) { } catch (error) {
dispatch(editRetentionPolicyFailed(database, oldRP)) dispatch(editRetentionPolicyFailed(database, oldRP))
dispatch( dispatch(
@ -446,7 +446,7 @@ export const updateRoleUsersAsync = (role, users) => async dispatch => {
users, users,
role.permissions role.permissions
) )
dispatch(notify(NOTIFY_ROLE_USERS_UPDATED)) dispatch(notify(notifyRoleUsersUpdated()))
dispatch(syncRole(role, data)) dispatch(syncRole(role, data))
} catch (error) { } catch (error) {
dispatch( dispatch(
@ -465,7 +465,7 @@ export const updateRolePermissionsAsync = (
role.users, role.users,
permissions permissions
) )
dispatch(notify(NOTIFY_ROLE_PERMISSIONS_UPDATED)) dispatch(notify(notifyRolePermissionsUpdated()))
dispatch(syncRole(role, data)) dispatch(syncRole(role, data))
} catch (error) { } catch (error) {
dispatch( dispatch(
@ -480,7 +480,7 @@ export const updateUserPermissionsAsync = (
) => async dispatch => { ) => async dispatch => {
try { try {
const {data} = await updateUserAJAX(user.links.self, {permissions}) const {data} = await updateUserAJAX(user.links.self, {permissions})
dispatch(notify(NOTIFY_DB_USER_PERMISSIONS_UPDATED)) dispatch(notify(notifyDBUserPermissionsUpdated()))
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
} catch (error) { } catch (error) {
dispatch( dispatch(
@ -495,7 +495,7 @@ export const updateUserPermissionsAsync = (
export const updateUserRolesAsync = (user, roles) => async dispatch => { export const updateUserRolesAsync = (user, roles) => async dispatch => {
try { try {
const {data} = await updateUserAJAX(user.links.self, {roles}) const {data} = await updateUserAJAX(user.links.self, {roles})
dispatch(notify(NOTIFY_DB_USER_ROLES_UPDATED)) dispatch(notify(notifyDBUserRolesUpdated()))
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
} catch (error) { } catch (error) {
dispatch( dispatch(
@ -507,7 +507,7 @@ export const updateUserRolesAsync = (user, roles) => async dispatch => {
export const updateUserPasswordAsync = (user, password) => async dispatch => { export const updateUserPasswordAsync = (user, password) => async dispatch => {
try { try {
const {data} = await updateUserAJAX(user.links.self, {password}) const {data} = await updateUserAJAX(user.links.self, {password})
dispatch(notify(NOTIFY_DB_USER_PASSWORD_UPDATED)) dispatch(notify(notifyDBUserPasswordUpdated()))
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
} catch (error) { } catch (error) {
dispatch( dispatch(

View File

@ -10,7 +10,7 @@ import {notify as notifyAction} from 'shared/actions/notifications'
import {formatRPDuration} from 'utils/formatting' import {formatRPDuration} from 'utils/formatting'
import YesNoButtons from 'shared/components/YesNoButtons' import YesNoButtons from 'shared/components/YesNoButtons'
import {DATABASE_TABLE} from 'src/admin/constants/tableSizing' import {DATABASE_TABLE} from 'src/admin/constants/tableSizing'
import {NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS} from 'shared/copy/notifications' import {notifyRetentionPolicyCantHaveEmptyFields} from 'shared/copy/notifications'
class DatabaseRow extends Component { class DatabaseRow extends Component {
constructor(props) { constructor(props) {
@ -116,7 +116,7 @@ class DatabaseRow extends Component {
const replication = isRFDisplayed ? +this.replication.value.trim() : 1 const replication = isRFDisplayed ? +this.replication.value.trim() : 1
if (!duration || (isRFDisplayed && !replication)) { if (!duration || (isRFDisplayed && !replication)) {
notify(NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS) notify(notifyRetentionPolicyCantHaveEmptyFields())
return return
} }

View File

@ -32,8 +32,8 @@ import FancyScrollbar from 'shared/components/FancyScrollbar'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_ROLE_NAME_INVALID, notifyRoleNameInvalid,
NOTIFY_DB_USER_NAME_PASSWORD_INVALID, notifyDBUserNamePasswordInvalid,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
const isValidUser = user => { const isValidUser = user => {
@ -80,7 +80,7 @@ class AdminInfluxDBPage extends Component {
handleSaveUser = async user => { handleSaveUser = async user => {
const {notify} = this.props const {notify} = this.props
if (!isValidUser(user)) { if (!isValidUser(user)) {
notify(NOTIFY_DB_USER_NAME_PASSWORD_INVALID) notify(notifyDBUserNamePasswordInvalid())
return return
} }
if (user.isNew) { if (user.isNew) {
@ -93,7 +93,7 @@ class AdminInfluxDBPage extends Component {
handleSaveRole = async role => { handleSaveRole = async role => {
const {notify} = this.props const {notify} = this.props
if (!isValidRole(role)) { if (!isValidRole(role)) {
notify(NOTIFY_ROLE_NAME_INVALID) notify(notifyRoleNameInvalid())
return return
} }
if (role.isNew) { if (role.isNew) {

View File

@ -11,8 +11,8 @@ import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
notifyDatabaseDeleteConfirmationRequired, notifyDatabaseDeleteConfirmationRequired,
NOTIFY_DATABASE_NAME_ALREADY_EXISTS, notifyDatabaseNameAlreadyExists,
NOTIFY_DATABASE_NAME_INVALID, notifyDatabaseNameInvalid,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class DatabaseManagerPage extends Component { class DatabaseManagerPage extends Component {
@ -41,11 +41,11 @@ class DatabaseManagerPage extends Component {
handleCreateDatabase = database => { handleCreateDatabase = database => {
const {actions, notify, source, databases} = this.props const {actions, notify, source, databases} = this.props
if (!database.name) { if (!database.name) {
return notify(NOTIFY_DATABASE_NAME_INVALID) return notify(notifyDatabaseNameInvalid())
} }
if (_.findIndex(databases, {name: database.name}, 1) !== -1) { if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS) return notify(notifyDatabaseNameAlreadyExists())
} }
actions.createDatabaseAsync(source.links.databases, database) actions.createDatabaseAsync(source.links.databases, database)
@ -66,11 +66,11 @@ class DatabaseManagerPage extends Component {
if (key === 'Enter') { if (key === 'Enter') {
if (!database.name) { if (!database.name) {
return notify(NOTIFY_DATABASE_NAME_INVALID) return notify(notifyDatabaseNameInvalid())
} }
if (_.findIndex(databases, {name: database.name}, 1) !== -1) { if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS) return notify(notifyDatabaseNameAlreadyExists())
} }
actions.createDatabaseAsync(source.links.databases, database) actions.createDatabaseAsync(source.links.databases, database)
@ -87,9 +87,7 @@ class DatabaseManagerPage extends Component {
if (key === 'Enter') { if (key === 'Enter') {
if (database.deleteCode !== `DELETE ${database.name}`) { if (database.deleteCode !== `DELETE ${database.name}`) {
return notify( return notify(notifyDatabaseDeleteConfirmationRequired(database.name))
notifyDatabaseDeleteConfirmationRequired(database.name)
)
} }
return actions.deleteDatabaseAsync(database) return actions.deleteDatabaseAsync(database)

View File

@ -15,7 +15,7 @@ import {
notifyAlertRuleDeleted, notifyAlertRuleDeleted,
notifyAlertRuleDeleteFailed, notifyAlertRuleDeleteFailed,
notifyAlertRuleStatusUpdated, notifyAlertRuleStatusUpdated,
NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED, notifyAlertRuleStatusUpdateFailed,
notifyTickScriptCreated, notifyTickScriptCreated,
notifyTickscriptCreationFailed, notifyTickscriptCreationFailed,
notifyTickscriptUpdated, notifyTickscriptUpdated,
@ -195,7 +195,7 @@ export const updateRuleStatus = (rule, status) => dispatch => {
}) })
.catch(() => { .catch(() => {
dispatch( dispatch(
notify(NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status)) notify(notifyAlertRuleStatusUpdateFailed(rule.name, status))
) )
}) })
} }

View File

@ -25,7 +25,7 @@ import {
} from './config' } from './config'
import { import {
NOTIFY_REFRESH_KAPACITOR_FAILED, notifyRefreshKapacitorFailed,
notifyAlertEndpointSaved, notifyAlertEndpointSaved,
notifyAlertEndpointSaveFailed, notifyAlertEndpointSaveFailed,
notifyTestAlertSent, notifyTestAlertSent,
@ -57,7 +57,7 @@ class AlertTabs extends Component {
this.setState({configSections: sections}) this.setState({configSections: sections})
} catch (error) { } catch (error) {
this.setState({configSections: null}) this.setState({configSections: null})
this.props.notify(NOTIFY_REFRESH_KAPACITOR_FAILED) this.props.notify(notifyRefreshKapacitorFailed())
} }
} }

View File

@ -17,13 +17,13 @@ import {DEFAULT_RULE_ID} from 'src/kapacitor/constants'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_ALERT_RULE_CREATED, notifyAlertRuleCreated,
NOTIFY_ALERT_RULE_CREATION_FAILED, notifyAlertRuleCreateFailed,
notifyAlertRuleUpdated, notifyAlertRuleUpdated,
notifyAlertRuleUpdateFailed, notifyAlertRuleUpdateFailed,
NOTIFY_ALERT_RULE_REQUIRES_QUERY, notifyAlertRuleRequiresQuery,
NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE, notifyAlertRuleRequiresConditionValue,
NOTIFY_ALERT_RULE_DEADMAN_INVALID, notifyAlertRuleDeadmanInvalid,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class KapacitorRule extends Component { class KapacitorRule extends Component {
@ -50,10 +50,10 @@ class KapacitorRule extends Component {
createRule(kapacitor, newRule) createRule(kapacitor, newRule)
.then(() => { .then(() => {
router.push(pathname || `/sources/${source.id}/alert-rules`) router.push(pathname || `/sources/${source.id}/alert-rules`)
notify(NOTIFY_ALERT_RULE_CREATED) notify(notifyAlertRuleCreated())
}) })
.catch(() => { .catch(() => {
notify(NOTIFY_ALERT_RULE_CREATION_FAILED) notify(notifyAlertRuleCreateFailed())
}) })
} }
@ -115,11 +115,11 @@ class KapacitorRule extends Component {
} }
if (!buildInfluxQLQuery({}, query)) { if (!buildInfluxQLQuery({}, query)) {
return NOTIFY_ALERT_RULE_REQUIRES_QUERY return notifyAlertRuleRequiresQuery()
} }
if (!rule.values.value) { if (!rule.values.value) {
return NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE return notifyAlertRuleRequiresConditionValue()
} }
return '' return ''
@ -128,7 +128,7 @@ class KapacitorRule extends Component {
deadmanValidation = () => { deadmanValidation = () => {
const {query} = this.props const {query} = this.props
if (query && (!query.database || !query.measurement)) { if (query && (!query.database || !query.measurement)) {
return NOTIFY_ALERT_RULE_DEADMAN_INVALID return notifyAlertRuleDeadmanInvalid()
} }
return '' return ''

View File

@ -17,12 +17,12 @@ import {
import KapacitorForm from '../components/KapacitorForm' import KapacitorForm from '../components/KapacitorForm'
import { import {
NOTIFY_KAPACITOR_CONNECTION_FAILED, notifyKapacitorConnectionFailed,
NOTIFY_KAPACITOR_CREATED, notifyKapacitorCreated,
NOTIFY_KAPACITOR_CREATION_FAILED, notifyKapacitorCreateFailed,
notifyKapacitorNameAlreadyTaken, notifyKapacitorNameAlreadyTaken,
NOTIFY_KAPACITOR_UPDATE_FAILED, notifyKapacitorUpdateFailed,
NOTIFY_KAPACITOR_UPDATED, notifyKapacitorUpdated,
} from 'src/shared/copy/notifications' } from 'src/shared/copy/notifications'
export const defaultName = 'My Kapacitor' export const defaultName = 'My Kapacitor'
@ -87,7 +87,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
await this.checkKapacitorConnection(kapacitor) await this.checkKapacitorConnection(kapacitor)
} catch (error) { } catch (error) {
console.error('Could not get kapacitor: ', error) console.error('Could not get kapacitor: ', error)
notify(NOTIFY_KAPACITOR_CONNECTION_FAILED) notify(notifyKapacitorConnectionFailed())
} }
} }
@ -140,10 +140,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
const {data} = await updateKapacitor(kapacitor) const {data} = await updateKapacitor(kapacitor)
this.setState({kapacitor: data}) this.setState({kapacitor: data})
this.checkKapacitorConnection(data) this.checkKapacitorConnection(data)
notify(NOTIFY_KAPACITOR_UPDATED) notify(notifyKapacitorUpdated())
} catch (error) { } catch (error) {
console.error(error) console.error(error)
notify(NOTIFY_KAPACITOR_UPDATE_FAILED) notify(notifyKapacitorUpdateFailed())
} }
} else { } else {
try { try {
@ -152,10 +152,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
this.setState({kapacitor: data}) this.setState({kapacitor: data})
this.checkKapacitorConnection(data) this.checkKapacitorConnection(data)
router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`) router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`)
notify(NOTIFY_KAPACITOR_CREATED) notify(notifyKapacitorCreated())
} catch (error) { } catch (error) {
console.error(error) console.error(error)
notify(NOTIFY_KAPACITOR_CREATION_FAILED) notify(notifyKapacitorCreateFailed())
} }
} }
} }
@ -207,7 +207,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
} catch (error) { } catch (error) {
console.error(error) console.error(error)
this.setState({exists: false}) this.setState({exists: false})
this.props.notify(NOTIFY_KAPACITOR_CONNECTION_FAILED) this.props.notify(notifyKapacitorConnectionFailed())
} }
} }

View File

@ -13,8 +13,8 @@ import parseHandlersFromConfig from 'src/shared/parsing/parseHandlersFromConfig'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_KAPACITOR_CREATION_FAILED, notifyKapacitorCreateFailed,
NOTIFY_COULD_NOT_FIND_KAPACITOR, notifyCouldNotFindKapacitor,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class KapacitorRulePage extends Component { class KapacitorRulePage extends Component {
@ -38,7 +38,7 @@ class KapacitorRulePage extends Component {
const kapacitor = await getActiveKapacitor(this.props.source) const kapacitor = await getActiveKapacitor(this.props.source)
if (!kapacitor) { if (!kapacitor) {
return notify(NOTIFY_COULD_NOT_FIND_KAPACITOR) return notify(notifyCouldNotFindKapacitor())
} }
try { try {
@ -46,7 +46,7 @@ class KapacitorRulePage extends Component {
const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig) const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig)
this.setState({kapacitor, handlersFromConfig}) this.setState({kapacitor, handlersFromConfig})
} catch (error) { } catch (error) {
notify(NOTIFY_KAPACITOR_CREATION_FAILED) notify(notifyKapacitorCreateFailed())
console.error(error) console.error(error)
throw error throw error
} }

View File

@ -17,7 +17,7 @@ const defaultSuccessNotification = {
// Misc Notifications // Misc Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_GENERIC_FAIL = 'Could not communicate with server.' export const notifyGenericFail = () => 'Could not communicate with server.'
export const notifyNewVersion = message => ({ export const notifyNewVersion = message => ({
type: 'info', type: 'info',
@ -227,34 +227,34 @@ export const notifyDBUserDeleted = userName => ({
export const notifyDBUserDeleteFailed = errorMessage => export const notifyDBUserDeleteFailed = errorMessage =>
`Failed to delete User: ${errorMessage}` `Failed to delete User: ${errorMessage}`
export const NOTIFY_DB_USER_PERMISSIONS_UPDATED = { export const notifyDBUserPermissionsUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'User Permissions updated successfully.', message: 'User Permissions updated successfully.',
} })
export const notifyDBUserPermissionsUpdateFailed = errorMessage => export const notifyDBUserPermissionsUpdateFailed = errorMessage =>
`Failed to update User Permissions: ${errorMessage}` `Failed to update User Permissions: ${errorMessage}`
export const NOTIFY_DB_USER_ROLES_UPDATED = { export const notifyDBUserRolesUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'User Roles updated successfully.', message: 'User Roles updated successfully.',
} })
export const notifyDBUserRolesUpdateFailed = errorMessage => export const notifyDBUserRolesUpdateFailed = errorMessage =>
`Failed to update User Roles: ${errorMessage}` `Failed to update User Roles: ${errorMessage}`
export const NOTIFY_DB_USER_PASSWORD_UPDATED = { export const notifyDBUserPasswordUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'User Password updated successfully.', message: 'User Password updated successfully.',
} })
export const notifyDBUserPasswordUpdateFailed = errorMessage => export const notifyDBUserPasswordUpdateFailed = errorMessage =>
`Failed to update User Password: ${errorMessage}` `Failed to update User Password: ${errorMessage}`
export const NOTIFY_DATABASE_CREATED = { export const notifyDatabaseCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Database created successfully.', message: 'Database created successfully.',
} })
export const notifyDBCreationFailed = errorMessage => export const notifyDBCreationFailed = errorMessage =>
`Failed to create Database: ${errorMessage}` `Failed to create Database: ${errorMessage}`
@ -267,10 +267,10 @@ export const notifyDBDeleted = databaseName => ({
export const notifyDBDeleteFailed = errorMessage => export const notifyDBDeleteFailed = errorMessage =>
`Failed to delete Database: ${errorMessage}` `Failed to delete Database: ${errorMessage}`
export const NOTIFY_ROLE_CREATED = { export const notifyRoleCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Role created successfully.', message: 'Role created successfully.',
} })
export const notifyRoleCreationFailed = errorMessage => export const notifyRoleCreationFailed = errorMessage =>
`Failed to create Role: ${errorMessage}` `Failed to create Role: ${errorMessage}`
@ -283,26 +283,26 @@ export const notifyRoleDeleted = roleName => ({
export const notifyRoleDeleteFailed = errorMessage => export const notifyRoleDeleteFailed = errorMessage =>
`Failed to delete Role: ${errorMessage}` `Failed to delete Role: ${errorMessage}`
export const NOTIFY_ROLE_USERS_UPDATED = { export const notifyRoleUsersUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Role Users updated successfully.', message: 'Role Users updated successfully.',
} })
export const notifyRoleUsersUpdateFailed = errorMessage => export const notifyRoleUsersUpdateFailed = errorMessage =>
`Failed to update Role Users: ${errorMessage}` `Failed to update Role Users: ${errorMessage}`
export const NOTIFY_ROLE_PERMISSIONS_UPDATED = { export const notifyRolePermissionsUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Role Permissions updated successfully.', message: 'Role Permissions updated successfully.',
} })
export const notifyRolePermissionsUpdateFailed = errorMessage => export const notifyRolePermissionsUpdateFailed = errorMessage =>
`Failed to update Role Permissions: ${errorMessage}` `Failed to update Role Permissions: ${errorMessage}`
export const NOTIFY_RETENTION_POLICY_CREATED = { export const notifyRetentionPolicyCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Retention Policy created successfully.', message: 'Retention Policy created successfully.',
} })
export const notifyRetentionPolicyCreationFailed = errorMessage => export const notifyRetentionPolicyCreationFailed = errorMessage =>
`Failed to create Retention Policy: ${errorMessage}` `Failed to create Retention Policy: ${errorMessage}`
@ -315,10 +315,10 @@ export const notifyRetentionPolicyDeleted = rpName => ({
export const notifyRetentionPolicyDeleteFailed = errorMessage => export const notifyRetentionPolicyDeleteFailed = errorMessage =>
`Failed to delete Retention Policy: ${errorMessage}` `Failed to delete Retention Policy: ${errorMessage}`
export const NOTIFY_RETENTION_POLICY_UPDATED = { export const notifyRetentionPolicyUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Retention Policy updated successfully.', message: 'Retention Policy updated successfully.',
} })
export const notifyRetentionPolicyUpdateFailed = errorMessage => export const notifyRetentionPolicyUpdateFailed = errorMessage =>
`Failed to update Retention Policy: ${errorMessage}` `Failed to update Retention Policy: ${errorMessage}`
@ -328,35 +328,35 @@ export const notifyQueriesError = errorMessage => ({
errorMessage, errorMessage,
}) })
export const NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS = { export const notifyRetentionPolicyCantHaveEmptyFields = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Fields cannot be empty.', message: 'Fields cannot be empty.',
} })
export const notifyDatabaseDeleteConfirmationRequired = databaseName => ({ export const notifyDatabaseDeleteConfirmationRequired = databaseName => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: `Type "DELETE ${databaseName}" to confirm.`, message: `Type "DELETE ${databaseName}" to confirm.`,
}) })
export const NOTIFY_DB_USER_NAME_PASSWORD_INVALID = { export const notifyDBUserNamePasswordInvalid = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Username and/or Password too short.', message: 'Username and/or Password too short.',
} })
export const NOTIFY_ROLE_NAME_INVALID = { export const notifyRoleNameInvalid = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Role name is too short.', message: 'Role name is too short.',
} })
export const NOTIFY_DATABASE_NAME_INVALID = { export const notifyDatabaseNameInvalid = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Database name cannot be blank.', message: 'Database name cannot be blank.',
} })
export const NOTIFY_DATABASE_NAME_ALREADY_EXISTS = { export const notifyDatabaseNameAlreadyExists = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'A Database by this name already exists.', message: 'A Database by this name already exists.',
} })
// Dashboard Notifications // Dashboard Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -383,15 +383,15 @@ export const notifyDashboardDeleteFailed = (name, errorMessage) =>
// Rule Builder Notifications // Rule Builder Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_ALERT_RULE_CREATED = { export const notifyAlertRuleCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Alert Rule created successfully.', message: 'Alert Rule created successfully.',
} })
export const NOTIFY_ALERT_RULE_CREATION_FAILED = { export const notifyAlertRuleCreateFailed = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Alert Rule could not be created.', message: 'Alert Rule could not be created.',
} })
export const notifyAlertRuleUpdated = ruleName => ({ export const notifyAlertRuleUpdated = ruleName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
@ -418,21 +418,18 @@ export const notifyAlertRuleStatusUpdated = (ruleName, updatedStatus) => ({
message: `${ruleName} ${updatedStatus} successfully.`, message: `${ruleName} ${updatedStatus} successfully.`,
}) })
export const NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED = ( export const notifyAlertRuleStatusUpdateFailed = (ruleName, updatedStatus) => ({
ruleName,
updatedStatus
) => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `${ruleName} could not be ${updatedStatus}.`, message: `${ruleName} could not be ${updatedStatus}.`,
}) })
export const NOTIFY_ALERT_RULE_REQUIRES_QUERY = export const notifyAlertRuleRequiresQuery = () =>
'Please select a Database, Measurement, and Field.' 'Please select a Database, Measurement, and Field.'
export const NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE = export const notifyAlertRuleRequiresConditionValue = () =>
'Please enter a value in the Conditions section.' 'Please enter a value in the Conditions section.'
export const NOTIFY_ALERT_RULE_DEADMAN_INVALID = export const notifyAlertRuleDeadmanInvalid = () =>
'Deadman rules require a Database and Measurement.' 'Deadman rules require a Database and Measurement.'
// Kapacitor Configuration Notifications // Kapacitor Configuration Notifications
@ -442,15 +439,15 @@ export const notifyKapacitorNameAlreadyTaken = kapacitorName => ({
message: `There is already a Kapacitor Connection named "${kapacitorName}".`, message: `There is already a Kapacitor Connection named "${kapacitorName}".`,
}) })
export const NOTIFY_COULD_NOT_FIND_KAPACITOR = { export const notifyCouldNotFindKapacitor = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'We could not find a Kapacitor configuration for this source.', message: 'We could not find a Kapacitor configuration for this source.',
} })
export const NOTIFY_REFRESH_KAPACITOR_FAILED = { export const notifyRefreshKapacitorFailed = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'There was an error getting the Kapacitor configuration.', message: 'There was an error getting the Kapacitor configuration.',
} })
export const notifyAlertEndpointSaved = endpoint => ({ export const notifyAlertEndpointSaved = endpoint => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
@ -475,32 +472,32 @@ export const notifyTestAlertFailed = (endpoint, errorMessage) => ({
}`, }`,
}) })
export const NOTIFY_KAPACITOR_CONNECTION_FAILED = { export const notifyKapacitorConnectionFailed = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: message:
'Could not connect to Kapacitor. Check your connection settings in the Configuration page.', 'Could not connect to Kapacitor. Check your connection settings in the Configuration page.',
} })
export const NOTIFY_KAPACITOR_CREATED = { export const notifyKapacitorCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: message:
'Connected to Kapacitor successfully! Configuring endpoints is optional.', 'Connected to Kapacitor successfully! Configuring endpoints is optional.',
} })
export const NOTIFY_KAPACITOR_CREATION_FAILED = { export const notifyKapacitorCreateFailed = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'There was a problem connecting to Kapacitor.', message: 'There was a problem connecting to Kapacitor.',
} })
export const NOTIFY_KAPACITOR_UPDATED = { export const notifyKapacitorUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Kapacitor Connection updated successfully.', message: 'Kapacitor Connection updated successfully.',
} })
export const NOTIFY_KAPACITOR_UPDATE_FAILED = { export const notifyKapacitorUpdateFailed = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'There was a problem updating the Kapacitor Connection.', message: 'There was a problem updating the Kapacitor Connection.',
} })
// TICKscript Notifications // TICKscript Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------