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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix validator in invite user modal
Benjamin Bädorfb886e8c8c2c0
diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts b/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.tsindex d58b18064fd..03f46d3d336 100644--- a/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-allowed.validator.ts@@ -1,15 +1,19 @@import { AbstractControl } from '@angular/forms';import { of } from 'rxjs';-import { catchError, map } from 'rxjs/operators';+import { catchError, map, take } from 'rxjs/operators';import { CurrentUserService } from 'core-app/core/current-user/current-user.service';import idFromLink from 'core-app/features/hal/helpers/id-from-link';export const ProjectAllowedValidator = (currentUserService:CurrentUserService) =>- (control:AbstractControl) =>- currentUserService.hasCapabilities$(+ (control:AbstractControl) => {+ const href = control.value?.href || control.value?.$links?.self.href;+ const id = href ? idFromLink(href) : control.value;+ return currentUserService.hasCapabilities$('memberships/create',- idFromLink(control.value.href)+ id,).pipe(+ take(1),map((isAllowed) => (isAllowed ? null : { lackingPermission: true })),catchError(() => of(null)),);+}diff --git a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.html b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.htmlindex bf7d8ef71bc..bdd99daf40f 100644--- a/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.html+++ b/frontend/src/app/features/invite-user-modal/project-selection/project-selection.component.html@@ -18,7 +18,7 @@<divslot="help-text"- *ngIf="projectControl!.errors?.lackingPermission"+ *ngIf="projectControl.errors?.lackingPermission">{{ text.project.lackingPermissionInfo }}</div>@@ -26,7 +26,7 @@<divslot="errors"class="op-form-field--error"- *ngIf="projectControl!.errors?.required"+ *ngIf="projectControl.errors?.required">{{ text.project.required }}</div>@@ -34,7 +34,7 @@<divslot="errors"class="op-form-field--error"- *ngIf="projectControl!.errors?.lackingPermission"+ *ngIf="projectControl.errors?.lackingPermission">{{ text.project.lackingPermission }}</div>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.tsindex c1b273f45a7..1a33b7f10a3 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@@ -72,11 +72,11 @@ export class ProjectSelectionComponent implements OnInit {});get typeControl() {- return this.projectAndTypeForm.get('type');+ return this.projectAndTypeForm.get('type')!;}get projectControl() {- return this.projectAndTypeForm.get('project');+ return this.projectAndTypeForm.get('project')!;}private projectInviteCapabilities:CapabilityResource[] = [];@@ -90,10 +90,10 @@ export class ProjectSelectionComponent implements OnInit {) {}ngOnInit() {- this.typeControl?.setValue(this.type);+ this.typeControl.setValue(this.type);if (this.project) {- this.projectControl?.setValue({ ...this.project });+ this.projectControl.setValue({ ...this.project });}this.setPlaceholderOption();