mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
added defaultbranchtag component
This commit is contained in:
@@ -63,7 +63,8 @@
|
||||
"branch": {
|
||||
"name": "Name:",
|
||||
"commits": "Commits",
|
||||
"sources": "Sources"
|
||||
"sources": "Sources",
|
||||
"defaultTag": "Default"
|
||||
},
|
||||
"changesets": {
|
||||
"errorTitle": "Fehler",
|
||||
|
||||
@@ -63,7 +63,8 @@
|
||||
"branch": {
|
||||
"name": "Name:",
|
||||
"commits": "Commits",
|
||||
"sources": "Sources"
|
||||
"sources": "Sources",
|
||||
"defaultTag": "Default"
|
||||
},
|
||||
"changesets": {
|
||||
"errorTitle": "Error",
|
||||
|
||||
@@ -2,23 +2,14 @@
|
||||
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";
|
||||
import DefaultBranchTag from "./DefaultBranchTag";
|
||||
|
||||
type Props = {
|
||||
repository: Repository,
|
||||
branch: Branch,
|
||||
// context props
|
||||
t: string => string,
|
||||
classes: any
|
||||
};
|
||||
|
||||
const styles = {
|
||||
tag: {
|
||||
marginLeft: "0.75rem",
|
||||
verticalAlign: "inherit"
|
||||
}
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class BranchDetail extends React.Component<Props> {
|
||||
@@ -27,25 +18,16 @@ class BranchDetail extends React.Component<Props> {
|
||||
|
||||
return (
|
||||
<div className="media">
|
||||
<div className="media-content subtitle"><strong>{t("branch.name")}</strong> {branch.name} {this.renderDefaultBranch()}</div>
|
||||
<div className="media-content subtitle">
|
||||
<strong>{t("branch.name")}</strong> {branch.name}{" "}
|
||||
<DefaultBranchTag defaultBranch={branch.defaultBranch} />
|
||||
</div>
|
||||
<div className="media-right">
|
||||
<BranchButtonGroup repository={repository} branch={branch} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderDefaultBranch() {
|
||||
const { branch, classes } = this.props;
|
||||
|
||||
let defaultLabel = null;
|
||||
if (branch.defaultBranch) {
|
||||
defaultLabel = (
|
||||
<span className={classNames("tag is-dark", classes.tag)}>Default</span>
|
||||
);
|
||||
}
|
||||
return defaultLabel;
|
||||
}
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(translate("repos")(BranchDetail));
|
||||
export default translate("repos")(BranchDetail);
|
||||
|
||||
@@ -2,33 +2,18 @@
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import type { Branch } from "@scm-manager/ui-types";
|
||||
import injectSheet from "react-jss";
|
||||
import classNames from "classnames";
|
||||
import DefaultBranchTag from "./DefaultBranchTag";
|
||||
|
||||
type Props = {
|
||||
baseUrl: string,
|
||||
branch: Branch,
|
||||
classes: any
|
||||
};
|
||||
|
||||
const styles = {
|
||||
tag: {
|
||||
marginLeft: "0.75rem",
|
||||
verticalAlign: "inherit"
|
||||
}
|
||||
branch: Branch
|
||||
};
|
||||
|
||||
class BranchRow extends React.Component<Props> {
|
||||
renderLink(to: string, label: string, defaultBranch?: boolean) {
|
||||
const { classes } = this.props;
|
||||
|
||||
let showLabel = null;
|
||||
if (defaultBranch) {
|
||||
showLabel = <span className={classNames("tag is-dark", classes.tag)}>Default</span>;
|
||||
}
|
||||
return (
|
||||
<Link to={to}>
|
||||
{label} {showLabel}
|
||||
{label} <DefaultBranchTag defaultBranch={defaultBranch} />
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -44,4 +29,4 @@ class BranchRow extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(BranchRow);
|
||||
export default BranchRow;
|
||||
|
||||
35
scm-ui/src/repos/branches/components/DefaultBranchTag.js
Normal file
35
scm-ui/src/repos/branches/components/DefaultBranchTag.js
Normal file
@@ -0,0 +1,35 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import injectSheet from "react-jss";
|
||||
import classNames from "classnames";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
defaultBranch?: boolean,
|
||||
classes: any,
|
||||
t: string => string
|
||||
};
|
||||
|
||||
const styles = {
|
||||
tag: {
|
||||
marginLeft: "0.75rem",
|
||||
verticalAlign: "inherit"
|
||||
}
|
||||
};
|
||||
|
||||
class DefaultBranchTag extends React.Component<Props> {
|
||||
render() {
|
||||
const { defaultBranch, classes, t } = this.props;
|
||||
|
||||
if (defaultBranch) {
|
||||
return (
|
||||
<span className={classNames("tag is-dark", classes.tag)}>
|
||||
{t("branch.defaultTag")}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default injectSheet(styles)(translate("repos")(DefaultBranchTag));
|
||||
Reference in New Issue
Block a user