Change publishNotification to notify

pull/2910/head
Andrew Watkins 2018-03-14 15:26:09 -07:00
parent bc41cbe459
commit 7f04f5c5e6
35 changed files with 200 additions and 245 deletions

View File

@ -15,7 +15,7 @@ import {showDatabases} from 'shared/apis/metaQuery'
import {getSourcesAsync} from 'shared/actions/sources'
import {errorThrown as errorThrownAction} from 'shared/actions/errors'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {DEFAULT_HOME_PAGE} from 'shared/constants'
import {
@ -78,7 +78,7 @@ class CheckSources extends Component {
errorThrown,
sources,
auth: {isUsingAuth, me, me: {organizations = [], currentOrganization}},
publishNotification,
notify,
getSources,
} = nextProps
const {isFetching} = nextState
@ -93,7 +93,7 @@ class CheckSources extends Component {
}
if (!isFetching && isUsingAuth && !organizations.length) {
publishNotification(NOTIFY_USER_REMOVED_FROM_ALL_ORGS)
notify(NOTIFY_USER_REMOVED_FROM_ALL_ORGS)
return router.push('/purgatory')
}
@ -101,7 +101,7 @@ class CheckSources extends Component {
me.superAdmin &&
!organizations.find(o => o.id === currentOrganization.id)
) {
publishNotification(NOTIFY_USER_REMOVED_FROM_CURRENT_ORG)
notify(NOTIFY_USER_REMOVED_FROM_CURRENT_ORG)
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.
publishNotification(NOTIFY_ORG_HAS_NO_SOURCES)
notify(NOTIFY_ORG_HAS_NO_SOURCES)
return router.push('/purgatory')
}
@ -222,7 +222,7 @@ CheckSources.propTypes = {
}),
}),
}),
publishNotification: func.isRequired,
notify: func.isRequired,
}
CheckSources.childContextTypes = {
@ -247,7 +247,7 @@ const mapStateToProps = ({sources, auth}) => ({
const mapDispatchToProps = dispatch => ({
getSources: bindActionCreators(getSourcesAsync, dispatch),
errorThrown: bindActionCreators(errorThrownAction, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(

View File

@ -16,7 +16,7 @@ import {
deleteMapping as deleteMappingAJAX,
} from 'src/admin/apis/chronograf'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors'
import {
NOTIFY_MAPPING_DELETED,
@ -183,9 +183,7 @@ export const deleteMappingAsync = mapping => async dispatch => {
dispatch(removeMapping(mapping))
try {
await deleteMappingAJAX(mapping)
dispatch(
publishNotification(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme))
)
dispatch(notify(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme)))
} catch (error) {
dispatch(errorThrown(error))
dispatch(addMapping(mapping))
@ -241,9 +239,7 @@ export const updateUserAsync = (
provider: null,
scheme: null,
})
dispatch(
publishNotification(NOTIFY_CHRONOGRAF_USER_UPDATED(successMessage))
)
dispatch(notify(NOTIFY_CHRONOGRAF_USER_UPDATED(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))
@ -261,9 +257,7 @@ export const deleteUserAsync = (
try {
await deleteUserAJAX(user)
dispatch(
publishNotification(
NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete)
)
notify(NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete))
)
} catch (error) {
dispatch(errorThrown(error))
@ -315,9 +309,7 @@ export const deleteOrganizationAsync = organization => async dispatch => {
dispatch(removeOrganization(organization))
try {
await deleteOrganizationAJAX(organization)
dispatch(
publishNotification(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name))
)
dispatch(notify(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name)))
} catch (error) {
dispatch(errorThrown(error))
dispatch(addOrganization(organization))

View File

@ -18,7 +18,7 @@ import {
import {killQuery as killQueryProxy} from 'shared/apis/metaQuery'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors'
import {
@ -307,7 +307,7 @@ export const loadDBsAndRPsAsync = url => async dispatch => {
export const createUserAsync = (url, user) => async dispatch => {
try {
const {data} = await createUserAJAX(url, user)
dispatch(publishNotification(NOTIFY_DB_USER_CREATED))
dispatch(notify(NOTIFY_DB_USER_CREATED))
dispatch(syncUser(user, data))
} catch (error) {
dispatch(
@ -321,7 +321,7 @@ export const createUserAsync = (url, user) => async dispatch => {
export const createRoleAsync = (url, role) => async dispatch => {
try {
const {data} = await createRoleAJAX(url, role)
dispatch(publishNotification(NOTIFY_ROLE_CREATED))
dispatch(notify(NOTIFY_ROLE_CREATED))
dispatch(syncRole(role, data))
} catch (error) {
dispatch(
@ -336,7 +336,7 @@ export const createDatabaseAsync = (url, database) => async dispatch => {
try {
const {data} = await createDatabaseAJAX(url, database)
dispatch(syncDatabase(database, data))
dispatch(publishNotification(NOTIFY_DATABASE_CREATED))
dispatch(notify(NOTIFY_DATABASE_CREATED))
} catch (error) {
dispatch(
errorThrown(error, NOTIFY_DATABASE_CREATION_FAILED(error.data.message))
@ -355,7 +355,7 @@ export const createRetentionPolicyAsync = (
database.links.retentionPolicies,
retentionPolicy
)
dispatch(publishNotification(NOTIFY_RETENTION_POLICY_CREATED))
dispatch(notify(NOTIFY_RETENTION_POLICY_CREATED))
dispatch(syncRetentionPolicy(database, retentionPolicy, data))
} catch (error) {
dispatch(
@ -378,7 +378,7 @@ export const updateRetentionPolicyAsync = (
dispatch(editRetentionPolicyRequested(database, oldRP, newRP))
const {data} = await updateRetentionPolicyAJAX(oldRP.links.self, newRP)
dispatch(editRetentionPolicyCompleted(database, oldRP, data))
dispatch(publishNotification(NOTIFY_RETENTION_POLICY_UPDATED))
dispatch(notify(NOTIFY_RETENTION_POLICY_UPDATED))
} catch (error) {
dispatch(editRetentionPolicyFailed(database, oldRP))
dispatch(
@ -407,7 +407,7 @@ export const deleteRoleAsync = role => async dispatch => {
dispatch(deleteRole(role))
try {
await deleteRoleAJAX(role.links.self)
dispatch(publishNotification(NOTIFY_ROLE_DELETED(role.name)))
dispatch(notify(NOTIFY_ROLE_DELETED(role.name)))
} catch (error) {
dispatch(
errorThrown(error, NOTIFY_ROLE_DELETION_FAILED(error.data.message))
@ -419,7 +419,7 @@ export const deleteUserAsync = user => async dispatch => {
dispatch(deleteUser(user))
try {
await deleteUserAJAX(user.links.self)
dispatch(publishNotification(NOTIFY_DB_USER_DELETED(user.name)))
dispatch(notify(NOTIFY_DB_USER_DELETED(user.name)))
} catch (error) {
dispatch(
errorThrown(error, NOTIFY_DB_USER_DELETION_FAILED(error.data.message))
@ -431,7 +431,7 @@ export const deleteDatabaseAsync = database => async dispatch => {
dispatch(removeDatabase(database))
try {
await deleteDatabaseAJAX(database.links.self)
dispatch(publishNotification(NOTIFY_DATABASE_DELETED(database.name)))
dispatch(notify(NOTIFY_DATABASE_DELETED(database.name)))
} catch (error) {
dispatch(
errorThrown(error, NOTIFY_DATABASE_DELETION_FAILED(error.data.message))
@ -446,9 +446,7 @@ export const deleteRetentionPolicyAsync = (
dispatch(removeRetentionPolicy(database, retentionPolicy))
try {
await deleteRetentionPolicyAJAX(retentionPolicy.links.self)
dispatch(
publishNotification(NOTIFY_RETENTION_POLICY_DELETED(retentionPolicy.name))
)
dispatch(notify(NOTIFY_RETENTION_POLICY_DELETED(retentionPolicy.name)))
} catch (error) {
dispatch(
errorThrown(
@ -466,7 +464,7 @@ export const updateRoleUsersAsync = (role, users) => async dispatch => {
users,
role.permissions
)
dispatch(publishNotification(NOTIFY_ROLE_USERS_UPDATED))
dispatch(notify(NOTIFY_ROLE_USERS_UPDATED))
dispatch(syncRole(role, data))
} catch (error) {
dispatch(
@ -485,7 +483,7 @@ export const updateRolePermissionsAsync = (
role.users,
permissions
)
dispatch(publishNotification(NOTIFY_ROLE_PERMISSIONS_UPDATED))
dispatch(notify(NOTIFY_ROLE_PERMISSIONS_UPDATED))
dispatch(syncRole(role, data))
} catch (error) {
dispatch(
@ -503,7 +501,7 @@ export const updateUserPermissionsAsync = (
) => async dispatch => {
try {
const {data} = await updateUserAJAX(user.links.self, {permissions})
dispatch(publishNotification(NOTIFY_DB_USER_PERMISSIONS_UPDATED))
dispatch(notify(NOTIFY_DB_USER_PERMISSIONS_UPDATED))
dispatch(syncUser(user, data))
} catch (error) {
dispatch(
@ -518,7 +516,7 @@ export const updateUserPermissionsAsync = (
export const updateUserRolesAsync = (user, roles) => async dispatch => {
try {
const {data} = await updateUserAJAX(user.links.self, {roles})
dispatch(publishNotification(NOTIFY_DB_USER_ROLES_UPDATED))
dispatch(notify(NOTIFY_DB_USER_ROLES_UPDATED))
dispatch(syncUser(user, data))
} catch (error) {
dispatch(
@ -530,7 +528,7 @@ export const updateUserRolesAsync = (user, roles) => async dispatch => {
export const updateUserPasswordAsync = (user, password) => async dispatch => {
try {
const {data} = await updateUserAJAX(user.links.self, {password})
dispatch(publishNotification(NOTIFY_DB_USER_PASSWORD_UPDATED))
dispatch(notify(NOTIFY_DB_USER_PASSWORD_UPDATED))
dispatch(syncUser(user, data))
} catch (error) {
dispatch(

View File

@ -5,7 +5,7 @@ import {bindActionCreators} from 'redux'
import onClickOutside from 'react-onclickoutside'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {formatRPDuration} from 'utils/formatting'
import YesNoButtons from 'shared/components/YesNoButtons'
@ -105,7 +105,7 @@ class DatabaseRow extends Component {
getInputValues = () => {
const {
publishNotification,
notify,
retentionPolicy: {name: currentName},
isRFDisplayed,
} = this.props
@ -116,7 +116,7 @@ class DatabaseRow extends Component {
const replication = isRFDisplayed ? +this.replication.value.trim() : 1
if (!duration || (isRFDisplayed && !replication)) {
publishNotification(NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS)
notify(NOTIFY_RETENTION_POLICY_CANT_HAVE_EMPTY_FIELDS)
return
}
@ -267,12 +267,12 @@ DatabaseRow.propTypes = {
onCreate: func,
onUpdate: func,
onDelete: func,
publishNotification: func.isRequired,
notify: func.isRequired,
isRFDisplayed: bool,
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(onClickOutside(DatabaseRow))

View File

@ -4,14 +4,14 @@ import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import ConfirmButtons from 'shared/components/ConfirmButtons'
import {NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED} from 'shared/copy/notifications'
const DatabaseTableHeader = ({
database,
onEdit,
publishNotification,
notify,
onKeyDown,
onConfirm,
onCancel,
@ -36,7 +36,7 @@ const DatabaseTableHeader = ({
return (
<Header
publishNotification={publishNotification}
notify={notify}
database={database}
onCancel={onRemoveDeleteCode}
onConfirm={onConfirm}
@ -50,7 +50,7 @@ const DatabaseTableHeader = ({
}
const Header = ({
publishNotification,
notify,
database,
onCancel,
onDelete,
@ -81,9 +81,7 @@ const Header = ({
const onConfirm = db => {
if (database.deleteCode !== `DELETE ${database.name}`) {
return publishNotification(
NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED(database.name)
)
return notify(NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED(database.name))
}
onDelete(db)
@ -143,7 +141,7 @@ const {func, shape, bool} = PropTypes
DatabaseTableHeader.propTypes = {
onEdit: func,
publishNotification: func.isRequired,
notify: func.isRequired,
database: shape(),
onKeyDown: func,
onCancel: func,
@ -157,7 +155,7 @@ DatabaseTableHeader.propTypes = {
}
Header.propTypes = {
publishNotification: func.isRequired,
notify: func.isRequired,
onConfirm: func,
onCancel: func,
onDelete: func,
@ -178,7 +176,7 @@ EditHeader.propTypes = {
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(DatabaseTableHeader)

View File

@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
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'
@ -83,7 +83,7 @@ class AllUsersTableRowNew extends Component {
if (e.key === 'Enter') {
if (preventCreate) {
return this.props.publishNotification(
return this.props.notify(
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
}
@ -181,11 +181,11 @@ AllUsersTableRowNew.propTypes = {
),
onBlur: func.isRequired,
onCreateUser: func.isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(AllUsersTableRowNew)

View File

@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import Dropdown from 'shared/components/Dropdown'
@ -65,7 +65,7 @@ class UsersTableRowNew extends Component {
if (e.key === 'Enter') {
if (preventCreate) {
return this.props.publishNotification(
return this.props.notify(
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
)
}
@ -149,11 +149,11 @@ UsersTableRowNew.propTypes = {
}),
onBlur: func.isRequired,
onCreateUser: func.isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(UsersTableRowNew)

View File

@ -29,7 +29,7 @@ import AdminTabs from 'src/admin/components/AdminTabs'
import SourceIndicator from 'shared/components/SourceIndicator'
import FancyScrollbar from 'shared/components/FancyScrollbar'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_ROLE_NAME_INVALID,
@ -78,9 +78,9 @@ class AdminInfluxDBPage extends Component {
}
handleSaveUser = async user => {
const {publishNotification} = this.props
const {notify} = this.props
if (!isValidUser(user)) {
publishNotification(NOTIFY_DB_USER_NAME_PASSWORD_INVALID)
notify(NOTIFY_DB_USER_NAME_PASSWORD_INVALID)
return
}
if (user.isNew) {
@ -91,9 +91,9 @@ class AdminInfluxDBPage extends Component {
}
handleSaveRole = async role => {
const {publishNotification} = this.props
const {notify} = this.props
if (!isValidRole(role)) {
publishNotification(NOTIFY_ROLE_NAME_INVALID)
notify(NOTIFY_ROLE_NAME_INVALID)
return
}
if (role.isNew) {
@ -234,7 +234,7 @@ AdminInfluxDBPage.propTypes = {
updateUserPermissions: func,
updateUserRoles: func,
updateUserPassword: func,
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({adminInfluxDB: {users, roles, permissions}}) => ({
@ -270,7 +270,7 @@ const mapDispatchToProps = dispatch => ({
),
updateUserRoles: bindActionCreators(updateUserRolesAsync, dispatch),
updateUserPassword: bindActionCreators(updateUserPasswordAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(AdminInfluxDBPage)

View File

@ -7,7 +7,7 @@ import _ from 'lodash'
import DatabaseManager from 'src/admin/components/DatabaseManager'
import * as adminActionCreators from 'src/admin/actions/influxdb'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED,
@ -39,13 +39,13 @@ class DatabaseManagerPage extends Component {
}
handleCreateDatabase = database => {
const {actions, publishNotification, source, databases} = this.props
const {actions, notify, source, databases} = this.props
if (!database.name) {
return publishNotification(NOTIFY_DATABASE_NAME_INVALID)
return notify(NOTIFY_DATABASE_NAME_INVALID)
}
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
return publishNotification(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
}
actions.createDatabaseAsync(source.links.databases, database)
@ -58,7 +58,7 @@ class DatabaseManagerPage extends Component {
handleKeyDownDatabase = database => e => {
const {key} = e
const {actions, publishNotification, source, databases} = this.props
const {actions, notify, source, databases} = this.props
if (key === 'Escape') {
actions.removeDatabase(database)
@ -66,11 +66,11 @@ class DatabaseManagerPage extends Component {
if (key === 'Enter') {
if (!database.name) {
return publishNotification(NOTIFY_DATABASE_NAME_INVALID)
return notify(NOTIFY_DATABASE_NAME_INVALID)
}
if (_.findIndex(databases, {name: database.name}, 1) !== -1) {
return publishNotification(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
return notify(NOTIFY_DATABASE_NAME_ALREADY_EXISTS)
}
actions.createDatabaseAsync(source.links.databases, database)
@ -79,7 +79,7 @@ class DatabaseManagerPage extends Component {
handleDatabaseDeleteConfirm = database => e => {
const {key, target: {value}} = e
const {actions, publishNotification} = this.props
const {actions, notify} = this.props
if (key === 'Escape') {
return actions.removeDatabaseDeleteCode(database)
@ -87,7 +87,7 @@ class DatabaseManagerPage extends Component {
if (key === 'Enter') {
if (database.deleteCode !== `DELETE ${database.name}`) {
return publishNotification(
return notify(
NOTIFY_DATABASE_DELETE_CONFIRMATION_REQUIRED(database.name)
)
}
@ -99,10 +99,10 @@ class DatabaseManagerPage extends Component {
}
render() {
const {source, databases, actions, publishNotification} = this.props
const {source, databases, actions, notify} = this.props
return (
<DatabaseManager
publishNotification={publishNotification}
notify={notify}
databases={databases}
isRFDisplayed={!!source.metaUrl}
addDatabase={actions.addDatabase}
@ -161,7 +161,7 @@ DatabaseManagerPage.propTypes = {
removeRetentionPolicy: func,
deleteRetentionPolicyAsync: func,
}),
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({adminInfluxDB: {databases, retentionPolicies}}) => ({
@ -171,7 +171,7 @@ const mapStateToProps = ({adminInfluxDB: {databases, retentionPolicies}}) => ({
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(adminActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(DatabaseManagerPage)

View File

@ -4,7 +4,7 @@ import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import ProvidersTable from 'src/admin/components/chronograf/ProvidersTable'
@ -82,7 +82,7 @@ ProvidersPage.propTypes = {
actions: shape({
loadOrganizationsAsync: func.isRequired,
}),
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({
@ -96,7 +96,7 @@ const mapStateToProps = ({
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(adminChronografActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(ProvidersPage)

View File

@ -20,7 +20,7 @@ import {
killQueryAsync,
} from 'src/admin/actions/influxdb'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
class QueriesPage extends Component {
componentDidMount() {
@ -40,13 +40,11 @@ class QueriesPage extends Component {
}
updateQueries = () => {
const {source, publishNotification, loadQueries} = this.props
const {source, notify, loadQueries} = this.props
showDatabases(source.links.proxy).then(resp => {
const {databases, errors} = showDatabasesParser(resp.data)
if (errors.length) {
errors.forEach(message =>
publishNotification(NOTIFY_QUERIES_ERROR(message))
)
errors.forEach(message => notify(NOTIFY_QUERIES_ERROR(message)))
return
}
@ -58,7 +56,7 @@ class QueriesPage extends Component {
const result = showQueriesParser(queryResponse.data)
if (result.errors.length) {
result.errors.forEach(message =>
publishNotification(NOTIFY_QUERIES_ERROR(message))
notify(NOTIFY_QUERIES_ERROR(message))
)
}
@ -98,7 +96,7 @@ QueriesPage.propTypes = {
queryIDToKill: string,
setQueryToKill: func,
killQuery: func,
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({adminInfluxDB: {queries, queryIDToKill}}) => ({
@ -110,7 +108,7 @@ const mapDispatchToProps = dispatch => ({
loadQueries: bindActionCreators(loadQueriesAction, dispatch),
setQueryToKill: bindActionCreators(setQueryToKillAction, dispatch),
killQuery: bindActionCreators(killQueryAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(QueriesPage)

View File

@ -5,7 +5,7 @@ import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import * as configActionCreators from 'shared/actions/config'
import {publishNotification as publishNotificationAction} from 'shared/dispatchers'
import {notify as notifyAction} from 'shared/dispatchers'
import AllUsersTable from 'src/admin/components/chronograf/AllUsersTable'
@ -73,7 +73,7 @@ class AllUsersPage extends Component {
authConfig,
actionsConfig,
links,
publishNotification,
notify,
} = this.props
return (
@ -88,7 +88,7 @@ class AllUsersPage extends Component {
links={links}
authConfig={authConfig}
actionsConfig={actionsConfig}
publishNotification={publishNotification}
notify={notify}
isLoading={this.state.isLoading}
/>
)
@ -121,7 +121,7 @@ AllUsersPage.propTypes = {
authConfig: shape({
superAdminNewUsers: bool,
}),
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({
@ -138,7 +138,7 @@ const mapStateToProps = ({
const mapDispatchToProps = dispatch => ({
actionsAdmin: bindActionCreators(adminChronografActionCreators, dispatch),
actionsConfig: bindActionCreators(configActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(AllUsersPage)

View File

@ -4,7 +4,7 @@ import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import * as adminChronografActionCreators from 'src/admin/actions/chronograf'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import UsersTable from 'src/admin/components/chronograf/UsersTable'
@ -62,7 +62,7 @@ class UsersPage extends Component {
organizations,
meID,
users,
publishNotification,
notify,
} = this.props
const {isLoading} = this.state
@ -78,7 +78,7 @@ class UsersPage extends Component {
onCreateUser={this.handleCreateUser}
onUpdateUserRole={this.handleUpdateUserRole}
onDeleteUser={this.handleDeleteUser}
publishNotification={publishNotification}
notify={notify}
isLoading={isLoading}
/>
)
@ -105,7 +105,7 @@ UsersPage.propTypes = {
updateUserAsync: func.isRequired,
deleteUserAsync: func.isRequired,
}),
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = ({links, adminChronograf: {organizations, users}}) => ({
@ -116,7 +116,7 @@ const mapStateToProps = ({links, adminChronograf: {organizations, users}}) => ({
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(adminChronografActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(UsersPage)

View File

@ -8,7 +8,7 @@ import {
runTemplateVariableQuery,
} from 'src/dashboards/apis'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors'
import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants'
@ -261,7 +261,7 @@ export const deleteDashboardAsync = dashboard => async dispatch => {
dispatch(deleteDashboard(dashboard))
try {
await deleteDashboardAJAX(dashboard)
dispatch(publishNotification(NOTIFY_DASHBOARD_DELETED(dashboard.name)))
dispatch(notify(NOTIFY_DASHBOARD_DELETED(dashboard.name)))
} catch (error) {
dispatch(
errorThrown(

View File

@ -22,7 +22,7 @@ import {TEMPLATE_TYPES} from 'src/dashboards/constants'
import generateTemplateVariableQuery from 'src/dashboards/utils/templateVariableQueryGenerator'
import {errorThrown as errorThrownAction} from 'shared/actions/errors'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {NOTIFY_TEMP_VAR_ALREADY_EXISTS} from 'shared/copy/notifications'
@ -139,14 +139,14 @@ class RowWrapper extends Component {
onRunQuerySuccess,
onRunQueryFailure,
tempVarAlreadyExists,
publishNotification,
notify,
} = this.props
const _tempVar = e.target.tempVar.value.replace(/\u003a/g, '')
const tempVar = `\u003a${_tempVar}\u003a` // add ':'s
if (tempVarAlreadyExists(tempVar, id)) {
return publishNotification(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar))
return notify(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar))
}
this.setState({
@ -328,7 +328,7 @@ RowWrapper.propTypes = {
onRunQueryFailure: func.isRequired,
onDelete: func.isRequired,
tempVarAlreadyExists: func.isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
}
TemplateVariableRow.propTypes = {
@ -347,7 +347,7 @@ TemplateVariableRow.propTypes = {
const mapDispatchToProps = dispatch => ({
onErrorThrown: bindActionCreators(errorThrownAction, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(OnClickOutside(RowWrapper))

View File

@ -16,7 +16,7 @@ import TemplateVariableManager from 'src/dashboards/components/template_variable
import ManualRefresh from 'src/shared/components/ManualRefresh'
import {errorThrown as errorThrownAction} from 'shared/actions/errors'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import idNormalizer, {TYPE_ID} from 'src/normalizers/id'
import {NULL_HOVER_TIME} from 'src/shared/constants/tableGraph'
@ -73,7 +73,7 @@ class DashboardPage extends Component {
meRole,
isUsingAuth,
router,
publishNotification,
notify,
getAnnotationsAsync,
timeRange,
} = this.props
@ -91,7 +91,7 @@ class DashboardPage extends Component {
if (!dashboard) {
router.push(`/sources/${source.id}/dashboards`)
return publishNotification(NOTIFY_DASHBOARD_NOT_FOUND(dashboardID))
return notify(NOTIFY_DASHBOARD_NOT_FOUND(dashboardID))
}
// Refresh and persists influxql generated template variable values.
@ -507,7 +507,7 @@ DashboardPage.propTypes = {
meRole: string,
isUsingAuth: bool.isRequired,
router: shape().isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
getAnnotationsAsync: func.isRequired,
handleShowCellEditorOverlay: func.isRequired,
handleHideCellEditorOverlay: func.isRequired,
@ -569,7 +569,7 @@ const mapDispatchToProps = dispatch => ({
handleClickPresentationButton: presentationButtonDispatcher(dispatch),
dashboardActions: bindActionCreators(dashboardActionCreators, dispatch),
errorThrown: bindActionCreators(errorThrownAction, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
getAnnotationsAsync: bindActionCreators(
annotationActions.getAnnotationsAsync,
dispatch

View File

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

View File

@ -12,7 +12,7 @@ import ManualRefresh from 'src/shared/components/ManualRefresh'
import {getCpuAndLoadForHosts, getLayouts, getAppsForHosts} from '../apis'
import {getEnv} from 'src/shared/apis/env'
import {setAutoRefresh} from 'shared/actions/app'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_UNABLE_TO_GET_HOSTS,
@ -31,7 +31,7 @@ class HostsPage extends Component {
}
async fetchHostsData() {
const {source, links, publishNotification} = this.props
const {source, links, notify} = this.props
const {telegrafSystemInterval} = await getEnv(links.environment)
const hostsError = NOTIFY_UNABLE_TO_GET_HOSTS.message
try {
@ -57,7 +57,7 @@ class HostsPage extends Component {
})
} catch (error) {
console.error(error)
publishNotification(NOTIFY_UNABLE_TO_GET_HOSTS)
notify(NOTIFY_UNABLE_TO_GET_HOSTS)
this.setState({
hostsError,
hostsLoading: false,
@ -66,14 +66,14 @@ class HostsPage extends Component {
}
async componentDidMount() {
const {publishNotification, autoRefresh} = this.props
const {notify, autoRefresh} = this.props
this.setState({hostsLoading: true}) // Only print this once
const {data} = await getLayouts()
this.layouts = data.layouts
if (!this.layouts) {
const layoutError = NOTIFY_UNABLE_TO_GET_APPS.message
publishNotification(NOTIFY_UNABLE_TO_GET_APPS)
notify(NOTIFY_UNABLE_TO_GET_APPS)
this.setState({
hostsError: layoutError,
hostsLoading: false,
@ -179,7 +179,7 @@ HostsPage.propTypes = {
manualRefresh: number,
onChooseAutoRefresh: func.isRequired,
onManualRefresh: func.isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
}
HostsPage.defaultProps = {
@ -188,7 +188,7 @@ HostsPage.defaultProps = {
const mapDispatchToProps = dispatch => ({
onChooseAutoRefresh: bindActionCreators(setAutoRefresh, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(

View File

@ -1,6 +1,6 @@
import uuid from 'uuid'
import {getActiveKapacitor} from 'shared/apis'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {
getRules,
getRule as getRuleAJAX,
@ -181,27 +181,21 @@ export const deleteRule = rule => dispatch => {
deleteRuleAPI(rule)
.then(() => {
dispatch(deleteRuleSuccess(rule.id))
dispatch(publishNotification(NOTIFY_ALERT_RULE_DELETED(rule.name)))
dispatch(notify(NOTIFY_ALERT_RULE_DELETED(rule.name)))
})
.catch(() => {
dispatch(
publishNotification(NOTIFY_ALERT_RULE_DELETION_FAILED(rule.name))
)
dispatch(notify(NOTIFY_ALERT_RULE_DELETION_FAILED(rule.name)))
})
}
export const updateRuleStatus = (rule, status) => dispatch => {
updateRuleStatusAPI(rule, status)
.then(() => {
dispatch(
publishNotification(NOTIFY_ALERT_RULE_STATUS_UPDATED(rule.name, status))
)
dispatch(notify(NOTIFY_ALERT_RULE_STATUS_UPDATED(rule.name, status)))
})
.catch(() => {
dispatch(
publishNotification(
NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status)
)
notify(NOTIFY_ALERT_RULE_STATUS_UPDATE_FAILED(rule.name, status))
)
})
}
@ -209,7 +203,7 @@ export const updateRuleStatus = (rule, status) => dispatch => {
export const createTask = (kapacitor, task) => async dispatch => {
try {
const {data} = await createTaskAJAX(kapacitor, task)
dispatch(publishNotification(NOTIFY_TICKSCRIPT_CREATED))
dispatch(notify(NOTIFY_TICKSCRIPT_CREATED))
return data
} catch (error) {
if (!error) {
@ -229,7 +223,7 @@ export const updateTask = (
) => async dispatch => {
try {
const {data} = await updateTaskAJAX(kapacitor, task, ruleID, sourceID)
dispatch(publishNotification(NOTIFY_TICKSCRIPT_UPDATED))
dispatch(notify(NOTIFY_TICKSCRIPT_UPDATED))
return data
} catch (error) {
if (!error) {

View File

@ -19,7 +19,7 @@ interface AlertOutputProps {
kapacitor: Kapacitor
source: Source
hash: string
publishNotification: (message: Notification | NotificationFunc) => void
notify: (message: Notification | NotificationFunc) => void
}
const AlertOutputs: SFC<AlertOutputProps> = ({
@ -27,7 +27,7 @@ const AlertOutputs: SFC<AlertOutputProps> = ({
exists,
source,
kapacitor,
publishNotification,
notify,
}) => {
if (exists) {
return (
@ -35,7 +35,7 @@ const AlertOutputs: SFC<AlertOutputProps> = ({
hash={hash}
source={source}
kapacitor={kapacitor}
publishNotification={publishNotification}
notify={notify}
/>
)
}

View File

@ -57,7 +57,7 @@ class AlertTabs extends Component {
this.setState({configSections: sections})
} catch (error) {
this.setState({configSections: null})
this.props.publishNotification(NOTIFY_REFRESH_KAPACITOR_FAILED)
this.props.notify(NOTIFY_REFRESH_KAPACITOR_FAILED)
}
}
@ -87,13 +87,11 @@ class AlertTabs extends Component {
propsToSend
)
this.refreshKapacitorConfig(this.props.kapacitor)
this.props.publishNotification(NOTIFY_ALERT_ENDPOINT_SAVED(section))
this.props.notify(NOTIFY_ALERT_ENDPOINT_SAVED(section))
return true
} catch ({data: {error}}) {
const errorMsg = _.join(_.drop(_.split(error, ': '), 2), ': ')
this.props.publishNotification(
NOTIFY_ALERT_ENDPOINT_SAVE_FAILED(section, errorMsg)
)
this.props.notify(NOTIFY_ALERT_ENDPOINT_SAVE_FAILED(section, errorMsg))
return false
}
}
@ -105,14 +103,12 @@ class AlertTabs extends Component {
try {
const {data} = await testAlertOutput(this.props.kapacitor, section)
if (data.success) {
this.props.publishNotification(NOTIFY_TEST_ALERT_SENT(section))
this.props.notify(NOTIFY_TEST_ALERT_SENT(section))
} else {
this.props.publishNotification(
NOTIFY_TEST_ALERT_FAILED(section, data.message)
)
this.props.notify(NOTIFY_TEST_ALERT_FAILED(section, data.message))
}
} catch (error) {
this.props.publishNotification(NOTIFY_TEST_ALERT_FAILED(section))
this.props.notify(NOTIFY_TEST_ALERT_FAILED(section))
}
}
@ -324,7 +320,7 @@ AlertTabs.propTypes = {
proxy: string.isRequired,
}).isRequired,
}),
publishNotification: func.isRequired,
notify: func.isRequired,
hash: string.isRequired,
}

View File

@ -25,7 +25,7 @@ interface Props {
onChangeUrl: (e: ChangeEvent<HTMLInputElement>) => void
source: Source
hash: string
publishNotification: (message: Notification | NotificationFunc) => void
notify: (message: Notification | NotificationFunc) => void
}
const KapacitorForm: SFC<Props> = ({
@ -38,7 +38,7 @@ const KapacitorForm: SFC<Props> = ({
onInputChange,
source,
hash,
publishNotification,
notify,
}) =>
<div className="page">
<div className="page-header">
@ -119,7 +119,7 @@ const KapacitorForm: SFC<Props> = ({
exists={exists}
source={source}
kapacitor={kapacitor}
publishNotification={publishNotification}
notify={notify}
/>
</div>
</div>

View File

@ -14,7 +14,7 @@ import {createRule, editRule} from 'src/kapacitor/apis'
import buildInfluxQLQuery from 'utils/influxql'
import {timeRanges} from 'shared/data/timeRanges'
import {DEFAULT_RULE_ID} from 'src/kapacitor/constants'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_ALERT_RULE_CREATED,
@ -40,14 +40,7 @@ class KapacitorRule extends Component {
}
handleCreate = pathname => {
const {
publishNotification,
queryConfigs,
rule,
source,
router,
kapacitor,
} = this.props
const {notify, queryConfigs, rule, source, router, kapacitor} = this.props
const newRule = Object.assign({}, rule, {
query: queryConfigs[rule.queryID],
@ -57,15 +50,15 @@ class KapacitorRule extends Component {
createRule(kapacitor, newRule)
.then(() => {
router.push(pathname || `/sources/${source.id}/alert-rules`)
publishNotification(NOTIFY_ALERT_RULE_CREATED)
notify(NOTIFY_ALERT_RULE_CREATED)
})
.catch(() => {
publishNotification(NOTIFY_ALERT_RULE_CREATION_FAILED)
notify(NOTIFY_ALERT_RULE_CREATION_FAILED)
})
}
handleEdit = pathname => {
const {publishNotification, queryConfigs, rule, router, source} = this.props
const {notify, queryConfigs, rule, router, source} = this.props
const updatedRule = Object.assign({}, rule, {
query: queryConfigs[rule.queryID],
})
@ -73,12 +66,10 @@ class KapacitorRule extends Component {
editRule(updatedRule)
.then(() => {
router.push(pathname || `/sources/${source.id}/alert-rules`)
publishNotification(NOTIFY_ALERT_RULE_UPDATED(rule.name))
notify(NOTIFY_ALERT_RULE_UPDATED(rule.name))
})
.catch(e => {
publishNotification(
NOTIFY_ALERT_RULE_UPDATE_FAILED(rule.name, e.data.message)
)
notify(NOTIFY_ALERT_RULE_UPDATE_FAILED(rule.name, e.data.message))
})
}
@ -240,7 +231,7 @@ KapacitorRule.propTypes = {
queryConfigs: shape({}).isRequired,
queryConfigActions: shape({}).isRequired,
ruleActions: shape({}).isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
ruleID: string.isRequired,
handlersFromConfig: arrayOf(shape({})).isRequired,
router: shape({
@ -251,7 +242,7 @@ KapacitorRule.propTypes = {
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(KapacitorRule)

View File

@ -3,7 +3,7 @@ import {withRouter} from 'react-router'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import {publishNotification as publishNotificationAction} from 'src/shared/actions/notifications'
import {notify as notifyAction} from 'src/shared/actions/notifications'
import {Source} from 'src/types'
@ -51,7 +51,7 @@ interface Kapacitor {
interface Props {
source: Source
publishNotification: (message: Notification | NotificationFunc) => void
notify: (message: Notification | NotificationFunc) => void
kapacitor: Kapacitor
router: {push: (url: string) => void}
location: {pathname: string; hash: string}
@ -84,7 +84,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
}
async componentDidMount() {
const {source, params: {id}, publishNotification} = this.props
const {source, params: {id}, notify} = this.props
if (!id) {
return
}
@ -95,7 +95,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
await this.checkKapacitorConnection(kapacitor)
} catch (error) {
console.error('Could not get kapacitor: ', error)
publishNotification(NOTIFY_KAPACITOR_CONNECTION_FAILED)
notify(NOTIFY_KAPACITOR_CONNECTION_FAILED)
}
}
@ -115,7 +115,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
handleSubmit = async e => {
e.preventDefault()
const {
publishNotification,
notify,
source,
source: {kapacitors = []},
params,
@ -128,7 +128,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
const isNew = !params.id
if (isNew && isNameTaken) {
publishNotification(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN)
notify(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN)
return
}
@ -137,10 +137,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
const {data} = await updateKapacitor(kapacitor)
this.setState({kapacitor: data})
this.checkKapacitorConnection(data)
publishNotification(NOTIFY_KAPACITOR_UPDATED)
notify(NOTIFY_KAPACITOR_UPDATED)
} catch (error) {
console.error(error)
publishNotification(NOTIFY_KAPACITOR_UPDATE_FAILED)
notify(NOTIFY_KAPACITOR_UPDATE_FAILED)
}
} else {
try {
@ -149,10 +149,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
this.setState({kapacitor: data})
this.checkKapacitorConnection(data)
router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`)
publishNotification(NOTIFY_KAPACITOR_CREATED)
notify(NOTIFY_KAPACITOR_CREATED)
} catch (error) {
console.error(error)
publishNotification(NOTIFY_KAPACITOR_CREATION_FAILED)
notify(NOTIFY_KAPACITOR_CREATION_FAILED)
}
}
}
@ -180,7 +180,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
} catch (error) {
console.error(error)
this.setState({exists: false})
this.props.publishNotification(NOTIFY_KAPACITOR_CONNECTION_FAILED)
this.props.notify(NOTIFY_KAPACITOR_CONNECTION_FAILED)
}
}
@ -192,7 +192,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
}
render() {
const {source, location, params, publishNotification} = this.props
const {source, location, params, notify} = this.props
const hash = (location && location.hash) || (params && params.hash) || ''
const {kapacitor, exists} = this.state
@ -206,14 +206,14 @@ export class KapacitorPage extends PureComponent<Props, State> {
onChangeUrl={this.handleChangeUrl}
onReset={this.handleResetToDefaults}
onInputChange={this.handleInputChange}
publishNotification={publishNotification}
notify={notify}
/>
)
}
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(null, mapDispatchToProps)(withRouter(KapacitorPage))

View File

@ -10,7 +10,7 @@ import {getActiveKapacitor, getKapacitorConfig} from 'shared/apis/index'
import {DEFAULT_RULE_ID} from 'src/kapacitor/constants'
import KapacitorRule from 'src/kapacitor/components/KapacitorRule'
import parseHandlersFromConfig from 'src/shared/parsing/parseHandlersFromConfig'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_KAPACITOR_CREATION_FAILED,
@ -28,7 +28,7 @@ class KapacitorRulePage extends Component {
}
async componentDidMount() {
const {params, source, ruleActions, publishNotification} = this.props
const {params, source, ruleActions, notify} = this.props
if (params.ruleID === 'new') {
ruleActions.loadDefaultRule()
@ -38,7 +38,7 @@ class KapacitorRulePage extends Component {
const kapacitor = await getActiveKapacitor(this.props.source)
if (!kapacitor) {
return publishNotification(NOTIFY_COULD_NOT_FIND_KAPACITOR)
return notify(NOTIFY_COULD_NOT_FIND_KAPACITOR)
}
try {
@ -46,7 +46,7 @@ class KapacitorRulePage extends Component {
const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig)
this.setState({kapacitor, handlersFromConfig})
} catch (error) {
publishNotification(NOTIFY_KAPACITOR_CREATION_FAILED)
notify(NOTIFY_KAPACITOR_CREATION_FAILED)
console.error(error)
throw error
}
@ -97,7 +97,7 @@ KapacitorRulePage.propTypes = {
self: string.isRequired,
}),
}),
publishNotification: func,
notify: func,
rules: shape({}).isRequired,
queryConfigs: shape({}).isRequired,
ruleActions: shape({
@ -126,7 +126,7 @@ const mapStateToProps = ({rules, kapacitorQueryConfigs: queryConfigs}) => ({
const mapDispatchToProps = dispatch => ({
ruleActions: bindActionCreators(kapacitorRuleActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
queryConfigActions: bindActionCreators(
kapacitorQueryConfigActionCreators,
dispatch

View File

@ -9,7 +9,7 @@ import * as kapactiorActionCreators from 'src/kapacitor/actions/view'
import * as errorActionCreators from 'shared/actions/errors'
import {getActiveKapacitor} from 'src/shared/apis'
import {getLogStreamByRuleID, pingKapacitorVersion} from 'src/kapacitor/apis'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {
NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE,
@ -41,7 +41,7 @@ class TickscriptPage extends Component {
}
fetchChunkedLogs = async (kapacitor, ruleID) => {
const {publishNotification} = this.props
const {notify} = this.props
try {
const version = await pingKapacitorVersion(kapacitor)
@ -50,7 +50,7 @@ class TickscriptPage extends Component {
this.setState({
areLogsEnabled: false,
})
publishNotification(NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE)
notify(NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE)
return
}
@ -119,7 +119,7 @@ class TickscriptPage extends Component {
}
} catch (error) {
console.error(error)
publishNotification(NOTIFY_TICKSCRIPT_LOGGING_ERROR(error))
notify(NOTIFY_TICKSCRIPT_LOGGING_ERROR(error))
throw error
}
}
@ -275,7 +275,7 @@ TickscriptPage.propTypes = {
ruleID: string,
}).isRequired,
rules: arrayOf(shape()),
publishNotification: func.isRequired,
notify: func.isRequired,
}
const mapStateToProps = state => {
@ -287,7 +287,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => ({
kapacitorActions: bindActionCreators(kapactiorActionCreators, dispatch),
errorActions: bindActionCreators(errorActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(TickscriptPage)

View File

@ -2,7 +2,7 @@ import {getMe as getMeAJAX, updateMe as updateMeAJAX} from 'shared/apis/auth'
import {getLinksAsync} from 'shared/actions/links'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors'
import {NOTIFY_USER_SWITCHED_ORGS} from 'shared/copy/notifications'
@ -92,7 +92,7 @@ export const meChangeOrganizationAsync = (
r => r.organization === me.currentOrganization.id
)
dispatch(
publishNotification(
notify(
NOTIFY_USER_SWITCHED_ORGS(me.currentOrganization.name, currentRole.name)
)
)

View File

@ -1,4 +1,4 @@
export const publishNotification = notification => ({
export const notify = notification => ({
type: 'PUBLISH_NOTIFICATION',
payload: {notification},
})

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import _ from 'lodash'
import {authExpired} from 'shared/actions/auth'
import {publishNotification} from 'shared/actions/notifications'
import {notify} from 'shared/actions/notifications'
import {HTTP_FORBIDDEN} from 'shared/constants'
import {
@ -42,22 +42,22 @@ 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(publishNotification(NOTIFY_ORG_IS_PRIVATE))
store.dispatch(notify(NOTIFY_ORG_IS_PRIVATE))
}
if (_.startsWith(message, 'Welcome to Chronograf')) {
store.dispatch(publishNotification(NOTIFY_NEW_VERSION(message)))
store.dispatch(notify(NOTIFY_NEW_VERSION(message)))
}
if (organizationWasRemoved) {
store.dispatch(publishNotification(NOTIFY_CURRENT_ORG_DELETED))
store.dispatch(notify(NOTIFY_CURRENT_ORG_DELETED))
allowNotifications = false
setTimeout(() => {
allowNotifications = true
}, notificationsBlackoutDuration)
} else if (wasSessionTimeout) {
store.dispatch(publishNotification(NOTIFY_SESSION_TIMED_OUT))
store.dispatch(notify(NOTIFY_SESSION_TIMED_OUT))
allowNotifications = false
setTimeout(() => {
@ -65,12 +65,10 @@ const errorsMiddleware = store => next => action => {
}, notificationsBlackoutDuration)
}
} else if (altText) {
store.dispatch(
publishNotification(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText))
)
store.dispatch(notify(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText)))
} else {
// TODO: actually do proper error handling
// store.dispatch(publishNotification({type: alertType, 'Cannot communicate with server.'))
// store.dispatch(notify({type: alertType, 'Cannot communicate with server.'))
}
}

View File

@ -9,7 +9,7 @@ import {
setActiveKapacitorAsync,
deleteKapacitorAsync,
} from 'shared/actions/sources'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import FancyScrollbar from 'shared/components/FancyScrollbar'
import SourceIndicator from 'shared/components/SourceIndicator'
@ -42,13 +42,13 @@ class ManageSources extends Component {
}
handleDeleteSource = source => () => {
const {publishNotification} = this.props
const {notify} = this.props
try {
this.props.removeAndLoadSources(source)
publishNotification(NOTIFY_SOURCE_DELETED(source.name))
notify(NOTIFY_SOURCE_DELETED(source.name))
} catch (e) {
publishNotification(NOTIFY_SOURCE_DELETE_FAILED(source.name))
notify(NOTIFY_SOURCE_DELETE_FAILED(source.name))
}
}
@ -101,7 +101,7 @@ ManageSources.propTypes = {
}),
}),
sources: array,
publishNotification: func.isRequired,
notify: func.isRequired,
removeAndLoadSources: func.isRequired,
fetchKapacitors: func.isRequired,
setActiveKapacitor: func.isRequired,
@ -117,7 +117,7 @@ const mapDispatchToProps = dispatch => ({
fetchKapacitors: bindActionCreators(fetchKapacitorsAsync, dispatch),
setActiveKapacitor: bindActionCreators(setActiveKapacitorAsync, dispatch),
deleteKapacitor: bindActionCreators(deleteKapacitorAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(ManageSources)

View File

@ -8,7 +8,7 @@ import {
addSource as addSourceAction,
updateSource as updateSourceAction,
} from 'shared/actions/sources'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications'
import {notify as notifyAction} from 'shared/actions/notifications'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
@ -41,7 +41,7 @@ class SourcePage extends Component {
componentDidMount() {
const {editMode} = this.state
const {params, publishNotification} = this.props
const {params, notify} = this.props
if (!editMode) {
return this.setState({isLoading: false})
@ -55,9 +55,7 @@ class SourcePage extends Component {
})
})
.catch(error => {
publishNotification(
NOTIFY_ERROR_CONNECTING_TO_SOURCE(this._parseError(error))
)
notify(NOTIFY_ERROR_CONNECTING_TO_SOURCE(this._parseError(error)))
this.setState({isLoading: false})
})
}
@ -142,15 +140,15 @@ class SourcePage extends Component {
_createSource = () => {
const {source} = this.state
const {publishNotification} = this.props
const {notify} = this.props
createSource(source)
.then(({data: sourceFromServer}) => {
this.props.addSource(sourceFromServer)
this._redirect(sourceFromServer)
publishNotification(NOTIFY_SOURCE_CREATION_SUCCEEDED(source.name))
notify(NOTIFY_SOURCE_CREATION_SUCCEEDED(source.name))
})
.catch(error => {
publishNotification(
notify(
NOTIFY_SOURCE_CREATION_FAILED(source.name, this._parseError(error))
)
})
@ -158,15 +156,15 @@ class SourcePage extends Component {
_updateSource = () => {
const {source} = this.state
const {publishNotification} = this.props
const {notify} = this.props
updateSource(source)
.then(({data: sourceFromServer}) => {
this.props.updateSource(sourceFromServer)
this._redirect(sourceFromServer)
publishNotification(NOTIFY_SOURCE_UPDATED(source.name))
notify(NOTIFY_SOURCE_UPDATED(source.name))
})
.catch(error => {
publishNotification(
notify(
NOTIFY_SOURCE_UPDATE_FAILED(source.name, this._parseError(error))
)
})
@ -269,13 +267,13 @@ SourcePage.propTypes = {
redirectPath: string,
}).isRequired,
}).isRequired,
publishNotification: func.isRequired,
notify: func.isRequired,
addSource: func.isRequired,
updateSource: func.isRequired,
}
const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch),
notify: bindActionCreators(notifyAction, dispatch),
addSource: bindActionCreators(addSourceAction, dispatch),
updateSource: bindActionCreators(updateSourceAction, dispatch),
})

View File

@ -17,7 +17,7 @@ jest.mock('src/shared/apis', () => require('mocks/shared/apis'))
const setup = (override = {}) => {
const props = {
source: source,
publishNotification: () => {},
notify: () => {},
kapacitor,
router: {
push: () => {},

View File

@ -1,9 +1,6 @@
import {initialState, notifications} from 'shared/reducers/notifications'
import {
publishNotification,
dismissNotification,
} from 'shared/actions/notifications'
import {notify, dismissNotification} from 'shared/actions/notifications'
import {FIVE_SECONDS} from 'shared/constants/index'
@ -21,10 +18,7 @@ const exampleNotifications = [exampleNotification]
describe('Shared.Reducers.notifications', () => {
it('should publish a notification', () => {
const [actual] = notifications(
initialState,
publishNotification(exampleNotification)
)
const [actual] = notifications(initialState, notify(exampleNotification))
const [expected] = [exampleNotification, ...initialState]
@ -45,7 +39,7 @@ describe('Shared.Reducers.notifications', () => {
const actual = notifications(
exampleNotifications,
publishNotification(newNotification)
notify(newNotification)
)
expect(actual.length).toBe(2)