2019-03-29 10:02:53 +01:00
|
|
|
// @flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
import type { Branch } from "@scm-manager/ui-types";
|
2019-04-01 15:58:07 +02:00
|
|
|
import injectSheet from "react-jss";
|
|
|
|
|
import classNames from "classnames";
|
2019-03-29 10:02:53 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
baseUrl: string,
|
2019-04-01 15:58:07 +02:00
|
|
|
branch: Branch,
|
|
|
|
|
classes: any
|
2019-03-29 10:02:53 +01:00
|
|
|
};
|
|
|
|
|
|
2019-04-01 15:58:07 +02:00
|
|
|
const styles = {
|
|
|
|
|
tag: {
|
|
|
|
|
marginLeft: "0.75rem",
|
|
|
|
|
verticalAlign: "inherit"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class BranchRow extends React.Component<Props> {
|
2019-03-29 14:24:54 +01:00
|
|
|
renderLink(to: string, label: string, defaultBranch: boolean) {
|
2019-04-01 15:58:07 +02:00
|
|
|
const { classes } = this.props;
|
|
|
|
|
|
2019-03-29 14:24:54 +01:00
|
|
|
let showLabel = null;
|
2019-03-29 14:54:18 +01:00
|
|
|
if (defaultBranch) {
|
2019-04-01 15:58:07 +02:00
|
|
|
showLabel = <span className={classNames("tag is-dark", classes.tag)}>Default</span>;
|
2019-03-29 14:24:54 +01:00
|
|
|
}
|
2019-03-29 14:54:18 +01:00
|
|
|
return (
|
|
|
|
|
<Link to={to}>
|
|
|
|
|
{label} {showLabel}
|
|
|
|
|
</Link>
|
|
|
|
|
);
|
2019-03-29 10:02:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { baseUrl, branch } = this.props;
|
|
|
|
|
const to = `${baseUrl}/${encodeURIComponent(branch.name)}/info`;
|
|
|
|
|
return (
|
|
|
|
|
<tr>
|
2019-03-29 14:24:54 +01:00
|
|
|
<td>{this.renderLink(to, branch.name, branch.defaultBranch)}</td>
|
2019-03-29 10:02:53 +01:00
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-01 15:58:07 +02:00
|
|
|
|
|
|
|
|
export default injectSheet(styles)(BranchRow);
|