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

View File

@ -16,7 +16,7 @@ import {
deleteMapping as deleteMappingAJAX, deleteMapping as deleteMappingAJAX,
} from 'src/admin/apis/chronograf' } from 'src/admin/apis/chronograf'
import {publishNotification} from 'shared/actions/notifications' import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import { import {
NOTIFY_MAPPING_DELETED, NOTIFY_MAPPING_DELETED,
@ -183,9 +183,7 @@ export const deleteMappingAsync = mapping => async dispatch => {
dispatch(removeMapping(mapping)) dispatch(removeMapping(mapping))
try { try {
await deleteMappingAJAX(mapping) await deleteMappingAJAX(mapping)
dispatch( dispatch(notify(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme)))
publishNotification(NOTIFY_MAPPING_DELETED(mapping.id, mapping.scheme))
)
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
dispatch(addMapping(mapping)) dispatch(addMapping(mapping))
@ -241,9 +239,7 @@ export const updateUserAsync = (
provider: null, provider: null,
scheme: null, scheme: null,
}) })
dispatch( dispatch(notify(NOTIFY_CHRONOGRAF_USER_UPDATED(successMessage)))
publishNotification(NOTIFY_CHRONOGRAF_USER_UPDATED(successMessage))
)
// it's not necessary to syncUser again but it's useful for good // it's not necessary to syncUser again but it's useful for good
// measure and for the clarity of insight in the redux story // measure and for the clarity of insight in the redux story
dispatch(syncUser(user, data)) dispatch(syncUser(user, data))
@ -261,9 +257,7 @@ export const deleteUserAsync = (
try { try {
await deleteUserAJAX(user) await deleteUserAJAX(user)
dispatch( dispatch(
publishNotification( notify(NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete))
NOTIFY_CHRONOGRAF_USER_DELETED(user.name, isAbsoluteDelete)
)
) )
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
@ -315,9 +309,7 @@ export const deleteOrganizationAsync = organization => async dispatch => {
dispatch(removeOrganization(organization)) dispatch(removeOrganization(organization))
try { try {
await deleteOrganizationAJAX(organization) await deleteOrganizationAJAX(organization)
dispatch( dispatch(notify(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name)))
publishNotification(NOTIFY_CHRONOGRAF_ORG_DELETED(organization.name))
)
} catch (error) { } catch (error) {
dispatch(errorThrown(error)) dispatch(errorThrown(error))
dispatch(addOrganization(organization)) dispatch(addOrganization(organization))

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import {connect} from 'react-redux' import {connect} from 'react-redux'
import {bindActionCreators} from '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 Dropdown from 'shared/components/Dropdown'
@ -65,7 +65,7 @@ class UsersTableRowNew extends Component {
if (e.key === 'Enter') { if (e.key === 'Enter') {
if (preventCreate) { if (preventCreate) {
return this.props.publishNotification( return this.props.notify(
NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER NOTIFY_CHRONOGRAF_USER_MISSING_NAME_AND_PROVIDER
) )
} }
@ -149,11 +149,11 @@ UsersTableRowNew.propTypes = {
}), }),
onBlur: func.isRequired, onBlur: func.isRequired,
onCreateUser: func.isRequired, onCreateUser: func.isRequired,
publishNotification: func.isRequired, notify: func.isRequired,
} }
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(null, mapDispatchToProps)(UsersTableRowNew) 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 SourceIndicator from 'shared/components/SourceIndicator'
import FancyScrollbar from 'shared/components/FancyScrollbar' import FancyScrollbar from 'shared/components/FancyScrollbar'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_ROLE_NAME_INVALID, NOTIFY_ROLE_NAME_INVALID,
@ -78,9 +78,9 @@ class AdminInfluxDBPage extends Component {
} }
handleSaveUser = async user => { handleSaveUser = async user => {
const {publishNotification} = this.props const {notify} = this.props
if (!isValidUser(user)) { if (!isValidUser(user)) {
publishNotification(NOTIFY_DB_USER_NAME_PASSWORD_INVALID) notify(NOTIFY_DB_USER_NAME_PASSWORD_INVALID)
return return
} }
if (user.isNew) { if (user.isNew) {
@ -91,9 +91,9 @@ class AdminInfluxDBPage extends Component {
} }
handleSaveRole = async role => { handleSaveRole = async role => {
const {publishNotification} = this.props const {notify} = this.props
if (!isValidRole(role)) { if (!isValidRole(role)) {
publishNotification(NOTIFY_ROLE_NAME_INVALID) notify(NOTIFY_ROLE_NAME_INVALID)
return return
} }
if (role.isNew) { if (role.isNew) {
@ -234,7 +234,7 @@ AdminInfluxDBPage.propTypes = {
updateUserPermissions: func, updateUserPermissions: func,
updateUserRoles: func, updateUserRoles: func,
updateUserPassword: func, updateUserPassword: func,
publishNotification: func.isRequired, notify: func.isRequired,
} }
const mapStateToProps = ({adminInfluxDB: {users, roles, permissions}}) => ({ const mapStateToProps = ({adminInfluxDB: {users, roles, permissions}}) => ({
@ -270,7 +270,7 @@ const mapDispatchToProps = dispatch => ({
), ),
updateUserRoles: bindActionCreators(updateUserRolesAsync, dispatch), updateUserRoles: bindActionCreators(updateUserRolesAsync, dispatch),
updateUserPassword: bindActionCreators(updateUserPasswordAsync, dispatch), updateUserPassword: bindActionCreators(updateUserPasswordAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(AdminInfluxDBPage) export default connect(mapStateToProps, mapDispatchToProps)(AdminInfluxDBPage)

View File

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

View File

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

View File

@ -20,7 +20,7 @@ import {
killQueryAsync, killQueryAsync,
} from 'src/admin/actions/influxdb' } 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 { class QueriesPage extends Component {
componentDidMount() { componentDidMount() {
@ -40,13 +40,11 @@ class QueriesPage extends Component {
} }
updateQueries = () => { updateQueries = () => {
const {source, publishNotification, loadQueries} = this.props const {source, notify, loadQueries} = this.props
showDatabases(source.links.proxy).then(resp => { showDatabases(source.links.proxy).then(resp => {
const {databases, errors} = showDatabasesParser(resp.data) const {databases, errors} = showDatabasesParser(resp.data)
if (errors.length) { if (errors.length) {
errors.forEach(message => errors.forEach(message => notify(NOTIFY_QUERIES_ERROR(message)))
publishNotification(NOTIFY_QUERIES_ERROR(message))
)
return return
} }
@ -58,7 +56,7 @@ class QueriesPage extends Component {
const result = showQueriesParser(queryResponse.data) const result = showQueriesParser(queryResponse.data)
if (result.errors.length) { if (result.errors.length) {
result.errors.forEach(message => result.errors.forEach(message =>
publishNotification(NOTIFY_QUERIES_ERROR(message)) notify(NOTIFY_QUERIES_ERROR(message))
) )
} }
@ -98,7 +96,7 @@ QueriesPage.propTypes = {
queryIDToKill: string, queryIDToKill: string,
setQueryToKill: func, setQueryToKill: func,
killQuery: func, killQuery: func,
publishNotification: func.isRequired, notify: func.isRequired,
} }
const mapStateToProps = ({adminInfluxDB: {queries, queryIDToKill}}) => ({ const mapStateToProps = ({adminInfluxDB: {queries, queryIDToKill}}) => ({
@ -110,7 +108,7 @@ const mapDispatchToProps = dispatch => ({
loadQueries: bindActionCreators(loadQueriesAction, dispatch), loadQueries: bindActionCreators(loadQueriesAction, dispatch),
setQueryToKill: bindActionCreators(setQueryToKillAction, dispatch), setQueryToKill: bindActionCreators(setQueryToKillAction, dispatch),
killQuery: bindActionCreators(killQueryAsync, dispatch), killQuery: bindActionCreators(killQueryAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(QueriesPage) 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 adminChronografActionCreators from 'src/admin/actions/chronograf'
import * as configActionCreators from 'shared/actions/config' 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' import AllUsersTable from 'src/admin/components/chronograf/AllUsersTable'
@ -73,7 +73,7 @@ class AllUsersPage extends Component {
authConfig, authConfig,
actionsConfig, actionsConfig,
links, links,
publishNotification, notify,
} = this.props } = this.props
return ( return (
@ -88,7 +88,7 @@ class AllUsersPage extends Component {
links={links} links={links}
authConfig={authConfig} authConfig={authConfig}
actionsConfig={actionsConfig} actionsConfig={actionsConfig}
publishNotification={publishNotification} notify={notify}
isLoading={this.state.isLoading} isLoading={this.state.isLoading}
/> />
) )
@ -121,7 +121,7 @@ AllUsersPage.propTypes = {
authConfig: shape({ authConfig: shape({
superAdminNewUsers: bool, superAdminNewUsers: bool,
}), }),
publishNotification: func.isRequired, notify: func.isRequired,
} }
const mapStateToProps = ({ const mapStateToProps = ({
@ -138,7 +138,7 @@ const mapStateToProps = ({
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
actionsAdmin: bindActionCreators(adminChronografActionCreators, dispatch), actionsAdmin: bindActionCreators(adminChronografActionCreators, dispatch),
actionsConfig: bindActionCreators(configActionCreators, dispatch), actionsConfig: bindActionCreators(configActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(AllUsersPage) export default connect(mapStateToProps, mapDispatchToProps)(AllUsersPage)

View File

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

View File

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

View File

@ -22,7 +22,7 @@ import {TEMPLATE_TYPES} from 'src/dashboards/constants'
import generateTemplateVariableQuery from 'src/dashboards/utils/templateVariableQueryGenerator' import generateTemplateVariableQuery from 'src/dashboards/utils/templateVariableQueryGenerator'
import {errorThrown as errorThrownAction} from 'shared/actions/errors' 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' import {NOTIFY_TEMP_VAR_ALREADY_EXISTS} from 'shared/copy/notifications'
@ -139,14 +139,14 @@ class RowWrapper extends Component {
onRunQuerySuccess, onRunQuerySuccess,
onRunQueryFailure, onRunQueryFailure,
tempVarAlreadyExists, tempVarAlreadyExists,
publishNotification, notify,
} = this.props } = this.props
const _tempVar = e.target.tempVar.value.replace(/\u003a/g, '') const _tempVar = e.target.tempVar.value.replace(/\u003a/g, '')
const tempVar = `\u003a${_tempVar}\u003a` // add ':'s const tempVar = `\u003a${_tempVar}\u003a` // add ':'s
if (tempVarAlreadyExists(tempVar, id)) { if (tempVarAlreadyExists(tempVar, id)) {
return publishNotification(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar)) return notify(NOTIFY_TEMP_VAR_ALREADY_EXISTS(_tempVar))
} }
this.setState({ this.setState({
@ -328,7 +328,7 @@ RowWrapper.propTypes = {
onRunQueryFailure: func.isRequired, onRunQueryFailure: func.isRequired,
onDelete: func.isRequired, onDelete: func.isRequired,
tempVarAlreadyExists: func.isRequired, tempVarAlreadyExists: func.isRequired,
publishNotification: func.isRequired, notify: func.isRequired,
} }
TemplateVariableRow.propTypes = { TemplateVariableRow.propTypes = {
@ -347,7 +347,7 @@ TemplateVariableRow.propTypes = {
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
onErrorThrown: bindActionCreators(errorThrownAction, dispatch), onErrorThrown: bindActionCreators(errorThrownAction, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(null, mapDispatchToProps)(OnClickOutside(RowWrapper)) 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 ManualRefresh from 'src/shared/components/ManualRefresh'
import {errorThrown as errorThrownAction} from 'shared/actions/errors' 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 idNormalizer, {TYPE_ID} from 'src/normalizers/id'
import {NULL_HOVER_TIME} from 'src/shared/constants/tableGraph' import {NULL_HOVER_TIME} from 'src/shared/constants/tableGraph'
@ -73,7 +73,7 @@ class DashboardPage extends Component {
meRole, meRole,
isUsingAuth, isUsingAuth,
router, router,
publishNotification, notify,
getAnnotationsAsync, getAnnotationsAsync,
timeRange, timeRange,
} = this.props } = this.props
@ -91,7 +91,7 @@ class DashboardPage extends Component {
if (!dashboard) { if (!dashboard) {
router.push(`/sources/${source.id}/dashboards`) router.push(`/sources/${source.id}/dashboards`)
return publishNotification(NOTIFY_DASHBOARD_NOT_FOUND(dashboardID)) return notify(NOTIFY_DASHBOARD_NOT_FOUND(dashboardID))
} }
// Refresh and persists influxql generated template variable values. // Refresh and persists influxql generated template variable values.
@ -507,7 +507,7 @@ DashboardPage.propTypes = {
meRole: string, meRole: string,
isUsingAuth: bool.isRequired, isUsingAuth: bool.isRequired,
router: shape().isRequired, router: shape().isRequired,
publishNotification: func.isRequired, notify: func.isRequired,
getAnnotationsAsync: func.isRequired, getAnnotationsAsync: func.isRequired,
handleShowCellEditorOverlay: func.isRequired, handleShowCellEditorOverlay: func.isRequired,
handleHideCellEditorOverlay: func.isRequired, handleHideCellEditorOverlay: func.isRequired,
@ -569,7 +569,7 @@ const mapDispatchToProps = dispatch => ({
handleClickPresentationButton: presentationButtonDispatcher(dispatch), handleClickPresentationButton: presentationButtonDispatcher(dispatch),
dashboardActions: bindActionCreators(dashboardActionCreators, dispatch), dashboardActions: bindActionCreators(dashboardActionCreators, dispatch),
errorThrown: bindActionCreators(errorThrownAction, dispatch), errorThrown: bindActionCreators(errorThrownAction, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
getAnnotationsAsync: bindActionCreators( getAnnotationsAsync: bindActionCreators(
annotationActions.getAnnotationsAsync, annotationActions.getAnnotationsAsync,
dispatch dispatch

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import {withRouter} from 'react-router'
import {connect} from 'react-redux' import {connect} from 'react-redux'
import {bindActionCreators} from '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' import {Source} from 'src/types'
@ -51,7 +51,7 @@ interface Kapacitor {
interface Props { interface Props {
source: Source source: Source
publishNotification: (message: Notification | NotificationFunc) => void notify: (message: Notification | NotificationFunc) => void
kapacitor: Kapacitor kapacitor: Kapacitor
router: {push: (url: string) => void} router: {push: (url: string) => void}
location: {pathname: string; hash: string} location: {pathname: string; hash: string}
@ -84,7 +84,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
} }
async componentDidMount() { async componentDidMount() {
const {source, params: {id}, publishNotification} = this.props const {source, params: {id}, notify} = this.props
if (!id) { if (!id) {
return return
} }
@ -95,7 +95,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
await this.checkKapacitorConnection(kapacitor) await this.checkKapacitorConnection(kapacitor)
} catch (error) { } catch (error) {
console.error('Could not get kapacitor: ', error) console.error('Could not get kapacitor: ', error)
publishNotification(NOTIFY_KAPACITOR_CONNECTION_FAILED) notify(NOTIFY_KAPACITOR_CONNECTION_FAILED)
} }
} }
@ -115,7 +115,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
handleSubmit = async e => { handleSubmit = async e => {
e.preventDefault() e.preventDefault()
const { const {
publishNotification, notify,
source, source,
source: {kapacitors = []}, source: {kapacitors = []},
params, params,
@ -128,7 +128,7 @@ export class KapacitorPage extends PureComponent<Props, State> {
const isNew = !params.id const isNew = !params.id
if (isNew && isNameTaken) { if (isNew && isNameTaken) {
publishNotification(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN) notify(NOTIFY_KAPACITOR_NAME_ALREADY_TAKEN)
return return
} }
@ -137,10 +137,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
const {data} = await updateKapacitor(kapacitor) const {data} = await updateKapacitor(kapacitor)
this.setState({kapacitor: data}) this.setState({kapacitor: data})
this.checkKapacitorConnection(data) this.checkKapacitorConnection(data)
publishNotification(NOTIFY_KAPACITOR_UPDATED) notify(NOTIFY_KAPACITOR_UPDATED)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
publishNotification(NOTIFY_KAPACITOR_UPDATE_FAILED) notify(NOTIFY_KAPACITOR_UPDATE_FAILED)
} }
} else { } else {
try { try {
@ -149,10 +149,10 @@ export class KapacitorPage extends PureComponent<Props, State> {
this.setState({kapacitor: data}) this.setState({kapacitor: data})
this.checkKapacitorConnection(data) this.checkKapacitorConnection(data)
router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`) router.push(`/sources/${source.id}/kapacitors/${data.id}/edit`)
publishNotification(NOTIFY_KAPACITOR_CREATED) notify(NOTIFY_KAPACITOR_CREATED)
} catch (error) { } catch (error) {
console.error(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) { } catch (error) {
console.error(error) console.error(error)
this.setState({exists: false}) 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() { render() {
const {source, location, params, publishNotification} = this.props const {source, location, params, notify} = this.props
const hash = (location && location.hash) || (params && params.hash) || '' const hash = (location && location.hash) || (params && params.hash) || ''
const {kapacitor, exists} = this.state const {kapacitor, exists} = this.state
@ -206,14 +206,14 @@ export class KapacitorPage extends PureComponent<Props, State> {
onChangeUrl={this.handleChangeUrl} onChangeUrl={this.handleChangeUrl}
onReset={this.handleResetToDefaults} onReset={this.handleResetToDefaults}
onInputChange={this.handleInputChange} onInputChange={this.handleInputChange}
publishNotification={publishNotification} notify={notify}
/> />
) )
} }
} }
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(null, mapDispatchToProps)(withRouter(KapacitorPage)) 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 {DEFAULT_RULE_ID} from 'src/kapacitor/constants'
import KapacitorRule from 'src/kapacitor/components/KapacitorRule' import KapacitorRule from 'src/kapacitor/components/KapacitorRule'
import parseHandlersFromConfig from 'src/shared/parsing/parseHandlersFromConfig' import parseHandlersFromConfig from 'src/shared/parsing/parseHandlersFromConfig'
import {publishNotification as publishNotificationAction} from 'shared/actions/notifications' import {notify as notifyAction} from 'shared/actions/notifications'
import { import {
NOTIFY_KAPACITOR_CREATION_FAILED, NOTIFY_KAPACITOR_CREATION_FAILED,
@ -28,7 +28,7 @@ class KapacitorRulePage extends Component {
} }
async componentDidMount() { async componentDidMount() {
const {params, source, ruleActions, publishNotification} = this.props const {params, source, ruleActions, notify} = this.props
if (params.ruleID === 'new') { if (params.ruleID === 'new') {
ruleActions.loadDefaultRule() ruleActions.loadDefaultRule()
@ -38,7 +38,7 @@ class KapacitorRulePage extends Component {
const kapacitor = await getActiveKapacitor(this.props.source) const kapacitor = await getActiveKapacitor(this.props.source)
if (!kapacitor) { if (!kapacitor) {
return publishNotification(NOTIFY_COULD_NOT_FIND_KAPACITOR) return notify(NOTIFY_COULD_NOT_FIND_KAPACITOR)
} }
try { try {
@ -46,7 +46,7 @@ class KapacitorRulePage extends Component {
const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig) const handlersFromConfig = parseHandlersFromConfig(kapacitorConfig)
this.setState({kapacitor, handlersFromConfig}) this.setState({kapacitor, handlersFromConfig})
} catch (error) { } catch (error) {
publishNotification(NOTIFY_KAPACITOR_CREATION_FAILED) notify(NOTIFY_KAPACITOR_CREATION_FAILED)
console.error(error) console.error(error)
throw error throw error
} }
@ -97,7 +97,7 @@ KapacitorRulePage.propTypes = {
self: string.isRequired, self: string.isRequired,
}), }),
}), }),
publishNotification: func, notify: func,
rules: shape({}).isRequired, rules: shape({}).isRequired,
queryConfigs: shape({}).isRequired, queryConfigs: shape({}).isRequired,
ruleActions: shape({ ruleActions: shape({
@ -126,7 +126,7 @@ const mapStateToProps = ({rules, kapacitorQueryConfigs: queryConfigs}) => ({
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
ruleActions: bindActionCreators(kapacitorRuleActionCreators, dispatch), ruleActions: bindActionCreators(kapacitorRuleActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
queryConfigActions: bindActionCreators( queryConfigActions: bindActionCreators(
kapacitorQueryConfigActionCreators, kapacitorQueryConfigActionCreators,
dispatch dispatch

View File

@ -9,7 +9,7 @@ import * as kapactiorActionCreators from 'src/kapacitor/actions/view'
import * as errorActionCreators from 'shared/actions/errors' import * as errorActionCreators from 'shared/actions/errors'
import {getActiveKapacitor} from 'src/shared/apis' import {getActiveKapacitor} from 'src/shared/apis'
import {getLogStreamByRuleID, pingKapacitorVersion} from 'src/kapacitor/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 { import {
NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE, NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE,
@ -41,7 +41,7 @@ class TickscriptPage extends Component {
} }
fetchChunkedLogs = async (kapacitor, ruleID) => { fetchChunkedLogs = async (kapacitor, ruleID) => {
const {publishNotification} = this.props const {notify} = this.props
try { try {
const version = await pingKapacitorVersion(kapacitor) const version = await pingKapacitorVersion(kapacitor)
@ -50,7 +50,7 @@ class TickscriptPage extends Component {
this.setState({ this.setState({
areLogsEnabled: false, areLogsEnabled: false,
}) })
publishNotification(NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE) notify(NOTIFY_TICKSCRIPT_LOGGING_UNAVAILABLE)
return return
} }
@ -119,7 +119,7 @@ class TickscriptPage extends Component {
} }
} catch (error) { } catch (error) {
console.error(error) console.error(error)
publishNotification(NOTIFY_TICKSCRIPT_LOGGING_ERROR(error)) notify(NOTIFY_TICKSCRIPT_LOGGING_ERROR(error))
throw error throw error
} }
} }
@ -275,7 +275,7 @@ TickscriptPage.propTypes = {
ruleID: string, ruleID: string,
}).isRequired, }).isRequired,
rules: arrayOf(shape()), rules: arrayOf(shape()),
publishNotification: func.isRequired, notify: func.isRequired,
} }
const mapStateToProps = state => { const mapStateToProps = state => {
@ -287,7 +287,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
kapacitorActions: bindActionCreators(kapactiorActionCreators, dispatch), kapacitorActions: bindActionCreators(kapactiorActionCreators, dispatch),
errorActions: bindActionCreators(errorActionCreators, dispatch), errorActions: bindActionCreators(errorActionCreators, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(TickscriptPage) 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 {getLinksAsync} from 'shared/actions/links'
import {publishNotification} from 'shared/actions/notifications' import {notify} from 'shared/actions/notifications'
import {errorThrown} from 'shared/actions/errors' import {errorThrown} from 'shared/actions/errors'
import {NOTIFY_USER_SWITCHED_ORGS} from 'shared/copy/notifications' import {NOTIFY_USER_SWITCHED_ORGS} from 'shared/copy/notifications'
@ -92,7 +92,7 @@ export const meChangeOrganizationAsync = (
r => r.organization === me.currentOrganization.id r => r.organization === me.currentOrganization.id
) )
dispatch( dispatch(
publishNotification( notify(
NOTIFY_USER_SWITCHED_ORGS(me.currentOrganization.name, currentRole.name) 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', type: 'PUBLISH_NOTIFICATION',
payload: {notification}, payload: {notification},
}) })

View File

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

View File

@ -1,7 +1,7 @@
import _ from 'lodash' import _ from 'lodash'
import {authExpired} from 'shared/actions/auth' 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 {HTTP_FORBIDDEN} from 'shared/constants'
import { import {
@ -42,22 +42,22 @@ const errorsMiddleware = store => next => action => {
message === message ===
`This organization is private. To gain access, you must be explicitly added by an administrator.` // eslint-disable-line quotes `This organization is private. To gain access, you must be explicitly added by an administrator.` // eslint-disable-line quotes
) { ) {
store.dispatch(publishNotification(NOTIFY_ORG_IS_PRIVATE)) store.dispatch(notify(NOTIFY_ORG_IS_PRIVATE))
} }
if (_.startsWith(message, 'Welcome to Chronograf')) { if (_.startsWith(message, 'Welcome to Chronograf')) {
store.dispatch(publishNotification(NOTIFY_NEW_VERSION(message))) store.dispatch(notify(NOTIFY_NEW_VERSION(message)))
} }
if (organizationWasRemoved) { if (organizationWasRemoved) {
store.dispatch(publishNotification(NOTIFY_CURRENT_ORG_DELETED)) store.dispatch(notify(NOTIFY_CURRENT_ORG_DELETED))
allowNotifications = false allowNotifications = false
setTimeout(() => { setTimeout(() => {
allowNotifications = true allowNotifications = true
}, notificationsBlackoutDuration) }, notificationsBlackoutDuration)
} else if (wasSessionTimeout) { } else if (wasSessionTimeout) {
store.dispatch(publishNotification(NOTIFY_SESSION_TIMED_OUT)) store.dispatch(notify(NOTIFY_SESSION_TIMED_OUT))
allowNotifications = false allowNotifications = false
setTimeout(() => { setTimeout(() => {
@ -65,12 +65,10 @@ const errorsMiddleware = store => next => action => {
}, notificationsBlackoutDuration) }, notificationsBlackoutDuration)
} }
} else if (altText) { } else if (altText) {
store.dispatch( store.dispatch(notify(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText)))
publishNotification(NOTIFY_ERR_WITH_ALT_TEXT(alertType, altText))
)
} else { } else {
// TODO: actually do proper error handling // 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, setActiveKapacitorAsync,
deleteKapacitorAsync, deleteKapacitorAsync,
} from 'shared/actions/sources' } 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 FancyScrollbar from 'shared/components/FancyScrollbar'
import SourceIndicator from 'shared/components/SourceIndicator' import SourceIndicator from 'shared/components/SourceIndicator'
@ -42,13 +42,13 @@ class ManageSources extends Component {
} }
handleDeleteSource = source => () => { handleDeleteSource = source => () => {
const {publishNotification} = this.props const {notify} = this.props
try { try {
this.props.removeAndLoadSources(source) this.props.removeAndLoadSources(source)
publishNotification(NOTIFY_SOURCE_DELETED(source.name)) notify(NOTIFY_SOURCE_DELETED(source.name))
} catch (e) { } catch (e) {
publishNotification(NOTIFY_SOURCE_DELETE_FAILED(source.name)) notify(NOTIFY_SOURCE_DELETE_FAILED(source.name))
} }
} }
@ -101,7 +101,7 @@ ManageSources.propTypes = {
}), }),
}), }),
sources: array, sources: array,
publishNotification: func.isRequired, notify: func.isRequired,
removeAndLoadSources: func.isRequired, removeAndLoadSources: func.isRequired,
fetchKapacitors: func.isRequired, fetchKapacitors: func.isRequired,
setActiveKapacitor: func.isRequired, setActiveKapacitor: func.isRequired,
@ -117,7 +117,7 @@ const mapDispatchToProps = dispatch => ({
fetchKapacitors: bindActionCreators(fetchKapacitorsAsync, dispatch), fetchKapacitors: bindActionCreators(fetchKapacitorsAsync, dispatch),
setActiveKapacitor: bindActionCreators(setActiveKapacitorAsync, dispatch), setActiveKapacitor: bindActionCreators(setActiveKapacitorAsync, dispatch),
deleteKapacitor: bindActionCreators(deleteKapacitorAsync, dispatch), deleteKapacitor: bindActionCreators(deleteKapacitorAsync, dispatch),
publishNotification: bindActionCreators(publishNotificationAction, dispatch), notify: bindActionCreators(notifyAction, dispatch),
}) })
export default connect(mapStateToProps, mapDispatchToProps)(ManageSources) export default connect(mapStateToProps, mapDispatchToProps)(ManageSources)

View File

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

View File

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

View File

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