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
|
|
|
};
|
|
|
|
|
|
2019-04-02 17:45:25 +02:00
|
|
|
class BranchDetail extends React.Component<Props> {
|
2019-03-28 17:09:59 +01:00
|
|
|
render() {
|
|
|
|
|
const { repository, branch, t } = this.props;
|
2019-04-01 13:47:41 +02:00
|
|
|
|
2019-03-28 17:09:59 +01:00
|
|
|
return (
|
2019-04-02 17:45:25 +02:00
|
|
|
<div className="media">
|
|
|
|
|
<div className="media-content subtitle"><strong>{t("branch.name")}</strong> {branch.name} {this.renderDefaultBranch()}</div>
|
|
|
|
|
<div className="media-right">
|
|
|
|
|
<BranchButtonGroup repository={repository} branch={branch} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-03-28 17:09:59 +01:00
|
|
|
);
|
|
|
|
|
}
|
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-02 17:45:25 +02:00
|
|
|
export default injectSheet(styles)(translate("repos")(BranchDetail));
|