Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Only try to set projects/projectsPath if we're in a project route

Oliver Günther401f1b391b6c
diff --git a/frontend/src/app/core/routing/openproject.routes.ts b/frontend/src/app/core/routing/openproject.routes.ts
index 68d9023f1a1..685197f7a90 100644
--- a/frontend/src/app/core/routing/openproject.routes.ts
+++ b/frontend/src/app/core/routing/openproject.routes.ts
@@ -38,6 +38,7 @@ import { appBaseSelector, ApplicationBaseComponent } from 'core-app/core/routing
import { BackRoutingService } from 'core-app/features/work-packages/components/back-routing/back-routing.service';
import { MY_ACCOUNT_LAZY_ROUTES } from 'core-app/features/user-preferences/user-preferences.lazy-routes';
import { IAN_LAZY_ROUTES } from 'core-app/features/in-app-notifications/in-app-notifications.lazy-routes';
+import { StateObject } from '@uirouter/core/lib/state/stateObject';
export const OPENPROJECT_ROUTES:Ng2StateDeclaration[] = [
{
@@ -221,7 +222,6 @@ export function initializeUiRouterListeners(injector:Injector) {
$transitions.onStart({}, (transition:Transition) => {
const $state = transition.router.stateService;
const toParams = transition.params('to');
- const fromState = transition.from();
const toState = transition.to();
// Remove start_onboarding_tour param if set
@@ -235,11 +235,13 @@ export function initializeUiRouterListeners(injector:Injector) {
backRoutingService.sync(transition);
// Reset profiler, if we're actually profiling
- const profiler:any = (window as any).MiniProfiler;
- profiler && profiler.pageTransition();
+ const profiler:{ pageTransition:() => void }|undefined = window.MiniProfiler;
+ profiler?.pageTransition();
- const projectIdentifier = toParams.projectPath || currentProject.identifier;
- if (!toParams.projects && projectIdentifier) {
+ const toStateObject:StateObject|undefined = toState.$$state && toState.$$state();
+ const hasProjectRoutes = toStateObject?.includes?.root;
+ const projectIdentifier = toParams.projectPath as string || currentProject.identifier;
+ if (hasProjectRoutes && !toParams.projects && projectIdentifier) {
const newParams = _.clone(toParams);
_.assign(newParams, { projectPath: projectIdentifier, projects: 'projects' });
return $state.target(toState, newParams, { location: 'replace' });
diff --git a/frontend/src/typings/shims.d.ts b/frontend/src/typings/shims.d.ts
index ffeb2b9fc20..48c023e9403 100644
--- a/frontend/src/typings/shims.d.ts
+++ b/frontend/src/typings/shims.d.ts
@@ -44,6 +44,7 @@ declare global {
ErrorReporter:ErrorReporter;
onboardingTourInstance:any;
screenfull:Screenfull;
+ MiniProfiler?:{ pageTransition:() => void };
}
interface JQuery {