diff --git a/scm-ui/src/changesets/components/DropDown.js b/scm-ui/src/changesets/components/DropDown.js index 28d3ef28f0..8d73ea4fa5 100644 --- a/scm-ui/src/changesets/components/DropDown.js +++ b/scm-ui/src/changesets/components/DropDown.js @@ -4,15 +4,17 @@ import React from "react"; type Props = { options: string[], - optionSelected: string => void + optionSelected: string => void, + preselectedOption: string } class DropDown extends React.Component { render() { - const {options} = this.props; - return {options.map(option => { - return + return })} } diff --git a/scm-ui/src/changesets/containers/Changesets.js b/scm-ui/src/changesets/containers/Changesets.js index a197ae293d..48e95dd5d6 100644 --- a/scm-ui/src/changesets/containers/Changesets.js +++ b/scm-ui/src/changesets/containers/Changesets.js @@ -5,11 +5,12 @@ import { fetchChangesetsByNamespaceAndName, fetchChangesetsByNamespaceNameAndBranch, getChangesets, } from "../modules/changesets"; -import {translate} from "react-i18next"; +import type { History } from "history"; import {fetchBranchesByNamespaceAndName, getBranchNames} from "../../repos/modules/branches"; import type {Repository} from "@scm-manager/ui-types"; import ChangesetTable from "../components/ChangesetTable"; import DropDown from "../components/DropDown"; +import {withRouter} from "react-router-dom"; type Props = { repository: Repository, @@ -18,30 +19,34 @@ type Props = { fetchChangesetsByNamespaceNameAndBranch: (namespace: string, name: string, branch: string) => void } -type State = { - branchName: string -} class Changesets extends React.Component { constructor(props) { super(props); - this.state = {}; + this.state = { + }; } componentDidMount() { const {namespace, name} = this.props.repository; - this.props.fetchChangesetsByNamespaceNameAndBranch(namespace, name, this.props.branchName); + const branchName = this.props.match.params.branch; + if (branchName) { + this.props.fetchChangesetsByNamespaceNameAndBranch(namespace, name, branchName); + } else { + this.props.fetchChangesetsByNamespaceAndName(namespace, name); + } this.props.fetchBranchesByNamespaceAndName(namespace, name); } render() { const {changesets, branchNames} = this.props; + const branch = this.props.match.params.branch; if (changesets === null) { return null } if (branchNames) { return
- + this.branchChanged(branch)}/>
; } else { @@ -51,16 +56,16 @@ class Changesets extends React.Component { } branchChanged = (branchName: string) => { - this.props.history.push(branchName) + const { history, repository } = this.props; + history.push(`/repo/${repository.namespace}/${repository.name}/history/${branchName}`); }; } const mapStateToProps = (state, ownProps: Props) => { - console.log("mapStateToProps ownProps: ", ownProps); const {namespace, name} = ownProps.repository; return { - changesets: getChangesets(namespace, name, ownProps.branchName, state), + changesets: getChangesets(namespace, name, ownProps.match.params.branch, state), branchNames: getBranchNames(namespace, name, state) } }; @@ -79,7 +84,7 @@ const mapDispatchToProps = dispatch => { } }; -export default connect( +export default withRouter(connect( mapStateToProps, mapDispatchToProps -)(Changesets); +)(Changesets)); diff --git a/scm-ui/src/repos/containers/RepositoryRoot.js b/scm-ui/src/repos/containers/RepositoryRoot.js index 7c8bae308f..75a938279c 100644 --- a/scm-ui/src/repos/containers/RepositoryRoot.js +++ b/scm-ui/src/repos/containers/RepositoryRoot.js @@ -103,13 +103,9 @@ class RepositoryRoot extends React.Component { component={() => } /> } + path={`${url}/history/:branch`} + component={() => } /> - {/* }*/} - {/*/>*/}