Merge pull request #3042 from influxdata/refactor/make-notifications-functions

Make Notification Constants into Functions
pull/10616/head
Alex Paxton 2018-03-23 11:18:59 -07:00 committed by GitHub
commit b2989bc7c8
33 changed files with 409 additions and 430 deletions

View File

@ -19,12 +19,12 @@ import {notify as notifyAction} from 'shared/actions/notifications'
import {DEFAULT_HOME_PAGE} from 'shared/constants' import {DEFAULT_HOME_PAGE} from 'shared/constants'
import { import {
NOTIFY_SOURCE_NO_LONGER_AVAILABLE, notifySourceNoLongerAvailable,
NOTIFY_NO_SOURCES_AVAILABLE, notifyNoSourcesAvailable,
NOTIFY_UNABLE_TO_RETRIEVE_SOURCES, notifyUnableToRetrieveSources,
NOTIFY_USER_REMOVED_FROM_ALL_ORGS, notifyUserRemovedFromAllOrgs,
NOTIFY_USER_REMOVED_FROM_CURRENT_ORG, notifyUserRemovedFromCurrentOrg,
NOTIFY_ORG_HAS_NO_SOURCES, notifyOrgHasNoSources,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
// Acts as a 'router middleware'. The main `App` component is responsible for // Acts as a 'router middleware'. The main `App` component is responsible for
@ -93,7 +93,7 @@ class CheckSources extends Component {
} }
if (!isFetching && isUsingAuth && !organizations.length) { if (!isFetching && isUsingAuth && !organizations.length) {
notify(NOTIFY_USER_REMOVED_FROM_ALL_ORGS) notify(notifyUserRemovedFromAllOrgs())
return router.push('/purgatory') return router.push('/purgatory')
} }
@ -101,7 +101,7 @@ class CheckSources extends Component {
me.superAdmin && me.superAdmin &&
!organizations.find(o => o.id === currentOrganization.id) !organizations.find(o => o.id === currentOrganization.id)
) { ) {
notify(NOTIFY_USER_REMOVED_FROM_CURRENT_ORG) notify(notifyUserRemovedFromCurrentOrg())
return router.push('/purgatory') return router.push('/purgatory')
} }
@ -123,7 +123,7 @@ class CheckSources extends Component {
return router.push(`/sources/${sources[0].id}/${restString}`) return router.push(`/sources/${sources[0].id}/${restString}`)
} }
// if you're a viewer and there are no sources, go to purgatory. // if you're a viewer and there are no sources, go to purgatory.
notify(NOTIFY_ORG_HAS_NO_SOURCES) notify(notifyOrgHasNoSources())
return router.push('/purgatory') return router.push('/purgatory')
} }
@ -148,12 +148,12 @@ class CheckSources extends Component {
try { try {
const newSources = await getSources() const newSources = await getSources()
if (newSources.length) { if (newSources.length) {
errorThrown(error, NOTIFY_SOURCE_NO_LONGER_AVAILABLE(source.name)) errorThrown(error, notifySourceNoLongerAvailable(source.name))
} else { } else {
errorThrown(error, NOTIFY_NO_SOURCES_AVAILABLE(source.name)) errorThrown(error, notifyNoSourcesAvailable(source.name))
} }
} catch (error2) { } catch (error2) {
errorThrown(error2, NOTIFY_UNABLE_TO_RETRIEVE_SOURCES) errorThrown(error2, notifyUnableToRetrieveSources())
} }
} }
} }

View File

