-
Notifications
You must be signed in to change notification settings - Fork 28
Feat(9556): [AUB] Contributors: missing ability to remove contributor from parent and all components #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(9556): [AUB] Contributors: missing ability to remove contributor from parent and all components #767
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { | |||||
| AddContributorDialogComponent, | ||||||
| AddUnregisteredContributorDialogComponent, | ||||||
| ContributorsTableComponent, | ||||||
| RemoveContributorDialogComponent, | ||||||
| RequestAccessTableComponent, | ||||||
| } from '@osf/shared/components/contributors'; | ||||||
| import { SearchInputComponent } from '@osf/shared/components/search-input/search-input.component'; | ||||||
|
|
@@ -397,26 +398,37 @@ export class ContributorsComponent implements OnInit, OnDestroy { | |||||
| removeContributor(contributor: ContributorModel) { | ||||||
| const isDeletingSelf = contributor.userId === this.currentUser()?.id; | ||||||
|
|
||||||
| this.customConfirmationService.confirmDelete({ | ||||||
| headerKey: 'project.contributors.removeDialog.title', | ||||||
| messageKey: 'project.contributors.removeDialog.message', | ||||||
| messageParams: { name: contributor.fullName }, | ||||||
| acceptLabelKey: 'common.buttons.remove', | ||||||
| onConfirm: () => { | ||||||
| this.actions | ||||||
| .deleteContributor(this.resourceId(), this.resourceType(), contributor.userId, isDeletingSelf) | ||||||
| .pipe(takeUntilDestroyed(this.destroyRef)) | ||||||
| .subscribe(() => { | ||||||
| this.toastService.showSuccess('project.contributors.removeDialog.successMessage', { | ||||||
| name: contributor.fullName, | ||||||
| }); | ||||||
| this.customDialogService | ||||||
| .open(RemoveContributorDialogComponent, { | ||||||
| header: 'project.contributors.removeDialog.title', | ||||||
| width: '448px', | ||||||
| data: { | ||||||
| messageKey: 'project.contributors.removeDialog.message', | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you pass it? Will it be different for each remove dialog? I think it better to use directly in |
||||||
| messageParams: { name: contributor.fullName }, | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass it as name.
Suggested change
|
||||||
| }, | ||||||
| }) | ||||||
| .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(['/']); | ||||||
| } | ||||||
| }); | ||||||
| }, | ||||||
| }); | ||||||
| if (isDeletingSelf) { | ||||||
| this.router.navigate(['/']); | ||||||
| } | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| loadMoreContributors(): void { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export * from './add-contributor-dialog/add-contributor-dialog.component'; | ||
| export * from './add-unregistered-contributor-dialog/add-unregistered-contributor-dialog.component'; | ||
| export * from './contributors-table/contributors-table.component'; | ||
| export * from './remove-contributor-dialog/remove-contributor-dialog.component'; | ||
| export * from './request-access-table/request-access-table.component'; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||
| <div class="flex flex-column"> | ||||||
| <p [innerHTML]="messageKey ? (messageKey | translate: messageParams) : ''"></p> | ||||||
|
|
||||||
| <div class="p-field-radiobutton flex align-items-center mt-3 mb-2"> | ||||||
| <p-radioButton name="removeMode" [value]="false" [(ngModel)]="selectedOption" inputId="projectOnly"> | ||||||
| </p-radioButton> | ||||||
| <label for="projectOnly" class="ml-2">{{ 'project.contributors.removeDialog.thisProjectOnly' | translate }}</label> | ||||||
| </div> | ||||||
| <div class="p-field-radiobutton flex align-items-center mb-3"> | ||||||
| <p-radioButton name="removeMode" [value]="true" [(ngModel)]="selectedOption" inputId="projectAll"> </p-radioButton> | ||||||
| <label for="projectAll" class="ml-2">{{ | ||||||
| 'project.contributors.removeDialog.thisProjectAndComponents' | translate | ||||||
| }}</label> | ||||||
| </div> | ||||||
|
|
||||||
| <div class="flex gap-2 mt-3"> | ||||||
| <p-button | ||||||
| class="w-full" | ||||||
| styleClass="w-full" | ||||||
| (click)="cancel()" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
|
||||||
| severity="info" | ||||||
| [label]="'common.buttons.cancel' | translate" | ||||||
| ></p-button> | ||||||
| <p-button | ||||||
| class="w-full" | ||||||
| styleClass="w-full" | ||||||
| (click)="confirm()" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| severity="danger" | ||||||
| [label]="'common.buttons.remove' | translate" | ||||||
| ></p-button> | ||||||
| </div> | ||||||
| </div> | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add unit tests. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
|
||
| import { RemoveContributorDialogComponent } from './remove-contributor-dialog.component'; | ||
|
|
||
| describe('RemoveContributorDialogComponent', () => { | ||
| let component: RemoveContributorDialogComponent; | ||
| let fixture: ComponentFixture<RemoveContributorDialogComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [RemoveContributorDialogComponent], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(RemoveContributorDialogComponent); | ||
| component = fixture.componentInstance; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('should create', () => { | ||
| expect(component).toBeTruthy(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { TranslatePipe } from '@ngx-translate/core'; | ||
|
|
||
| import { Button } from 'primeng/button'; | ||
| import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog'; | ||
| import { RadioButton } from 'primeng/radiobutton'; | ||
|
|
||
| import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
|
|
||
| @Component({ | ||
| selector: 'osf-remove-contributor-dialog', | ||
| imports: [RadioButton, FormsModule, Button, TranslatePipe], | ||
| templateUrl: './remove-contributor-dialog.component.html', | ||
| styleUrl: './remove-contributor-dialog.component.scss', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| }) | ||
| export class RemoveContributorDialogComponent { | ||
| readonly dialogRef = inject(DynamicDialogRef); | ||
| readonly config = inject(DynamicDialogConfig); | ||
| selectedOption = false; | ||
|
|
||
| get messageKey(): string | undefined { | ||
| return this.config?.data?.messageKey as string | undefined; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| get messageParams(): any { | ||
| return this.config?.data?.messageParams; | ||
| } | ||
|
|
||
| confirm(): void { | ||
| this.dialogRef.close(this.selectedOption); | ||
| } | ||
|
|
||
| cancel(): void { | ||
| this.dialogRef.close(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will happen if project doesn't have any component?