Code cleanup and formatting

This commit is contained in:
Dane Everitt 2020-04-10 10:11:15 -07:00
parent 4e2602e1e7
commit 07d19ad326
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 44 additions and 43 deletions

View file

@ -1,6 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import { hot } from 'react-hot-loader/root'; import { hot } from 'react-hot-loader/root';
import { BrowserRouter, BrowserRouter as Router, Route, Switch } from 'react-router-dom'; import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { StoreProvider } from 'easy-peasy'; import { StoreProvider } from 'easy-peasy';
import { store } from '@/state'; import { store } from '@/state';
import DashboardRouter from '@/routers/DashboardRouter'; import DashboardRouter from '@/routers/DashboardRouter';
@ -57,17 +57,15 @@ const App = () => {
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<StoreProvider store={store}> <StoreProvider store={store}>
<Provider store={store}> <Provider store={store}>
<Router basename={'/'}> <div className={'mx-auto w-auto'}>
<div className={'mx-auto w-auto'}> <BrowserRouter basename={'/'} key={'root-router'}>
<BrowserRouter basename={'/'}> <Switch>
<Switch> <Route path="/server/:id" component={ServerRouter}/>
<Route path="/server/:id" component={ServerRouter}/> <Route path="/auth" component={AuthenticationRouter}/>
<Route path="/auth" component={AuthenticationRouter}/> <Route path="/" component={DashboardRouter}/>
<Route path="/" component={DashboardRouter}/> </Switch>
</Switch> </BrowserRouter>
</BrowserRouter> </div>
</div>
</Router>
</Provider> </Provider>
</StoreProvider> </StoreProvider>
</ThemeProvider> </ThemeProvider>

View file

@ -15,6 +15,7 @@ import useServer from '@/plugins/useServer';
import deleteBackup from '@/api/server/backups/deleteBackup'; import deleteBackup from '@/api/server/backups/deleteBackup';
import { ServerContext } from '@/state/server'; import { ServerContext } from '@/state/server';
import ConfirmationModal from '@/components/elements/ConfirmationModal'; import ConfirmationModal from '@/components/elements/ConfirmationModal';
import Can from '@/components/elements/Can';
interface Props { interface Props {
backup: ServerBackup; backup: ServerBackup;
@ -90,18 +91,22 @@ export default ({ backup }: Props) => {
)} )}
> >
<div className={'text-sm'}> <div className={'text-sm'}>
<DropdownButtonRow onClick={() => doDownload()}> <Can action={'backup.download'}>
<FontAwesomeIcon fixedWidth={true} icon={faCloudDownloadAlt} className={'text-xs'}/> <DropdownButtonRow onClick={() => doDownload()}>
<span className={'ml-2'}>Download</span> <FontAwesomeIcon fixedWidth={true} icon={faCloudDownloadAlt} className={'text-xs'}/>
</DropdownButtonRow> <span className={'ml-2'}>Download</span>
</DropdownButtonRow>
</Can>
<DropdownButtonRow onClick={() => setVisible(true)}> <DropdownButtonRow onClick={() => setVisible(true)}>
<FontAwesomeIcon fixedWidth={true} icon={faLock} className={'text-xs'}/> <FontAwesomeIcon fixedWidth={true} icon={faLock} className={'text-xs'}/>
<span className={'ml-2'}>Checksum</span> <span className={'ml-2'}>Checksum</span>
</DropdownButtonRow> </DropdownButtonRow>
<DropdownButtonRow danger={true} onClick={() => setDeleteVisible(true)}> <Can action={'backup.delete'}>
<FontAwesomeIcon fixedWidth={true} icon={faTrashAlt} className={'text-xs'}/> <DropdownButtonRow danger={true} onClick={() => setDeleteVisible(true)}>
<span className={'ml-2'}>Delete</span> <FontAwesomeIcon fixedWidth={true} icon={faTrashAlt} className={'text-xs'}/>
</DropdownButtonRow> <span className={'ml-2'}>Delete</span>
</DropdownButtonRow>
</Can>
</div> </div>
</DropdownMenu> </DropdownMenu>
</> </>

View file

@ -30,7 +30,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
useEffect(() => () => clearServerState(), [ clearServerState ]); useEffect(() => () => clearServerState(), [ clearServerState ]);
return ( return (
<React.Fragment> <React.Fragment key={'server-router'}>
<NavigationBar/> <NavigationBar/>
<CSSTransition timeout={250} classNames={'fade'} appear={true} in={true}> <CSSTransition timeout={250} classNames={'fade'} appear={true} in={true}>
<div id={'sub-navigation'}> <div id={'sub-navigation'}>
@ -51,7 +51,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
<Can action={'backup.*'}> <Can action={'backup.*'}>
<NavLink to={`${match.url}/backups`}>Backups</NavLink> <NavLink to={`${match.url}/backups`}>Backups</NavLink>
</Can> </Can>
<Can action={['settings.*', 'file.sftp']} matchAny={true}> <Can action={[ 'settings.*', 'file.sftp' ]} matchAny={true}>
<NavLink to={`${match.url}/settings`}>Settings</NavLink> <NavLink to={`${match.url}/settings`}>Settings</NavLink>
</Can> </Can>
</div> </div>
@ -64,27 +64,25 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
<Spinner size={'large'}/> <Spinner size={'large'}/>
</div> </div>
: :
<React.Fragment> <Switch location={location} key={'server-switch'}>
<Switch location={location}> <Route path={`${match.path}`} component={ServerConsole} exact/>
<Route path={`${match.path}`} component={ServerConsole} exact/> <Route path={`${match.path}/files`} component={FileManagerContainer} exact/>
<Route path={`${match.path}/files`} component={FileManagerContainer} exact/> <Route
<Route path={`${match.path}/files/:action(edit|new)`}
path={`${match.path}/files/:action(edit|new)`} render={props => (
render={props => ( <SuspenseSpinner>
<SuspenseSpinner> <FileEditContainer {...props as any}/>
<FileEditContainer {...props as any}/> </SuspenseSpinner>
</SuspenseSpinner> )}
)} exact
exact />
/> <Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/> <Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/>
<Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/> <Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} exact/>
<Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} exact/> <Route path={`${match.path}/users`} component={UsersContainer} exact/>
<Route path={`${match.path}/users`} component={UsersContainer} exact/> <Route path={`${match.path}/backups`} component={BackupContainer} exact/>
<Route path={`${match.path}/backups`} component={BackupContainer} exact/> <Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
<Route path={`${match.path}/settings`} component={SettingsContainer} exact/> </Switch>
</Switch>
</React.Fragment>
} }
</TransitionRouter> </TransitionRouter>
</React.Fragment> </React.Fragment>