2019-03-28 17:09:59 +01:00
|
|
|
//@flow
|
|
|
|
|
import React from "react";
|
|
|
|
|
import type { Repository, Branch } from "@scm-manager/ui-types";
|
|
|
|
|
import { translate } from "react-i18next";
|
2019-04-01 15:58:07 +02:00
|
|
|
import injectSheet from "react-jss";
|
|
|
|
|
import classNames from "classnames";
|
2019-03-29 13:52:19 +01:00
|
|
|
import BranchButtonGroup from "./BranchButtonGroup";
|
2019-03-28 17:09:59 +01:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
repository: Repository,
|
|
|
|
|
branch: Branch,
|
|
|
|
|
// context props
|
2019-04-01 15:58:07 +02:00
|
|
|
t: string => string,
|
|
|
|
|
classes: any
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const styles = {
|
|
|
|
|
tag: {
|
|
|
|
|
marginLeft: "0.75rem",
|
|
|
|
|
verticalAlign: "inherit"
|
|
|
|
|
}
|
2019-03-28 17:09:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class BranchDetailTable extends React.Component<Props> {
|
|
|
|
|
render() {
|
|
|
|
|
const { repository, branch, t } = this.props;
|
2019-04-01 13:47:41 +02:00
|
|
|
|
2019-03-28 17:09:59 +01:00
|
|
|
return (
|
|
|
|
|
<table className="table">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
2019-04-01 15:13:44 +02:00
|
|
|
<th>{t("branch.name")}</th>
|
2019-04-01 13:47:41 +02:00
|
|
|
<td>
|
|
|
|
|
{branch.name} {this.renderDefaultBranch()}
|
|
|
|
|
</td>
|
2019-03-28 17:09:59 +01:00
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2019-04-01 15:58:07 +02:00
|
|
|
<th>{t("branch.repository")}</th>
|
2019-03-28 17:09:59 +01:00
|
|
|
<td>{repository.name}</td>
|
|
|
|
|
</tr>
|
2019-03-29 13:52:19 +01:00
|
|
|
<tr>
|
2019-04-01 15:13:44 +02:00
|
|
|
<th>{t("branch.actions")}</th>
|
2019-04-01 13:47:41 +02:00
|
|
|
<td>
|
|
|
|
|
<BranchButtonGroup repository={repository} branch={branch} />
|
2019-03-29 13:52:19 +01:00
|
|
|
</td>
|
|
|
|
|
</tr>
|
2019-03-28 17:09:59 +01:00
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
);
|
|
|
|
|
}
|
2019-04-01 13:47:41 +02:00
|
|
|
|
|
|
|
|
renderDefaultBranch() {
|
2019-04-01 15:58:07 +02:00
|
|
|
const { branch, classes } = this.props;
|
2019-04-01 13:47:41 +02:00
|
|
|
|
|
|
|
|
let defaultLabel = null;
|
|
|
|
|
if (branch.defaultBranch) {
|
2019-04-01 15:58:07 +02:00
|
|
|
defaultLabel = (
|
|
|
|
|
<span className={classNames("tag is-dark", classes.tag)}>Default</span>
|
|
|
|
|
);
|
2019-04-01 13:47:41 +02:00
|
|
|
}
|
|
|
|
|
return defaultLabel;
|
|
|
|
|
}
|
2019-03-28 17:09:59 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-01 15:58:07 +02:00
|
|
|
export default injectSheet(styles)(translate("repos")(BranchDetailTable));
|