From 063391a0e52b6435a40a711ce3f52c9f7cab7798 Mon Sep 17 00:00:00 2001 From: nsemets Date: Fri, 13 Feb 2026 18:03:06 +0200 Subject: [PATCH] fix(contributors): updated delete contributors logic --- .../contributors/contributors.component.ts | 68 +++++++++++-------- .../remove-contributor-dialog.component.html | 2 +- .../shared/services/contributors.service.ts | 8 +-- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 8db8f09f6..9be8e6435 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -395,37 +395,49 @@ export class ContributorsComponent implements OnInit, OnDestroy { removeContributor(contributor: ContributorModel) { const isDeletingSelf = contributor.userId === this.currentUser()?.id; + const resourceDetails = this.resourceDetails(); + const resourceId = this.resourceId(); + const rootParentId = resourceDetails.rootParentId ?? resourceId; - this.customDialogService - .open(RemoveContributorDialogComponent, { - header: 'project.contributors.removeDialog.title', - width: '448px', - data: { - name: contributor.fullName, - hasChildren: !!this.resourceChildren()?.length, - }, - }) - .onClose.pipe( - filter((res) => res !== undefined), - switchMap((removeFromChildren: boolean) => - this.actions.deleteContributor( - this.resourceId(), - this.resourceType(), - contributor.userId, - isDeletingSelf, - removeFromChildren - ) - ), - takeUntilDestroyed(this.destroyRef) - ) + this.loaderService.show(); + + this.actions + .getResourceWithChildren(rootParentId, resourceId, this.resourceType()) + .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { - this.toastService.showSuccess('project.contributors.removeDialog.successMessage', { - name: contributor.fullName, - }); + this.loaderService.hide(); - if (isDeletingSelf) { - this.router.navigate(['/']); - } + this.customDialogService + .open(RemoveContributorDialogComponent, { + header: 'project.contributors.removeDialog.title', + width: '448px', + data: { + name: contributor.fullName, + hasChildren: !!this.resourceChildren()?.length, + }, + }) + .onClose.pipe( + filter((res) => res !== undefined), + switchMap((removeFromChildren: boolean) => + this.actions.deleteContributor( + this.resourceId(), + this.resourceType(), + contributor.userId, + isDeletingSelf, + removeFromChildren + ) + ), + takeUntilDestroyed(this.destroyRef) + ) + .subscribe(() => { + this.toastService.showSuccess('project.contributors.removeDialog.successMessage', { + name: contributor.fullName, + }); + + if (isDeletingSelf) { + this.router.navigate(['/']); + } + }); }); } diff --git a/src/app/shared/components/contributors/remove-contributor-dialog/remove-contributor-dialog.component.html b/src/app/shared/components/contributors/remove-contributor-dialog/remove-contributor-dialog.component.html index 6b579178e..520de170a 100644 --- a/src/app/shared/components/contributors/remove-contributor-dialog/remove-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/remove-contributor-dialog/remove-contributor-dialog.component.html @@ -1,5 +1,5 @@
-

{{ 'project.contributors.removeDialog.message' | translate: { name: name } }}

+

diff --git a/src/app/shared/services/contributors.service.ts b/src/app/shared/services/contributors.service.ts index 80b123dcd..266ba23f2 100644 --- a/src/app/shared/services/contributors.service.ts +++ b/src/app/shared/services/contributors.service.ts @@ -248,11 +248,9 @@ export class ContributorsService { userId: string, removeFromChildren = false ): Observable { - let baseUrl = `${this.getBaseUrl(resourceType, resourceId)}/${userId}/`; - if (removeFromChildren) { - baseUrl = baseUrl.concat('?propagate_to_children=true'); - } + const baseUrl = `${this.getBaseUrl(resourceType, resourceId)}/${userId}/`; + const url = removeFromChildren ? `${baseUrl}?include_children=true` : baseUrl; - return this.jsonApiService.delete(baseUrl); + return this.jsonApiService.delete(url); } }