removed duplicate route components from browser (#5584)

All routes '/', '/:bucket/', '/:bucket/*' render the same
component. Instead we could just have a single route like following which
combines all the above routes

'/:bucket?/*'

bucket is optional here, so it can cover '/'
This commit is contained in:
Kanagaraj M
2018-03-01 00:49:00 +05:30
committed by Harshavardhana
parent a6adef0bdf
commit 54e5ee6535
3 changed files with 45 additions and 19 deletions

View File

@@ -19,28 +19,12 @@ import { Route, Switch, Redirect } from "react-router-dom"
import Browser from "./browser/Browser"
import Login from "./browser/Login"
import web from "./web"
import { minioBrowserPrefix } from "./constants"
const AuthorizedRoute = ({ component: Component, ...rest }) => (
<Route
{...rest}
render={props =>
web.LoggedIn() ? (
<Component {...props} />
) : (
<Redirect to={`${minioBrowserPrefix}/login`} />
)
}
/>
)
export const App = () => {
return (
<Switch>
<AuthorizedRoute exact path={"/"} component={Browser} />
<Route path={"/login"} component={Login} />
<Route path={"/:bucket/*"} component={Browser} />
<Route path={"/:bucket"} component={Browser} />
<Route path={"/:bucket?/*"} component={Browser} />
</Switch>
)
}