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-03 08:52:29 +02:00
|
|
|
import DefaultBranchTag from "./DefaultBranchTag";
|
2019-03-29 10:02:53 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
baseUrl: string,
|
2019-04-03 08:52:29 +02:00
|
|
|
branch: Branch
|
2019-04-01 15:58:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class BranchRow extends React.Component<Props> {
|
2019-04-02 17:31:32 +02:00
|
|
|
renderLink(to: string, label: string, defaultBranch?: boolean) {
|
2019-03-29 14:54:18 +01:00
|
|
|
return (
|
|
|
|
|
<Link to={to}>
|
2019-04-03 08:52:29 +02:00
|
|
|
{label} <DefaultBranchTag defaultBranch={defaultBranch} />
|
2019-03-29 14:54:18 +01:00
|
|
|
</Link>
|
|
|
|
|
);
|
2019-03-29 10:02:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { baseUrl, branch } = this.props;
|
|
|
|
|
const to = `${baseUrl}/${encodeURIComponent(branch.name)}/info`;
|
2019-04-03 08:52:29 +02:00
|
|
|
return (
|
|
|
|
|
<tr>
|
|
|
|
|
<td>{this.renderLink(to, branch.name, branch.defaultBranch)}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
);
|
2019-03-29 10:02:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-01 15:58:07 +02:00
|
|
|
|
2019-04-03 08:52:29 +02:00
|
|
|
export default BranchRow;
|