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 {
NOTIFY_SOURCE_NO_LONGER_AVAILABLE,
NOTIFY_NO_SOURCES_AVAILABLE,
NOTIFY_UNABLE_TO_RETRIEVE_SOURCES,
NOTIFY_USER_REMOVED_FROM_ALL_ORGS,
NOTIFY_USER_REMOVED_FROM_CURRENT_ORG,
NOTIFY_ORG_HAS_NO_SOURCES,
notifySourceNoLongerAvailable,
notifyNoSourcesAvailable,
notifyUnableToRetrieveSources,
notifyUserRemovedFromAllOrgs,
notifyUserRemovedFromCurrentOrg,
notifyOrgHasNoSources,
} from 'shared/copy/notifications'
// 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) {
notify(NOTIFY_USER_REMOVED_FROM_ALL_ORGS)
notify(notifyUserRemovedFromAllOrgs())
return router.push('/purgatory')
}
@ -101,7 +101,7 @@ class CheckSources extends Component {
me.superAdmin &&
!organizations.find(o => o.id === currentOrganization.id)
) {
notify(NOTIFY_USER_REMOVED_FROM_CURRENT_ORG)
notify(notifyUserRemovedFromCurrentOrg())
return router.push('/purgatory')
}
@ -123,7 +123,7 @@ class CheckSources extends Component {
return router.push(`/sources/${sources[0].id}/${restString}`)
}
// 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')
}
@ -148,12 +148,12 @@ class CheckSources extends Component {
try {
const newSources = await getSources()
if (newSources.length) {
errorThrown(error, NOTIFY_SOURCE_NO_LONGER_AVAILABLE(source.name))
errorThrown(error, notifySourceNoLongerAvailable(source.name))
} else {
errorThrown(error, NOTIFY_NO_SOURCES_AVAILABLE(source.name))
errorThrown(error, notifyNoSourcesAvailable(source.name))
}
} 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 {errorThrown} from 'shared/actions/errors'
import {
NOTIFY_MAPPING_DELETED,
NOTIFY_CHRONOGRAF_ORG_DELETED,
NOTIFY_CHRONOGRAF_USER_UPDATED,
NOTIFY_CHRONOGRAF_USER_DELETED,
notifyMappingDeleted,
notifyChronografOrgDeleted,
notifyChronografUserUpdated,
notifyChronografUserDeleted,
} from 'shared/copy/notifications'
import {REVERT_STATE_DELAY} from 'shared/constants'
@ -183,7 +183,7 @@ export const deleteMappingAsync = mapping => async dispatch => {
dispatch(removeMapping(mapping))
try {
await deleteMappingAJAX(mapping)
dispatch(notify(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme)))
dispatch(notify(notifyMappingDeleted(mapping.id, mapping.scheme)))
} catch (error) {
dispatch(errorThrown(error))
dispatch(addMapping(mapping))
@ -239,7 +239,7 @@ export const updateUserAsync = (
provider: 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
// measure and for the clarity of insight in the redux story
dispatch(syncUser(user, data))
@ -256,9 +256,7 @@ export const deleteUserAsync = (
dispatch(removeUser(user))
try {
await deleteUserAJAX(user)
dispatch(
notify(NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete))
)
dispatch(notify(notifyChronografUserDeleted(user.name, isAbsoluteDelete)))
} catch (error) {
dispatch(errorThrown(error))
dispatch(addUser(user))
@ -309,7 +307,7 @@ export const deleteOrganizationAsync = organization => async dispatch => {
dispatch(removeOrganization(organization))
try {
await deleteOrganizationAJAX(organization)
dispatch(notify(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name)))
dispatch(notify(notifyChronografOrgDeleted(organization.name)))
} catch (error) {
dispatch(errorThrown(error))
dispatch(addOrganization(organization))

View File

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

View File

@ -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
}

View File

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

View File

@ -17,8 +17,8 @@ const {
} = ALL_USERS_TABLE
import {
NOTIFY_CHRONOGRAF_USER_ADDED_TO_ORG,
NOTIFY_CHRONOGRAF_USER_REMOVED_FROM_ORG,
notifyChronografUserAddedToOrg,
notifyChronografUserRemovedFromOrg,
} from 'shared/copy/notifications'
class AllUsersTable extends Component {
@ -52,7 +52,7 @@ class AllUsersTable extends Component {
this.props.onUpdateUserRoles(
user,
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(
user,
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 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'
const {
colOrganizations,
@ -83,9 +83,7 @@ class AllUsersTableRowNew extends Component {
if (e.key === 'Enter') {
if (preventCreate) {
return this.props.notify(
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
return this.props.notify(notifyChronografUserMissingNameAndProvider())
}
this.handleConfirmCreateUser()
}

View File

@ -7,7 +7,7 @@ import {notify as notifyAction} from 'shared/actions/notifications'
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 {USER_ROLES} from 'src/admin/constants/chronografAdmin'
@ -65,9 +65,7 @@ class UsersTableRowNew extends Component {
if (e.key === 'Enter') {
if (preventCreate) {
return this.props.notify(
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
return this.props.notify(notifyChronografUserMissingNameAndProvider())
}
this.handleConfirmCreateUser()
}

View File

@ -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) {

View File

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

View File

@ -12,7 +12,7 @@ import QueriesTable from 'src/admin/components/QueriesTable'
import showDatabasesParser from 'shared/parsing/showDatabases'
import showQueriesParser from 'shared/parsing/showQueries'
import {TIMES} from 'src/admin/constants'
import {NOTIFY_QUERIES_ERROR} from 'shared/copy/notifications'
import {notifyQueriesError} from 'shared/copy/notifications'
import {
loadQueries as loadQueriesAction,
@ -44,7 +44,7 @@ class QueriesPage extends Component {
showDatabases(source.links.proxy).then(resp => {
const {databases, errors} = showDatabasesParser(resp.data)
if (errors.length) {
errors.forEach(message => notify(NOTIFY_QUERIES_ERROR(message)))
errors.forEach(message => notify(notifyQueriesError(message)))
return
}
@ -56,7 +56,7 @@ class QueriesPage extends Component {
const result = showQueriesParser(queryResponse.data)
if (result.errors.length) {
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 {
NOTIFY_DASHBOARD_DELETED,
NOTIFY_DASHBOARD_DELETE_FAILED,
notifyDashboardDeleted,
notifyDashboardDeleteFailed,
} from 'shared/copy/notifications'
import {
@ -261,12 +261,12 @@ export const deleteDashboardAsync = dashboard => async dispatch => {
dispatch(deleteDashboard(dashboard))
try {
await deleteDashboardAJAX(dashboard)
dispatch(notify(NOTIFY_DASHBOARD_DELETED(dashboard.name)))
dispatch(notify(notifyDashboardDeleted(dashboard.name)))
} catch (error) {
dispatch(
errorThrown(
error,
NOTIFY_DASHBOARD_DELETE_FAILED(dashboard.name, error.data.message)
notifyDashboardDeleteFailed(dashboard.name, error.data.message)
)
)
dispatch(deleteDashboardFailed(dashboard))

View File

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

View File

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

View File

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

View File

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

View File

@ -39,6 +39,7 @@ import {getMeAsync} from 'shared/actions/auth'
import {disablePresentationMode} from 'shared/actions/app'
import {errorThrown} from 'shared/actions/errors'
import {notify} from 'shared/actions/notifications'
import 'src/style/chronograf.scss'
@ -114,8 +115,12 @@ const Root = React.createClass({
flushErrorsQueue() {
if (errorsQueue.length) {
errorsQueue.forEach(errorText => {
dispatch(errorThrown({status: 0, auth: null}, errorText, 'warning'))
errorsQueue.forEach(error => {
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 {
NOTIFY_ALERT_RULE_DELETED,
NOTIFY_ALERT_RULE_DELETION_FAILED,
NOTIFY_ALERT_RULE_STATUS_UPDATED,
NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED,
NOTIFY_TICKSCRIPT_CREATED,
NOTIFY_TICKSCRIPT_CREATION_FAILED,
NOTIFY_TICKSCRIPT_UPDATED,
NOTIFY_TICKSCRIPT_UPDATE_FAILED,
notifyAlertRuleDeleted,
notifyAlertRuleDeleteFailed,
notifyAlertRuleStatusUpdated,
notifyAlertRuleStatusUpdateFailed,
notifyTickScriptCreated,
notifyTickscriptCreationFailed,
notifyTickscriptUpdated,
notifyTickscriptUpdateFailed,
} from 'shared/copy/notifications'
const loadQuery = query => ({
@ -181,33 +181,31 @@ export const deleteRule = rule => dispatch => {
deleteRuleAPI(rule)
.then(() => {
dispatch(deleteRuleSuccess(rule.id))
dispatch(notify(NOTIFY_ALERT_RULE_DELETED(rule.name)))
dispatch(notify(notifyAlertRuleDeleted(rule.name)))
})
.catch(() => {
dispatch(notify(NOTIFY_ALERT_RULE_DELETION_FAILED(rule.name)))
dispatch(notify(notifyAlertRuleDeleteFailed(rule.name)))
})
}
export const updateRuleStatus = (rule, status) => dispatch => {
updateRuleStatusAPI(rule, status)
.then(() => {
dispatch(notify(NOTIFY_ALERT_RULE_STATUS_UPDATED(rule.name, status)))
dispatch(notify(notifyAlertRuleStatusUpdated(rule.name, status)))
})
.catch(() => {
dispatch(
notify(NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status))
)
dispatch(notify(notifyAlertRuleStatusUpdateFailed(rule.name, status)))
})
}
export const createTask = (kapacitor, task) => async dispatch => {
try {
const {data} = await createTaskAJAX(kapacitor, task)
dispatch(notify(NOTIFY_TICKSCRIPT_CREATED))
dispatch(notify(notifyTickScriptCreated()))
return data
} catch (error) {
if (!error) {
dispatch(errorThrown(NOTIFY_TICKSCRIPT_CREATION_FAILED))
dispatch(errorThrown(notifyTickscriptCreationFailed()))
return
}
@ -223,11 +221,11 @@ export const updateTask = (
) => async dispatch => {
try {
const {data} = await updateTaskAJAX(kapacitor, task, ruleID, sourceID)
dispatch(notify(NOTIFY_TICKSCRIPT_UPDATED))
dispatch(notify(notifyTickscriptUpdated()))
return data
} catch (error) {
if (!error) {
dispatch(errorThrown(NOTIFY_TICKSCRIPT_UPDATE_FAILED))
dispatch(errorThrown(notifyTickscriptUpdateFailed()))
return
}
return error.data

View File

@ -25,11 +25,11 @@ import {
} from './config'
import {
NOTIFY_REFRESH_KAPACITOR_FAILED,
NOTIFY_ALERT_ENDPOINT_SAVED,
NOTIFY_ALERT_ENDPOINT_SAVE_FAILED,
NOTIFY_TEST_ALERT_SENT,
NOTIFY_TEST_ALERT_FAILED,
notifyRefreshKapacitorFailed,
notifyAlertEndpointSaved,
notifyAlertEndpointSaveFailed,
notifyTestAlertSent,
notifyTestAlertFailed,
} from 'shared/copy/notifications'
class AlertTabs extends Component {
@ -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())
}
}
@ -87,11 +87,11 @@ class AlertTabs extends Component {
propsToSend
)
this.refreshKapacitorConfig(this.props.kapacitor)
this.props.notify(NOTIFY_ALERT_ENDPOINT_SAVED(section))
this.props.notify(notifyAlertEndpointSaved(section))
return true
} catch ({data: {error}}) {
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
}
}
@ -103,12 +103,12 @@ class AlertTabs extends Component {
try {
const {data} = await testAlertOutput(this.props.kapacitor, section)
if (data.success) {
this.props.notify(NOTIFY_TEST_ALERT_SENT(section))
this.props.notify(notifyTestAlertSent(section))
} else {
this.props.notify(NOTIFY_TEST_ALERT_FAILED(section, data.message))
this.props.notify(notifyTestAlertFailed(section, data.message))
}
} 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_ALERT_RULE_CREATED,
NOTIFY_ALERT_RULE_CREATION_FAILED,
NOTIFY_ALERT_RULE_UPDATED,
NOTIFY_ALERT_RULE_UPDATE_FAILED,
NOTIFY_ALERT_RULE_REQUIRES_QUERY,
NOTIFY_ALERT_RULE_REQUIRES_CONDITION_VALUE,
NOTIFY_ALERT_RULE_DEADMAN_INVALID,
notifyAlertRuleCreated,
notifyAlertRuleCreateFailed,
notifyAlertRuleUpdated,
notifyAlertRuleUpdateFailed,
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())
})
}
@ -66,10 +66,10 @@ class KapacitorRule extends Component {
editRule(updatedRule)
.then(() => {
router.push(pathname || `/sources/${source.id}/alert-rules`)
notify(NOTIFY_ALERT_RULE_UPDATED(rule.name))
notify(notifyAlertRuleUpdated(rule.name))
})
.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)) {
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 ''

View File

@ -17,12 +17,12 @@ import {
import KapacitorForm from '../components/KapacitorForm'
import {
NOTIFY_KAPACITOR_CONNECTION_FAILED,
NOTIFY_KAPACITOR_CREATED,
NOTIFY_KAPACITOR_CREATION_FAILED,
NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN,
NOTIFY_KAPACITOR_UPDATE_FAILED,
NOTIFY_KAPACITOR_UPDATED,
notifyKapacitorConnectionFailed,
notifyKapacitorCreated,
notifyKapacitorCreateFailed,
notifyKapacitorNameAlreadyTaken,
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())
}
}
@ -131,7 +131,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
const isNew = !params.id
if (isNew && isNameTaken) {
notify(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN)
notify(notifyKapacitorNameAlreadyTaken)
return
}
@ -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())
}
}

View File

@ -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
}

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import {getLinksAsync} from 'shared/actions/links'
import {notify} from 'shared/actions/notifications'
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 => ({
type: 'AUTH_EXPIRED',
@ -93,7 +93,7 @@ export const meChangeOrganizationAsync = (
)
dispatch(
notify(
NOTIFY_USER_SWITCHED_ORGS(me.currentOrganization.name, currentRole.name)
notifyUserSwitchedOrgs(me.currentOrganization.name, currentRole.name)
)
)
dispatch(meChangeOrganizationCompleted())

View File

@ -10,9 +10,9 @@ import {errorThrown} from 'shared/actions/errors'
import {HTTP_NOT_FOUND} from 'shared/constants'
import {
NOTIFY_SERVER_ERROR,
NOTIFY_COULD_NOT_RETRIEVE_KAPACITORS,
NOTIFY_COULD_NOT_DELETE_KAPACITOR,
notifyServerError,
notifyCouldNotRetrieveKapacitors,
notifyCouldNotDeleteKapacitor,
} from 'shared/copy/notifications'
export const loadSources = sources => ({
@ -76,7 +76,7 @@ export const removeAndLoadSources = source => async dispatch => {
const {data: {sources: newSources}} = await getSourcesAJAX()
dispatch(loadSources(newSources))
} 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)
dispatch(fetchKapacitors(source, data.kapacitors))
} 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)
dispatch(deleteKapacitor(kapacitor))
} 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 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 download from 'src/external/download.js'
@ -25,7 +26,7 @@ class LayoutCell extends Component {
try {
download(dashboardtoCSV(celldata), `${joinedName}.csv`, 'text/plain')
} catch (error) {
errorThrown(error, 'Unable to download .csv file')
notify(notifyCSVDownloadFailed())
console.error(error)
}
}

View File

@ -17,184 +17,204 @@ const defaultSuccessNotification = {
// 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',
icon: 'cubo-uniform',
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,
icon: 'triangle',
duration: TEN_SECONDS,
message,
})
export const NOTIFY_PRESENTATION_MODE = {
export const notifyPresentationMode = () => ({
type: 'primary',
icon: 'expand-b',
duration: 7500,
message: 'Press ESC to exit Presentation Mode.',
}
})
export const NOTIFY_DATA_WRITTEN = {
export const notifyDataWritten = () => ({
...defaultSuccessNotification,
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',
icon: 'triangle',
duration: INFINITE,
message: 'Your session has timed out. Log in again to continue.',
}
})
export const NOTIFY_SERVER_ERROR = {
export const notifyServerError = () => ({
...defaultErrorNotification,
mesasage: 'Internal Server Error. Check API Logs.',
}
})
export const NOTIFY_COULD_NOT_RETRIEVE_KAPACITORS = sourceID => ({
export const notifyCouldNotRetrieveKapacitors = sourceID => ({
...defaultErrorNotification,
mesasage: `Internal Server Error. Could not retrieve Kapacitor Connections for source ${sourceID}.`,
})
export const NOTIFY_COULD_NOT_DELETE_KAPACITOR = {
export const notifyCouldNotDeleteKapacitor = () => ({
...defaultErrorNotification,
message: 'Internal Server Error. Could not delete Kapacitor Connection.',
}
})
export const notifyCSVDownloadFailed = () => ({
...defaultErrorNotification,
message: 'Unable to download .CSV file',
})
// Hosts Page Notifications
// ----------------------------------------------------------------------------
export const NOTIFY_UNABLE_TO_GET_HOSTS = {
export const notifyUnableToGetHosts = () => ({
...defaultErrorNotification,
message: 'Unable to get Hosts.',
}
})
export const NOTIFY_UNABLE_TO_GET_APPS = {
export const notifyUnableToGetApps = () => ({
...defaultErrorNotification,
message: 'Unable to get Apps for Hosts.',
}
})
// InfluxDB Sources Notifications
// ----------------------------------------------------------------------------
export const NOTIFY_SOURCE_CREATION_SUCCEEDED = sourceName => ({
export const notifySourceCreationSucceeded = sourceName => ({
...defaultSuccessNotification,
icon: 'server2',
message: `Connected to InfluxDB ${sourceName} successfully.`,
})
export const NOTIFY_SOURCE_CREATION_FAILED = (sourceName, errorMessage) => ({
export const notifySourceCreationFailed = (sourceName, errorMessage) => ({
...defaultErrorNotification,
icon: 'server2',
message: `Unable to connect to InfluxDB ${sourceName}: ${errorMessage}`,
})
export const NOTIFY_SOURCE_UPDATED = sourceName => ({
export const notifySourceUdpated = sourceName => ({
...defaultSuccessNotification,
icon: 'server2',
message: `Updated InfluxDB ${sourceName} Connection successfully.`,
})
export const NOTIFY_SOURCE_UPDATE_FAILED = (sourceName, errorMessage) => ({
export const notifySourceUdpateFailed = (sourceName, errorMessage) => ({
...defaultErrorNotification,
icon: 'server2',
message: `Failed to update InfluxDB ${sourceName} Connection: ${errorMessage}`,
})
export const NOTIFY_SOURCE_DELETED = sourceName => ({
export const notifySourceDeleted = sourceName => ({
...defaultSuccessNotification,
icon: 'server2',
message: `${sourceName} deleted successfully.`,
})
export const NOTIFY_SOURCE_DELETE_FAILED = sourceName => ({
export const notifySourceDeleteFailed = sourceName => ({
...defaultErrorNotification,
icon: 'server2',
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.`
export const NOTIFY_NO_SOURCES_AVAILABLE = sourceName =>
export const notifyNoSourcesAvailable = sourceName =>
`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}.`
export const NOTIFY_ERROR_CONNECTING_TO_SOURCE = errorMessage =>
export const notifyErrorConnectingToSource = errorMessage =>
`Unable to connect to InfluxDB source: ${errorMessage}`
// Multitenancy User Notifications
// ----------------------------------------------------------------------------
export const NOTIFY_USER_REMOVED_FROM_ALL_ORGS = {
export const notifyUserRemovedFromAllOrgs = () => ({
...defaultErrorNotification,
duration: INFINITE,
message:
'You have been removed from all organizations. Please contact your administrator.',
}
})
export const NOTIFY_USER_REMOVED_FROM_CURRENT_ORG = {
export const notifyUserRemovedFromCurrentOrg = () => ({
...defaultErrorNotification,
duration: INFINITE,
message: 'You were removed from your current organization.',
}
})
export const NOTIFY_ORG_HAS_NO_SOURCES = {
export const notifyOrgHasNoSources = () => ({
...defaultErrorNotification,
duration: INFINITE,
message: 'Organization has no sources configured.',
}
})
export const NOTIFY_USER_SWITCHED_ORGS = (orgName, roleName) => ({
export const notifyUserSwitchedOrgs = (orgName, roleName) => ({
...defaultSuccessNotification,
type: 'primary',
message: `Now logged in to '${orgName}' as '${roleName}'.`,
})
export const NOTIFY_ORG_IS_PRIVATE = {
export const notifyOrgIsPrivate = () => ({
...defaultErrorNotification,
duration: INFINITE,
message:
'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,
duration: INFINITE,
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
// ----------------------------------------------------------------------------
export const NOTIFY_MAPPING_DELETED = (id, scheme) => ({
export const notifyMappingDeleted = (id, scheme) => ({
...defaultSuccessNotification,
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.`
export const NOTIFY_CHRONOGRAF_USER_REMOVED_FROM_ORG = (user, organization) =>
export const notifyChronografUserRemovedFromOrg = (user, organization) =>
`${user} has been removed from ${organization} successfully.`
export const NOTIFY_CHRONOGRAF_USER_UPDATED = message => ({
export const notifyChronografUserUpdated = message => ({
...defaultSuccessNotification,
message,
})
export const NOTIFY_CHRONOGRAF_ORG_DELETED = orgName => ({
export const notifyChronografOrgDeleted = orgName => ({
...defaultSuccessNotification,
message: `Organization ${orgName} deleted successfully.`,
})
export const NOTIFY_CHRONOGRAF_USER_DELETED = (user, isAbsoluteDelete) => ({
export const notifyChronografUserDeleted = (user, isAbsoluteDelete) => ({
...defaultSuccessNotification,
message: `${user} has been removed from ${
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,
type: 'warning',
message: 'User must have a Name and Provider.',
}
})
// InfluxDB Admin Notifications
// ----------------------------------------------------------------------------
export const NOTIFY_DB_USER_CREATED = {
export const notifyDBUserCreated = () => ({
...defaultSuccessNotification,
message: 'User created successfully.',
}
})
export const NOTIFY_DB_USER_CREATION_FAILED = errorMessage =>
export const notifyDBUserCreationFailed = errorMessage =>
`Failed to create User: ${errorMessage}`
export const NOTIFY_DB_USER_DELETED = userName => ({
export const notifyDBUserDeleted = userName => ({
...defaultSuccessNotification,
message: `User "${userName}" deleted successfully.`,
})
export const NOTIFY_DB_USER_DELETION_FAILED = errorMessage =>
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 NOTIFY_DB_USER_PERMISSIONS_UPDATE_FAILED = errorMessage =>
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 NOTIFY_DB_USER_ROLES_UPDATE_FAILED = errorMessage =>
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 NOTIFY_DB_USER_PASSWORD_UPDATE_FAILED = errorMessage =>
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 NOTIFY_DATABASE_CREATION_FAILED = errorMessage =>
export const notifyDBCreationFailed = errorMessage =>
`Failed to create Database: ${errorMessage}`
export const NOTIFY_DATABASE_DELETED = databaseName => ({
export const notifyDBDeleted = databaseName => ({
...defaultSuccessNotification,
message: `Database "${databaseName}" deleted successfully.`,
})
export const NOTIFY_DATABASE_DELETION_FAILED = errorMessage =>
export const notifyDBDeleteFailed = errorMessage =>
`Failed to delete Database: ${errorMessage}`
export const NOTIFY_ROLE_CREATED = {
export const notifyRoleCreated = () => ({
...defaultSuccessNotification,
message: 'Role created successfully.',
}
})
export const NOTIFY_ROLE_CREATION_FAILED = errorMessage =>
export const notifyRoleCreationFailed = errorMessage =>
`Failed to create Role: ${errorMessage}`
export const NOTIFY_ROLE_DELETED = roleName => ({
export const notifyRoleDeleted = roleName => ({
...defaultSuccessNotification,
message: `Role "${roleName}" deleted successfully.`,
})
export const NOTIFY_ROLE_DELETION_FAILED = errorMessage =>
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 NOTIFY_ROLE_USERS_UPDATE_FAILED = errorMessage =>
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 NOTIFY_ROLE_PERMISSIONS_UPDATE_FAILED = errorMessage =>
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 NOTIFY_RETENTION_POLICY_CREATION_FAILED = errorMessage =>
export const notifyRetentionPolicyCreationFailed = errorMessage =>
`Failed to create Retention Policy: ${errorMessage}`
export const NOTIFY_RETENTION_POLICY_DELETED = rpName => ({
export const notifyRetentionPolicyDeleted = rpName => ({
...defaultSuccessNotification,
message: `Retention Policy "${rpName}" deleted successfully.`,
})
export const NOTIFY_RETENTION_POLICY_DELETION_FAILED = errorMessage =>
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 NOTIFY_RETENTION_POLICY_UPDATE_FAILED = errorMessage =>
export const notifyRetentionPolicyUpdateFailed = errorMessage =>
`Failed to update Retention Policy: ${errorMessage}`
export const NOTIFY_QUERIES_ERROR = errorMessage => ({
export const notifyQueriesError = errorMessage => ({
...defaultErrorNotification,
errorMessage,
})
export const NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS = {
export const notifyRetentionPolicyCantHaveEmptyFields = () => ({
...defaultErrorNotification,
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,
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
// ----------------------------------------------------------------------------
export const NOTIFY_TEMP_VAR_ALREADY_EXISTS = tempVarName => ({
export const notifyTempVarAlreadyExists = tempVarName => ({
...defaultErrorNotification,
icon: 'cube',
message: `Variable '${tempVarName}' already exists. Please enter a new value.`,
})
export const NOTIFY_DASHBOARD_NOT_FOUND = dashboardID => ({
export const notifyDashboardNotFound = dashboardID => ({
...defaultErrorNotification,
icon: 'dash-h',
message: `Dashboard ${dashboardID} could not be found`,
})
export const NOTIFY_DASHBOARD_DELETED = name => ({
export const notifyDashboardDeleted = name => ({
...defaultSuccessNotification,
icon: 'dash-h',
message: `Dashboard ${name} deleted successfully.`,
})
export const NOTIFY_DASHBOARD_DELETE_FAILED = (name, errorMessage) =>
export const notifyDashboardDeleteFailed = (name, errorMessage) =>
`Failed to delete Dashboard ${name}: ${errorMessage}.`
// Rule Builder Notifications
// ----------------------------------------------------------------------------
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 NOTIFY_ALERT_RULE_UPDATED = ruleName => ({
export const notifyAlertRuleUpdated = ruleName => ({
...defaultSuccessNotification,
message: `${ruleName} saved successfully.`,
})
export const NOTIFY_ALERT_RULE_UPDATE_FAILED = (ruleName, errorMessage) => ({
export const notifyAlertRuleUpdateFailed = (ruleName, errorMessage) => ({
...defaultErrorNotification,
message: `There was a problem saving ${ruleName}: ${errorMessage}`,
})
export const NOTIFY_ALERT_RULE_DELETED = ruleName => ({
export const notifyAlertRuleDeleted = ruleName => ({
...defaultSuccessNotification,
message: `${ruleName} deleted successfully.`,
})
export const NOTIFY_ALERT_RULE_DELETION_FAILED = ruleName => ({
export const notifyAlertRuleDeleteFailed = ruleName => ({
...defaultErrorNotification,
message: `${ruleName} could not be deleted.`,
})
export const NOTIFY_ALERT_RULE_STATUS_UPDATED = (ruleName, updatedStatus) => ({
export const notifyAlertRuleStatusUpdated = (ruleName, updatedStatus) => ({
...defaultSuccessNotification,
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
// ----------------------------------------------------------------------------
export const NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN = kapacitorName => ({
export const notifyKapacitorNameAlreadyTaken = kapacitorName => ({
...defaultErrorNotification,
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 NOTIFY_ALERT_ENDPOINT_SAVED = endpoint => ({
export const notifyAlertEndpointSaved = endpoint => ({
...defaultSuccessNotification,
message: `Alert configuration for ${endpoint} saved successfully.`,
})
export const NOTIFY_ALERT_ENDPOINT_SAVE_FAILED = (endpoint, errorMessage) => ({
export const notifyAlertEndpointSaveFailed = (endpoint, errorMessage) => ({
...defaultErrorNotification,
message: `There was an error saving the alert configuration for ${endpoint}: ${errorMessage}`,
})
export const NOTIFY_TEST_ALERT_SENT = endpoint => ({
export const notifyTestAlertSent = endpoint => ({
...defaultSuccessNotification,
duration: TEN_SECONDS,
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,
message: `There was an error sending a Test Alert to ${endpoint}${
errorMessage ? `: ${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
// ----------------------------------------------------------------------------
export const NOTIFY_TICKSCRIPT_CREATED = {
export const notifyTickScriptCreated = () => ({
...defaultSuccessNotification,
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,
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',
icon: 'alert-triangle',
duration: INFINITE,
message: 'Kapacitor version 1.4 required to view TICKscript logs',
}
})
export const NOTIFY_TICKSCRIPT_LOGGING_ERROR = message => ({
export const notifyTickscriptLoggingError = message => ({
...defaultErrorNotification,
message,
})
export const NOTIFY_KAPACITOR_NOT_FOUND =
export const notifyKapacitorNotFound = () =>
'We could not find a Kapacitor configuration for this source.'

View File

@ -1,8 +1,8 @@
import {notify} from 'shared/actions/notifications'
import {delayEnablePresentationMode} from 'shared/actions/app'
import {NOTIFY_PRESENTATION_MODE} from 'shared/copy/notifications'
import {notifyPresentationMode} from 'shared/copy/notifications'
export const presentationButtonDispatcher = dispatch => () => {
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 {
NOTIFY_SESSION_TIMED_OUT,
NOTIFY_ERR_WITH_ALT_TEXT,
NOTIFY_NEW_VERSION,
NOTIFY_ORG_IS_PRIVATE,
NOTIFY_CURRENT_ORG_DELETED,
notifySessionTimedOut,
notifyErrorWithAltText,
notifyOrgIsPrivate,
notifyCurrentOrgDeleted,
} from 'shared/copy/notifications'
const actionsAllowedDuringBlackout = [
@ -42,22 +41,18 @@ const errorsMiddleware = store => next => action => {
message ===
`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))
}
if (_.startsWith(message, 'Welcome to Chronograf')) {
store.dispatch(notify(NOTIFY_NEW_VERSION(message)))
store.dispatch(notify(notifyOrgIsPrivate()))
}
if (organizationWasRemoved) {
store.dispatch(notify(NOTIFY_CURRENT_ORG_DELETED))
store.dispatch(notify(notifyCurrentOrgDeleted()))
allowNotifications = false
setTimeout(() => {
allowNotifications = true
}, notificationsBlackoutDuration)
} else if (wasSessionTimeout) {
store.dispatch(notify(NOTIFY_SESSION_TIMED_OUT))
store.dispatch(notify(notifySessionTimedOut()))
allowNotifications = false
setTimeout(() => {
@ -65,7 +60,7 @@ const errorsMiddleware = store => next => action => {
}, notificationsBlackoutDuration)
}
} else if (altText) {
store.dispatch(notify(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText)))
store.dispatch(notify(notifyErrorWithAltText(alertType, altText)))
} else {
// TODO: actually do proper error handling
// 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 {
NOTIFY_SOURCE_DELETED,
NOTIFY_SOURCE_DELETE_FAILED,
notifySourceDeleted,
notifySourceDeleteFailed,
} from 'shared/copy/notifications'
const V_NUMBER = VERSION // eslint-disable-line no-undef
@ -46,9 +46,9 @@ class ManageSources extends Component {
try {
this.props.removeAndLoadSources(source)
notify(NOTIFY_SOURCE_DELETED(source.name))
notify(notifySourceDeleted(source.name))
} 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'
import {
NOTIFY_ERROR_CONNECTING_TO_SOURCE,
NOTIFY_SOURCE_CREATION_SUCCEEDED,
NOTIFY_SOURCE_CREATION_FAILED,
NOTIFY_SOURCE_UPDATED,
NOTIFY_SOURCE_UPDATE_FAILED,
notifyErrorConnectingToSource,
notifySourceCreationSucceeded,
notifySourceCreationFailed,
notifySourceUdpated,
notifySourceUdpateFailed,
} from 'shared/copy/notifications'
class SourcePage extends Component {
@ -55,7 +55,7 @@ class SourcePage extends Component {
})
})
.catch(error => {
notify(NOTIFY_ERROR_CONNECTING_TO_SOURCE(this._parseError(error)))
notify(notifyErrorConnectingToSource(this._parseError(error)))
this.setState({isLoading: false})
})
}
@ -145,12 +145,10 @@ class SourcePage extends Component {
.then(({data: sourceFromServer}) => {
this.props.addSource(sourceFromServer)
this._redirect(sourceFromServer)
notify(NOTIFY_SOURCE_CREATION_SUCCEEDED(source.name))
notify(notifySourceCreationSucceeded(source.name))
})
.catch(error => {
notify(
NOTIFY_SOURCE_CREATION_FAILED(source.name, this._parseError(error))
)
notify(notifySourceCreationFailed(source.name, this._parseError(error)))
})
}
@ -161,12 +159,10 @@ class SourcePage extends Component {
.then(({data: sourceFromServer}) => {
this.props.updateSource(sourceFromServer)
this._redirect(sourceFromServer)
notify(NOTIFY_SOURCE_UPDATED(source.name))
notify(notifySourceUdpated(source.name))
})
.catch(error => {
notify(
NOTIFY_SOURCE_UPDATE_FAILED(source.name, this._parseError(error))
)
notify(notifySourceUdpateFailed(source.name, this._parseError(error)))
})
}

View File

@ -3,7 +3,8 @@ import he from 'he'
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'
@ -43,11 +44,6 @@ export const fetchJSONFeedAsync = url => async dispatch => {
} catch (error) {
console.error(error)
dispatch(fetchJSONFeedFailed())
dispatch(
errorThrown(
error,
`Failed to fetch JSON Feed for News Feed from '${url}'`
)
)
dispatch(notify(notifyJSONFeedFailed(url)))
}
}