diff --git a/ui/src/CheckSources.js b/ui/src/CheckSources.js index 358528755..b18103253 100644 --- a/ui/src/CheckSources.js +++ b/ui/src/CheckSources.js @@ -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)( diff --git a/ui/src/admin/actions/chronograf.js b/ui/src/admin/actions/chronograf.js index 1ec29b672..4e155fe1f 100644 --- a/ui/src/admin/actions/chronograf.js +++ b/ui/src/admin/actions/chronograf.js @@ -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)) diff --git a/ui/src/admin/actions/influxdb.js b/ui/src/admin/actions/influxdb.js index 1ed33cf1e..530f3507a 100644 --- a/ui/src/admin/actions/influxdb.js +++ b/ui/src/admin/actions/influxdb.js @@ -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( diff --git a/ui/src/admin/components/DatabaseRow.js b/ui/src/admin/components/DatabaseRow.js index 23552d38d..11943c746 100644 --- a/ui/src/admin/components/DatabaseRow.js +++ b/ui/src/admin/components/DatabaseRow.js @@ -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)) diff --git a/ui/src/admin/components/DatabaseTableHeader.js b/ui/src/admin/components/DatabaseTableHeader.js index 2ad3f49d0..33dca15a5 100644 --- a/ui/src/admin/components/DatabaseTableHeader.js +++ b/ui/src/admin/components/DatabaseTableHeader.js @@ -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 (
{ 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) diff --git a/ui/src/admin/components/chronograf/AllUsersTableRowNew.js b/ui/src/admin/components/chronograf/AllUsersTableRowNew.js index cd93e98ec..406f5e290 100644 --- a/ui/src/admin/components/chronograf/AllUsersTableRowNew.js +++ b/ui/src/admin/components/chronograf/AllUsersTableRowNew.js @@ -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) diff --git a/ui/src/admin/components/chronograf/UsersTableRowNew.js b/ui/src/admin/components/chronograf/UsersTableRowNew.js index a283a2be1..9b05fac0e 100644 --- a/ui/src/admin/components/chronograf/UsersTableRowNew.js +++ b/ui/src/admin/components/chronograf/UsersTableRowNew.js @@ -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) diff --git a/ui/src/admin/containers/AdminInfluxDBPage.js b/ui/src/admin/containers/AdminInfluxDBPage.js index 4a205938f..76fe7d6a6 100644 --- a/ui/src/admin/containers/AdminInfluxDBPage.js +++ b/ui/src/admin/containers/AdminInfluxDBPage.js @@ -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) diff --git a/ui/src/admin/containers/DatabaseManagerPage.js b/ui/src/admin/containers/DatabaseManagerPage.js index db9569f33..2448ea417 100644 --- a/ui/src/admin/containers/DatabaseManagerPage.js +++ b/ui/src/admin/containers/DatabaseManagerPage.js @@ -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 ( ({ @@ -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) diff --git a/ui/src/admin/containers/ProvidersPage.js b/ui/src/admin/containers/ProvidersPage.js index 948802336..64bcef0de 100644 --- a/ui/src/admin/containers/ProvidersPage.js +++ b/ui/src/admin/containers/ProvidersPage.js @@ -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) diff --git a/ui/src/admin/containers/QueriesPage.js b/ui/src/admin/containers/QueriesPage.js index fbbd88e1e..709e6e7d7 100644 --- a/ui/src/admin/containers/QueriesPage.js +++ b/ui/src/admin/containers/QueriesPage.js @@ -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) diff --git a/ui/src/admin/containers/chronograf/AllUsersPage.js b/ui/src/admin/containers/chronograf/AllUsersPage.js index a47659265..3407cd90a 100644 --- a/ui/src/admin/containers/chronograf/AllUsersPage.js +++ b/ui/src/admin/containers/chronograf/AllUsersPage.js @@ -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) diff --git a/ui/src/admin/containers/chronograf/UsersPage.js b/ui/src/admin/containers/chronograf/UsersPage.js index 7aee17f84..0d79e31b6 100644 --- a/ui/src/admin/containers/chronograf/UsersPage.js +++ b/ui/src/admin/containers/chronograf/UsersPage.js @@ -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) diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index eda29e635..2cafbd89b 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -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( diff --git a/ui/src/dashboards/components/template_variables/Row.js b/ui/src/dashboards/components/template_variables/Row.js index 579cc6329..f75c8afdf 100644 --- a/ui/src/dashboards/components/template_variables/Row.js +++ b/ui/src/dashboards/components/template_variables/Row.js @@ -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)) diff --git a/ui/src/dashboards/containers/DashboardPage.js b/ui/src/dashboards/containers/DashboardPage.js index ee74dc322..19851d8f3 100644 --- a/ui/src/dashboards/containers/DashboardPage.js +++ b/ui/src/dashboards/containers/DashboardPage.js @@ -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 diff --git a/ui/src/data_explorer/actions/view/write.js b/ui/src/data_explorer/actions/view/write.js index dd5c5a476..0ed46bc9c 100644 --- a/ui/src/data_explorer/actions/view/write.js +++ b/ui/src/data_explorer/actions/view/write.js @@ -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)) diff --git a/ui/src/hosts/containers/HostsPage.js b/ui/src/hosts/containers/HostsPage.js index 7bfb5e35e..c66eec7ac 100644 --- a/ui/src/hosts/containers/HostsPage.js +++ b/ui/src/hosts/containers/HostsPage.js @@ -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)( diff --git a/ui/src/kapacitor/actions/view/index.js b/ui/src/kapacitor/actions/view/index.js index c04b2c4be..8ff36abbc 100644 --- a/ui/src/kapacitor/actions/view/index.js +++ b/ui/src/kapacitor/actions/view/index.js @@ -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) { diff --git a/ui/src/kapacitor/components/AlertOutputs.tsx b/ui/src/kapacitor/components/AlertOutputs.tsx index 45684790d..235d6b031 100644 --- a/ui/src/kapacitor/components/AlertOutputs.tsx +++ b/ui/src/kapacitor/components/AlertOutputs.tsx @@ -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 = ({ @@ -27,7 +27,7 @@ const AlertOutputs: SFC = ({ exists, source, kapacitor, - publishNotification, + notify, }) => { if (exists) { return ( @@ -35,7 +35,7 @@ const AlertOutputs: SFC = ({ hash={hash} source={source} kapacitor={kapacitor} - publishNotification={publishNotification} + notify={notify} /> ) } diff --git a/ui/src/kapacitor/components/AlertTabs.js b/ui/src/kapacitor/components/AlertTabs.js index 5d6827c6f..75e6c16fc 100644 --- a/ui/src/kapacitor/components/AlertTabs.js +++ b/ui/src/kapacitor/components/AlertTabs.js @@ -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, } diff --git a/ui/src/kapacitor/components/KapacitorForm.tsx b/ui/src/kapacitor/components/KapacitorForm.tsx index b722e89f0..27cad075a 100644 --- a/ui/src/kapacitor/components/KapacitorForm.tsx +++ b/ui/src/kapacitor/components/KapacitorForm.tsx @@ -25,7 +25,7 @@ interface Props { onChangeUrl: (e: ChangeEvent) => void source: Source hash: string - publishNotification: (message: Notification | NotificationFunc) => void + notify: (message: Notification | NotificationFunc) => void } const KapacitorForm: SFC = ({ @@ -38,7 +38,7 @@ const KapacitorForm: SFC = ({ onInputChange, source, hash, - publishNotification, + notify, }) =>
@@ -119,7 +119,7 @@ const KapacitorForm: SFC = ({ exists={exists} source={source} kapacitor={kapacitor} - publishNotification={publishNotification} + notify={notify} />
diff --git a/ui/src/kapacitor/components/KapacitorRule.js b/ui/src/kapacitor/components/KapacitorRule.js index 50e1686f0..ca60f66c0 100644 --- a/ui/src/kapacitor/components/KapacitorRule.js +++ b/ui/src/kapacitor/components/KapacitorRule.js @@ -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) diff --git a/ui/src/kapacitor/containers/KapacitorPage.tsx b/ui/src/kapacitor/containers/KapacitorPage.tsx index aee066d33..b8fb44257 100644 --- a/ui/src/kapacitor/containers/KapacitorPage.tsx +++ b/ui/src/kapacitor/containers/KapacitorPage.tsx @@ -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 { } 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 { 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 { handleSubmit = async e => { e.preventDefault() const { - publishNotification, + notify, source, source: {kapacitors = []}, params, @@ -128,7 +128,7 @@ export class KapacitorPage extends PureComponent { 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 { 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 { 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 { } 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 { } 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 { 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)) diff --git a/ui/src/kapacitor/containers/KapacitorRulePage.js b/ui/src/kapacitor/containers/KapacitorRulePage.js index 2edaf35ff..a0c4f283c 100644 --- a/ui/src/kapacitor/containers/KapacitorRulePage.js +++ b/ui/src/kapacitor/containers/KapacitorRulePage.js @@ -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 diff --git a/ui/src/kapacitor/containers/TickscriptPage.js b/ui/src/kapacitor/containers/TickscriptPage.js index 1787a19d2..00721c2ab 100644 --- a/ui/src/kapacitor/containers/TickscriptPage.js +++ b/ui/src/kapacitor/containers/TickscriptPage.js @@ -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) diff --git a/ui/src/shared/actions/auth.js b/ui/src/shared/actions/auth.js index c3a756414..8b99280f7 100644 --- a/ui/src/shared/actions/auth.js +++ b/ui/src/shared/actions/auth.js @@ -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) ) ) diff --git a/ui/src/shared/actions/notifications.js b/ui/src/shared/actions/notifications.js index f212406b1..5e1fbce2c 100644 --- a/ui/src/shared/actions/notifications.js +++ b/ui/src/shared/actions/notifications.js @@ -1,4 +1,4 @@ -export const publishNotification = notification => ({ +export const notify = notification => ({ type: 'PUBLISH_NOTIFICATION', payload: {notification}, }) diff --git a/ui/src/shared/actions/sources.js b/ui/src/shared/actions/sources.js index 02a8d6e9a..f81009bac 100644 --- a/ui/src/shared/actions/sources.js +++ b/ui/src/shared/actions/sources.js @@ -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)) } } diff --git a/ui/src/shared/dispatchers/index.js b/ui/src/shared/dispatchers/index.js index 6d068ebad..fc8019d8a 100644 --- a/ui/src/shared/dispatchers/index.js +++ b/ui/src/shared/dispatchers/index.js @@ -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)) } diff --git a/ui/src/shared/middleware/errors.js b/ui/src/shared/middleware/errors.js index 8cd42b2c1..c72965b15 100644 --- a/ui/src/shared/middleware/errors.js +++ b/ui/src/shared/middleware/errors.js @@ -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.')) } } diff --git a/ui/src/sources/containers/ManageSources.js b/ui/src/sources/containers/ManageSources.js index 9353be436..2368cd191 100644 --- a/ui/src/sources/containers/ManageSources.js +++ b/ui/src/sources/containers/ManageSources.js @@ -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) diff --git a/ui/src/sources/containers/SourcePage.js b/ui/src/sources/containers/SourcePage.js index 6dcafc518..8c813e76f 100644 --- a/ui/src/sources/containers/SourcePage.js +++ b/ui/src/sources/containers/SourcePage.js @@ -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), }) diff --git a/ui/test/kapacitor/containers/KapacitorPage.test.tsx b/ui/test/kapacitor/containers/KapacitorPage.test.tsx index fbba550ce..d4a5d7039 100644 --- a/ui/test/kapacitor/containers/KapacitorPage.test.tsx +++ b/ui/test/kapacitor/containers/KapacitorPage.test.tsx @@ -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: () => {}, diff --git a/ui/test/shared/reducers/notifications.test.js b/ui/test/shared/reducers/notifications.test.js index 5dc0a1dfa..4c57534d4 100644 --- a/ui/test/shared/reducers/notifications.test.js +++ b/ui/test/shared/reducers/notifications.test.js @@ -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)