import React from 'react';
import Path from 'path';
import { Route, Switch, Link, NavLink } from 'react-router-dom';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import './error.scss';
import './adminpage.scss';
import { Icon, LoadingPage } from '../components/';
import { Config, Admin } from '../model';
import { notify } from '../helpers/';
import { HomePage, DashboardPage, ConfigPage, LogPage, PluginPage, SupportPage, SetupPage, LoginPage } from './adminpage/';
import { t } from '../locales/';
function AdminOnly(WrappedComponent){
return class extends React.Component {
constructor(props){
super(props);
this.state = {
isAdmin: null
};
this.admin = () => {
Admin.isAdmin().then((t) => {
this.setState({isAdmin: t});
}).catch((err) => {
notify.send("Error: " + (err && err.message) , "error");
});
};
this.timeout = window.setInterval(this.admin.bind(this), 30 * 1000);
}
componentDidMount(){
this.admin.call(this);
}
componentWillUnmount(){
window.clearInterval(this.timeout);
}
render(){
if(this.state.isAdmin === true){
return ( );
} else if(this.state.isAdmin === false) {
return ( this.admin()} /> );
}
return ( );
}
};
}
@AdminOnly
export class AdminPage extends React.Component {
constructor(props){
super(props);
this.state = {
isAdmin: null,
isSaving: false
};
}
isSaving(yesOrNo){
this.setState({isSaving: yesOrNo});
}
render(){
return (
);
}
}
const SideMenu = (props) => {
return (
{ props.isLoading ?
:
}
{ t("Admin console") }
-
{ t("Dashboard") }
-
{ t("Configure") }
-
{ t("Activity") }
-
{ t("Support") }
);
};