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

ignore undisclosed ancestors on hierarchy building

ulfertsa62079727f88
diff --git a/frontend/src/app/shared/components/project-include/insert-in-list.ts b/frontend/src/app/shared/components/project-include/insert-in-list.ts
index cc931bf2d7b..b725af545f8 100644
--- a/frontend/src/app/shared/components/project-include/insert-in-list.ts
+++ b/frontend/src/app/shared/components/project-include/insert-in-list.ts
@@ -2,6 +2,8 @@ import { IProject } from 'core-app/core/state/projects/project.model';
import { IHalResourceLink } from 'core-app/core/state/hal-resource';
import { IProjectData } from './project-data';
+const UNDISCLOSED_ANCESTOR = 'urn:openproject-org:api:v3:undisclosed';
+
// Helper function that recursively inserts a project into the hierarchy at the right place
export const insertInList = (
projects:IProject[],
@@ -9,7 +11,12 @@ export const insertInList = (
list:IProjectData[],
ancestors:IHalResourceLink[],
):IProjectData[] => {
- if (!ancestors.length) {
+ // In a set of projects, some of the ancestors may be undisclosed. The client then knows of its existence
+ // but knows nothing more than that. Those projects receive an 'undisclosed' urn for their href. For building
+ // the project hierarchy, they can be ignored.
+ const visibleAncestors = ancestors.filter((ancestor) => ancestor.href !== UNDISCLOSED_ANCESTOR);
+
+ if (!visibleAncestors.length) {
return [
...list,
{
@@ -22,11 +29,11 @@ export const insertInList = (
];
}
- const ancestorHref = ancestors[0].href;
+ const ancestorHref = visibleAncestors[0].href;
const ancestor:IProjectData|undefined = list.find((projectInList) => projectInList.href === ancestorHref);
if (ancestor) {
- ancestor.children = insertInList(projects, project, ancestor.children, ancestors.slice(1));
+ ancestor.children = insertInList(projects, project, ancestor.children, visibleAncestors.slice(1));
return [...list];
}
@@ -42,7 +49,7 @@ export const insertInList = (
name: ancestorProject.name,
href: ancestorProject._links.self.href,
found: false,
- children: insertInList(projects, project, [], ancestors.slice(1)),
+ children: insertInList(projects, project, [], visibleAncestors.slice(1)),
},
];
};
diff --git a/modules/calendar/spec/features/calendar_project_include_spec.rb b/modules/calendar/spec/features/calendar_project_include_spec.rb
index 17399a80552..1f064750bc6 100644
--- a/modules/calendar/spec/features/calendar_project_include_spec.rb
+++ b/modules/calendar/spec/features/calendar_project_include_spec.rb
@@ -56,7 +56,7 @@ describe 'Calendar project include', type: :feature, js: true do
work_package_view.expect_event other_other_task, present: false
dropdown.toggle!
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_count 1
diff --git a/modules/team_planner/spec/features/team_planner_project_include_spec.rb b/modules/team_planner/spec/features/team_planner_project_include_spec.rb
index 92edfb90c44..eaadc2dc2a1 100644
--- a/modules/team_planner/spec/features/team_planner_project_include_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_project_include_spec.rb
@@ -86,7 +86,7 @@ describe 'Team planner project include', type: :feature, js: true do
end
dropdown.toggle!
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_count 1
diff --git a/spec/features/work_packages/project_include/project_include_shared_examples.rb b/spec/features/work_packages/project_include/project_include_shared_examples.rb
index fdf694b29a3..7a4e9fc8609 100644
--- a/spec/features/work_packages/project_include/project_include_shared_examples.rb
+++ b/spec/features/work_packages/project_include/project_include_shared_examples.rb
@@ -39,8 +39,14 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
create(:project, name: 'Direct Child', parent: project, enabled_module_names: enabled_modules)
end
- shared_let(:sub_sub_project) do
- create(:project, name: 'Direct Grandchild', parent: sub_project, enabled_module_names: enabled_modules)
+ # The user will not receive a membership in this project
+ # which is why it is invisible to the user.
+ shared_let(:sub_sub_project_invisible) do
+ create(:project, name: 'Invisible Grandchild', parent: sub_project, enabled_module_names: enabled_modules)
+ end
+
+ shared_let(:sub_sub_sub_project) do
+ create(:project, name: 'Direct grand Grandchild', parent: sub_sub_project_invisible, enabled_module_names: enabled_modules)
end
shared_let(:other_project) do
@@ -64,7 +70,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
member_in_projects: [
project,
sub_project,
- sub_sub_project,
+ sub_sub_sub_project,
other_project,
other_sub_project,
other_sub_sub_project,
@@ -80,7 +86,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
member_in_projects: [
project,
sub_project,
- sub_sub_project,
+ sub_sub_sub_project,
other_project,
other_sub_project,
other_sub_sub_project,
@@ -117,7 +123,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
shared_let(:sub_sub_bug) do
create :work_package,
- project: sub_sub_project,
+ project: sub_sub_sub_project,
type: type_bug,
assigned_to: user,
start_date: Time.zone.today - 1.day,
@@ -150,8 +156,8 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
project.types << type_task
sub_project.types << type_bug
sub_project.types << type_task
- sub_sub_project.types << type_bug
- sub_sub_project.types << type_task
+ sub_sub_sub_project.types << type_bug
+ sub_sub_sub_project.types << type_task
other_project.types << type_bug
other_project.types << type_task
@@ -177,7 +183,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
dropdown.toggle_include_all_subprojects
@@ -187,10 +193,10 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id)
+ dropdown.expect_checkbox(sub_sub_sub_project.id)
dropdown.toggle_checkbox(other_sub_project.id)
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.expect_checkbox(other_project.id)
dropdown.expect_checkbox(other_sub_project.id, true)
@@ -198,9 +204,9 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.expect_checkbox(other_project.id)
dropdown.expect_checkbox(other_sub_project.id, true)
@@ -208,7 +214,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id)
+ dropdown.expect_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_closed
@@ -216,7 +222,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.toggle!
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_closed
dropdown.expect_count 3
@@ -235,7 +241,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id, true)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
dropdown.toggle_include_all_subprojects
@@ -245,9 +251,9 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_closed
@@ -261,7 +267,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.toggle_checkbox(other_project.id)
dropdown.toggle_checkbox(project.id)
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.expect_checkbox(other_project.id, true)
dropdown.expect_checkbox(other_sub_project.id, true)
@@ -269,7 +275,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id, true)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
dropdown.click_button 'Apply'
dropdown.expect_closed
@@ -285,12 +291,12 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
dropdown.toggle_include_all_subprojects
dropdown.toggle_checkbox(other_sub_project.id)
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.expect_checkbox(other_project.id)
dropdown.expect_checkbox(other_sub_project.id, true)
@@ -298,7 +304,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
dropdown.click_button 'Apply'
dropdown.expect_closed
@@ -314,7 +320,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id)
+ dropdown.expect_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_closed
@@ -327,7 +333,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_open
retry_block do
- dropdown.search sub_sub_project.name
+ dropdown.search sub_sub_sub_project.name
dropdown.expect_no_checkbox(other_project.id)
dropdown.expect_no_checkbox(other_sub_project.id)
@@ -335,7 +341,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
end
retry_block do
@@ -347,7 +353,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_no_checkbox(project.id)
dropdown.expect_no_checkbox(sub_project.id)
- dropdown.expect_no_checkbox(sub_sub_project.id)
+ dropdown.expect_no_checkbox(sub_sub_sub_project.id)
end
retry_block do
@@ -359,7 +365,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
end
dropdown.toggle_checkbox(other_sub_sub_project.id)
@@ -373,7 +379,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
end
dropdown.toggle_checkbox(other_project.id)
@@ -385,7 +391,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id, true)
- dropdown.expect_checkbox(sub_sub_project.id, true)
+ dropdown.expect_checkbox(sub_sub_sub_project.id, true)
end
dropdown.toggle_include_all_subprojects
@@ -397,7 +403,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_no_checkbox(sub_project.id)
- dropdown.expect_no_checkbox(sub_sub_project.id)
+ dropdown.expect_no_checkbox(sub_sub_sub_project.id)
end
retry_block do
@@ -409,7 +415,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_no_checkbox(project.id)
dropdown.expect_no_checkbox(sub_project.id)
- dropdown.expect_no_checkbox(sub_sub_project.id)
+ dropdown.expect_no_checkbox(sub_sub_sub_project.id)
end
retry_block do
@@ -421,7 +427,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_no_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_no_checkbox(sub_project.id)
- dropdown.expect_no_checkbox(sub_sub_project.id)
+ dropdown.expect_no_checkbox(sub_sub_sub_project.id)
end
retry_block do
@@ -433,7 +439,7 @@ shared_examples 'has a project include dropdown', type: :feature, js: true do
dropdown.expect_checkbox(another_sub_sub_project.id)
dropdown.expect_checkbox(project.id, true)
dropdown.expect_checkbox(sub_project.id)
- dropdown.expect_checkbox(sub_sub_project.id)
+ dropdown.expect_checkbox(sub_sub_sub_project.id)
end
end
end
diff --git a/spec/features/work_packages/table/work_packages_table_project_include_spec.rb b/spec/features/work_packages/table/work_packages_table_project_include_spec.rb
index 9391c5d85a9..a18d84b7d75 100644
--- a/spec/features/work_packages/table/work_packages_table_project_include_spec.rb
+++ b/spec/features/work_packages/table/work_packages_table_project_include_spec.rb
@@ -51,7 +51,7 @@ describe 'Work package project include', type: :feature, js: true do
work_package_view.ensure_work_package_not_listed!(other_other_task)
dropdown.toggle!
- dropdown.toggle_checkbox(sub_sub_project.id)
+ dropdown.toggle_checkbox(sub_sub_sub_project.id)
dropdown.click_button 'Apply'
dropdown.expect_count 1