Files
SCM-Manager/scm-ui/src/repos/branches/components/BranchDetailTable.js

66 lines
1.5 KiB
JavaScript
Raw Normal View History

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