mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Keep selected path when switching to other branch
This commit is contained in:
@@ -20,6 +20,7 @@ type Props = {
|
|||||||
error: Error,
|
error: Error,
|
||||||
baseUrl: string,
|
baseUrl: string,
|
||||||
branches: Branch[],
|
branches: Branch[],
|
||||||
|
path: string,
|
||||||
|
|
||||||
// dispatch props
|
// dispatch props
|
||||||
fetchBranches: Repository => void,
|
fetchBranches: Repository => void,
|
||||||
@@ -37,10 +38,10 @@ class Sources extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
branchSelected = (branch?: Branch) => {
|
branchSelected = (branch?: Branch) => {
|
||||||
const { baseUrl, history } = this.props;
|
const { baseUrl, history, path } = this.props;
|
||||||
let url;
|
let url;
|
||||||
if (branch) {
|
if (branch) {
|
||||||
url = `${baseUrl}/${branch.name}`;
|
url = `${baseUrl}/${branch.name}/${path}`;
|
||||||
} else {
|
} else {
|
||||||
url = `${baseUrl}/`;
|
url = `${baseUrl}/`;
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,8 @@ class Sources extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = (state, ownProps) => {
|
const mapStateToProps = (state, ownProps) => {
|
||||||
const { repository } = ownProps;
|
const { repository, match } = ownProps;
|
||||||
|
const { path } = match.params;
|
||||||
|
|
||||||
const loading = isFetchBranchesPending(state, repository);
|
const loading = isFetchBranchesPending(state, repository);
|
||||||
const error = getFetchBranchesFailure(state, repository);
|
const error = getFetchBranchesFailure(state, repository);
|
||||||
@@ -104,6 +106,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
repository,
|
repository,
|
||||||
|
path,
|
||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
branches
|
branches
|
||||||
|
|||||||
Reference in New Issue
Block a user