Skip to content

Commit 07d19ad

Browse files
committed
Code cleanup and formatting
1 parent 4e2602e commit 07d19ad

File tree

3 files changed

+44
-43
lines changed

3 files changed

+44
-43
lines changed

resources/scripts/components/App.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { hot } from 'react-hot-loader/root';
3-
import { BrowserRouter, BrowserRouter as Router, Route, Switch } from 'react-router-dom';
3+
import { BrowserRouter, Route, Switch } from 'react-router-dom';
44
import { StoreProvider } from 'easy-peasy';
55
import { store } from '@/state';
66
import DashboardRouter from '@/routers/DashboardRouter';
@@ -57,17 +57,15 @@ const App = () => {
5757
<ThemeProvider theme={theme}>
5858
<StoreProvider store={store}>
5959
<Provider store={store}>
60-
<Router basename={'/'}>
61-
<div className={'mx-auto w-auto'}>
62-
<BrowserRouter basename={'/'}>
63-
<Switch>
64-
<Route path="/server/:id" component={ServerRouter}/>
65-
<Route path="/auth" component={AuthenticationRouter}/>
66-
<Route path="/" component={DashboardRouter}/>
67-
</Switch>
68-
</BrowserRouter>
69-
</div>
70-
</Router>
60+
<div className={'mx-auto w-auto'}>
61+
<BrowserRouter basename={'/'} key={'root-router'}>
62+
<Switch>
63+
<Route path="/server/:id" component={ServerRouter}/>
64+
<Route path="/auth" component={AuthenticationRouter}/>
65+
<Route path="/" component={DashboardRouter}/>
66+
</Switch>
67+
</BrowserRouter>
68+
</div>
7169
</Provider>
7270
</StoreProvider>
7371
</ThemeProvider>

resources/scripts/components/server/backups/BackupContextMenu.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import useServer from '@/plugins/useServer';
1515
import deleteBackup from '@/api/server/backups/deleteBackup';
1616
import { ServerContext } from '@/state/server';
1717
import ConfirmationModal from '@/components/elements/ConfirmationModal';
18+
import Can from '@/components/elements/Can';
1819

1920
interface Props {
2021
backup: ServerBackup;
@@ -90,18 +91,22 @@ export default ({ backup }: Props) => {
9091
)}
9192
>
9293
<div className={'text-sm'}>
93-
<DropdownButtonRow onClick={() => doDownload()}>
94-
<FontAwesomeIcon fixedWidth={true} icon={faCloudDownloadAlt} className={'text-xs'}/>
95-
<span className={'ml-2'}>Download</span>
96-
</DropdownButtonRow>
94+
<Can action={'backup.download'}>
95+
<DropdownButtonRow onClick={() => doDownload()}>
96+
<FontAwesomeIcon fixedWidth={true} icon={faCloudDownloadAlt} className={'text-xs'}/>
97+
<span className={'ml-2'}>Download</span>
98+
</DropdownButtonRow>
99+
</Can>
97100
<DropdownButtonRow onClick={() => setVisible(true)}>
98101
<FontAwesomeIcon fixedWidth={true} icon={faLock} className={'text-xs'}/>
99102
<span className={'ml-2'}>Checksum</span>
100103
</DropdownButtonRow>
101-
<DropdownButtonRow danger={true} onClick={() => setDeleteVisible(true)}>
102-
<FontAwesomeIcon fixedWidth={true} icon={faTrashAlt} className={'text-xs'}/>
103-
<span className={'ml-2'}>Delete</span>
104-
</DropdownButtonRow>
104+
<Can action={'backup.delete'}>
105+
<DropdownButtonRow danger={true} onClick={() => setDeleteVisible(true)}>
106+
<FontAwesomeIcon fixedWidth={true} icon={faTrashAlt} className={'text-xs'}/>
107+
<span className={'ml-2'}>Delete</span>
108+
</DropdownButtonRow>
109+
</Can>
105110
</div>
106111
</DropdownMenu>
107112
</>

resources/scripts/routers/ServerRouter.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
3030
useEffect(() => () => clearServerState(), [ clearServerState ]);
3131

3232
return (
33-
<React.Fragment>
33+
<React.Fragment key={'server-router'}>
3434
<NavigationBar/>
3535
<CSSTransition timeout={250} classNames={'fade'} appear={true} in={true}>
3636
<div id={'sub-navigation'}>
@@ -51,7 +51,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
5151
<Can action={'backup.*'}>
5252
<NavLink to={`${match.url}/backups`}>Backups</NavLink>
5353
</Can>
54-
<Can action={['settings.*', 'file.sftp']} matchAny={true}>
54+
<Can action={[ 'settings.*', 'file.sftp' ]} matchAny={true}>
5555
<NavLink to={`${match.url}/settings`}>Settings</NavLink>
5656
</Can>
5757
</div>
@@ -64,27 +64,25 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
6464
<Spinner size={'large'}/>
6565
</div>
6666
:
67-
<React.Fragment>
68-
<Switch location={location}>
69-
<Route path={`${match.path}`} component={ServerConsole} exact/>
70-
<Route path={`${match.path}/files`} component={FileManagerContainer} exact/>
71-
<Route
72-
path={`${match.path}/files/:action(edit|new)`}
73-
render={props => (
74-
<SuspenseSpinner>
75-
<FileEditContainer {...props as any}/>
76-
</SuspenseSpinner>
77-
)}
78-
exact
79-
/>
80-
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
81-
<Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/>
82-
<Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} exact/>
83-
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
84-
<Route path={`${match.path}/backups`} component={BackupContainer} exact/>
85-
<Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
86-
</Switch>
87-
</React.Fragment>
67+
<Switch location={location} key={'server-switch'}>
68+
<Route path={`${match.path}`} component={ServerConsole} exact/>
69+
<Route path={`${match.path}/files`} component={FileManagerContainer} exact/>
70+
<Route
71+
path={`${match.path}/files/:action(edit|new)`}
72+
render={props => (
73+
<SuspenseSpinner>
74+
<FileEditContainer {...props as any}/>
75+
</SuspenseSpinner>
76+
)}
77+
exact
78+
/>
79+
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
80+
<Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/>
81+
<Route path={`${match.path}/schedules/:id`} component={ScheduleEditContainer} exact/>
82+
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
83+
<Route path={`${match.path}/backups`} component={BackupContainer} exact/>
84+
<Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
85+
</Switch>
8886
}
8987
</TransitionRouter>
9088
</React.Fragment>

0 commit comments

Comments
 (0)