Added redirect from server base path to overview page, to ease changing default page

This commit is contained in:
Alejandro Celaya 2020-12-08 18:27:36 +01:00
parent f359a16004
commit 43af6fdaba
5 changed files with 6 additions and 5 deletions

View file

@ -1,5 +1,5 @@
import { FC, useEffect } from 'react'; import { FC, useEffect } from 'react';
import { Route, Switch } from 'react-router-dom'; import { Redirect, Route, Switch } from 'react-router-dom';
import { useSwipeable } from 'react-swipeable'; import { useSwipeable } from 'react-swipeable';
import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@ -61,6 +61,7 @@ const MenuLayout = (
<div className="col-lg-10 offset-lg-2 col-md-9 offset-md-3" onClick={() => hideSidebar()}> <div className="col-lg-10 offset-lg-2 col-md-9 offset-md-3" onClick={() => hideSidebar()}>
<div className="menu-layout__container"> <div className="menu-layout__container">
<Switch> <Switch>
<Redirect exact from="/server/:serverId" to="/server/:serverId/overview" />
<Route exact path="/server/:serverId/overview" component={Overview} /> <Route exact path="/server/:serverId/overview" component={Overview} />
<Route exact path="/server/:serverId/list-short-urls/:page" component={ShortUrls} /> <Route exact path="/server/:serverId/list-short-urls/:page" component={ShortUrls} />
<Route exact path="/server/:serverId/create-short-url" component={CreateShortUrl} /> <Route exact path="/server/:serverId/create-short-url" component={CreateShortUrl} />

View file

@ -39,7 +39,7 @@ const CreateServer = (ImportServersBtn: FC<ImportServersBtnProps>, useStateFlagT
const id = uuid(); const id = uuid();
createServer({ ...serverData, id }); createServer({ ...serverData, id });
push(`/server/${id}/overview`); push(`/server/${id}`);
}; };
return ( return (

View file

@ -18,7 +18,7 @@ export const EditServer = (ServerError: FC) => withSelectedServer<EditServerProp
const handleSubmit = (serverData: ServerData) => { const handleSubmit = (serverData: ServerData) => {
editServer(selectedServer.id, serverData); editServer(selectedServer.id, serverData);
push(`/server/${selectedServer.id}/overview`); push(`/server/${selectedServer.id}`);
}; };
return ( return (

View file

@ -23,7 +23,7 @@ const ServersDropdown = (serversExporter: ServersExporter) => ({ servers, select
<DropdownItem <DropdownItem
key={id} key={id}
tag={Link} tag={Link}
to={`/server/${id}/overview`} to={`/server/${id}`}
active={isServerWithId(selectedServer) && selectedServer.id === id} active={isServerWithId(selectedServer) && selectedServer.id === id}
> >
{name} {name}

View file

@ -11,7 +11,7 @@ interface ServersListGroup {
} }
const ServerListItem = ({ id, name }: { id: string; name: string }) => ( const ServerListItem = ({ id, name }: { id: string; name: string }) => (
<ListGroupItem tag={Link} to={`/server/${id}/overview`} className="servers-list__server-item"> <ListGroupItem tag={Link} to={`/server/${id}`} className="servers-list__server-item">
{name} {name}
<FontAwesomeIcon icon={chevronIcon} className="servers-list__server-item-icon" /> <FontAwesomeIcon icon={chevronIcon} className="servers-list__server-item-icon" />
</ListGroupItem> </ListGroupItem>