-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to group routes (#42)
* First version of grouping routes * Switched to new calculation of groups and styled them * Added group routing based on togglable state * Updated package-lock * DB - Moved some components around, added some tests and fixed jest running tests * DB - Added more test coverage
- Loading branch information
1 parent
e2fb276
commit 0500789
Showing
18 changed files
with
648 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
jest: function(config) { | ||
config.testMatch.push("<rootDir>/src/**/{spec,test}.{js,jsx,ts,tsx}"); | ||
return config; | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from "react"; | ||
|
||
const RouteItem = ({ title, value }) => { | ||
const buildAriaLabel = label => (label ? `route-${title.toLowerCase()}-${label}` : `route-${title.toLowerCase()}`); | ||
|
||
return ( | ||
<div className="level-item has-text-centered" aria-label={buildAriaLabel()}> | ||
<div> | ||
<p className="heading" aria-label={buildAriaLabel("title")}> | ||
{title} | ||
</p> | ||
<p className="title is-size-6" aria-label={buildAriaLabel("value")}> | ||
{value} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RouteItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react"; | ||
import url from "url"; | ||
import RouteItem from "./RouteItem"; | ||
|
||
import { MOCKIT_SERVER_URL } from "../../utils/consts"; | ||
|
||
const Route = ({ routeItem, onRouteDelete, onRouteEdit }) => { | ||
const { delay = 0, route, statusCode, httpMethod, disabled = false } = routeItem; | ||
const routeClassName = disabled ? "disabled" : ""; | ||
|
||
const openRoute = route => { | ||
return () => { | ||
window.open(url.resolve(MOCKIT_SERVER_URL, route), "_blank"); | ||
}; | ||
}; | ||
|
||
const editRoute = event => { | ||
event.stopPropagation(); | ||
onRouteEdit(routeItem); | ||
}; | ||
|
||
const deleteRoute = event => { | ||
event.stopPropagation(); | ||
onRouteDelete(routeItem); | ||
}; | ||
|
||
return ( | ||
<div className="column is-full"> | ||
<div className={`route ${routeClassName}`} onClick={openRoute(route)} aria-label="Route"> | ||
<nav className="level"> | ||
<RouteItem title="Route" value={route} /> | ||
<RouteItem title="Delay" value={`${delay} ms`} /> | ||
<RouteItem title="Status Code" value={statusCode} /> | ||
<RouteItem title="HTTP" value={httpMethod} /> | ||
|
||
<div className="level-item has-text-centered"> | ||
<div> | ||
<p className="title is-size-4"> | ||
<button className="button is-info mr10" onClick={editRoute} aria-label="Edit Route"> | ||
<strong>Edit</strong> | ||
</button> | ||
<button className="button is-danger" onClick={deleteRoute} aria-label="Delete Route"> | ||
<strong>Delete</strong> | ||
</button> | ||
</p> | ||
</div> | ||
</div> | ||
</nav> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Route; |
Oops, something went wrong.