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

[37184] Hide archived projects from project search (#9283)

Oliver Günther2a40ec02033b
diff --git a/frontend/src/app/modules/invite-user-modal/project-selection/project-search.component.ts b/frontend/src/app/modules/invite-user-modal/project-selection/project-search.component.ts
index 645b80b2a95..9447ff24c6b 100644
--- a/frontend/src/app/modules/invite-user-modal/project-selection/project-search.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/project-selection/project-search.component.ts
@@ -37,6 +37,7 @@ export class ProjectSearchComponent extends UntilDestroyedMixin implements OnIni
debounceTime(100),
switchMap((searchTerm:string) => {
const filters = new ApiV3FilterBuilder();
+ filters.add('active', '=', true);
if (searchTerm) {
filters.add('name_and_identifier', '~', [searchTerm]);
}
diff --git a/spec/features/users/invite_user_modal/invite_user_modal_spec.rb b/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
index e793b8f6ee0..793b18e8bae 100644
--- a/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
+++ b/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
@@ -169,6 +169,17 @@ describe 'Invite user modal', type: :feature, js: true do
expect(ngselect).to have_text "#{project_no_permissions.name}\nYou are not allowed to invite members to this project"
end
end
+
+ context 'with a project that is archived' do
+ let!(:archived_project) { FactoryBot.create :project, active: false }
+ # Use admin to ensure all projects are visible
+ let(:current_user) { FactoryBot.create :admin }
+
+ it 'disables projects for which you do not have rights' do
+ ngselect = modal.open_select_in_step
+ expect(ngselect).to have_no_text archived_project
+ end
+ end
end
describe 'inviting placeholders' do
diff --git a/spec/support/components/ng_select_autocomplete_helpers.rb b/spec/support/components/ng_select_autocomplete_helpers.rb
index 936acc5e4df..8f18cc8c603 100644
--- a/spec/support/components/ng_select_autocomplete_helpers.rb
+++ b/spec/support/components/ng_select_autocomplete_helpers.rb
@@ -6,7 +6,7 @@ module Components
element.click
# Insert the text to find
within(element) do
- page.find('input', visible: :all).set(query)
+ ng_enter_query(query)
end
sleep(0.5)
@@ -25,6 +25,25 @@ module Components
list
end
+ ##
+ # Insert the query, typing
+ def ng_enter_query(query)
+ input = page.find('input', visible: :all).native
+ input.clear
+
+ query = query.to_s
+
+ if query.length > 1
+ # Send all keys, and then with a delay the last one
+ # to emulate normal typing
+ input.send_keys(query[0..-2])
+ sleep 0.2
+ input.send_keys(query[-1])
+ else
+ input.send_keys(query)
+ end
+ end
+
##
# Get the ng_select input element
def ng_select_input(from_element)