From e5db7166f0f2e1d806f42856c042bb9f41246a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 8 Nov 2016 15:40:59 +0100 Subject: [PATCH 1/2] [24233] Fix deep link into work package project context When deep linking to a work package such as `/work_packages/:id`, Rails renders a project context (project menu, etc.), but the frontend does not respect the `projectIdentifier` setting as long as the `projectPath` is missing from ui-router. We can enforce the projectPath by looking at the root projectIdentifier. If that is set, we're within the project context. --- frontend/app/components/routing/ui-router.config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/app/components/routing/ui-router.config.ts b/frontend/app/components/routing/ui-router.config.ts index bf524f2acf..1f11c0b84b 100644 --- a/frontend/app/components/routing/ui-router.config.ts +++ b/frontend/app/components/routing/ui-router.config.ts @@ -235,10 +235,13 @@ openprojectModule }); $rootScope.$on('$stateChangeStart', (event, toState, toParams) => { + const projectIdentifier = toParams.projectPath || $rootScope.projectIdentifier; + // Close all open dropdowns, if any $rootScope.$broadcast('openproject.dropdown.closeDropdowns'); - if (!toParams.projects && toParams.projectPath) { + if (!toParams.projects && projectIdentifier) { + toParams.projectPath = projectIdentifier; toParams.projects = 'projects'; $state.go(toState, toParams); } From 777759d65eadf3a15af0a17c6d9241666a778e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 8 Nov 2016 21:06:07 +0100 Subject: [PATCH 2/2] Adapt specs that now result in project scoped link --- features/work_packages/work_package_textile_link.feature | 6 +++--- spec/features/work_packages/copy_spec.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/work_packages/work_package_textile_link.feature b/features/work_packages/work_package_textile_link.feature index 26cc9b2824..96daa697c3 100644 --- a/features/work_packages/work_package_textile_link.feature +++ b/features/work_packages/work_package_textile_link.feature @@ -63,7 +63,7 @@ Feature: Work package textile quickinfo links Then I should see a 1 hash work package quickinfo link to "January" within "div.wiki" When I follow the 1 hash work package quickinfo link to "January" Then I should see "January" within ".wp-edit-field.subject" - And I should be on the page of the work package "January" + And I should be on the page of the work package "January" in project "ecookbook" @javascript Scenario: Adding a work package quickinfo link @@ -74,7 +74,7 @@ Feature: Work package textile quickinfo links Then I should see a 2 hashes work package quickinfo link to "January" within "div.wiki" When I follow the 2 hashes work package quickinfo link to "January" Then I should see "January" within ".wp-edit-field.subject" - And I should be on the page of the work package "January" + And I should be on the page of the work package "January" in project "ecookbook" @javascript Scenario: Adding a work package quickinfo link with description @@ -85,7 +85,7 @@ Feature: Work package textile quickinfo links Then I should see a 3 hashes work package quickinfo link to "January" within "div.wiki" When I follow the 3 hashes work package quickinfo link to "January" Then I should see "January" within ".wp-edit-field.subject" - And I should be on the page of the work package "January" + And I should be on the page of the work package "January" in project "ecookbook" Scenario: Adding a work package quickinfo link without the right to see the work package diff --git a/spec/features/work_packages/copy_spec.rb b/spec/features/work_packages/copy_spec.rb index 5df52cc9cb..fdbb69e3ec 100644 --- a/spec/features/work_packages/copy_spec.rb +++ b/spec/features/work_packages/copy_spec.rb @@ -109,7 +109,7 @@ RSpec.feature 'Work package copy', js: true, selenium: true do expect(copied_work_package).to_not eql original_work_package - work_package_page = Pages::FullWorkPackage.new(copied_work_package) + work_package_page = Pages::FullWorkPackage.new(copied_work_package, project) work_package_page.ensure_page_loaded work_package_page.expect_attributes Subject: original_work_package.subject,