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";
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
baseUrl: string,
|
|
|
|
|
branch: Branch
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default class BranchRow extends React.Component<Props> {
|
2019-03-29 14:24:54 +01:00
|
|
|
renderLink(to: string, label: string, defaultBranch: boolean) {
|
|
|
|
|
let showLabel = null;
|
|
|
|
|
if(defaultBranch) {
|
|
|
|
|
showLabel = <span className="tag is-dark">Default</span>;
|
|
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|