mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 04:10:52 +01:00
check if sources view should redirect to defaultBranch
This commit is contained in:
@@ -69,7 +69,7 @@ class Sources extends React.Component<Props, State> {
|
||||
fetchBranches(repository);
|
||||
fetchSources(repository, revision, path);
|
||||
|
||||
if (branches) {
|
||||
if (this.shouldRedirect()) {
|
||||
const defaultBranches = branches.filter(b => b.defaultBranch);
|
||||
|
||||
if (defaultBranches.length > 0)
|
||||
@@ -91,12 +91,7 @@ class Sources extends React.Component<Props, State> {
|
||||
fetchSources(repository, revision, path);
|
||||
}
|
||||
|
||||
const currentUrl = this.props.location.pathname;
|
||||
|
||||
if (
|
||||
branches &&
|
||||
(currentUrl.endsWith("sources") || currentUrl.endsWith("sources/"))
|
||||
) {
|
||||
if (this.shouldRedirect()) {
|
||||
const defaultBranches = branches.filter(b => b.defaultBranch);
|
||||
|
||||
if (defaultBranches.length > 0)
|
||||
@@ -105,6 +100,15 @@ class Sources extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
shouldRedirect = () => {
|
||||
const { branches, location } = this.props;
|
||||
return (
|
||||
branches &&
|
||||
(location.pathname.endsWith("sources") ||
|
||||
location.pathname.endsWith("sources/"))
|
||||
);
|
||||
};
|
||||
|
||||
branchSelected = (branch?: Branch) => {
|
||||
const { baseUrl, history, path } = this.props;
|
||||
let url;
|
||||
|
||||
Reference in New Issue
Block a user