From 6513de47d8754d11920f519f99c84ff6b6a9ec68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Mon, 22 Oct 2018 10:23:45 +0200 Subject: [PATCH] Keep selected path when switching to other branch --- scm-ui/src/repos/sources/containers/Sources.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scm-ui/src/repos/sources/containers/Sources.js b/scm-ui/src/repos/sources/containers/Sources.js index 40d4e6c214..9646c4b458 100644 --- a/scm-ui/src/repos/sources/containers/Sources.js +++ b/scm-ui/src/repos/sources/containers/Sources.js @@ -20,6 +20,7 @@ type Props = { error: Error, baseUrl: string, branches: Branch[], + path: string, // dispatch props fetchBranches: Repository => void, @@ -37,10 +38,10 @@ class Sources extends React.Component { } branchSelected = (branch?: Branch) => { - const { baseUrl, history } = this.props; + const { baseUrl, history, path } = this.props; let url; if (branch) { - url = `${baseUrl}/${branch.name}`; + url = `${baseUrl}/${branch.name}/${path}`; } else { url = `${baseUrl}/`; } @@ -96,7 +97,8 @@ class Sources extends React.Component { } const mapStateToProps = (state, ownProps) => { - const { repository } = ownProps; + const { repository, match } = ownProps; + const { path } = match.params; const loading = isFetchBranchesPending(state, repository); const error = getFetchBranchesFailure(state, repository); @@ -104,6 +106,7 @@ const mapStateToProps = (state, ownProps) => { return { repository, + path, loading, error, branches