add home icon to breadcrumb

This commit is contained in:
Florian Scholdei
2019-09-25 09:15:33 +02:00
parent eb1812dea6
commit 17f6a66cf6
4 changed files with 36 additions and 10 deletions

View File

@@ -1,10 +1,12 @@
//@flow //@flow
import React from "react"; import React from "react";
import {Link} from "react-router-dom"; import { Link } from "react-router-dom";
import type {Branch, Repository} from "@scm-manager/ui-types"; import { translate } from "react-i18next";
import injectSheet from "react-jss"; import injectSheet from "react-jss";
import {binder, ExtensionPoint} from "@scm-manager/ui-extensions";
import classNames from "classnames"; import classNames from "classnames";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import type { Branch, Repository } from "@scm-manager/ui-types";
import Icon from "./Icon";
type Props = { type Props = {
repository: Repository, repository: Repository,
@@ -14,7 +16,10 @@ type Props = {
revision: string, revision: string,
path: string, path: string,
baseUrl: string, baseUrl: string,
classes: any
// Context props
classes: any,
t: string => string
}; };
const styles = { const styles = {
@@ -45,7 +50,7 @@ class Breadcrumb extends React.Component<Props> {
if (paths.length - 1 === index) { if (paths.length - 1 === index) {
return ( return (
<li className="is-active" key={index}> <li className="is-active" key={index}>
<Link to={"#"} aria-current="page"> <Link to="#" aria-current="page">
{path} {path}
</Link> </Link>
</li> </li>
@@ -59,19 +64,20 @@ class Breadcrumb extends React.Component<Props> {
}); });
return map; return map;
} }
return <li />; return null;
} }
render() { render() {
const { const {
classes,
baseUrl, baseUrl,
branch, branch,
defaultBranch, defaultBranch,
branches, branches,
revision, revision,
path, path,
repository repository,
classes,
t
} = this.props; } = this.props;
return ( return (
@@ -84,7 +90,18 @@ class Breadcrumb extends React.Component<Props> {
)} )}
aria-label="breadcrumbs" aria-label="breadcrumbs"
> >
<ul>{this.renderPath()}</ul> <ul>
<li>
<Link to={baseUrl + "/" + revision + "/"}>
<Icon
title={t("breadcrumb.home")}
name="home"
color="inherit"
/>
</Link>
</li>
{this.renderPath()}
</ul>
</nav> </nav>
{binder.hasExtension("repos.sources.actionbar") && ( {binder.hasExtension("repos.sources.actionbar") && (
<div className={classes.buttonGroup}> <div className={classes.buttonGroup}>
@@ -112,4 +129,4 @@ class Breadcrumb extends React.Component<Props> {
} }
} }
export default injectSheet(styles)(Breadcrumb); export default translate("commons")(injectSheet(styles)(Breadcrumb));

View File

@@ -23,6 +23,9 @@
"subtitle": "Ein unbekannter Fehler ist aufgetreten." "subtitle": "Ein unbekannter Fehler ist aufgetreten."
} }
}, },
"breadcrumb": {
"home": "Hauptseite"
},
"errorNotification": { "errorNotification": {
"prefix": "Fehler", "prefix": "Fehler",
"loginLink": "Erneute Anmeldung", "loginLink": "Erneute Anmeldung",

View File

@@ -24,6 +24,9 @@
"subtitle": "Unknown error occurred" "subtitle": "Unknown error occurred"
} }
}, },
"breadcrumb": {
"home": "Main page"
},
"errorNotification": { "errorNotification": {
"prefix": "Error", "prefix": "Error",
"loginLink": "You can login here again.", "loginLink": "You can login here again.",

View File

@@ -24,6 +24,9 @@
"subtitle": "Ha ocurrido un error desconocido" "subtitle": "Ha ocurrido un error desconocido"
} }
}, },
"breadcrumb": {
"home": "Página principal"
},
"errorNotification": { "errorNotification": {
"prefix": "Error", "prefix": "Error",
"loginLink": "Aquí puede iniciar la sesión de nuevo.", "loginLink": "Aquí puede iniciar la sesión de nuevo.",