mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
implemented Breadcrumb ui-component
This commit is contained in:
44
scm-ui-components/packages/ui-components/src/Breadcrumb.js
Normal file
44
scm-ui-components/packages/ui-components/src/Breadcrumb.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//@flow
|
||||||
|
import React from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
path: string,
|
||||||
|
baseUrl: string
|
||||||
|
};
|
||||||
|
|
||||||
|
class Breadcrumb extends React.Component<Props> {
|
||||||
|
render() {
|
||||||
|
const { path, baseUrl } = this.props;
|
||||||
|
|
||||||
|
if (path) {
|
||||||
|
const paths = path.split("/");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav className="breadcrumb" aria-label="breadcrumbs">
|
||||||
|
<ul>
|
||||||
|
{paths.map((path, index) => {
|
||||||
|
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 + "/" + path}>{path}</Link>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Breadcrumb;
|
||||||
@@ -27,6 +27,7 @@ export { default as Tooltip } from "./Tooltip";
|
|||||||
export { getPageFromMatch } from "./urls";
|
export { getPageFromMatch } from "./urls";
|
||||||
export { default as Autocomplete} from "./Autocomplete";
|
export { default as Autocomplete} from "./Autocomplete";
|
||||||
export { default as BranchSelector } from "./BranchSelector";
|
export { default as BranchSelector } from "./BranchSelector";
|
||||||
|
export { default as Breadcrumb } from "./Breadcrumb";
|
||||||
export { default as MarkdownView } from "./MarkdownView";
|
export { default as MarkdownView } from "./MarkdownView";
|
||||||
export { default as SyntaxHighlighter } from "./SyntaxHighlighter";
|
export { default as SyntaxHighlighter } from "./SyntaxHighlighter";
|
||||||
export { default as ErrorBoundary } from "./ErrorBoundary";
|
export { default as ErrorBoundary } from "./ErrorBoundary";
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import { connect } from "react-redux";
|
|||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import type { Branch, Repository } from "@scm-manager/ui-types";
|
import type { Branch, Repository } from "@scm-manager/ui-types";
|
||||||
import FileTree from "../components/FileTree";
|
import FileTree from "../components/FileTree";
|
||||||
import { ErrorNotification, Loading } from "@scm-manager/ui-components";
|
import { ErrorNotification, Loading, BranchSelector, Breadcrumb } from "@scm-manager/ui-components";
|
||||||
import BranchSelector from "../../../../../scm-ui-components/packages/ui-components/src/BranchSelector";
|
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
fetchBranches,
|
fetchBranches,
|
||||||
@@ -95,6 +94,7 @@ class Sources extends React.Component<Props> {
|
|||||||
return (
|
return (
|
||||||
<div className="panel">
|
<div className="panel">
|
||||||
{this.renderBranchSelector()}
|
{this.renderBranchSelector()}
|
||||||
|
<Breadcrumb path={path} baseUrl={baseUrl} />
|
||||||
<FileTree
|
<FileTree
|
||||||
repository={repository}
|
repository={repository}
|
||||||
revision={revision}
|
revision={revision}
|
||||||
|
|||||||
Reference in New Issue
Block a user