mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
* Updates eslint packages * Expected parentheses around arrow function argument having a body with curly braces * Prop type `object` is forbidden * Visible, non-interactive elements should not have mouse or keyboard event listeners * Prop type is defined but not used * Unexpected use of file extension "jsx" * Expected 'this' to be used by class method * HTML entities must be escaped * Prevent default behavior on more options button click
47 lines
917 B
JavaScript
47 lines
917 B
JavaScript
import React, { Component, PropTypes } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { push } from 'react-router-redux';
|
|
|
|
import paths from '../../router/paths';
|
|
import userInterface from '../../interfaces/user';
|
|
|
|
export class AuthenticatedAdminRoutes extends Component {
|
|
static propTypes = {
|
|
children: PropTypes.node,
|
|
dispatch: PropTypes.func,
|
|
user: userInterface,
|
|
};
|
|
|
|
componentWillMount () {
|
|
const { dispatch, user: { admin } } = this.props;
|
|
const { HOME } = paths;
|
|
|
|
if (!admin) {
|
|
dispatch(push(HOME));
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
render () {
|
|
const { children, user } = this.props;
|
|
|
|
if (!user) {
|
|
return false;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
const mapStateToProps = (state) => {
|
|
const { user } = state.auth;
|
|
|
|
return { user };
|
|
};
|
|
|
|
export default connect(mapStateToProps)(AuthenticatedAdminRoutes);
|