2019-06-26 15:06:59 +02:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { Link } from "react-router-dom";
|
2019-06-26 15:17:16 +02:00
|
|
|
import injectSheet from "react-jss";
|
2019-06-26 15:06:59 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-06-27 13:54:04 +02:00
|
|
|
revision: string,
|
2019-06-26 15:06:59 +02:00
|
|
|
path: string,
|
2019-06-26 15:17:16 +02:00
|
|
|
baseUrl: string,
|
|
|
|
|
classes: any
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = {
|
2019-06-27 17:56:26 +02:00
|
|
|
noMargin: {
|
|
|
|
|
margin: "0"
|
2019-06-26 15:17:16 +02:00
|
|
|
}
|
2019-06-26 15:06:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Breadcrumb extends React.Component<Props> {
|
2019-06-27 17:56:26 +02:00
|
|
|
renderPath() {
|
|
|
|
|
const { revision, path, baseUrl } = this.props;
|
2019-06-26 15:06:59 +02:00
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
const paths = path.split("/");
|
2019-06-27 17:56:26 +02:00
|
|
|
const map = paths.map((path, index) => {
|
|
|
|
|
const currPath = paths.slice(0, index + 1).join("/");
|
|
|
|
|
if (paths.length - 1 === index) {
|
|
|
|
|
return (
|
|
|
|
|
<li className="is-active" key={index}>
|
|
|
|
|
<Link to={"#"} aria-current="page">
|
|
|
|
|
{path}
|
|
|
|
|
</Link>
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<li key={index}>
|
|
|
|
|
<Link to={baseUrl + "/" + revision + "/" + currPath}>{path}</Link>
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
return map;
|
2019-06-26 15:06:59 +02:00
|
|
|
}
|
2019-06-27 17:56:26 +02:00
|
|
|
return <li />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { classes } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<nav className="breadcrumb sources-breadcrumb" aria-label="breadcrumbs">
|
|
|
|
|
<ul>{this.renderPath()}</ul>
|
|
|
|
|
</nav>
|
|
|
|
|
<hr className={classes.noMargin} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2019-06-26 15:06:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 15:17:16 +02:00
|
|
|
export default injectSheet(styles)(Breadcrumb);
|