diff --git a/ui/src/CheckSources.js b/ui/src/CheckSources.js index d17a6f71d1..3d1838d64b 100644 --- a/ui/src/CheckSources.js +++ b/ui/src/CheckSources.js @@ -47,6 +47,10 @@ const CheckSources = React.createClass({ auth: shape({ isUsingAuth: bool, me: shape(), + currentOrganization: shape({ + name: string.isRequired, + id: string.isRequired, + }), }), }, @@ -106,8 +110,8 @@ const CheckSources = React.createClass({ const restString = rest === null ? DEFAULT_HOME_PAGE : rest[1] if (isUsingAuth && me.role === MEMBER_ROLE) { - // if you're a member, go to limbo. - return router.push('/limbo') + // if you're a member, go to purgatory. + return router.push('/purgatory') } if (isUsingAuth && me.role === VIEWER_ROLE) { @@ -116,8 +120,8 @@ const CheckSources = React.createClass({ } else if (sources[0]) { return router.push(`/sources/${sources[0].id}/${restString}`) } - // if you're a viewer and there are no sources, go to limbo. - return router.push('/limbo') + // if you're a viewer and there are no sources, go to purgatory. + return router.push('/purgatory') } // if you're an editor or not using auth, try for sources or otherwise @@ -142,7 +146,11 @@ const CheckSources = React.createClass({ }, render() { - const {params, sources, auth: {isUsingAuth, me}} = this.props + const { + params, + sources, + auth: {isUsingAuth, me, currentOrganization}, + } = this.props const {isFetching} = this.state const source = sources.find(s => s.id === params.sourceID) @@ -150,7 +158,8 @@ const CheckSources = React.createClass({ isFetching || !source || typeof isUsingAuth !== 'boolean' || - (me && me.role === undefined) // TODO: not sure this happens + (me && me.role === undefined) || // TODO: not sure this happens + !currentOrganization ) { return
} diff --git a/ui/src/auth/Purgatory.js b/ui/src/auth/Purgatory.js new file mode 100644 index 0000000000..14774a9feb --- /dev/null +++ b/ui/src/auth/Purgatory.js @@ -0,0 +1,70 @@ +import React, {PropTypes} from 'react' +import {connect} from 'react-redux' + +import {MEMBER_ROLE} from 'src/auth/Authorized' + +const memberCopy = ( +

This role does not grant you sufficient permissions to view Chronograf.

+) +const viewerCopy = ( +

+ This organization does not have any configured sources
and your role + does not have permission to configure a source. +

+) + +const Purgatory = ({name, provider, scheme, currentOrganization, role}) => +
+
+
+
+
+

+ Logged in to {currentOrganization.name} as a{' '} + {role}. +

+ {role === MEMBER_ROLE ? memberCopy : viewerCopy} +

Contact your Administrator for assistance.

+
+
+            
+              username: {name}
+              
+ provider: {provider} +
+ scheme: {scheme} +
+
+
+
+

+ Made by InfluxData +

+
+
+
+ +const {shape, string} = PropTypes + +Purgatory.propTypes = { + name: string.isRequired, + provider: string.isRequired, + scheme: string.isRequired, + currentOrganization: shape({ + id: string.isRequired, + name: string.isRequired, + }).isRequired, + role: string.isRequired, +} + +const mapStateToProps = ({ + auth: {me: {name, provider, scheme, currentOrganization, role}}, +}) => ({ + name, + provider, + scheme, + currentOrganization, + role, +}) + +export default connect(mapStateToProps)(Purgatory) diff --git a/ui/src/auth/index.js b/ui/src/auth/index.js index 0b9eb546a7..9239661bea 100644 --- a/ui/src/auth/index.js +++ b/ui/src/auth/index.js @@ -1,7 +1,15 @@ import Login from './Login' +import Purgatory from './Purgatory' + import { UserIsAuthenticated, Authenticated, UserIsNotAuthenticated, } from './Authenticated' -export {Login, UserIsAuthenticated, Authenticated, UserIsNotAuthenticated} +export { + Login, + Purgatory, + UserIsAuthenticated, + Authenticated, + UserIsNotAuthenticated, +} diff --git a/ui/src/index.js b/ui/src/index.js index ff3cb0f921..d025747e9b 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -11,7 +11,12 @@ import configureStore from 'src/store/configureStore' import {loadLocalStorage} from 'src/localStorage' import App from 'src/App' -import {Login, UserIsAuthenticated, UserIsNotAuthenticated} from 'src/auth' +import { + Login, + UserIsAuthenticated, + UserIsNotAuthenticated, + Purgatory, +} from 'src/auth' import CheckSources from 'src/CheckSources' import {StatusPage} from 'src/status' import {HostsPage, HostPage} from 'src/hosts' @@ -141,6 +146,7 @@ const Root = React.createClass({ + h3 { + white-space: nowrap; + } + > p { + text-align: center; + } + + hr { + width: 100%; } }