Select current revision in selector if it is a branch

This commit is contained in:
René Pfeuffer
2018-10-23 11:24:23 +02:00
parent 0834420e4b
commit fa7626619c
2 changed files with 9 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ const styles = {
type Props = {
branches: Branch[], // TODO: Use generics?
selected: (branch?: Branch) => void,
selectedBranch: string,
// context props
classes: Object,
@@ -31,6 +32,12 @@ class BranchSelector extends React.Component<Props, State> {
this.state = {};
}
componentDidMount() {
this.props.branches
.filter(branch => branch.name === this.props.selectedBranch)
.forEach(branch => this.setState({ selectedBranch: branch }));
}
render() {
const { branches, classes, t } = this.props;