import React, { Fragment } from 'react'; import { HashRouter as Router, Redirect, Switch, } from 'react-router-dom'; import { BackgroundImage, BackgroundImageSrc, Nav, NavExpandable, NavList, NavItem, Page, PageHeader, PageSidebar } from '@patternfly/react-core'; import { global_breakpoint_md as breakpointMd } from '@patternfly/react-tokens'; import api from './api'; // import About from './components/About'; import LogoutButton from './components/LogoutButton'; import TowerLogo from './components/TowerLogo'; import ConditionalRedirect from './components/ConditionalRedirect'; import Applications from './pages/Applications'; import Credentials from './pages/Credentials'; import CredentialTypes from './pages/CredentialTypes'; import Dashboard from './pages/Dashboard'; import InstanceGroups from './pages/InstanceGroups'; import Inventories from './pages/Inventories'; import InventoryScripts from './pages/InventoryScripts'; import Jobs from './pages/Jobs'; import Login from './pages/Login'; import ManagementJobs from './pages/ManagementJobs'; import NotificationTemplates from './pages/NotificationTemplates'; import Organizations from './pages/Organizations'; import Portal from './pages/Portal'; import Projects from './pages/Projects'; import Schedules from './pages/Schedules'; import AuthSettings from './pages/AuthSettings'; import JobsSettings from './pages/JobsSettings'; import SystemSettings from './pages/SystemSettings'; import UISettings from './pages/UISettings'; import License from './pages/License'; import Teams from './pages/Teams'; import Templates from './pages/Templates'; import Users from './pages/Users'; class App extends React.Component { constructor (props) { super(props); const isNavOpen = typeof window !== 'undefined' && window.innerWidth >= parseInt(breakpointMd.value, 10); this.state = { isNavOpen, activeGroup: 'views_group', activeItem: 'views_group_dashboard' }; } onNavSelect = result => { this.setState({ activeItem: result.itemId, activeGroup: result.groupId }); }; onNavToggle = () => { this.setState(({ isNavOpen }) => ({ isNavOpen: !isNavOpen })); }; onLogoClick = () => { this.setState({ activeGroup: 'views_group', activeItem: 'views_group_dashboard' }); } onDevLogout = () => { api.logout() .then(() => { this.setState({ activeGroup: 'views_group', activeItem: 'views_group_dashboard' }); }); } render () { const { activeItem, activeGroup, isNavOpen } = this.state; const { logo, loginInfo } = this.props; return ( api.isAuthenticated()} redirectPath="/" path="/login" component={() => } /> } avatar={ this.onDevLogout()} />} showNavToggle onNavToggle={this.onNavToggle} /> )} sidebar={( Dashboard Jobs Schedules My View Templates Credentials Projects Inventories Inventory Scripts Organizations Users Teams Credential Types Notification Templates Management Jobs Instance Groups Applications Authentication Jobs System User Interface )} /> )} > !api.isAuthenticated()} redirectPath="/login" exact path="/" component={() => ()} /> !api.isAuthenticated()} redirectPath="/login" path="/home" component={Dashboard} /> !api.isAuthenticated()} redirectPath="/login" path="/jobs" component={Jobs} /> !api.isAuthenticated()} redirectPath="/login" path="/schedules" component={Schedules} /> !api.isAuthenticated()} redirectPath="/login" path="/portal" component={Portal} /> !api.isAuthenticated()} redirectPath="/login" path="/templates" component={Templates} /> !api.isAuthenticated()} redirectPath="/login" path="/credentials" component={Credentials} /> !api.isAuthenticated()} redirectPath="/login" path="/projects" component={Projects} /> !api.isAuthenticated()} redirectPath="/login" path="/inventories" component={Inventories} /> !api.isAuthenticated()} redirectPath="/login" path="/inventory_scripts" component={InventoryScripts} /> !api.isAuthenticated()} redirectPath="/login" path="/organizations" component={Organizations} /> !api.isAuthenticated()} redirectPath="/login" path="/users" component={Users} /> !api.isAuthenticated()} redirectPath="/login" path="/teams" component={Teams} /> !api.isAuthenticated()} redirectPath="/login" path="/credential_types" component={CredentialTypes} /> !api.isAuthenticated()} redirectPath="/login" path="/notification_templates" component={NotificationTemplates} /> !api.isAuthenticated()} redirectPath="/login" path="/management_jobs" component={ManagementJobs} /> !api.isAuthenticated()} redirectPath="/login" path="/instance_groups" component={InstanceGroups} /> !api.isAuthenticated()} redirectPath="/login" path="/applications" component={Applications} /> !api.isAuthenticated()} redirectPath="/login" path="/auth_settings" component={AuthSettings} /> !api.isAuthenticated()} redirectPath="/login" path="/jobs_settings" component={JobsSettings} /> !api.isAuthenticated()} redirectPath="/login" path="/system_settings" component={SystemSettings} /> !api.isAuthenticated()} redirectPath="/login" path="/ui_settings" component={UISettings} /> !api.isAuthenticated()} redirectPath="/login" path="/license" component={License} /> ); } } export default App;