@ -19,10 +19,10 @@ import {
import {notify} from 'shared/actions/notifications' import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import { import {
NOTIFY_MAPPING_DELETED, notifyMappingDeleted,
NOTIFY_CHRONOGRAF_ORG_DELETED, notifyChronografOrgDeleted,
NOTIFY_CHRONOGRAF_USER_UPDATED, notifyChronografUserUpdated,
NOTIFY_CHRONOGRAF_USER_DELETED, notifyChronografUserDeleted,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
import {REVERT_STATE_DELAY} from 'shared/constants' import {REVERT_STATE_DELAY} from 'shared/constants'
@ -183,7 +183,7 @@ export const deleteMappingAsync = mapping => async dispatch => {
dispatch(removeMapping(mapping)) dispatch(removeMapping(mapping))
try { try {
await deleteMappingAJAX(mapping) await deleteMappingAJAX(mapping)
dispatch(notify(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme))) dispatch(notify(notifyMappingDeleted(mapping.id, mapping.scheme)))
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
dispatch(addMapping(mapping)) dispatch(addMapping(mapping))
@ -239,7 +239,7 @@ export const updateUserAsync = (
provider: null, provider: null,
scheme: null, scheme: null,
}) })
dispatch(notify(NOTIFY_CHRONOGRAF_USER_UPDATED(successMessage))) dispatch(notify(notifyChronografUserUpdated(successMessage)))
// it's not necessary to syncUser again but it's useful for good // it's not necessary to syncUser again but it's useful for good
// measure and for the clarity of insight in the redux story // measure and for the clarity of insight in the redux story
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
@ -256,9 +256,7 @@ export const deleteUserAsync = (
dispatch(removeUser(user)) dispatch(removeUser(user))
try { try {
await deleteUserAJAX(user) await deleteUserAJAX(user)
dispatch( dispatch(notify(notifyChronografUserDeleted(user.name, isAbsoluteDelete)))
notify(NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete))
)
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
dispatch(addUser(user)) dispatch(addUser(user))
@ -309,7 +307,7 @@ export const deleteOrganizationAsync = organization => async dispatch => {
dispatch(removeOrganization(organization)) dispatch(removeOrganization(organization))
try { try {
await deleteOrganizationAJAX(organization) await deleteOrganizationAJAX(organization)
dispatch(notify(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name))) dispatch(notify(notifyChronografOrgDeleted(organization.name)))
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
dispatch(addOrganization(organization)) dispatch(addOrganization(organization))

View File

@ -22,34 +22,34 @@ import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import { import {
NOTIFY_DB_USER_CREATED, notifyDBUserCreated,
NOTIFY_DB_USER_CREATION_FAILED, notifyDBUserCreationFailed,
NOTIFY_DB_USER_DELETED, notifyDBUserDeleted,
NOTIFY_DB_USER_DELETION_FAILED, notifyDBUserDeleteFailed,
NOTIFY_DB_USER_PERMISSIONS_UPDATED, notifyDBUserPermissionsUpdated,
NOTIFY_DB_USER_PERMISSIONS_UPDATE_FAILED, notifyDBUserPermissionsUpdateFailed,
NOTIFY_DB_USER_ROLES_UPDATED, notifyDBUserRolesUpdated,
NOTIFY_DB_USER_ROLES_UPDATE_FAILED, notifyDBUserRolesUpdateFailed,
NOTIFY_DB_USER_PASSWORD_UPDATED, notifyDBUserPasswordUpdated,
NOTIFY_DB_USER_PASSWORD_UPDATE_FAILED, notifyDBUserPasswordUpdateFailed,
NOTIFY_DATABASE_CREATED, notifyDatabaseCreated,
NOTIFY_DATABASE_CREATION_FAILED, notifyDBCreationFailed,
NOTIFY_DATABASE_DELETED, notifyDBDeleted,
NOTIFY_DATABASE_DELETION_FAILED, notifyDBDeleteFailed,
NOTIFY_ROLE_CREATED, notifyRoleCreated,
NOTIFY_ROLE_CREATION_FAILED, notifyRoleCreationFailed,
NOTIFY_ROLE_DELETED, notifyRoleDeleted,
NOTIFY_ROLE_DELETION_FAILED, notifyRoleDeleteFailed,
NOTIFY_ROLE_USERS_UPDATED, notifyRoleUsersUpdated,
NOTIFY_ROLE_USERS_UPDATE_FAILED, notifyRoleUsersUpdateFailed,
NOTIFY_ROLE_PERMISSIONS_UPDATED, notifyRolePermissionsUpdated,
NOTIFY_ROLE_PERMISSIONS_UPDATE_FAILED, notifyRolePermissionsUpdateFailed,
NOTIFY_RETENTION_POLICY_CREATED, notifyRetentionPolicyCreated,
NOTIFY_RETENTION_POLICY_CREATION_FAILED, notifyRetentionPolicyCreationFailed,
NOTIFY_RETENTION_POLICY_DELETED, notifyRetentionPolicyDeleted,
NOTIFY_RETENTION_POLICY_DELETION_FAILED, notifyRetentionPolicyDeleteFailed,
NOTIFY_RETENTION_POLICY_UPDATED, notifyRetentionPolicyUpdated,
NOTIFY_RETENTION_POLICY_UPDATE_FAILED, notifyRetentionPolicyUpdateFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
import {REVERT_STATE_DELAY} from 'shared/constants' import {REVERT_STATE_DELAY} from 'shared/constants'
@ -307,12 +307,10 @@ export const loadDBsAndRPsAsync = url => async dispatch => {
export const createUserAsync = (url, user) => async dispatch => { export const createUserAsync = (url, user) => async dispatch => {
try { try {
const {data} = await createUserAJAX(url, user) const {data} = await createUserAJAX(url, user)
dispatch(notify(NOTIFY_DB_USER_CREATED)) dispatch(notify(notifyDBUserCreated()))
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
} catch (error) { } catch (error) {
dispatch( dispatch(errorThrown(error, notifyDBUserCreationFailed(error.data.message)))
errorThrown(error, NOTIFY_DB_USER_CREATION_FAILED(error.data.message))
)
// undo optimistic update // undo optimistic update
setTimeout(() => dispatch(deleteUser(user)), REVERT_STATE_DELAY) setTimeout(() => dispatch(deleteUser(user)), REVERT_STATE_DELAY)
} }
@ -321,12 +319,10 @@ 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( dispatch(errorThrown(error, notifyRoleCreationFailed(error.data.message)))
errorThrown(error, NOTIFY_ROLE_CREATION_FAILED(error.data.message))
)
// undo optimistic update // undo optimistic update
setTimeout(() => dispatch(deleteRole(role)), REVERT_STATE_DELAY) setTimeout(() => dispatch(deleteRole(role)), REVERT_STATE_DELAY)
} }
@ -336,11 +332,9 @@ 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( dispatch(errorThrown(error, notifyDBCreationFailed(error.data.message)))
errorThrown(error, NOTIFY_DATABASE_CREATION_FAILED(error.data.message))
)
// undo optimistic update // undo optimistic update
setTimeout(() => dispatch(removeDatabase(database)), REVERT_STATE_DELAY) setTimeout(() => dispatch(removeDatabase(database)), REVERT_STATE_DELAY)
} }
@ -355,11 +349,11 @@ 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(
errorThrown(NOTIFY_RETENTION_POLICY_CREATION_FAILED(error.data.message)) errorThrown(notifyRetentionPolicyCreationFailed(error.data.message))
) )
// undo optimistic update // undo optimistic update
setTimeout( setTimeout(
@ -378,14 +372,11 @@ 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(
errorThrown( errorThrown(error, notifyRetentionPolicyUpdateFailed(error.data.message))
error,
NOTIFY_RETENTION_POLICY_UPDATE_FAILED(error.data.message)
)
) )
} }
} }
@ -407,11 +398,9 @@ export const deleteRoleAsync = role => async dispatch => {
dispatch(deleteRole(role)) dispatch(deleteRole(role))
try { try {
await deleteRoleAJAX(role.links.self) await deleteRoleAJAX(role.links.self)
dispatch(notify(NOTIFY_ROLE_DELETED(role.name))) dispatch(notify(notifyRoleDeleted(role.name)))
} catch (error) { } catch (error) {
dispatch( dispatch(errorThrown(error, notifyRoleDeleteFailed(error.data.message)))
errorThrown(error, NOTIFY_ROLE_DELETION_FAILED(error.data.message))
)
} }
} }
@ -419,11 +408,9 @@ export const deleteUserAsync = user => async dispatch => {
dispatch(deleteUser(user)) dispatch(deleteUser(user))
try { try {
await deleteUserAJAX(user.links.self) await deleteUserAJAX(user.links.self)
dispatch(notify(NOTIFY_DB_USER_DELETED(user.name))) dispatch(notify(notifyDBUserDeleted(user.name)))
} catch (error) { } catch (error) {
dispatch( dispatch(errorThrown(error, notifyDBUserDeleteFailed(error.data.message)))
errorThrown(error, NOTIFY_DB_USER_DELETION_FAILED(error.data.message))
)
} }
} }
@ -431,11 +418,9 @@ export const deleteDatabaseAsync = database => async dispatch => {
dispatch(removeDatabase(database)) dispatch(removeDatabase(database))
try { try {
await deleteDatabaseAJAX(database.links.self) await deleteDatabaseAJAX(database.links.self)
dispatch(notify(NOTIFY_DATABASE_DELETED(database.name))) dispatch(notify(notifyDBDeleted(database.name)))
} catch (error) { } catch (error) {
dispatch( dispatch(errorThrown(error, notifyDBDeleteFailed(error.data.message)))
errorThrown(error, NOTIFY_DATABASE_DELETION_FAILED(error.data.message))
)
} }
} }
@ -446,13 +431,10 @@ export const deleteRetentionPolicyAsync = (
dispatch(removeRetentionPolicy(database, retentionPolicy)) dispatch(removeRetentionPolicy(database, retentionPolicy))
try { try {
await deleteRetentionPolicyAJAX(retentionPolicy.links.self) await deleteRetentionPolicyAJAX(retentionPolicy.links.self)
dispatch(notify(NOTIFY_RETENTION_POLICY_DELETED(retentionPolicy.name))) dispatch(notify(notifyRetentionPolicyDeleted(retentionPolicy.name)))
} catch (error) { } catch (error) {
dispatch( dispatch(
errorThrown( errorThrown(error, notifyRetentionPolicyDeleteFailed(error.data.message))
error,
NOTIFY_RETENTION_POLICY_DELETION_FAILED(error.data.message)
)
) )
} }
} }
@ -464,11 +446,11 @@ 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(
errorThrown(error, NOTIFY_ROLE_USERS_UPDATE_FAILED(error.data.message)) errorThrown(error, notifyRoleUsersUpdateFailed(error.data.message))
) )
} }
} }
@ -483,14 +465,11 @@ 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(
errorThrown( errorThrown(error, notifyRolePermissionsUpdateFailed(error.data.message))
error,
NOTIFY_ROLE_PERMISSIONS_UPDATE_FAILED(error.data.message)
)
) )
} }
} }
@ -501,13 +480,13 @@ 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(
errorThrown( errorThrown(
error, error,
NOTIFY_DB_USER_PERMISSIONS_UPDATE_FAILED(error.data.message) notifyDBUserPermissionsUpdateFailed(error.data.message)
) )
) )
} }
@ -516,11 +495,11 @@ 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(
errorThrown(error, NOTIFY_DB_USER_ROLES_UPDATE_FAILED(error.data.message)) errorThrown(error, notifyDBUserRolesUpdateFailed(error.data.message))
) )
} }
} }
@ -528,14 +507,11 @@ 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(
errorThrown( errorThrown(error, notifyDBUserPasswordUpdateFailed(error.data.message))
error,
NOTIFY_DB_USER_PASSWORD_UPDATE_FAILED(error.data.message)
)
) )
} }
} }

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

