diff --git a/scm-ui/src/containers/Main.js b/scm-ui/src/containers/Main.js index 770985360c..0a5f99da43 100644 --- a/scm-ui/src/containers/Main.js +++ b/scm-ui/src/containers/Main.js @@ -1,15 +1,14 @@ //@flow import React from "react"; -import { Route, Redirect, withRouter } from "react-router"; +import {Redirect, Route, Switch, withRouter} from "react-router-dom"; import Overview from "../repos/containers/Overview"; import Users from "../users/containers/Users"; import Login from "../containers/Login"; import Logout from "../containers/Logout"; -import { Switch } from "react-router-dom"; -import { ProtectedRoute } from "@scm-manager/ui-components"; +import {ProtectedRoute} from "@scm-manager/ui-components"; import AddUser from "../users/containers/AddUser"; import SingleUser from "../users/containers/SingleUser"; import RepositoryRoot from "../repos/containers/RepositoryRoot"; diff --git a/scm-ui/src/repos/containers/BranchRoot.js b/scm-ui/src/repos/containers/BranchRoot.js index b7ac0a45ca..8b1965044a 100644 --- a/scm-ui/src/repos/containers/BranchRoot.js +++ b/scm-ui/src/repos/containers/BranchRoot.js @@ -1,12 +1,12 @@ // @flow import React from "react"; -import type { Repository, Branch } from "@scm-manager/ui-types"; -import { Route, Switch, withRouter } from "react-router-dom"; +import type { Branch, Repository } from "@scm-manager/ui-types"; +import { Route, withRouter } from "react-router-dom"; import Changesets from "./Changesets"; import BranchSelector from "./BranchSelector"; import { connect } from "react-redux"; -import { ErrorPage, Loading } from "@scm-manager/ui-components"; +import { Loading } from "@scm-manager/ui-components"; import { fetchBranches, getBranches, @@ -35,13 +35,14 @@ type State = { selectedBranch?: Branch }; -class BranchRoot extends React.PureComponent { +class BranchRoot extends React.Component { constructor(props: Props) { super(props); this.state = {}; } componentDidMount() { + console.log("BR did mount"); this.props.fetchBranches(this.props.repository); } @@ -75,23 +76,22 @@ class BranchRoot extends React.PureComponent { branchSelected = (branch: Branch) => { const url = this.matchedUrl(); this.props.history.push( - `${url}/${encodeURIComponent(branch.name)}/changesets/` + `${url}/${encodeURIComponent(branch.name)}/changesets` ); }; render() { + console.log("BR render"); const { repository, match, branches, loading } = this.props; const url = this.stripEndingSlash(match.url); if (loading) { return ; } - if (!repository || !branches) { return null; } - return ( <> { /> )} /> - ); } } - const mapDispatchToProps = dispatch => { return { fetchBranches: (repo: Repository) => { @@ -138,9 +136,9 @@ const mapStateToProps = (state: any, ownProps: Props) => { }; export default compose( + withRouter, connect( mapStateToProps, mapDispatchToProps - ), - withRouter + ) )(BranchRoot); diff --git a/scm-ui/src/repos/containers/Changesets.js b/scm-ui/src/repos/containers/Changesets.js index 6fd6cac825..c88b2d40a1 100644 --- a/scm-ui/src/repos/containers/Changesets.js +++ b/scm-ui/src/repos/containers/Changesets.js @@ -1,13 +1,8 @@ // @flow import React from "react"; -import { withRouter } from "react-router-dom"; -import type { - Branch, - Changeset, - PagedCollection, - Repository -} from "@scm-manager/ui-types"; +import {withRouter} from "react-router-dom"; +import type {Branch, Changeset, PagedCollection, Repository} from "@scm-manager/ui-types"; import { fetchChangesetsByBranch, fetchChangesetsByBranchAndPage, @@ -16,21 +11,27 @@ import { isFetchChangesetsPending, selectListAsCollection } from "../modules/changesets"; -import { connect } from "react-redux"; +import {connect} from "react-redux"; import ChangesetList from "../components/changesets/ChangesetList"; -import { ErrorPage, LinkPaginator, Loading } from "@scm-manager/ui-components"; -import { translate } from "react-i18next"; +import {ErrorPage, LinkPaginator, Loading} from "@scm-manager/ui-components"; +import {translate} from "react-i18next"; type Props = { - fetchChangesetsByBranch: (Repository, Branch) => void, - fetchChangesetsByBranchAndPage: (Repository, Branch, number) => void, repository: Repository, //TODO: Do we really need/want this here? branch: Branch, + + // State props changesets: Changeset[], loading: boolean, - match: any, list: PagedCollection, error: Error, + + // Dispatch props + fetchChangesetsByBranch: (Repository, Branch) => void, + fetchChangesetsByBranchAndPage: (Repository, Branch, number) => void, + + // Context Props + match: any, t: string => string }; @@ -38,6 +39,7 @@ type State = {}; class Changesets extends React.Component { componentDidMount() { + console.log("CDM"); const { fetchChangesetsByBranch, fetchChangesetsByBranchAndPage, @@ -57,26 +59,26 @@ class Changesets extends React.Component { } } - componentDidUpdate(prevProps: Props) { - const { - match, - repository, - branch, - fetchChangesetsByBranch, - fetchChangesetsByBranchAndPage - } = this.props; - const { page } = match.params; - - if (branch === prevProps.branch) { - return; - } - - if (!page) { - fetchChangesetsByBranch(repository, branch); - } else { - fetchChangesetsByBranchAndPage(repository, branch, page); - } - } + // componentDidUpdate(prevProps: Props) { + // const { + // match, + // repository, + // branch, + // fetchChangesetsByBranch, + // fetchChangesetsByBranchAndPage + // } = this.props; + // const { page } = match.params; + // + // if (branch === prevProps.branch) { + // return; + // } + // + // if (!page) { + // fetchChangesetsByBranch(repository, branch); + // } else { + // fetchChangesetsByBranchAndPage(repository, branch, page); + // } + // } render() { const { changesets, loading, error, t } = this.props; diff --git a/scm-ui/src/repos/containers/RepositoryRoot.js b/scm-ui/src/repos/containers/RepositoryRoot.js index f248bd07eb..d94d2b855f 100644 --- a/scm-ui/src/repos/containers/RepositoryRoot.js +++ b/scm-ui/src/repos/containers/RepositoryRoot.js @@ -1,32 +1,17 @@ //@flow import React from "react"; -import { - deleteRepo, - fetchRepo, - getFetchRepoFailure, - getRepository, - isFetchRepoPending -} from "../modules/repos"; -import { connect } from "react-redux"; -import { Route, Switch } from "react-router-dom"; -import type { Repository } from "@scm-manager/ui-types"; -import { - ErrorPage, - Loading, - Navigation, - NavLink, - Page, - Section -} from "@scm-manager/ui-components"; -import { translate } from "react-i18next"; +import {deleteRepo, fetchRepo, getFetchRepoFailure, getRepository, isFetchRepoPending} from "../modules/repos"; +import {connect} from "react-redux"; +import {Route, Switch} from "react-router-dom"; +import type {Repository} from "@scm-manager/ui-types"; +import {ErrorPage, Loading, Navigation, NavLink, Page, Section} from "@scm-manager/ui-components"; +import {translate} from "react-i18next"; import RepositoryDetails from "../components/RepositoryDetails"; import DeleteNavAction from "../components/DeleteNavAction"; import Edit from "../containers/Edit"; -import type { History } from "history"; +import type {History} from "history"; import EditNavLink from "../components/EditNavLink"; -import BranchChooser from "./BranchChooser"; -import Changesets from "./Changesets"; import BranchRoot from "./BranchRoot"; type Props = {