added defaultbranchtag component

This commit is contained in:
Florian Scholdei
2019-04-03 08:52:29 +02:00
parent 81d25e74eb
commit b1d631fe57
5 changed files with 55 additions and 51 deletions

View File

@@ -2,33 +2,18 @@
import React from "react";
import { Link } from "react-router-dom";
import type { Branch } from "@scm-manager/ui-types";
import injectSheet from "react-jss";
import classNames from "classnames";
import DefaultBranchTag from "./DefaultBranchTag";
type Props = {
baseUrl: string,
branch: Branch,
classes: any
};
const styles = {
tag: {
marginLeft: "0.75rem",
verticalAlign: "inherit"
}
branch: Branch
};
class BranchRow extends React.Component<Props> {
renderLink(to: string, label: string, defaultBranch?: boolean) {
const { classes } = this.props;
let showLabel = null;
if (defaultBranch) {
showLabel = <span className={classNames("tag is-dark", classes.tag)}>Default</span>;
}
return (
<Link to={to}>
{label} {showLabel}
{label} <DefaultBranchTag defaultBranch={defaultBranch} />
</Link>
);
}
@@ -36,12 +21,12 @@ class BranchRow extends React.Component<Props> {
render() {
const { baseUrl, branch } = this.props;
const to = `${baseUrl}/${encodeURIComponent(branch.name)}/info`;
return (
<tr>
<td>{this.renderLink(to, branch.name, branch.defaultBranch)}</td>
</tr>
);
return (
<tr>
<td>{this.renderLink(to, branch.name, branch.defaultBranch)}</td>
</tr>
);
}
}
export default injectSheet(styles)(BranchRow);
export default BranchRow;