mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Select current revision in selector if it is a branch
This commit is contained in:
@@ -17,6 +17,7 @@ const styles = {
|
|||||||
type Props = {
|
type Props = {
|
||||||
branches: Branch[], // TODO: Use generics?
|
branches: Branch[], // TODO: Use generics?
|
||||||
selected: (branch?: Branch) => void,
|
selected: (branch?: Branch) => void,
|
||||||
|
selectedBranch: string,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
classes: Object,
|
classes: Object,
|
||||||
@@ -31,6 +32,12 @@ class BranchSelector extends React.Component<Props, State> {
|
|||||||
this.state = {};
|
this.state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.props.branches
|
||||||
|
.filter(branch => branch.name === this.props.selectedBranch)
|
||||||
|
.forEach(branch => this.setState({ selectedBranch: branch }));
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { branches, classes, t } = this.props;
|
const { branches, classes, t } = this.props;
|
||||||
|
|
||||||
|
|||||||
@@ -79,11 +79,12 @@ class Sources extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderBranchSelector = () => {
|
renderBranchSelector = () => {
|
||||||
const { repository, branches } = this.props;
|
const { repository, branches, revision } = this.props;
|
||||||
if (repository._links.branches) {
|
if (repository._links.branches) {
|
||||||
return (
|
return (
|
||||||
<BranchSelector
|
<BranchSelector
|
||||||
branches={branches}
|
branches={branches}
|
||||||
|
selectedBranch={revision}
|
||||||
selected={(b: Branch) => {
|
selected={(b: Branch) => {
|
||||||
this.branchSelected(b);
|
this.branchSelected(b);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user