@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import ConfirmButtons from 'shared/components/ConfirmButtons' import ConfirmButtons from 'shared/components/ConfirmButtons'
import {NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED} from 'shared/copy/notifications' import {notifyDatabaseDeleteConfirmationRequired} from 'shared/copy/notifications'
const DatabaseTableHeader = ({ const DatabaseTableHeader = ({
database, database,
@ -81,7 +81,7 @@ const Header = ({
function onConfirm(db) { function onConfirm(db) {
if (database.deleteCode !== `DELETE ${database.name}`) { if (database.deleteCode !== `DELETE ${database.name}`) {
return notify(NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED(database.name)) return notify(notifyDatabaseDeleteConfirmationRequired(database.name))
} }
onDelete(db) onDelete(db)

View File

@ -17,8 +17,8 @@ const {
} = ALL_USERS_TABLE } = ALL_USERS_TABLE
import { import {
NOTIFY_CHRONOGRAF_USER_ADDED_TO_ORG, notifyChronografUserAddedToOrg,
NOTIFY_CHRONOGRAF_USER_REMOVED_FROM_ORG, notifyChronografUserRemovedFromOrg,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class AllUsersTable extends Component { class AllUsersTable extends Component {
@ -52,7 +52,7 @@ class AllUsersTable extends Component {
this.props.onUpdateUserRoles( this.props.onUpdateUserRoles(
user, user,
newRoles, newRoles,
NOTIFY_CHRONOGRAF_USER_ADDED_TO_ORG(user.name, organization.name) notifyChronografUserAddedToOrg(user.name, organization.name)
) )
} }
@ -66,7 +66,7 @@ class AllUsersTable extends Component {
this.props.onUpdateUserRoles( this.props.onUpdateUserRoles(
user, user,
newRoles, newRoles,
NOTIFY_CHRONOGRAF_USER_REMOVED_FROM_ORG(user.name, name) notifyChronografUserRemovedFromOrg(user.name, name)
) )
} }

View File

@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import Dropdown from 'shared/components/Dropdown' import Dropdown from 'shared/components/Dropdown'
import {NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER} from 'shared/copy/notifications' import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications'
import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {ALL_USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
const { const {
colOrganizations, colOrganizations,
@ -83,9 +83,7 @@ class AllUsersTableRowNew extends Component {
if (e.key === 'Enter') { if (e.key === 'Enter') {
if (preventCreate) { if (preventCreate) {
return this.props.notify( return this.props.notify(notifyChronografUserMissingNameAndProvider())
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
} }
this.handleConfirmCreateUser() this.handleConfirmCreateUser()
} }

View File

@ -7,7 +7,7 @@ import {notify as notifyAction} from 'shared/actions/notifications'
import Dropdown from 'shared/components/Dropdown' import Dropdown from 'shared/components/Dropdown'
import {NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER} from 'shared/copy/notifications' import {notifyChronografUserMissingNameAndProvider} from 'shared/copy/notifications'
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing' import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin' import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
@ -65,9 +65,7 @@ class UsersTableRowNew extends Component {
if (e.key === 'Enter') { if (e.key === 'Enter') {
if (preventCreate) { if (preventCreate) {
return this.props.notify( return this.props.notify(notifyChronografUserMissingNameAndProvider())
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
} }
this.handleConfirmCreateUser() this.handleConfirmCreateUser()
} }

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

@ -10,9 +10,9 @@ import * as adminActionCreators from 'src/admin/actions/influxdb'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED, 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))
NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED(database.name)
)
} }
return actions.deleteDatabaseAsync(database) return actions.deleteDatabaseAsync(database)

View File

@ -12,7 +12,7 @@ import QueriesTable from 'src/admin/components/QueriesTable'
import showDatabasesParser from 'shared/parsing/showDatabases' import showDatabasesParser from 'shared/parsing/showDatabases'
import showQueriesParser from 'shared/parsing/showQueries' import showQueriesParser from 'shared/parsing/showQueries'
import {TIMES} from 'src/admin/constants' import {TIMES} from 'src/admin/constants'
import {NOTIFY_QUERIES_ERROR} from 'shared/copy/notifications' import {notifyQueriesError} from 'shared/copy/notifications'
import { import {
loadQueries as loadQueriesAction, loadQueries as loadQueriesAction,
@ -44,7 +44,7 @@ class QueriesPage extends Component {
showDatabases(source.links.proxy).then(resp => { showDatabases(source.links.proxy).then(resp => {
const {databases, errors} = showDatabasesParser(resp.data) const {databases, errors} = showDatabasesParser(resp.data)
if (errors.length) { if (errors.length) {
errors.forEach(message => notify(NOTIFY_QUERIES_ERROR(message))) errors.forEach(message => notify(notifyQueriesError(message)))
return return
} }
@ -56,7 +56,7 @@ class QueriesPage extends Component {
const result = showQueriesParser(queryResponse.data) const result = showQueriesParser(queryResponse.data)
if (result.errors.length) { if (result.errors.length) {
result.errors.forEach(message => result.errors.forEach(message =>
notify(NOTIFY_QUERIES_ERROR(message)) notify(notifyQueriesError(message))
) )
} }

View File

@ -13,8 +13,8 @@ import {errorThrown} from 'shared/actions/errors'
import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants' import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants'
import { import {
NOTIFY_DASHBOARD_DELETED, notifyDashboardDeleted,
NOTIFY_DASHBOARD_DELETE_FAILED, notifyDashboardDeleteFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
import { import {
@ -261,12 +261,12 @@ export const deleteDashboardAsync = dashboard => async dispatch => {
dispatch(deleteDashboard(dashboard)) dispatch(deleteDashboard(dashboard))
try { try {
await deleteDashboardAJAX(dashboard) await deleteDashboardAJAX(dashboard)
dispatch(notify(NOTIFY_DASHBOARD_DELETED(dashboard.name))) dispatch(notify(notifyDashboardDeleted(dashboard.name)))
} catch (error) { } catch (error) {
dispatch( dispatch(
errorThrown( errorThrown(
error, error,
NOTIFY_DASHBOARD_DELETE_FAILED(dashboard.name, error.data.message) notifyDashboardDeleteFailed(dashboard.name, error.data.message)
) )
) )
dispatch(deleteDashboardFailed(dashboard)) 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 {errorThrown as errorThrownAction} from 'shared/actions/errors'
import {notify as notifyAction} from 'shared/actions/notifications' 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)) 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 const tempVar = `\u003a${_tempVar}\u003a` // add ':'s
if (tempVarAlreadyExists(tempVar, id)) { if (tempVarAlreadyExists(tempVar, id)) {
return notify(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar)) return notify(notifyTempVarAlreadyExists(_tempVar))
} }
this.setState({ this.setState({

View File

@ -34,7 +34,7 @@ import {
} from 'shared/actions/app' } from 'shared/actions/app'
import {presentationButtonDispatcher} from 'shared/dispatchers' import {presentationButtonDispatcher} from 'shared/dispatchers'
import {DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants' 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 FORMAT_INFLUXQL = 'influxql'
const defaultTimeRange = { const defaultTimeRange = {
@ -91,7 +91,7 @@ class DashboardPage extends Component {
if (!dashboard) { if (!dashboard) {
router.push(`/sources/${source.id}/dashboards`) 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. // Refresh and persists influxql generated template variable values.

View File

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

View File

@ -15,8 +15,8 @@ import {setAutoRefresh} from 'shared/actions/app'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_UNABLE_TO_GET_HOSTS, notifyUnableToGetHosts,
NOTIFY_UNABLE_TO_GET_APPS, notifyUnableToGetApps,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class HostsPage extends Component { class HostsPage extends Component {
@ -33,7 +33,7 @@ class HostsPage extends Component {
async fetchHostsData() { async fetchHostsData() {
const {source, links, notify} = this.props const {source, links, notify} = this.props
const {telegrafSystemInterval} = await getEnv(links.environment) const {telegrafSystemInterval} = await getEnv(links.environment)
const hostsError = NOTIFY_UNABLE_TO_GET_HOSTS.message const hostsError = notifyUnableToGetHosts().message
try { try {
const hosts = await getCpuAndLoadForHosts( const hosts = await getCpuAndLoadForHosts(
source.links.proxy, source.links.proxy,
@ -57,7 +57,7 @@ class HostsPage extends Component {
}) })
} catch (error) { } catch (error) {
console.error(error) console.error(error)
notify(NOTIFY_UNABLE_TO_GET_HOSTS) notify(notifyUnableToGetHosts())
this.setState({ this.setState({
hostsError, hostsError,
hostsLoading: false, hostsLoading: false,
@ -72,8 +72,8 @@ class HostsPage extends Component {
const {data} = await getLayouts() const {data} = await getLayouts()
this.layouts = data.layouts this.layouts = data.layouts
if (!this.layouts) { if (!this.layouts) {
const layoutError = NOTIFY_UNABLE_TO_GET_APPS.message const layoutError = notifyUnableToGetApps().message
notify(NOTIFY_UNABLE_TO_GET_APPS) notify(notifyUnableToGetApps())
this.setState({ this.setState({
hostsError: layoutError, hostsError: layoutError,
hostsLoading: false, hostsLoading: false,

View File

@ -39,6 +39,7 @@ import {getMeAsync} from 'shared/actions/auth'
import {disablePresentationMode} from 'shared/actions/app' import {disablePresentationMode} from 'shared/actions/app'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import {notify} from 'shared/actions/notifications'
import 'src/style/chronograf.scss' import 'src/style/chronograf.scss'
@ -114,8 +115,12 @@ const Root = React.createClass({
flushErrorsQueue() { flushErrorsQueue() {
if (errorsQueue.length) { if (errorsQueue.length) {
errorsQueue.forEach(errorText => { errorsQueue.forEach(error => {
dispatch(errorThrown({status: 0, auth: null}, errorText, 'warning')) if (typeof error === 'object') {
dispatch(notify(error))
} else {
dispatch(errorThrown({status: 0, auth: null}, error, 'warning'))
}
}) })
} }
}, },

View File

@ -12,14 +12,14 @@ import {
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import { import {
NOTIFY_ALERT_RULE_DELETED, notifyAlertRuleDeleted,
NOTIFY_ALERT_RULE_DELETION_FAILED, notifyAlertRuleDeleteFailed,
NOTIFY_ALERT_RULE_STATUS_UPDATED, notifyAlertRuleStatusUpdated,
NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED, notifyAlertRuleStatusUpdateFailed,
NOTIFY_TICKSCRIPT_CREATED, notifyTickScriptCreated,
NOTIFY_TICKSCRIPT_CREATION_FAILED, notifyTickscriptCreationFailed,
NOTIFY_TICKSCRIPT_UPDATED, notifyTickscriptUpdated,
NOTIFY_TICKSCRIPT_UPDATE_FAILED, notifyTickscriptUpdateFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
const loadQuery = query => ({ const loadQuery = query => ({
@ -181,33 +181,31 @@ export const deleteRule = rule => dispatch => {
deleteRuleAPI(rule) deleteRuleAPI(rule)
.then(() => { .then(() => {
dispatch(deleteRuleSuccess(rule.id)) dispatch(deleteRuleSuccess(rule.id))
dispatch(notify(NOTIFY_ALERT_RULE_DELETED(rule.name))) dispatch(notify(notifyAlertRuleDeleted(rule.name)))
}) })
.catch(() => { .catch(() => {
dispatch(notify(NOTIFY_ALERT_RULE_DELETION_FAILED(rule.name))) dispatch(notify(notifyAlertRuleDeleteFailed(rule.name)))
}) })
} }
export const updateRuleStatus = (rule, status) => dispatch => { export const updateRuleStatus = (rule, status) => dispatch => {
updateRuleStatusAPI(rule, status) updateRuleStatusAPI(rule, status)
.then(() => { .then(() => {
dispatch(notify(NOTIFY_ALERT_RULE_STATUS_UPDATED(rule.name, status))) dispatch(notify(notifyAlertRuleStatusUpdated(rule.name, status)))
}) })
.catch(() => { .catch(() => {
dispatch( dispatch(notify(notifyAlertRuleStatusUpdateFailed(rule.name, status)))
notify(NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status))
)
}) })
} }
export const createTask = (kapacitor, task) => async dispatch => { export const createTask = (kapacitor, task) => async dispatch => {
try { try {
const {data} = await createTaskAJAX(kapacitor, task) const {data} = await createTaskAJAX(kapacitor, task)
dispatch(notify(NOTIFY_TICKSCRIPT_CREATED)) dispatch(notify(notifyTickScriptCreated()))
return data return data
} catch (error) { } catch (error) {
if (!error) { if (!error) {
dispatch(errorThrown(NOTIFY_TICKSCRIPT_CREATION_FAILED)) dispatch(errorThrown(notifyTickscriptCreationFailed()))
return return
} }
@ -223,11 +221,11 @@ export const updateTask = (
) => async dispatch => { ) => async dispatch => {
try { try {
const {data} = await updateTaskAJAX(kapacitor, task, ruleID, sourceID) const {data} = await updateTaskAJAX(kapacitor, task, ruleID, sourceID)
dispatch(notify(NOTIFY_TICKSCRIPT_UPDATED)) dispatch(notify(notifyTickscriptUpdated()))
return data return data
} catch (error) { } catch (error) {
if (!error) { if (!error) {
dispatch(errorThrown(NOTIFY_TICKSCRIPT_UPDATE_FAILED)) dispatch(errorThrown(notifyTickscriptUpdateFailed()))
return return
} }
return error.data return error.data

View File

@ -25,11 +25,11 @@ import {
} from './config' } from './config'
import { import {
NOTIFY_REFRESH_KAPACITOR_FAILED, notifyRefreshKapacitorFailed,
NOTIFY_ALERT_ENDPOINT_SAVED, notifyAlertEndpointSaved,
NOTIFY_ALERT_ENDPOINT_SAVE_FAILED, notifyAlertEndpointSaveFailed,
NOTIFY_TEST_ALERT_SENT, notifyTestAlertSent,
NOTIFY_TEST_ALERT_FAILED, notifyTestAlertFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class AlertTabs extends Component { class AlertTabs extends Component {
@ -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())
} }
} }
@ -87,11 +87,11 @@ class AlertTabs extends Component {
propsToSend propsToSend
) )
this.refreshKapacitorConfig(this.props.kapacitor) this.refreshKapacitorConfig(this.props.kapacitor)
this.props.notify(NOTIFY_ALERT_ENDPOINT_SAVED(section)) this.props.notify(notifyAlertEndpointSaved(section))
return true return true
} catch ({data: {error}}) { } catch ({data: {error}}) {
const errorMsg = _.join(_.drop(_.split(error, ': '), 2), ': ') const errorMsg = _.join(_.drop(_.split(error, ': '), 2), ': ')
this.props.notify(NOTIFY_ALERT_ENDPOINT_SAVE_FAILED(section, errorMsg)) this.props.notify(notifyAlertEndpointSaveFailed(section, errorMsg))
return false return false
} }
} }
@ -103,12 +103,12 @@ class AlertTabs extends Component {
try { try {
const {data} = await testAlertOutput(this.props.kapacitor, section) const {data} = await testAlertOutput(this.props.kapacitor, section)
if (data.success) { if (data.success) {
this.props.notify(NOTIFY_TEST_ALERT_SENT(section)) this.props.notify(notifyTestAlertSent(section))
} else { } else {
this.props.notify(NOTIFY_TEST_ALERT_FAILED(section, data.message)) this.props.notify(notifyTestAlertFailed(section, data.message))
} }
} catch (error) { } catch (error) {
this.props.notify(NOTIFY_TEST_ALERT_FAILED(section)) this.props.notify(notifyTestAlertFailed(section))
} }
} }

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,
NOTIFY_ALERT_RULE_UPDATED, notifyAlertRuleUpdated,
NOTIFY_ALERT_RULE_UPDATE_FAILED, 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())
}) })
} }
@ -66,10 +66,10 @@ class KapacitorRule extends Component {
editRule(updatedRule) editRule(updatedRule)
.then(() => { .then(() => {
router.push(pathname || `/sources/${source.id}/alert-rules`) router.push(pathname || `/sources/${source.id}/alert-rules`)
notify(NOTIFY_ALERT_RULE_UPDATED(rule.name)) notify(notifyAlertRuleUpdated(rule.name))
}) })
.catch(e => { .catch(e => {
notify(NOTIFY_ALERT_RULE_UPDATE_FAILED(rule.name, e.data.message)) notify(notifyAlertRuleUpdateFailed(rule.name, e.data.message))
}) })
} }
@ -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,
NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN, 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())
} }
} }
@ -131,7 +131,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
const isNew = !params.id const isNew = !params.id
if (isNew && isNameTaken) { if (isNew && isNameTaken) {
notify(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN) notify(notifyKapacitorNameAlreadyTaken)
return return
} }
@ -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

@ -12,9 +12,9 @@ import {getLogStreamByRuleID, pingKapacitorVersion} from 'src/kapacitor/apis'
import {notify as notifyAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE, notifyTickscriptLoggingUnavailable,
NOTIFY_TICKSCRIPT_LOGGING_ERROR, notifyTickscriptLoggingError,
NOTIFY_KAPACITOR_NOT_FOUND, notifyKapacitorNotFound,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class TickscriptPage extends Component { class TickscriptPage extends Component {
@ -50,7 +50,7 @@ class TickscriptPage extends Component {
this.setState({ this.setState({
areLogsEnabled: false, areLogsEnabled: false,
}) })
notify(NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE) notify(notifyTickscriptLoggingUnavailable())
return return
} }
@ -119,7 +119,7 @@ class TickscriptPage extends Component {
} }
} catch (error) { } catch (error) {
console.error(error) console.error(error)
notify(NOTIFY_TICKSCRIPT_LOGGING_ERROR(error)) notify(notifyTickscriptLoggingError()(error))
throw error throw error
} }
} }
@ -134,7 +134,7 @@ class TickscriptPage extends Component {
const kapacitor = await getActiveKapacitor(source) const kapacitor = await getActiveKapacitor(source)
if (!kapacitor) { if (!kapacitor) {
errorActions.errorThrown(NOTIFY_KAPACITOR_NOT_FOUND) errorActions.errorThrown(notifyKapacitorNotFound())
} }
if (this._isEditing()) { if (this._isEditing()) {

View File

@ -1,5 +1,9 @@
import _ from 'lodash' import _ from 'lodash'
import normalizer from 'src/normalizers/dashboardTime' import normalizer from 'src/normalizers/dashboardTime'
import {
notifyNewVersion,
notifyLoadLocalSettingsFailed,
} from 'src/shared/copy/notifications'
export const loadLocalStorage = errorsQueue => { export const loadLocalStorage = errorsQueue => {
try { try {
@ -11,10 +15,9 @@ export const loadLocalStorage = errorsQueue => {
if (state.VERSION && state.VERSION !== VERSION) { if (state.VERSION && state.VERSION !== VERSION) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
const version = VERSION ? ` (${VERSION})` : '' const version = VERSION ? ` (${VERSION})` : ''
const errorText = `Welcome to the latest Chronograf ${version}. Local settings cleared.`
console.log(errorText) // eslint-disable-line no-console console.log(notifyNewVersion(version).message) // eslint-disable-line no-console
errorsQueue.push(errorText) errorsQueue.push(notifyNewVersion(version))
if (!state.dashTimeV1) { if (!state.dashTimeV1) {
window.localStorage.removeItem('state') window.localStorage.removeItem('state')
@ -38,10 +41,8 @@ export const loadLocalStorage = errorsQueue => {
return state return state
} catch (error) { } catch (error) {
const errorText = `Loading local settings failed: ${error}` console.error(notifyLoadLocalSettingsFailed(error).message) // eslint-disable-line no-console
errorsQueue.push(notifyLoadLocalSettingsFailed(error))
console.error(errorText) // eslint-disable-line no-console
errorsQueue.push(errorText)
return {} return {}
} }

View File

@ -5,7 +5,7 @@ import {getLinksAsync} from 'shared/actions/links'
import {notify} from 'shared/actions/notifications' import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import {NOTIFY_USER_SWITCHED_ORGS} from 'shared/copy/notifications' import {notifyUserSwitchedOrgs} from 'shared/copy/notifications'
export const authExpired = auth => ({ export const authExpired = auth => ({
type: 'AUTH_EXPIRED', type: 'AUTH_EXPIRED',
@ -93,7 +93,7 @@ export const meChangeOrganizationAsync = (
) )
dispatch( dispatch(
notify( notify(
NOTIFY_USER_SWITCHED_ORGS(me.currentOrganization.name, currentRole.name) notifyUserSwitchedOrgs(me.currentOrganization.name, currentRole.name)
) )
) )
dispatch(meChangeOrganizationCompleted()) dispatch(meChangeOrganizationCompleted())

View File

@ -10,9 +10,9 @@ import {errorThrown} from 'shared/actions/errors'
import {HTTP_NOT_FOUND} from 'shared/constants' import {HTTP_NOT_FOUND} from 'shared/constants'
import { import {
NOTIFY_SERVER_ERROR, notifyServerError,
NOTIFY_COULD_NOT_RETRIEVE_KAPACITORS, notifyCouldNotRetrieveKapacitors,
NOTIFY_COULD_NOT_DELETE_KAPACITOR, notifyCouldNotDeleteKapacitor,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
export const loadSources = sources => ({ export const loadSources = sources => ({
@ -76,7 +76,7 @@ export const removeAndLoadSources = source => async dispatch => {
const {data: {sources: newSources}} = await getSourcesAJAX() const {data: {sources: newSources}} = await getSourcesAJAX()
dispatch(loadSources(newSources)) dispatch(loadSources(newSources))
} catch (err) { } catch (err) {
dispatch(notify(NOTIFY_SERVER_ERROR)) dispatch(notify(notifyServerError()))
} }
} }
@ -85,7 +85,7 @@ export const fetchKapacitorsAsync = source => async dispatch => {
const {data} = await getKapacitorsAJAX(source) const {data} = await getKapacitorsAJAX(source)
dispatch(fetchKapacitors(source, data.kapacitors)) dispatch(fetchKapacitors(source, data.kapacitors))
} catch (err) { } catch (err) {
dispatch(notify(NOTIFY_COULD_NOT_RETRIEVE_KAPACITORS(source.id))) dispatch(notify(notifyCouldNotRetrieveKapacitors(source.id)))
} }
} }
@ -101,7 +101,7 @@ export const deleteKapacitorAsync = kapacitor => async dispatch => {
await deleteKapacitorAJAX(kapacitor) await deleteKapacitorAJAX(kapacitor)
dispatch(deleteKapacitor(kapacitor)) dispatch(deleteKapacitor(kapacitor))
} catch (err) { } catch (err) {
dispatch(notify(NOTIFY_COULD_NOT_DELETE_KAPACITOR)) dispatch(notify(notifyCouldNotDeleteKapacitor()))
} }
} }

View File

@ -6,7 +6,8 @@ import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'
import LayoutCellMenu from 'shared/components/LayoutCellMenu' import LayoutCellMenu from 'shared/components/LayoutCellMenu'
import LayoutCellHeader from 'shared/components/LayoutCellHeader' import LayoutCellHeader from 'shared/components/LayoutCellHeader'
import {errorThrown} from 'shared/actions/errors' import {notify} from 'src/shared/actions/notifications'
import {notifyCSVDownloadFailed} from 'src/shared/copy/notifications'
import {dashboardtoCSV} from 'shared/parsing/resultsToCSV' import {dashboardtoCSV} from 'shared/parsing/resultsToCSV'
import download from 'src/external/download.js' import download from 'src/external/download.js'
@ -25,7 +26,7 @@ class LayoutCell extends Component {
try { try {
download(dashboardtoCSV(celldata), `${joinedName}.csv`, 'text/plain') download(dashboardtoCSV(celldata), `${joinedName}.csv`, 'text/plain')
} catch (error) { } catch (error) {
errorThrown(error, 'Unable to download .csv file') notify(notifyCSVDownloadFailed())
console.error(error) console.error(error)
} }
} }

View File

@ -17,184 +17,204 @@ 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 NOTIFY_NEW_VERSION = message => ({ export const notifyNewVersion = version => ({
type: 'info', type: 'info',
icon: 'cubo-uniform', icon: 'cubo-uniform',
duration: INFINITE, duration: INFINITE,
message, message: `Welcome to the latest Chronograf${version}. Local settings cleared.`,
}) })
export const NOTIFY_ERR_WITH_ALT_TEXT = (type, message) => ({ export const notifyLoadLocalSettingsFailed = error => ({
...defaultErrorNotification,
message: `Loading local settings failed: ${error}`,
})
export const notifyErrorWithAltText = (type, message) => ({
type, type,
icon: 'triangle', icon: 'triangle',
duration: TEN_SECONDS, duration: TEN_SECONDS,
message, message,
}) })
export const NOTIFY_PRESENTATION_MODE = { export const notifyPresentationMode = () => ({
type: 'primary', type: 'primary',
icon: 'expand-b', icon: 'expand-b',
duration: 7500, duration: 7500,
message: 'Press ESC to exit Presentation Mode.', message: 'Press ESC to exit Presentation Mode.',
} })
export const NOTIFY_DATA_WRITTEN = { export const notifyDataWritten = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'Data was written successfully.', message: 'Data was written successfully.',
} })
export const NOTIFY_SESSION_TIMED_OUT = { export const notifyDataWriteFailed = errorMessage => ({
...defaultErrorNotification,
message: `Data write failed: ${errorMessage}`,
})
export const notifySessionTimedOut = () => ({
type: 'primary', type: 'primary',
icon: 'triangle', icon: 'triangle',
duration: INFINITE, duration: INFINITE,
message: 'Your session has timed out. Log in again to continue.', message: 'Your session has timed out. Log in again to continue.',
} })
export const NOTIFY_SERVER_ERROR = { export const notifyServerError = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
mesasage: 'Internal Server Error. Check API Logs.', mesasage: 'Internal Server Error. Check API Logs.',
} })
export const NOTIFY_COULD_NOT_RETRIEVE_KAPACITORS = sourceID => ({ export const notifyCouldNotRetrieveKapacitors = sourceID => ({
...defaultErrorNotification, ...defaultErrorNotification,
mesasage: `Internal Server Error. Could not retrieve Kapacitor Connections for source ${sourceID}.`, mesasage: `Internal Server Error. Could not retrieve Kapacitor Connections for source ${sourceID}.`,
}) })
export const NOTIFY_COULD_NOT_DELETE_KAPACITOR = { export const notifyCouldNotDeleteKapacitor = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Internal Server Error. Could not delete Kapacitor Connection.', message: 'Internal Server Error. Could not delete Kapacitor Connection.',
} })
export const notifyCSVDownloadFailed = () => ({
...defaultErrorNotification,
message: 'Unable to download .CSV file',
})
// Hosts Page Notifications // Hosts Page Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_UNABLE_TO_GET_HOSTS = { export const notifyUnableToGetHosts = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Unable to get Hosts.', message: 'Unable to get Hosts.',
} })
export const NOTIFY_UNABLE_TO_GET_APPS = { export const notifyUnableToGetApps = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: 'Unable to get Apps for Hosts.', message: 'Unable to get Apps for Hosts.',
} })
// InfluxDB Sources Notifications // InfluxDB Sources Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_SOURCE_CREATION_SUCCEEDED = sourceName => ({ export const notifySourceCreationSucceeded = sourceName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
icon: 'server2', icon: 'server2',
message: `Connected to InfluxDB ${sourceName} successfully.`, message: `Connected to InfluxDB ${sourceName} successfully.`,
}) })
export const NOTIFY_SOURCE_CREATION_FAILED = (sourceName, errorMessage) => ({ export const notifySourceCreationFailed = (sourceName, errorMessage) => ({
...defaultErrorNotification, ...defaultErrorNotification,
icon: 'server2', icon: 'server2',
message: `Unable to connect to InfluxDB ${sourceName}: ${errorMessage}`, message: `Unable to connect to InfluxDB ${sourceName}: ${errorMessage}`,
}) })
export const NOTIFY_SOURCE_UPDATED = sourceName => ({ export const notifySourceUdpated = sourceName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
icon: 'server2', icon: 'server2',
message: `Updated InfluxDB ${sourceName} Connection successfully.`, message: `Updated InfluxDB ${sourceName} Connection successfully.`,
}) })
export const NOTIFY_SOURCE_UPDATE_FAILED = (sourceName, errorMessage) => ({ export const notifySourceUdpateFailed = (sourceName, errorMessage) => ({
...defaultErrorNotification, ...defaultErrorNotification,
icon: 'server2', icon: 'server2',
message: `Failed to update InfluxDB ${sourceName} Connection: ${errorMessage}`, message: `Failed to update InfluxDB ${sourceName} Connection: ${errorMessage}`,
}) })
export const NOTIFY_SOURCE_DELETED = sourceName => ({ export const notifySourceDeleted = sourceName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
icon: 'server2', icon: 'server2',
message: `${sourceName} deleted successfully.`, message: `${sourceName} deleted successfully.`,
}) })
export const NOTIFY_SOURCE_DELETE_FAILED = sourceName => ({ export const notifySourceDeleteFailed = sourceName => ({
...defaultErrorNotification, ...defaultErrorNotification,
icon: 'server2', icon: 'server2',
message: `There was a problem deleting ${sourceName}.`, message: `There was a problem deleting ${sourceName}.`,
}) })
export const NOTIFY_SOURCE_NO_LONGER_AVAILABLE = sourceName => export const notifySourceNoLongerAvailable = sourceName =>
`Source ${sourceName} is no longer available. Successfully connected to another source.` `Source ${sourceName} is no longer available. Successfully connected to another source.`
export const NOTIFY_NO_SOURCES_AVAILABLE = sourceName => export const notifyNoSourcesAvailable = sourceName =>
`Unable to connect to source ${sourceName}. No other sources available.` `Unable to connect to source ${sourceName}. No other sources available.`
export const NOTIFY_UNABLE_TO_RETRIEVE_SOURCES = 'Unable to retrieve sources.' export const notifyUnableToRetrieveSources = () => 'Unable to retrieve sources.'
export const NOTIFY_UNABLE_TO_CONNECT_SOURCE = sourceName => export const notifyUnableToConnectSource = sourceName =>
`Unable to connect to source ${sourceName}.` `Unable to connect to source ${sourceName}.`
export const NOTIFY_ERROR_CONNECTING_TO_SOURCE = errorMessage => export const notifyErrorConnectingToSource = errorMessage =>
`Unable to connect to InfluxDB source: ${errorMessage}` `Unable to connect to InfluxDB source: ${errorMessage}`
// Multitenancy User Notifications // Multitenancy User Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_USER_REMOVED_FROM_ALL_ORGS = { export const notifyUserRemovedFromAllOrgs = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
duration: INFINITE, duration: INFINITE,
message: message:
'You have been removed from all organizations. Please contact your administrator.', 'You have been removed from all organizations. Please contact your administrator.',
} })
export const NOTIFY_USER_REMOVED_FROM_CURRENT_ORG = { export const notifyUserRemovedFromCurrentOrg = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
duration: INFINITE, duration: INFINITE,
message: 'You were removed from your current organization.', message: 'You were removed from your current organization.',
} })
export const NOTIFY_ORG_HAS_NO_SOURCES = { export const notifyOrgHasNoSources = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
duration: INFINITE, duration: INFINITE,
message: 'Organization has no sources configured.', message: 'Organization has no sources configured.',
} })
export const NOTIFY_USER_SWITCHED_ORGS = (orgName, roleName) => ({ export const notifyUserSwitchedOrgs = (orgName, roleName) => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
type: 'primary', type: 'primary',
message: `Now logged in to '${orgName}' as '${roleName}'.`, message: `Now logged in to '${orgName}' as '${roleName}'.`,
}) })
export const NOTIFY_ORG_IS_PRIVATE = { export const notifyOrgIsPrivate = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
duration: INFINITE, duration: INFINITE,
message: message:
'This organization is private. To gain access, you must be explicitly added by an administrator.', 'This organization is private. To gain access, you must be explicitly added by an administrator.',
} })
export const NOTIFY_CURRENT_ORG_DELETED = { export const notifyCurrentOrgDeleted = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
duration: INFINITE, duration: INFINITE,
message: 'Your current organization was deleted.', message: 'Your current organization was deleted.',
} })
export const notifyJSONFeedFailed = url => ({
...defaultErrorNotification,
message: `Failed to fetch JSON Feed for News Feed from '${url}'`,
})
// Chronograf Admin Notifications // Chronograf Admin Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_MAPPING_DELETED = (id, scheme) => ({ export const notifyMappingDeleted = (id, scheme) => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Mapping ${id}/${scheme} deleted successfully.`, message: `Mapping ${id}/${scheme} deleted successfully.`,
}) })
export const NOTIFY_CHRONOGRAF_USER_ADDED_TO_ORG = (user, organization) => export const notifyChronografUserAddedToOrg = (user, organization) =>
`${user} has been added to ${organization} successfully.` `${user} has been added to ${organization} successfully.`
export const NOTIFY_CHRONOGRAF_USER_REMOVED_FROM_ORG = (user, organization) => export const notifyChronografUserRemovedFromOrg = (user, organization) =>
`${user} has been removed from ${organization} successfully.` `${user} has been removed from ${organization} successfully.`
export const NOTIFY_CHRONOGRAF_USER_UPDATED = message => ({ export const notifyChronografUserUpdated = message => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message, message,
}) })
export const NOTIFY_CHRONOGRAF_ORG_DELETED = orgName => ({ export const notifyChronografOrgDeleted = orgName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Organization ${orgName} deleted successfully.`, message: `Organization ${orgName} deleted successfully.`,
}) })
export const NOTIFY_CHRONOGRAF_USER_DELETED = (user, isAbsoluteDelete) => ({ export const notifyChronografUserDeleted = (user, isAbsoluteDelete) => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `${user} has been removed from ${ message: `${user} has been removed from ${
isAbsoluteDelete isAbsoluteDelete
@ -203,332 +223,330 @@ export const NOTIFY_CHRONOGRAF_USER_DELETED = (user, isAbsoluteDelete) => ({
}`, }`,
}) })
export const NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER = { export const notifyChronografUserMissingNameAndProvider = () => ({
...defaultErrorNotification, ...defaultErrorNotification,
type: 'warning', type: 'warning',
message: 'User must have a Name and Provider.', message: 'User must have a Name and Provider.',
} })
// InfluxDB Admin Notifications // InfluxDB Admin Notifications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_DB_USER_CREATED = { export const notifyDBUserCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'User created successfully.', message: 'User created successfully.',
} })
export const NOTIFY_DB_USER_CREATION_FAILED = errorMessage => export const notifyDBUserCreationFailed = errorMessage =>
`Failed to create User: ${errorMessage}` `Failed to create User: ${errorMessage}`
export const NOTIFY_DB_USER_DELETED = userName => ({ export const notifyDBUserDeleted = userName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `User "${userName}" deleted successfully.`, message: `User "${userName}" deleted successfully.`,
}) })
export const NOTIFY_DB_USER_DELETION_FAILED = 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 NOTIFY_DB_USER_PERMISSIONS_UPDATE_FAILED = 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 NOTIFY_DB_USER_ROLES_UPDATE_FAILED = 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 NOTIFY_DB_USER_PASSWORD_UPDATE_FAILED = 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 NOTIFY_DATABASE_CREATION_FAILED = errorMessage => export const notifyDBCreationFailed = errorMessage =>
`Failed to create Database: ${errorMessage}` `Failed to create Database: ${errorMessage}`
export const NOTIFY_DATABASE_DELETED = databaseName => ({ export const notifyDBDeleted = databaseName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Database "${databaseName}" deleted successfully.`, message: `Database "${databaseName}" deleted successfully.`,
}) })
export const NOTIFY_DATABASE_DELETION_FAILED = 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 NOTIFY_ROLE_CREATION_FAILED = errorMessage => export const notifyRoleCreationFailed = errorMessage =>
`Failed to create Role: ${errorMessage}` `Failed to create Role: ${errorMessage}`
export const NOTIFY_ROLE_DELETED = roleName => ({ export const notifyRoleDeleted = roleName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Role "${roleName}" deleted successfully.`, message: `Role "${roleName}" deleted successfully.`,
}) })
export const NOTIFY_ROLE_DELETION_FAILED = 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 NOTIFY_ROLE_USERS_UPDATE_FAILED = 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 NOTIFY_ROLE_PERMISSIONS_UPDATE_FAILED = 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 NOTIFY_RETENTION_POLICY_CREATION_FAILED = errorMessage => export const notifyRetentionPolicyCreationFailed = errorMessage =>
`Failed to create Retention Policy: ${errorMessage}` `Failed to create Retention Policy: ${errorMessage}`
export const NOTIFY_RETENTION_POLICY_DELETED = rpName => ({ export const notifyRetentionPolicyDeleted = rpName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Retention Policy "${rpName}" deleted successfully.`, message: `Retention Policy "${rpName}" deleted successfully.`,
}) })
export const NOTIFY_RETENTION_POLICY_DELETION_FAILED = 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 NOTIFY_RETENTION_POLICY_UPDATE_FAILED = errorMessage => export const notifyRetentionPolicyUpdateFailed = errorMessage =>
`Failed to update Retention Policy: ${errorMessage}` `Failed to update Retention Policy: ${errorMessage}`
export const NOTIFY_QUERIES_ERROR = errorMessage => ({ export const notifyQueriesError = errorMessage => ({
...defaultErrorNotification, ...defaultErrorNotification,
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 NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED = databaseName => ({
...defaultErrorNotification,
message: `Type "DELETE ${databaseName}" to confirm.`,
}) })
export const NOTIFY_DB_USER_NAME_PASSWORD_INVALID = { export const notifyDatabaseDeleteConfirmationRequired = databaseName => ({
...defaultErrorNotification,
message: `Type "DELETE ${databaseName}" to confirm. This action cannot be undone.`,
})
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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_TEMP_VAR_ALREADY_EXISTS = tempVarName => ({ export const notifyTempVarAlreadyExists = tempVarName => ({
...defaultErrorNotification, ...defaultErrorNotification,
icon: 'cube', icon: 'cube',
message: `Variable '${tempVarName}' already exists. Please enter a new value.`, message: `Variable '${tempVarName}' already exists. Please enter a new value.`,
}) })
export const NOTIFY_DASHBOARD_NOT_FOUND = dashboardID => ({ export const notifyDashboardNotFound = dashboardID => ({
...defaultErrorNotification, ...defaultErrorNotification,
icon: 'dash-h', icon: 'dash-h',
message: `Dashboard ${dashboardID} could not be found`, message: `Dashboard ${dashboardID} could not be found`,
}) })
export const NOTIFY_DASHBOARD_DELETED = name => ({ export const notifyDashboardDeleted = name => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
icon: 'dash-h', icon: 'dash-h',
message: `Dashboard ${name} deleted successfully.`, message: `Dashboard ${name} deleted successfully.`,
}) })
export const NOTIFY_DASHBOARD_DELETE_FAILED = (name, errorMessage) => export const notifyDashboardDeleteFailed = (name, errorMessage) =>
`Failed to delete Dashboard ${name}: ${errorMessage}.` `Failed to delete Dashboard ${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 NOTIFY_ALERT_RULE_UPDATED = ruleName => ({ export const notifyAlertRuleUpdated = ruleName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `${ruleName} saved successfully.`, message: `${ruleName} saved successfully.`,
}) })
export const NOTIFY_ALERT_RULE_UPDATE_FAILED = (ruleName, errorMessage) => ({ export const notifyAlertRuleUpdateFailed = (ruleName, errorMessage) => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: `There was a problem saving ${ruleName}: ${errorMessage}`, message: `There was a problem saving ${ruleName}: ${errorMessage}`,
}) })
export const NOTIFY_ALERT_RULE_DELETED = ruleName => ({ export const notifyAlertRuleDeleted = ruleName => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `${ruleName} deleted successfully.`, message: `${ruleName} deleted successfully.`,
}) })
export const NOTIFY_ALERT_RULE_DELETION_FAILED = ruleName => ({ export const notifyAlertRuleDeleteFailed = ruleName => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: `${ruleName} could not be deleted.`, message: `${ruleName} could not be deleted.`,
}) })
export const NOTIFY_ALERT_RULE_STATUS_UPDATED = (ruleName, updatedStatus) => ({ export const notifyAlertRuleStatusUpdated = (ruleName, updatedStatus) => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN = kapacitorName => ({ export const notifyKapacitorNameAlreadyTaken = kapacitorName => ({
...defaultErrorNotification, ...defaultErrorNotification,
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 NOTIFY_ALERT_ENDPOINT_SAVED = endpoint => ({ export const notifyAlertEndpointSaved = endpoint => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: `Alert configuration for ${endpoint} saved successfully.`, message: `Alert configuration for ${endpoint} saved successfully.`,
}) })
export const NOTIFY_ALERT_ENDPOINT_SAVE_FAILED = (endpoint, errorMessage) => ({ export const notifyAlertEndpointSaveFailed = (endpoint, errorMessage) => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: `There was an error saving the alert configuration for ${endpoint}: ${errorMessage}`, message: `There was an error saving the alert configuration for ${endpoint}: ${errorMessage}`,
}) })
export const NOTIFY_TEST_ALERT_SENT = endpoint => ({ export const notifyTestAlertSent = endpoint => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
duration: TEN_SECONDS, duration: TEN_SECONDS,
message: `Test Alert sent to ${endpoint}. If the Alert does not reach its destination, please check your endpoint configuration settings.`, message: `Test Alert sent to ${endpoint}. If the Alert does not reach its destination, please check your endpoint configuration settings.`,
}) })
export const NOTIFY_TEST_ALERT_FAILED = (endpoint, errorMessage) => ({ export const notifyTestAlertFailed = (endpoint, errorMessage) => ({
...defaultErrorNotification, ...defaultErrorNotification,
message: `There was an error sending a Test Alert to ${endpoint}${ message: `There was an error sending a Test Alert to ${endpoint}${
errorMessage ? `: ${errorMessage}` : '.' errorMessage ? `: ${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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
export const NOTIFY_TICKSCRIPT_CREATED = { export const notifyTickScriptCreated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'TICKscript successfully created.', message: 'TICKscript successfully created.',
} })
export const NOTIFY_TICKSCRIPT_CREATION_FAILED = 'Failed to create TICKscript.' export const notifyTickscriptCreationFailed = () =>
'Failed to create TICKscript.'
export const NOTIFY_TICKSCRIPT_UPDATED = { export const notifyTickscriptUpdated = () => ({
...defaultSuccessNotification, ...defaultSuccessNotification,
message: 'TICKscript successfully updated.', message: 'TICKscript successfully updated.',
} })
export const NOTIFY_TICKSCRIPT_UPDATE_FAILED = 'Failed to update TICKscript.' export const notifyTickscriptUpdateFailed = () => 'Failed to update TICKscript.'
export const NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE = { export const notifyTickscriptLoggingUnavailable = () => ({
type: 'warning', type: 'warning',
icon: 'alert-triangle', icon: 'alert-triangle',
duration: INFINITE, duration: INFINITE,
message: 'Kapacitor version 1.4 required to view TICKscript logs', message: 'Kapacitor version 1.4 required to view TICKscript logs',
} })
export const NOTIFY_TICKSCRIPT_LOGGING_ERROR = message => ({ export const notifyTickscriptLoggingError = message => ({
...defaultErrorNotification, ...defaultErrorNotification,
message, message,
}) })
export const NOTIFY_KAPACITOR_NOT_FOUND = export const notifyKapacitorNotFound = () =>
'We could not find a Kapacitor configuration for this source.' 'We could not find a Kapacitor configuration for this source.'

View File

@ -1,8 +1,8 @@
import {notify} from 'shared/actions/notifications' import {notify} from 'shared/actions/notifications'
import {delayEnablePresentationMode} from 'shared/actions/app' import {delayEnablePresentationMode} from 'shared/actions/app'
import {NOTIFY_PRESENTATION_MODE} from 'shared/copy/notifications' import {notifyPresentationMode} from 'shared/copy/notifications'
export const presentationButtonDispatcher = dispatch => () => { export const presentationButtonDispatcher = dispatch => () => {
dispatch(delayEnablePresentationMode()) dispatch(delayEnablePresentationMode())
dispatch(notify(NOTIFY_PRESENTATION_MODE)) dispatch(notify(notifyPresentationMode()))
} }

View File

@ -5,11 +5,10 @@ import {notify} from 'shared/actions/notifications'
import {HTTP_FORBIDDEN} from 'shared/constants' import {HTTP_FORBIDDEN} from 'shared/constants'
import { import {
NOTIFY_SESSION_TIMED_OUT, notifySessionTimedOut,
NOTIFY_ERR_WITH_ALT_TEXT, notifyErrorWithAltText,
NOTIFY_NEW_VERSION, notifyOrgIsPrivate,
NOTIFY_ORG_IS_PRIVATE, notifyCurrentOrgDeleted,
NOTIFY_CURRENT_ORG_DELETED,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
const actionsAllowedDuringBlackout = [ const actionsAllowedDuringBlackout = [
@ -42,22 +41,18 @@ const errorsMiddleware = store => next => action => {
message === message ===
`This organization is private. To gain access, you must be explicitly added by an administrator.` // eslint-disable-line quotes `This organization is private. To gain access, you must be explicitly added by an administrator.` // eslint-disable-line quotes
) { ) {
store.dispatch(notify(NOTIFY_ORG_IS_PRIVATE)) store.dispatch(notify(notifyOrgIsPrivate()))
}
if (_.startsWith(message, 'Welcome to Chronograf')) {
store.dispatch(notify(NOTIFY_NEW_VERSION(message)))
} }
if (organizationWasRemoved) { if (organizationWasRemoved) {
store.dispatch(notify(NOTIFY_CURRENT_ORG_DELETED)) store.dispatch(notify(notifyCurrentOrgDeleted()))
allowNotifications = false allowNotifications = false
setTimeout(() => { setTimeout(() => {
allowNotifications = true allowNotifications = true
}, notificationsBlackoutDuration) }, notificationsBlackoutDuration)
} else if (wasSessionTimeout) { } else if (wasSessionTimeout) {
store.dispatch(notify(NOTIFY_SESSION_TIMED_OUT)) store.dispatch(notify(notifySessionTimedOut()))
allowNotifications = false allowNotifications = false
setTimeout(() => { setTimeout(() => {
@ -65,7 +60,7 @@ const errorsMiddleware = store => next => action => {
}, notificationsBlackoutDuration) }, notificationsBlackoutDuration)
} }
} else if (altText) { } else if (altText) {
store.dispatch(notify(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText))) store.dispatch(notify(notifyErrorWithAltText(alertType, altText)))
} else { } else {
// TODO: actually do proper error handling // TODO: actually do proper error handling
// store.dispatch(notify({type: alertType, 'Cannot communicate with server.')) // store.dispatch(notify({type: alertType, 'Cannot communicate with server.'))

View File

@ -16,8 +16,8 @@ import SourceIndicator from 'shared/components/SourceIndicator'
import InfluxTable from 'src/sources/components/InfluxTable' import InfluxTable from 'src/sources/components/InfluxTable'
import { import {
NOTIFY_SOURCE_DELETED, notifySourceDeleted,
NOTIFY_SOURCE_DELETE_FAILED, notifySourceDeleteFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
const V_NUMBER = VERSION // eslint-disable-line no-undef const V_NUMBER = VERSION // eslint-disable-line no-undef
@ -46,9 +46,9 @@ class ManageSources extends Component {
try { try {
this.props.removeAndLoadSources(source) this.props.removeAndLoadSources(source)
notify(NOTIFY_SOURCE_DELETED(source.name)) notify(notifySourceDeleted(source.name))
} catch (e) { } catch (e) {
notify(NOTIFY_SOURCE_DELETE_FAILED(source.name)) notify(notifySourceDeleteFailed(source.name))
} }
} }

View File

@ -20,11 +20,11 @@ import {DEFAULT_SOURCE} from 'shared/constants'
const initialPath = '/sources/new' const initialPath = '/sources/new'
import { import {
NOTIFY_ERROR_CONNECTING_TO_SOURCE, notifyErrorConnectingToSource,
NOTIFY_SOURCE_CREATION_SUCCEEDED, notifySourceCreationSucceeded,
NOTIFY_SOURCE_CREATION_FAILED, notifySourceCreationFailed,
NOTIFY_SOURCE_UPDATED, notifySourceUdpated,
NOTIFY_SOURCE_UPDATE_FAILED, notifySourceUdpateFailed,
} from 'shared/copy/notifications' } from 'shared/copy/notifications'
class SourcePage extends Component { class SourcePage extends Component {
@ -55,7 +55,7 @@ class SourcePage extends Component {
}) })
}) })
.catch(error => { .catch(error => {
notify(NOTIFY_ERROR_CONNECTING_TO_SOURCE(this._parseError(error))) notify(notifyErrorConnectingToSource(this._parseError(error)))
this.setState({isLoading: false}) this.setState({isLoading: false})
}) })
} }
@ -145,12 +145,10 @@ class SourcePage extends Component {
.then(({data: sourceFromServer}) => { .then(({data: sourceFromServer}) => {
this.props.addSource(sourceFromServer) this.props.addSource(sourceFromServer)
this._redirect(sourceFromServer) this._redirect(sourceFromServer)
notify(NOTIFY_SOURCE_CREATION_SUCCEEDED(source.name)) notify(notifySourceCreationSucceeded(source.name))
}) })
.catch(error => { .catch(error => {
notify( notify(notifySourceCreationFailed(source.name, this._parseError(error)))
NOTIFY_SOURCE_CREATION_FAILED(source.name, this._parseError(error))
)
}) })
} }
@ -161,12 +159,10 @@ class SourcePage extends Component {
.then(({data: sourceFromServer}) => { .then(({data: sourceFromServer}) => {
this.props.updateSource(sourceFromServer) this.props.updateSource(sourceFromServer)
this._redirect(sourceFromServer) this._redirect(sourceFromServer)
notify(NOTIFY_SOURCE_UPDATED(source.name)) notify(notifySourceUdpated(source.name))
}) })
.catch(error => { .catch(error => {
notify( notify(notifySourceUdpateFailed(source.name, this._parseError(error)))
NOTIFY_SOURCE_UPDATE_FAILED(source.name, this._parseError(error))
)
}) })
} }

View File

@ -3,7 +3,8 @@ import he from 'he'
import {fetchJSONFeed as fetchJSONFeedAJAX} from 'src/status/apis' import {fetchJSONFeed as fetchJSONFeedAJAX} from 'src/status/apis'
import {errorThrown} from 'shared/actions/errors' import {notify} from 'src/shared/actions/notifications'
import {notifyJSONFeedFailed} from 'src/shared/copy/notifications'
import * as actionTypes from 'src/status/constants/actionTypes' import * as actionTypes from 'src/status/constants/actionTypes'
@ -43,11 +44,6 @@ export const fetchJSONFeedAsync = url => async dispatch => {
} catch (error) { } catch (error) {
console.error(error) console.error(error)
dispatch(fetchJSONFeedFailed()) dispatch(fetchJSONFeedFailed())
dispatch( dispatch(notify(notifyJSONFeedFailed(url)))
errorThrown(
error,
`Failed to fetch JSON Feed for News Feed from '${url}'`
)
)
} }
} }