1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

feat(cp-frontend): Add 404 to router and redirects for not matched routes

This commit is contained in:
JUDIT GRESKOVITS 2017-08-02 16:54:28 +01:00 committed by Sérgio Ramos
parent b1f76553ce
commit 2f8ca24fa0
3 changed files with 113 additions and 80 deletions

View File

@ -6,7 +6,7 @@
"repository": "github:yldio/joyent-portal", "repository": "github:yldio/joyent-portal",
"main": "src/index.js", "main": "src/index.js",
"scripts": { "scripts": {
"dev": "REACT_APP_GQL_PORT=3000 PORT=3069 react-scripts start", "dev": "REACT_APP_GQL_PORT=3000 PORT=3069 REACT_APP_GQL_PROTOCOL=http react-scripts start",
"start": "PORT=3069 react-scripts start", "start": "PORT=3069 react-scripts start",
"build": "NODE_ENV=production react-scripts build", "build": "NODE_ENV=production react-scripts build",
"lint:css": "echo 0", "lint:css": "echo 0",

View File

@ -90,11 +90,23 @@ const StyledIconButton = styled(IconButton)`
border: none; border: none;
&:hover, &:hover,
&:focus,
&:active, &:active,
&:active:hover, &:active:hover,
&:active:focus { &:active:focus {
background-color: ${props => props.theme.white}; background-color: ${props => props.theme.white};
} }
&:focus > svg,
&:hover > svg {
fill: ${props => props.theme.red};
}
&:active > svg,
&:active:hover > svg,
&:active:focus > svg {
fill: ${props => props.theme.redDark};
}
`; `;
const DeploymentGroupList = ({ const DeploymentGroupList = ({

View File

@ -41,10 +41,15 @@ const serviceRedirect = p =>
.params.service}/instances`} .params.service}/instances`}
/>; />;
const Router = ( // TODO component to be designed
<BrowserRouter> const notFound = p => {
<Container> return <p>
<Route path="/" component={Header} /> NOT FOUND
</p>;
}
const APP = p => (
<div>
<Switch> <Switch>
<Route <Route
@ -57,6 +62,7 @@ const Router = (
/> />
<Route path="/deployment-groups" component={Breadcrumb} /> <Route path="/deployment-groups" component={Breadcrumb} />
</Switch> </Switch>
<Switch> <Switch>
<Route <Route
path="/deployment-groups/:deploymentGroup/delete" path="/deployment-groups/:deploymentGroup/delete"
@ -70,25 +76,7 @@ const Router = (
<Route path="/deployment-groups/:deploymentGroup" component={Menu} /> <Route path="/deployment-groups/:deploymentGroup" component={Menu} />
</Switch> </Switch>
<Route path="/" exact component={rootRedirect} />
<Route path="/deployment-groups" exact component={DeploymentGroupList} /> <Route path="/deployment-groups" exact component={DeploymentGroupList} />
<Route
path="/deployment-groups/:deploymentGroup/delete"
exact
component={DeploymentGroupList}
/>
<Route
path="/deployment-groups/:deploymentGroup"
exact
component={deploymentGroupRedirect}
/>
<Route
path="/deployment-groups/:deploymentGroup/services/:service"
exact
component={serviceRedirect}
/>
<Route <Route
path="/deployment-groups/:deploymentGroup/services-list" path="/deployment-groups/:deploymentGroup/services-list"
@ -101,6 +89,12 @@ const Router = (
/> />
<Switch> <Switch>
<Route
path="/deployment-groups/:deploymentGroup/delete"
exact
component={DeploymentGroupList}
/>
<Route <Route
path="/deployment-groups/~create/:stage?" path="/deployment-groups/~create/:stage?"
exact exact
@ -112,12 +106,6 @@ const Router = (
component={DeploymentGroupImport} component={DeploymentGroupImport}
/> />
<Route
path="/deployment-groups/:deploymentGroup/services"
exact
component={deploymentGroupRedirect}
/>
<Route <Route
path="/deployment-groups/:deploymentGroup/instances" path="/deployment-groups/:deploymentGroup/instances"
exact exact
@ -145,8 +133,19 @@ const Router = (
exact exact
component={InstanceList} component={InstanceList}
/> />
<Route
path="/deployment-groups/:deploymentGroup/services/:service"
component={serviceRedirect}
/>
<Route
path="/deployment-groups/:deploymentGroup"
component={deploymentGroupRedirect}
/>
</Switch> </Switch>
<Switch>
<Route <Route
path="/deployment-groups/:deploymentGroup/services-list/:service/scale" path="/deployment-groups/:deploymentGroup/services-list/:service/scale"
exact exact
@ -169,6 +168,28 @@ const Router = (
exact exact
component={ServiceDelete} component={ServiceDelete}
/> />
<Route
path="/deployment-groups/:deploymentGroup/services-list"
component={deploymentGroupRedirect}
/>
<Route
path="/deployment-groups/:deploymentGroup/services-topology"
component={deploymentGroupRedirect}
/>
</Switch>
</div>
)
const Router = (
<BrowserRouter>
<Container>
<Route path="/" component={Header} />
<Switch>
<Route path="/deployment-groups" component={APP} />
<Route path="/" exact component={rootRedirect} />
<Route path="/*" component={notFound} />
</Switch>
</Container> </Container>
</BrowserRouter> </BrowserRouter>
); );