Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions src/app/features/contributors/contributors.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(['/']);
}
});
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="flex flex-column">
<p>{{ 'project.contributors.removeDialog.message' | translate: { name: name } }}</p>
<p [innerHTML]="'project.contributors.removeDialog.message' | translate: { name: name }"></p>

<div class="p-field-radiobutton flex align-items-center mt-3 mb-2">
<p-radioButton name="removeMode" [value]="false" [(ngModel)]="selectedOption" inputId="projectOnly">
Expand Down
8 changes: 3 additions & 5 deletions src/app/shared/services/contributors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,9 @@ export class ContributorsService {
userId: string,
removeFromChildren = false
): Observable<void> {
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);
}
}