always render breadcrumd

This commit is contained in:
Eduard Heimbuch
2019-10-23 17:25:52 +02:00
parent 1d7d854ea8
commit a62c4a1fc0
2 changed files with 37 additions and 38 deletions

View File

@@ -1,11 +1,11 @@
//@flow
import React from "react";
import { Link } from "react-router-dom";
import { translate } from "react-i18next";
import {Link} from "react-router-dom";
import {translate} from "react-i18next";
import classNames from "classnames";
import styled from "styled-components";
import { binder, ExtensionPoint } from "@scm-manager/ui-extensions";
import type { Branch, Repository } from "@scm-manager/ui-types";
import {binder, ExtensionPoint} from "@scm-manager/ui-extensions";
import type {Branch, Repository} from "@scm-manager/ui-types";
import Icon from "./Icon";
type Props = {
@@ -74,6 +74,11 @@ class Breadcrumb extends React.Component<Props> {
t
} = this.props;
let homeUrl = baseUrl + "/";
if (revision) {
homeUrl += encodeURIComponent(revision) + "/";
}
return (
<>
<div className="is-flex">
@@ -83,7 +88,7 @@ class Breadcrumb extends React.Component<Props> {
>
<ul>
<li>
<Link to={baseUrl + "/" + revision + "/"}>
<Link to={homeUrl}>
<HomeIcon
title={t("breadcrumb.home")}
name="home"
@@ -101,12 +106,13 @@ class Breadcrumb extends React.Component<Props> {
props={{
baseUrl,
branch: branch ? branch : defaultBranch,
revision: branches ? undefined : revision,
path,
isBranchUrl:
branches &&
branches.filter(
b => b.name.replace("/", "%2F") === revision
).length > 0,
isBranchUrl: branches
? branches.filter(
b => b.name.replace("/", "%2F") === revision
).length > 0
: true,
repository
}}
renderAll={true}

View File

@@ -1,25 +1,20 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import type { Branch, Repository } from "@scm-manager/ui-types";
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 {
BranchSelector,
Breadcrumb,
ErrorNotification,
Loading
} from "@scm-manager/ui-components";
import { translate } from "react-i18next";
import {BranchSelector, Breadcrumb, ErrorNotification, Loading} from "@scm-manager/ui-components";
import {translate} from "react-i18next";
import {
fetchBranches,
getBranches,
getFetchBranchesFailure,
isFetchBranchesPending
} from "../../branches/modules/branches";
import { compose } from "redux";
import {compose} from "redux";
import Content from "./Content";
import { fetchSources, isDirectory } from "../modules/sources";
import {fetchSources, isDirectory} from "../modules/sources";
type Props = {
repository: Repository,
@@ -175,22 +170,20 @@ class Sources extends React.Component<Props, State> {
const { revision, path, baseUrl, branches, repository } = this.props;
const { selectedBranch } = this.state;
if (revision) {
return (
<Breadcrumb
revision={encodeURIComponent(revision)}
path={path}
baseUrl={baseUrl}
branch={selectedBranch}
defaultBranch={
branches && branches.filter(b => b.defaultBranch === true)[0]
}
branches={branches}
repository={repository}
/>
);
}
return null;
//TODO refactor
return (
<Breadcrumb
revision={revision}
path={path}
baseUrl={baseUrl}
branch={selectedBranch}
defaultBranch={
branches && branches.filter(b => b.defaultBranch === true)[0]
}
branches={branches}
repository={repository}
/>
);
};
}