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

[#43257] Fix Can not find users with the user creation/invitation form

Dombi Attila367555397d6f
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
index 7d4a6c10efc..f9aebaeef74 100644
--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.ts
@@ -1,4 +1,5 @@
import {
+ ChangeDetectionStrategy,
Component,
OnInit,
Input,
@@ -16,6 +17,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';
import { BannersService } from 'core-app/core/enterprise/banners.service';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
import { IOpOptionListOption } from 'core-app/shared/components/option-list/option-list.component';
+import { cloneHalResource } from 'core-app/features/hal/helpers/hal-resource-builder';
import { ProjectResource } from 'core-app/features/hal/resources/project-resource';
import { PrincipalType } from '../invite-user.component';
import { ProjectAllowedValidator } from './project-allowed.validator';
@@ -27,6 +29,7 @@ import idFromLink from 'core-app/features/hal/helpers/id-from-link';
@Component({
selector: 'op-ium-project-selection',
+ changeDetection: ChangeDetectionStrategy.OnPush,
templateUrl: './project-selection.component.html',
styleUrls: ['./project-selection.component.sass'],
})
@@ -94,7 +97,7 @@ export class ProjectSelectionComponent implements OnInit {
this.typeControl.setValue(this.type);
if (this.project) {
- this.projectControl.setValue({ ...this.project });
+ this.projectControl.setValue(cloneHalResource<ProjectResource>(this.project));
}
this.setPlaceholderOption();
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 4724db7a7d6..bcc1151135c 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
@@ -56,10 +56,10 @@ describe 'Invite user modal', type: :feature, js: true do
global_permissions:
end
- shared_examples 'invites the principal to the project' do
+ shared_examples 'invites the principal to the project' do |skip_project_autocomplete = false|
it 'invites that principal to the project' do
perform_enqueued_jobs do
- modal.run_all_steps
+ modal.run_all_steps(skip_project_autocomplete:)
end
assignee_field.expect_inactive!
@@ -153,6 +153,13 @@ describe 'Invite user modal', type: :feature, js: true do
let(:added_principal) { principal }
let(:mail_membership_recipients) { [principal] }
end
+
+ context 'when keeping the default project selection' do
+ it_behaves_like 'invites the principal to the project', skip_project_autocomplete: true do
+ let(:added_principal) { principal }
+ let(:mail_membership_recipients) { [principal] }
+ end
+ end
end
context 'with a user to be invited' do
diff --git a/spec/support/components/users/invite_user_modal.rb b/spec/support/components/users/invite_user_modal.rb
index ce999611394..b53632cbee0 100644
--- a/spec/support/components/users/invite_user_modal.rb
+++ b/spec/support/components/users/invite_user_modal.rb
@@ -44,11 +44,11 @@ module Components
super()
end
- def run_all_steps
+ def run_all_steps(skip_project_autocomplete: false)
expect_open
# STEP 1: Project and type
- project_step
+ project_step(skip_autocomplete: skip_project_autocomplete)
# STEP 2: User name
principal_step
@@ -90,9 +90,9 @@ module Components
expect_closed
end
- def project_step(next_step: true)
+ def project_step(next_step: true, skip_autocomplete: false)
expect_title 'Invite user'
- autocomplete project.name
+ autocomplete project.name unless skip_autocomplete
select_type type
click_next if next_step