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

View File

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