diff --git a/scm-ui-components/packages/ui-components/src/Breadcrumb.js b/scm-ui-components/packages/ui-components/src/Breadcrumb.js new file mode 100644 index 0000000000..d26bb826b4 --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/Breadcrumb.js @@ -0,0 +1,61 @@ +//@flow +import React from "react"; +import { Link } from "react-router-dom"; +import injectSheet from "react-jss"; + +type Props = { + revision: string, + path: string, + baseUrl: string, + classes: any +}; + +const styles = { + noMargin: { + margin: "0" + } +}; + +class Breadcrumb extends React.Component { + renderPath() { + const { revision, path, baseUrl } = this.props; + + if (path) { + const paths = path.split("/"); + const map = paths.map((path, index) => { + const currPath = paths.slice(0, index + 1).join("/"); + if (paths.length - 1 === index) { + return ( +
  • + + {path} + +
  • + ); + } + return ( +
  • + {path} +
  • + ); + }); + return map; + } + return
  • ; + } + + render() { + const { classes } = this.props; + + return ( + <> + +
    + + ); + } +} + +export default injectSheet(styles)(Breadcrumb); diff --git a/scm-ui-components/packages/ui-components/src/index.js b/scm-ui-components/packages/ui-components/src/index.js index 82780c94eb..ae6fd6f875 100644 --- a/scm-ui-components/packages/ui-components/src/index.js +++ b/scm-ui-components/packages/ui-components/src/index.js @@ -27,6 +27,7 @@ export { default as Tooltip } from "./Tooltip"; export { getPageFromMatch } from "./urls"; export { default as Autocomplete} from "./Autocomplete"; export { default as BranchSelector } from "./BranchSelector"; +export { default as Breadcrumb } from "./Breadcrumb"; export { default as MarkdownView } from "./MarkdownView"; export { default as SyntaxHighlighter } from "./SyntaxHighlighter"; export { default as ErrorBoundary } from "./ErrorBoundary"; diff --git a/scm-ui/src/repos/sources/containers/Sources.js b/scm-ui/src/repos/sources/containers/Sources.js index 5cbf66c032..ddc469760c 100644 --- a/scm-ui/src/repos/sources/containers/Sources.js +++ b/scm-ui/src/repos/sources/containers/Sources.js @@ -4,8 +4,12 @@ import { connect } from "react-redux"; import { withRouter } from "react-router-dom"; import type { Branch, Repository } from "@scm-manager/ui-types"; import FileTree from "../components/FileTree"; -import { ErrorNotification, Loading } from "@scm-manager/ui-components"; -import BranchSelector from "../../../../../scm-ui-components/packages/ui-components/src/BranchSelector"; +import { + ErrorNotification, + Loading, + BranchSelector, + Breadcrumb +} from "@scm-manager/ui-components"; import { translate } from "react-i18next"; import { fetchBranches, @@ -95,6 +99,7 @@ class Sources extends React.Component { return (
    {this.renderBranchSelector()} +