Refactor notifications to be functions
parent
d41089279b
commit
1a4b7b8dd6
|
@ -26,29 +26,29 @@ import {
|
|||
notifyDBUserCreationFailed,
|
||||
notifyDBUserDeleted,
|
||||
notifyDBUserDeleteFailed,
|
||||
NOTIFY_DB_USER_PERMISSIONS_UPDATED,
|
||||
notifyDBUserPermissionsUpdated,
|
||||
notifyDBUserPermissionsUpdateFailed,
|
||||
NOTIFY_DB_USER_ROLES_UPDATED,
|
||||
notifyDBUserRolesUpdated,
|
||||
notifyDBUserRolesUpdateFailed,
|
||||
NOTIFY_DB_USER_PASSWORD_UPDATED,
|
||||
notifyDBUserPasswordUpdated,
|
||||
notifyDBUserPasswordUpdateFailed,
|
||||
NOTIFY_DATABASE_CREATED,
|
||||
notifyDatabaseCreated,
|
||||
notifyDBCreationFailed,
|
||||
notifyDBDeleted,
|
||||
notifyDBDeleteFailed,
|
||||
NOTIFY_ROLE_CREATED,
|
||||
notifyRoleCreated,
|
||||
notifyRoleCreationFailed,
|
||||
notifyRoleDeleted,
|
||||
notifyRoleDeleteFailed,
|
||||
NOTIFY_ROLE_USERS_UPDATED,
|
||||
notifyRoleUsersUpdated,
|
||||
notifyRoleUsersUpdateFailed,
|
||||
NOTIFY_ROLE_PERMISSIONS_UPDATED,
|
||||
notifyRolePermissionsUpdated,
|
||||
notifyRolePermissionsUpdateFailed,
|
||||
NOTIFY_RETENTION_POLICY_CREATED,
|
||||
notifyRetentionPolicyCreated,
|
||||
notifyRetentionPolicyCreationFailed,
|
||||
notifyRetentionPolicyDeleted,
|
||||
notifyRetentionPolicyDeleteFailed,
|
||||
NOTIFY_RETENTION_POLICY_UPDATED,
|
||||
notifyRetentionPolicyUpdated,
|
||||
notifyRetentionPolicyUpdateFailed,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
|
@ -319,7 +319,7 @@ export const createUserAsync = (url, user) => async dispatch => {
|
|||
export const createRoleAsync = (url, role) => async dispatch => {
|
||||
try {
|
||||
const {data} = await createRoleAJAX(url, role)
|
||||
dispatch(notify(NOTIFY_ROLE_CREATED))
|
||||
dispatch(notify(notifyRoleCreated()))
|
||||
dispatch(syncRole(role, data))
|
||||
} catch (error) {
|
||||
dispatch(errorThrown(error, notifyRoleCreationFailed(error.data.message)))
|
||||
|
@ -332,7 +332,7 @@ export const createDatabaseAsync = (url, database) => async dispatch => {
|
|||
try {
|
||||
const {data} = await createDatabaseAJAX(url, database)
|
||||
dispatch(syncDatabase(database, data))
|
||||
dispatch(notify(NOTIFY_DATABASE_CREATED))
|
||||
dispatch(notify(notifyDatabaseCreated()))
|
||||
} catch (error) {
|
||||
dispatch(errorThrown(error, notifyDBCreationFailed(error.data.message)))
|
||||
// undo optimistic update
|
||||
|
@ -349,7 +349,7 @@ export const createRetentionPolicyAsync = (
|
|||
database.links.retentionPolicies,
|
||||
retentionPolicy
|
||||
)
|
||||
dispatch(notify(NOTIFY_RETENTION_POLICY_CREATED))
|
||||
dispatch(notify(notifyRetentionPolicyCreated()))
|
||||
dispatch(syncRetentionPolicy(database, retentionPolicy, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
@ -372,7 +372,7 @@ export const updateRetentionPolicyAsync = (
|
|||
dispatch(editRetentionPolicyRequested(database, oldRP, newRP))
|
||||
const {data} = await updateRetentionPolicyAJAX(oldRP.links.self, newRP)
|
||||
dispatch(editRetentionPolicyCompleted(database, oldRP, data))
|
||||
dispatch(notify(NOTIFY_RETENTION_POLICY_UPDATED))
|
||||
dispatch(notify(notifyRetentionPolicyUpdated()))
|
||||
} catch (error) {
|
||||
dispatch(editRetentionPolicyFailed(database, oldRP))
|
||||
dispatch(
|
||||
|
@ -446,7 +446,7 @@ export const updateRoleUsersAsync = (role, users) => async dispatch => {
|
|||
users,
|
||||
role.permissions
|
||||
)
|
||||
dispatch(notify(NOTIFY_ROLE_USERS_UPDATED))
|
||||
dispatch(notify(notifyRoleUsersUpdated()))
|
||||
dispatch(syncRole(role, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
@ -465,7 +465,7 @@ export const updateRolePermissionsAsync = (
|
|||
role.users,
|
||||
permissions
|
||||
)
|
||||
dispatch(notify(NOTIFY_ROLE_PERMISSIONS_UPDATED))
|
||||
dispatch(notify(notifyRolePermissionsUpdated()))
|
||||
dispatch(syncRole(role, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
@ -480,7 +480,7 @@ export const updateUserPermissionsAsync = (
|
|||
) => async dispatch => {
|
||||
try {
|
||||
const {data} = await updateUserAJAX(user.links.self, {permissions})
|
||||
dispatch(notify(NOTIFY_DB_USER_PERMISSIONS_UPDATED))
|
||||
dispatch(notify(notifyDBUserPermissionsUpdated()))
|
||||
dispatch(syncUser(user, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
@ -495,7 +495,7 @@ export const updateUserPermissionsAsync = (
|
|||
export const updateUserRolesAsync = (user, roles) => async dispatch => {
|
||||
try {
|
||||
const {data} = await updateUserAJAX(user.links.self, {roles})
|
||||
dispatch(notify(NOTIFY_DB_USER_ROLES_UPDATED))
|
||||
dispatch(notify(notifyDBUserRolesUpdated()))
|
||||
dispatch(syncUser(user, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
@ -507,7 +507,7 @@ export const updateUserRolesAsync = (user, roles) => async dispatch => {
|
|||
export const updateUserPasswordAsync = (user, password) => async dispatch => {
|
||||
try {
|
||||
const {data} = await updateUserAJAX(user.links.self, {password})
|
||||
dispatch(notify(NOTIFY_DB_USER_PASSWORD_UPDATED))
|
||||
dispatch(notify(notifyDBUserPasswordUpdated()))
|
||||
dispatch(syncUser(user, data))
|
||||
} catch (error) {
|
||||
dispatch(
|
||||
|
|
|
@ -10,7 +10,7 @@ import {notify as notifyAction} from 'shared/actions/notifications'
|
|||
import {formatRPDuration} from 'utils/formatting'
|
||||
import YesNoButtons from 'shared/components/YesNoButtons'
|
||||
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 {
|
||||
constructor(props) {
|
||||
|
@ -116,7 +116,7 @@ class DatabaseRow extends Component {
|
|||
const replication = isRFDisplayed ? +this.replication.value.trim() : 1
|
||||
|
||||
if (!duration || (isRFDisplayed && !replication)) {
|
||||
notify(NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS)
|
||||
notify(notifyRetentionPolicyCantHaveEmptyFields())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ import FancyScrollbar from 'shared/components/FancyScrollbar'
|
|||
import {notify as notifyAction} from 'shared/actions/notifications'
|
||||
|
||||
import {
|
||||
NOTIFY_ROLE_NAME_INVALID,
|
||||
NOTIFY_DB_USER_NAME_PASSWORD_INVALID,
|
||||
notifyRoleNameInvalid,
|
||||
notifyDBUserNamePasswordInvalid,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
const isValidUser = user => {
|
||||
|
@ -80,7 +80,7 @@ class AdminInfluxDBPage extends Component {
|
|||
handleSaveUser = async user => {
|
||||
const {notify} = this.props
|
||||
if (!isValidUser(user)) {
|
||||
notify(NOTIFY_DB_USER_NAME_PASSWORD_INVALID)
|
||||
notify(notifyDBUserNamePasswordInvalid())
|
||||
return
|
||||
}
|
||||
if (user.isNew) {
|
||||
|
@ -93,7 +93,7 @@ class AdminInfluxDBPage extends Component {
|
|||
handleSaveRole = async role => {
|
||||
const {notify} = this.props
|
||||
if (!isValidRole(role)) {
|
||||
notify(NOTIFY_ROLE_NAME_INVALID)
|
||||
notify(notifyRoleNameInvalid())
|
||||
return
|
||||
}
|
||||
if (role.isNew) {
|
||||
|
|
|
@ -11,8 +11,8 @@ import {notify as notifyAction} from 'shared/actions/notifications'
|
|||
|
||||
import {
|
||||
notifyDatabaseDeleteConfirmationRequired,
|
||||
NOTIFY_DATABASE_NAME_ALREADY_EXISTS,
|
||||
NOTIFY_DATABASE_NAME_INVALID,
|
||||
notifyDatabaseNameAlreadyExists,
|
||||
notifyDatabaseNameInvalid,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
class DatabaseManagerPage extends Component {
|
||||
|
@ -41,11 +41,11 @@ class DatabaseManagerPage extends Component {
|
|||
handleCreateDatabase = database => {
|
||||
const {actions, notify, source, databases} = this.props
|
||||
if (!database.name) {
|
||||
return notify(NOTIFY_DATABASE_NAME_INVALID)
|
||||
return notify(notifyDatabaseNameInvalid())
|
||||
}
|
||||
|
||||
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
|
||||
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
|
||||
return notify(notifyDatabaseNameAlreadyExists())
|
||||
}
|
||||
|
||||
actions.createDatabaseAsync(source.links.databases, database)
|
||||
|
@ -66,11 +66,11 @@ class DatabaseManagerPage extends Component {
|
|||
|
||||
if (key === 'Enter') {
|
||||
if (!database.name) {
|
||||
return notify(NOTIFY_DATABASE_NAME_INVALID)
|
||||
return notify(notifyDatabaseNameInvalid())
|
||||
}
|
||||
|
||||
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
|
||||
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
|
||||
return notify(notifyDatabaseNameAlreadyExists())
|
||||
}
|
||||
|
||||
actions.createDatabaseAsync(source.links.databases, database)
|
||||
|
@ -87,9 +87,7 @@ class DatabaseManagerPage extends Component {
|
|||
|
||||
if (key === 'Enter') {
|
||||
if (database.deleteCode !== `DELETE ${database.name}`) {
|
||||
return notify(
|
||||
notifyDatabaseDeleteConfirmationRequired(database.name)
|
||||
)
|
||||
return notify(notifyDatabaseDeleteConfirmationRequired(database.name))
|
||||
}
|
||||
|
||||
return actions.deleteDatabaseAsync(database)
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
notifyAlertRuleDeleted,
|
||||
notifyAlertRuleDeleteFailed,
|
||||
notifyAlertRuleStatusUpdated,
|
||||
NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED,
|
||||
notifyAlertRuleStatusUpdateFailed,
|
||||
notifyTickScriptCreated,
|
||||
notifyTickscriptCreationFailed,
|
||||
notifyTickscriptUpdated,
|
||||
|
@ -195,7 +195,7 @@ export const updateRuleStatus = (rule, status) => dispatch => {
|
|||
})
|
||||
.catch(() => {
|
||||
dispatch(
|
||||
notify(NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status))
|
||||
notify(notifyAlertRuleStatusUpdateFailed(rule.name, status))
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from './config'
|
||||
|
||||
import {
|
||||
NOTIFY_REFRESH_KAPACITOR_FAILED,
|
||||
notifyRefreshKapacitorFailed,
|
||||
notifyAlertEndpointSaved,
|
||||
notifyAlertEndpointSaveFailed,
|
||||
notifyTestAlertSent,
|
||||
|
@ -57,7 +57,7 @@ class AlertTabs extends Component {
|
|||
this.setState({configSections: sections})
|
||||
} catch (error) {
|
||||
this.setState({configSections: null})
|
||||
this.props.notify(NOTIFY_REFRESH_KAPACITOR_FAILED)
|
||||
this.props.notify(notifyRefreshKapacitorFailed())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,13 +17,13 @@ import {DEFAULT_RULE_ID} from 'src/kapacitor/constants'
|
|||
import {notify as notifyAction} from 'shared/actions/notifications'
|
||||
|
||||
import {
|
||||
NOTIFY_ALERT_RULE_CREATED,
|
||||
NOTIFY_ALERT_RULE_CREATION_FAILED,
|
||||
notifyAlertRuleCreated,
|
||||
notifyAlertRuleCreateFailed,
|
||||
notifyAlertRuleUpdated,
|
||||
notifyAlertRuleUpdateFailed,
|
||||
NOTIFY_ALERT_RULE_REQUIRES_QUERY,
|
||||
NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE,
|
||||
NOTIFY_ALERT_RULE_DEADMAN_INVALID,
|
||||
notifyAlertRuleRequiresQuery,
|
||||
notifyAlertRuleRequiresConditionValue,
|
||||
notifyAlertRuleDeadmanInvalid,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
class KapacitorRule extends Component {
|
||||
|
@ -50,10 +50,10 @@ class KapacitorRule extends Component {
|
|||
createRule(kapacitor, newRule)
|
||||
.then(() => {
|
||||
router.push(pathname || `/sources/${source.id}/alert-rules`)
|
||||
notify(NOTIFY_ALERT_RULE_CREATED)
|
||||
notify(notifyAlertRuleCreated())
|
||||
})
|
||||
.catch(() => {
|
||||
notify(NOTIFY_ALERT_RULE_CREATION_FAILED)
|
||||
notify(notifyAlertRuleCreateFailed())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ class KapacitorRule extends Component {
|
|||
}
|
||||
|
||||
if (!buildInfluxQLQuery({}, query)) {
|
||||
return NOTIFY_ALERT_RULE_REQUIRES_QUERY
|
||||
return notifyAlertRuleRequiresQuery()
|
||||
}
|
||||
|
||||
if (!rule.values.value) {
|
||||
return NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE
|
||||
return notifyAlertRuleRequiresConditionValue()
|
||||
}
|
||||
|
||||
return ''
|
||||
|
@ -128,7 +128,7 @@ class KapacitorRule extends Component {
|
|||
deadmanValidation = () => {
|
||||
const {query} = this.props
|
||||
if (query && (!query.database || !query.measurement)) {
|
||||
return NOTIFY_ALERT_RULE_DEADMAN_INVALID
|
||||
return notifyAlertRuleDeadmanInvalid()
|
||||
}
|
||||
|
||||
return ''
|
||||
|
|
|
@ -17,12 +17,12 @@ import {
|
|||
import KapacitorForm from '../components/KapacitorForm'
|
||||
|
||||
import {
|
||||
NOTIFY_KAPACITOR_CONNECTION_FAILED,
|
||||
NOTIFY_KAPACITOR_CREATED,
|
||||
NOTIFY_KAPACITOR_CREATION_FAILED,
|
||||
notifyKapacitorConnectionFailed,
|
||||
notifyKapacitorCreated,
|
||||
notifyKapacitorCreateFailed,
|
||||
notifyKapacitorNameAlreadyTaken,
|
||||
NOTIFY_KAPACITOR_UPDATE_FAILED,
|
||||
NOTIFY_KAPACITOR_UPDATED,
|
||||
notifyKapacitorUpdateFailed,
|
||||
notifyKapacitorUpdated,
|
||||
} from 'src/shared/copy/notifications'
|
||||
|
||||
export const defaultName = 'My Kapacitor'
|
||||
|
@ -87,7 +87,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
|
|||
await this.checkKapacitorConnection(kapacitor)
|
||||
} catch (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)
|
||||
this.setState({kapacitor: data})
|
||||
this.checkKapacitorConnection(data)
|
||||
notify(NOTIFY_KAPACITOR_UPDATED)
|
||||
notify(notifyKapacitorUpdated())
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
notify(NOTIFY_KAPACITOR_UPDATE_FAILED)
|
||||
notify(notifyKapacitorUpdateFailed())
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
@ -152,10 +152,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
|
|||
this.setState({kapacitor: data})
|
||||
this.checkKapacitorConnection(data)
|
||||
router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`)
|
||||
notify(NOTIFY_KAPACITOR_CREATED)
|
||||
notify(notifyKapacitorCreated())
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
notify(NOTIFY_KAPACITOR_CREATION_FAILED)
|
||||
notify(notifyKapacitorCreateFailed())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
|
|||
} catch (error) {
|
||||
console.error(error)
|
||||
this.setState({exists: false})
|
||||
this.props.notify(NOTIFY_KAPACITOR_CONNECTION_FAILED)
|
||||
this.props.notify(notifyKapacitorConnectionFailed())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ import parseHandlersFromConfig from 'src/shared/parsing/parseHandlersFromConfig'
|
|||
import {notify as notifyAction} from 'shared/actions/notifications'
|
||||
|
||||
import {
|
||||
NOTIFY_KAPACITOR_CREATION_FAILED,
|
||||
NOTIFY_COULD_NOT_FIND_KAPACITOR,
|
||||
notifyKapacitorCreateFailed,
|
||||
notifyCouldNotFindKapacitor,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
class KapacitorRulePage extends Component {
|
||||
|
@ -38,7 +38,7 @@ class KapacitorRulePage extends Component {
|
|||
|
||||
const kapacitor = await getActiveKapacitor(this.props.source)
|
||||
if (!kapacitor) {
|
||||
return notify(NOTIFY_COULD_NOT_FIND_KAPACITOR)
|
||||
return notify(notifyCouldNotFindKapacitor())
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -46,7 +46,7 @@ class KapacitorRulePage extends Component {
|
|||
const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig)
|
||||
this.setState({kapacitor, handlersFromConfig})
|
||||
} catch (error) {
|
||||
notify(NOTIFY_KAPACITOR_CREATION_FAILED)
|
||||
notify(notifyKapacitorCreateFailed())
|
||||
console.error(error)
|
||||
throw error
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ const defaultSuccessNotification = {
|
|||
|
||||
// Misc Notifications
|
||||
// ----------------------------------------------------------------------------
|
||||
export const NOTIFY_GENERIC_FAIL = 'Could not communicate with server.'
|
||||
export const notifyGenericFail = () => 'Could not communicate with server.'
|
||||
|
||||
export const notifyNewVersion = message => ({
|
||||
type: 'info',
|
||||
|
@ -227,34 +227,34 @@ export const notifyDBUserDeleted = userName => ({
|
|||
export const notifyDBUserDeleteFailed = errorMessage =>
|
||||
`Failed to delete User: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_DB_USER_PERMISSIONS_UPDATED = {
|
||||
export const notifyDBUserPermissionsUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'User Permissions updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyDBUserPermissionsUpdateFailed = errorMessage =>
|
||||
`Failed to update User Permissions: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_DB_USER_ROLES_UPDATED = {
|
||||
export const notifyDBUserRolesUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'User Roles updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyDBUserRolesUpdateFailed = errorMessage =>
|
||||
`Failed to update User Roles: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_DB_USER_PASSWORD_UPDATED = {
|
||||
export const notifyDBUserPasswordUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'User Password updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyDBUserPasswordUpdateFailed = errorMessage =>
|
||||
`Failed to update User Password: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_DATABASE_CREATED = {
|
||||
export const notifyDatabaseCreated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Database created successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyDBCreationFailed = errorMessage =>
|
||||
`Failed to create Database: ${errorMessage}`
|
||||
|
@ -267,10 +267,10 @@ export const notifyDBDeleted = databaseName => ({
|
|||
export const notifyDBDeleteFailed = errorMessage =>
|
||||
`Failed to delete Database: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_ROLE_CREATED = {
|
||||
export const notifyRoleCreated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Role created successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyRoleCreationFailed = errorMessage =>
|
||||
`Failed to create Role: ${errorMessage}`
|
||||
|
@ -283,26 +283,26 @@ export const notifyRoleDeleted = roleName => ({
|
|||
export const notifyRoleDeleteFailed = errorMessage =>
|
||||
`Failed to delete Role: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_ROLE_USERS_UPDATED = {
|
||||
export const notifyRoleUsersUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Role Users updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyRoleUsersUpdateFailed = errorMessage =>
|
||||
`Failed to update Role Users: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_ROLE_PERMISSIONS_UPDATED = {
|
||||
export const notifyRolePermissionsUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Role Permissions updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyRolePermissionsUpdateFailed = errorMessage =>
|
||||
`Failed to update Role Permissions: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_RETENTION_POLICY_CREATED = {
|
||||
export const notifyRetentionPolicyCreated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Retention Policy created successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyRetentionPolicyCreationFailed = errorMessage =>
|
||||
`Failed to create Retention Policy: ${errorMessage}`
|
||||
|
@ -315,10 +315,10 @@ export const notifyRetentionPolicyDeleted = rpName => ({
|
|||
export const notifyRetentionPolicyDeleteFailed = errorMessage =>
|
||||
`Failed to delete Retention Policy: ${errorMessage}`
|
||||
|
||||
export const NOTIFY_RETENTION_POLICY_UPDATED = {
|
||||
export const notifyRetentionPolicyUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Retention Policy updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyRetentionPolicyUpdateFailed = errorMessage =>
|
||||
`Failed to update Retention Policy: ${errorMessage}`
|
||||
|
@ -328,35 +328,35 @@ export const notifyQueriesError = errorMessage => ({
|
|||
errorMessage,
|
||||
})
|
||||
|
||||
export const NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS = {
|
||||
export const notifyRetentionPolicyCantHaveEmptyFields = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'Fields cannot be empty.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyDatabaseDeleteConfirmationRequired = databaseName => ({
|
||||
...defaultErrorNotification,
|
||||
message: `Type "DELETE ${databaseName}" to confirm.`,
|
||||
})
|
||||
|
||||
export const NOTIFY_DB_USER_NAME_PASSWORD_INVALID = {
|
||||
export const notifyDBUserNamePasswordInvalid = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'Username and/or Password too short.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_ROLE_NAME_INVALID = {
|
||||
export const notifyRoleNameInvalid = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'Role name is too short.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_DATABASE_NAME_INVALID = {
|
||||
export const notifyDatabaseNameInvalid = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'Database name cannot be blank.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_DATABASE_NAME_ALREADY_EXISTS = {
|
||||
export const notifyDatabaseNameAlreadyExists = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'A Database by this name already exists.',
|
||||
}
|
||||
})
|
||||
|
||||
// Dashboard Notifications
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -383,15 +383,15 @@ export const notifyDashboardDeleteFailed = (name, errorMessage) =>
|
|||
|
||||
// Rule Builder Notifications
|
||||
// ----------------------------------------------------------------------------
|
||||
export const NOTIFY_ALERT_RULE_CREATED = {
|
||||
export const notifyAlertRuleCreated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Alert Rule created successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_ALERT_RULE_CREATION_FAILED = {
|
||||
export const notifyAlertRuleCreateFailed = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'Alert Rule could not be created.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyAlertRuleUpdated = ruleName => ({
|
||||
...defaultSuccessNotification,
|
||||
|
@ -418,21 +418,18 @@ export const notifyAlertRuleStatusUpdated = (ruleName, updatedStatus) => ({
|
|||
message: `${ruleName} ${updatedStatus} successfully.`,
|
||||
})
|
||||
|
||||
export const NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED = (
|
||||
ruleName,
|
||||
updatedStatus
|
||||
) => ({
|
||||
export const notifyAlertRuleStatusUpdateFailed = (ruleName, updatedStatus) => ({
|
||||
...defaultSuccessNotification,
|
||||
message: `${ruleName} could not be ${updatedStatus}.`,
|
||||
})
|
||||
|
||||
export const NOTIFY_ALERT_RULE_REQUIRES_QUERY =
|
||||
export const notifyAlertRuleRequiresQuery = () =>
|
||||
'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.'
|
||||
|
||||
export const NOTIFY_ALERT_RULE_DEADMAN_INVALID =
|
||||
export const notifyAlertRuleDeadmanInvalid = () =>
|
||||
'Deadman rules require a Database and Measurement.'
|
||||
|
||||
// Kapacitor Configuration Notifications
|
||||
|
@ -442,15 +439,15 @@ export const notifyKapacitorNameAlreadyTaken = kapacitorName => ({
|
|||
message: `There is already a Kapacitor Connection named "${kapacitorName}".`,
|
||||
})
|
||||
|
||||
export const NOTIFY_COULD_NOT_FIND_KAPACITOR = {
|
||||
export const notifyCouldNotFindKapacitor = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'We could not find a Kapacitor configuration for this source.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_REFRESH_KAPACITOR_FAILED = {
|
||||
export const notifyRefreshKapacitorFailed = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'There was an error getting the Kapacitor configuration.',
|
||||
}
|
||||
})
|
||||
|
||||
export const notifyAlertEndpointSaved = endpoint => ({
|
||||
...defaultSuccessNotification,
|
||||
|
@ -475,32 +472,32 @@ export const notifyTestAlertFailed = (endpoint, errorMessage) => ({
|
|||
}`,
|
||||
})
|
||||
|
||||
export const NOTIFY_KAPACITOR_CONNECTION_FAILED = {
|
||||
export const notifyKapacitorConnectionFailed = () => ({
|
||||
...defaultErrorNotification,
|
||||
message:
|
||||
'Could not connect to Kapacitor. Check your connection settings in the Configuration page.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_KAPACITOR_CREATED = {
|
||||
export const notifyKapacitorCreated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message:
|
||||
'Connected to Kapacitor successfully! Configuring endpoints is optional.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_KAPACITOR_CREATION_FAILED = {
|
||||
export const notifyKapacitorCreateFailed = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'There was a problem connecting to Kapacitor.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_KAPACITOR_UPDATED = {
|
||||
export const notifyKapacitorUpdated = () => ({
|
||||
...defaultSuccessNotification,
|
||||
message: 'Kapacitor Connection updated successfully.',
|
||||
}
|
||||
})
|
||||
|
||||
export const NOTIFY_KAPACITOR_UPDATE_FAILED = {
|
||||
export const notifyKapacitorUpdateFailed = () => ({
|
||||
...defaultErrorNotification,
|
||||
message: 'There was a problem updating the Kapacitor Connection.',
|
||||
}
|
||||
})
|
||||
|
||||
// TICKscript Notifications
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue