From aa700f540b1368d81b271f0212416213abd25126 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Thu, 16 Oct 2025 15:19:23 +0300 Subject: [PATCH 1/9] fix( ENG-9127 ): add option of setting project contributors to preprint/registration --- .../contributors/contributors.component.ts | 13 +++++++++- .../preprints-contributors.component.ts | 13 +++++++++- .../add-contributor-dialog.component.html | 13 ++++++++++ .../add-contributor-dialog.component.ts | 8 +++++-- .../contributors/add-contributor-type.enum.ts | 1 + .../shared/services/contributors.service.ts | 6 +++++ .../contributors/contributors.actions.ts | 9 +++++++ .../stores/contributors/contributors.state.ts | 24 +++++++++++++++++++ 8 files changed, 83 insertions(+), 4 deletions(-) diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 46ae814a1..08732b6a8 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -49,6 +49,7 @@ import { AcceptRequestAccess, AddContributor, BulkAddContributors, + BulkAddContributorsFromParentProject, BulkUpdateContributors, ContributorsSelectors, CreateViewOnlyLink, @@ -155,6 +156,7 @@ export class ContributorsComponent implements OnInit { deleteContributor: DeleteContributor, bulkUpdateContributors: BulkUpdateContributors, bulkAddContributors: BulkAddContributors, + bulkAddContributorsFromParentProject: BulkAddContributorsFromParentProject, addContributor: AddContributor, createViewOnlyLink: CreateViewOnlyLink, deleteViewOnlyLink: DeleteViewOnlyLink, @@ -269,7 +271,9 @@ export class ContributorsComponent implements OnInit { takeUntilDestroyed(this.destroyRef) ) .subscribe((res: ContributorDialogAddModel) => { - if (res.type === AddContributorType.Unregistered) { + if (res.type === AddContributorType.ParentProject) { + this.addContributorsFromParentProjectToComponents(); + } else if (res.type === AddContributorType.Unregistered) { this.openAddUnregisteredContributorDialog(); } else { this.addContributorsToComponents(res); @@ -299,6 +303,13 @@ export class ContributorsComponent implements OnInit { .subscribe(() => this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage')); } + private addContributorsFromParentProjectToComponents(): void { + this.actions + .bulkAddContributorsFromParentProject(this.resourceId(), this.resourceType()) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage')); + } + openAddUnregisteredContributorDialog() { this.customDialogService .open(AddUnregisteredContributorDialogComponent, { diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts index c94ee8457..18f26c356 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts @@ -38,6 +38,7 @@ import { CustomConfirmationService, CustomDialogService, ToastService } from '@o import { AddContributor, BulkAddContributors, + BulkAddContributorsFromParentProject, BulkUpdateContributors, ContributorsSelectors, DeleteContributor, @@ -89,6 +90,7 @@ export class PreprintsContributorsComponent implements OnInit { bulkUpdateContributors: BulkUpdateContributors, bulkAddContributors: BulkAddContributors, addContributor: AddContributor, + bulkAddContributorsFromParentProject: BulkAddContributorsFromParentProject, }); get hasChanges(): boolean { @@ -134,7 +136,9 @@ export class PreprintsContributorsComponent implements OnInit { takeUntilDestroyed(this.destroyRef) ) .subscribe((res: ContributorDialogAddModel) => { - if (res.type === AddContributorType.Unregistered) { + if (res.type === AddContributorType.ParentProject) { + this.addContributorsFromParentProjectToComponents(); + } else if (res.type === AddContributorType.Unregistered) { this.openAddUnregisteredContributorDialog(); } else { this.actions @@ -147,6 +151,13 @@ export class PreprintsContributorsComponent implements OnInit { }); } + private addContributorsFromParentProjectToComponents(): void { + this.actions + .bulkAddContributorsFromParentProject(this.preprintId(), ResourceType.Preprint) + .pipe(takeUntilDestroyed(this.destroyRef)) + .subscribe(() => this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage')); + } + openAddUnregisteredContributorDialog() { this.customDialogService .open(AddUnregisteredContributorDialogComponent, { diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index 933bf2479..d3acc0fc7 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -65,6 +65,19 @@ } + @if (this.isSearchState()) { +
+ + +
+ } +
c.checked && !c.isCurrent) .map((c) => c.id); this.dialogRef.close({ data: this.selectedUsers(), - type: AddContributorType.Registered, + type: AddContributorTypeValue, childNodeIds: childNodeIds.length > 0 ? childNodeIds : undefined, } as ContributorDialogAddModel); } diff --git a/src/app/shared/enums/contributors/add-contributor-type.enum.ts b/src/app/shared/enums/contributors/add-contributor-type.enum.ts index 17ce058fc..cd0e360e4 100644 --- a/src/app/shared/enums/contributors/add-contributor-type.enum.ts +++ b/src/app/shared/enums/contributors/add-contributor-type.enum.ts @@ -1,4 +1,5 @@ export enum AddContributorType { Registered = 1, Unregistered, + ParentProject, } diff --git a/src/app/shared/services/contributors.service.ts b/src/app/shared/services/contributors.service.ts index 62c178759..e9a01369e 100644 --- a/src/app/shared/services/contributors.service.ts +++ b/src/app/shared/services/contributors.service.ts @@ -150,6 +150,12 @@ export class ContributorsService { .pipe(map((contributor) => ContributorsMapper.getContributor(contributor.data))); } + addContributorsFromProject(resourceType: ResourceType, resourceId: string): Observable { + const baseUrl = `${this.getBaseUrl(resourceType, resourceId)}/?copy_contributors_from_parent_project=${true}`; + let contributorData = { data: { type: AddContributorType.ParentProject } }; + return this.jsonApiService.patch(baseUrl, contributorData); + } + deleteContributor(resourceType: ResourceType, resourceId: string, userId: string): Observable { const baseUrl = `${this.getBaseUrl(resourceType, resourceId)}/${userId}/`; diff --git a/src/app/shared/stores/contributors/contributors.actions.ts b/src/app/shared/stores/contributors/contributors.actions.ts index 4eaaead98..2ee6ccf7a 100644 --- a/src/app/shared/stores/contributors/contributors.actions.ts +++ b/src/app/shared/stores/contributors/contributors.actions.ts @@ -62,6 +62,15 @@ export class BulkAddContributors { ) {} } +export class BulkAddContributorsFromParentProject { + static readonly type = '[Contributors] Bulk Add Contributors From Parent Project'; + + constructor( + public resourceId: string | undefined | null, + public resourceType: ResourceType | undefined + ) {} +} + export class DeleteContributor { static readonly type = '[Contributors] Delete Contributor'; diff --git a/src/app/shared/stores/contributors/contributors.state.ts b/src/app/shared/stores/contributors/contributors.state.ts index 1731cf44d..9d8f7fd99 100644 --- a/src/app/shared/stores/contributors/contributors.state.ts +++ b/src/app/shared/stores/contributors/contributors.state.ts @@ -11,6 +11,7 @@ import { AcceptRequestAccess, AddContributor, BulkAddContributors, + BulkAddContributorsFromParentProject, BulkUpdateContributors, ClearUsers, DeleteContributor, @@ -191,6 +192,29 @@ export class ContributorsState { ); } + @Action(BulkAddContributorsFromParentProject) + bulkAddContributorsFromParentProject( + ctx: StateContext, + action: BulkAddContributorsFromParentProject + ) { + const state = ctx.getState(); + + if (!action.resourceId || !action.resourceType) { + return; + } + + ctx.patchState({ + contributorsList: { ...state.contributorsList, isLoading: true, error: null }, + }); + + return this.contributorsService.addContributorsFromProject(action.resourceType, action.resourceId).pipe( + tap(() => { + ctx.dispatch(new GetAllContributors(action.resourceId, action.resourceType)); + }), + catchError((error) => handleSectionError(ctx, 'contributorsList', error)) + ); + } + @Action(DeleteContributor) deleteContributor(ctx: StateContext, action: DeleteContributor) { const state = ctx.getState(); From 1eb586d6b07b50b87b2d7fa0e8d32ba0bb8413ed Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 15:15:51 +0300 Subject: [PATCH 2/9] update code --- .../project-contributors-step.component.ts | 1 + src/app/features/contributors/contributors.component.ts | 2 ++ .../contributors-dialog/contributors-dialog.component.ts | 1 + .../preprints-contributors.component.ts | 3 ++- .../registries-contributors.component.ts | 1 + .../add-contributor-dialog.component.html | 2 +- .../add-contributor-dialog.component.ts | 7 ++++++- 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts index f6518e2d4..da7371a4a 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts @@ -151,6 +151,7 @@ export class ProjectContributorsStepComponent { } private openAddContributorDialog() { + alert('project'); const addedContributorIds = this.projectContributors().map((x) => x.userId); this.customDialogService diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 08732b6a8..42c967fa0 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -243,6 +243,7 @@ export class ContributorsComponent implements OnInit { } openAddContributorDialog() { + alert('contributors'); const addedContributorIds = this.initialContributors().map((x) => x.userId); const rootParentId = this.resourceDetails().rootParentId ?? this.resourceId(); @@ -264,6 +265,7 @@ export class ContributorsComponent implements OnInit { addedContributorIds, components, resourceName: this.resourceDetails().title, + allowAddingContributorsFromParentProject: true }, }) .onClose.pipe( diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts index 93ef2e95d..2d84ce303 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts @@ -128,6 +128,7 @@ export class ContributorsDialogComponent implements OnInit { } openAddContributorDialog(): void { + alert('contributors dialog'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts index 18f26c356..42b4b067d 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts @@ -123,13 +123,14 @@ export class PreprintsContributorsComponent implements OnInit { } openAddContributorDialog() { + alert('preprints'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService .open(AddContributorDialogComponent, { header: 'project.contributors.addDialog.addRegisteredContributor', width: '448px', - data: addedContributorIds, + data: {addedContributorIds, allowAddingContributorsFromParentProject: true}, }) .onClose.pipe( filter((res: ContributorDialogAddModel) => !!res), diff --git a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts index 5974ed64e..44d91bc67 100644 --- a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts +++ b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts @@ -133,6 +133,7 @@ export class RegistriesContributorsComponent implements OnInit { } openAddContributorDialog() { + alert('registries'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index d3acc0fc7..06b003dbf 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -65,7 +65,7 @@
} - @if (this.isSearchState()) { + @if (allowAddingContributorsFromParentProject() && this.isSearchState()) {
([]); readonly components = signal([]); readonly resourceName = signal(''); + readonly allowAddingContributorsFromParentProject = signal(false); readonly contributorNames = computed(() => this.selectedUsers() @@ -133,7 +134,7 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { private initializeDialogData(): void { this.selectedUsers.set([]); - const { components, resourceName } = this.config.data || {}; + const { components, resourceName, allowAddingContributorsFromParentProject } = this.config.data || {}; if (components) { this.components.set(components); @@ -142,6 +143,10 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { if (resourceName) { this.resourceName.set(resourceName); } + + if (allowAddingContributorsFromParentProject) { + this.allowAddingContributorsFromParentProject.set(allowAddingContributorsFromParentProject); + } } private closeDialogWithData(AddContributorTypeValue = AddContributorType.Registered): void { From 42bdd7ecf5d44d489320515f07744f13c86ed6b4 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 15:23:52 +0300 Subject: [PATCH 3/9] update code --- src/app/features/contributors/contributors.component.ts | 2 +- .../preprints-contributors/preprints-contributors.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 42c967fa0..b75be9fc9 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -265,7 +265,7 @@ export class ContributorsComponent implements OnInit { addedContributorIds, components, resourceName: this.resourceDetails().title, - allowAddingContributorsFromParentProject: true + allowAddingContributorsFromParentProject: true, }, }) .onClose.pipe( diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts index 42b4b067d..9b24a656e 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts @@ -130,7 +130,7 @@ export class PreprintsContributorsComponent implements OnInit { .open(AddContributorDialogComponent, { header: 'project.contributors.addDialog.addRegisteredContributor', width: '448px', - data: {addedContributorIds, allowAddingContributorsFromParentProject: true}, + data: { addedContributorIds, allowAddingContributorsFromParentProject: true }, }) .onClose.pipe( filter((res: ContributorDialogAddModel) => !!res), From 4b83f036ca14dc27ad1e7bdfe1dfc7caaa8db25d Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 17:09:00 +0300 Subject: [PATCH 4/9] ENG-9127 add contributors from parent project to component (project) updates --- .../project-contributors-step.component.ts | 1 - .../contributors/contributors.component.ts | 3 +-- .../contributors-dialog.component.ts | 1 - .../preprints-contributors.component.ts | 14 +------------- .../registries-contributors.component.ts | 1 - 5 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts index da7371a4a..f6518e2d4 100644 --- a/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts +++ b/src/app/features/collections/components/add-to-collection/project-contributors-step/project-contributors-step.component.ts @@ -151,7 +151,6 @@ export class ProjectContributorsStepComponent { } private openAddContributorDialog() { - alert('project'); const addedContributorIds = this.projectContributors().map((x) => x.userId); this.customDialogService diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index b75be9fc9..d430add4b 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -243,7 +243,6 @@ export class ContributorsComponent implements OnInit { } openAddContributorDialog() { - alert('contributors'); const addedContributorIds = this.initialContributors().map((x) => x.userId); const rootParentId = this.resourceDetails().rootParentId ?? this.resourceId(); @@ -265,7 +264,7 @@ export class ContributorsComponent implements OnInit { addedContributorIds, components, resourceName: this.resourceDetails().title, - allowAddingContributorsFromParentProject: true, + allowAddingContributorsFromParentProject: this.resourceType() === ResourceType.Project, }, }) .onClose.pipe( diff --git a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts index 2d84ce303..93ef2e95d 100644 --- a/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts +++ b/src/app/features/metadata/dialogs/contributors-dialog/contributors-dialog.component.ts @@ -128,7 +128,6 @@ export class ContributorsDialogComponent implements OnInit { } openAddContributorDialog(): void { - alert('contributors dialog'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService diff --git a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts index 9b24a656e..d20676f16 100644 --- a/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts +++ b/src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-contributors/preprints-contributors.component.ts @@ -38,7 +38,6 @@ import { CustomConfirmationService, CustomDialogService, ToastService } from '@o import { AddContributor, BulkAddContributors, - BulkAddContributorsFromParentProject, BulkUpdateContributors, ContributorsSelectors, DeleteContributor, @@ -90,7 +89,6 @@ export class PreprintsContributorsComponent implements OnInit { bulkUpdateContributors: BulkUpdateContributors, bulkAddContributors: BulkAddContributors, addContributor: AddContributor, - bulkAddContributorsFromParentProject: BulkAddContributorsFromParentProject, }); get hasChanges(): boolean { @@ -123,7 +121,6 @@ export class PreprintsContributorsComponent implements OnInit { } openAddContributorDialog() { - alert('preprints'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService @@ -137,9 +134,7 @@ export class PreprintsContributorsComponent implements OnInit { takeUntilDestroyed(this.destroyRef) ) .subscribe((res: ContributorDialogAddModel) => { - if (res.type === AddContributorType.ParentProject) { - this.addContributorsFromParentProjectToComponents(); - } else if (res.type === AddContributorType.Unregistered) { + if (res.type === AddContributorType.Unregistered) { this.openAddUnregisteredContributorDialog(); } else { this.actions @@ -152,13 +147,6 @@ export class PreprintsContributorsComponent implements OnInit { }); } - private addContributorsFromParentProjectToComponents(): void { - this.actions - .bulkAddContributorsFromParentProject(this.preprintId(), ResourceType.Preprint) - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe(() => this.toastService.showSuccess('project.contributors.toastMessages.multipleAddSuccessMessage')); - } - openAddUnregisteredContributorDialog() { this.customDialogService .open(AddUnregisteredContributorDialogComponent, { diff --git a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts index 44d91bc67..5974ed64e 100644 --- a/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts +++ b/src/app/features/registries/components/registries-metadata-step/registries-contributors/registries-contributors.component.ts @@ -133,7 +133,6 @@ export class RegistriesContributorsComponent implements OnInit { } openAddContributorDialog() { - alert('registries'); const addedContributorIds = this.initialContributors().map((x) => x.userId); this.customDialogService From e2750cc47bfa0f394b48d1b7df53e70eb8a3a868 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 18:07:40 +0300 Subject: [PATCH 5/9] ENG-9127 get parent node project --- .../add-contributor-dialog.component.html | 2 +- .../add-contributor-dialog.component.ts | 41 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index 06b003dbf..60b5b5974 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -71,7 +71,7 @@ class="w-full" styleClass="w-full" (click)="addSourceProjectContributors()" - [label]="'add Source Project Contributors' | translate" + [label]="'Import contributors from ' | translate" data-test-add-contributor-button > diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts index 67710f414..75c954185 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts @@ -14,6 +14,7 @@ import { Component, computed, DestroyRef, + effect, inject, OnDestroy, OnInit, @@ -23,15 +24,22 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormControl, FormsModule } from '@angular/forms'; import { DEFAULT_TABLE_PARAMS } from '@osf/shared/constants'; -import { AddContributorType, AddDialogState } from '@osf/shared/enums'; +import { AddContributorType, AddDialogState, ResourceType } from '@osf/shared/enums'; import { ComponentCheckboxItemModel, ContributorAddModel, ContributorDialogAddModel } from '@osf/shared/models'; -import { ClearUsers, ContributorsSelectors, SearchUsers } from '@osf/shared/stores'; +import { + ClearUsers, + ContributorsSelectors, + FetchSelectedSubjects, + GetResourceWithChildren, + SearchUsers, +} from '@osf/shared/stores'; import { ComponentsSelectionListComponent } from '../../components-selection-list/components-selection-list.component'; import { CustomPaginatorComponent } from '../../custom-paginator/custom-paginator.component'; import { LoadingSpinnerComponent } from '../../loading-spinner/loading-spinner.component'; import { SearchInputComponent } from '../../search-input/search-input.component'; import { AddContributorItemComponent } from '../add-contributor-item/add-contributor-item.component'; +import { GetParentProject, ProjectOverviewSelectors } from '@osf/features/project/overview/store'; @Component({ selector: 'osf-add-contributor-dialog', @@ -54,7 +62,13 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { readonly dialogRef = inject(DynamicDialogRef); private readonly destroyRef = inject(DestroyRef); private readonly config = inject(DynamicDialogConfig); - private readonly actions = createDispatchMap({ searchUsers: SearchUsers, clearUsers: ClearUsers }); + private readonly actions = createDispatchMap({ + searchUsers: SearchUsers, + clearUsers: ClearUsers, + getParentProject: GetParentProject, + getComponentsTree: GetResourceWithChildren, + getSubjects: FetchSelectedSubjects, + }); readonly users = select(ContributorsSelectors.getUsers); readonly isLoading = select(ContributorsSelectors.isUsersLoading); @@ -83,11 +97,32 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { readonly hasComponents = computed(() => this.components().length > 0); readonly buttonLabel = computed(() => (this.isComponentsState() ? 'common.buttons.done' : 'common.buttons.next')); + currentProject = select(ProjectOverviewSelectors.getProject); + ngOnInit(): void { this.initializeDialogData(); this.setSearchSubscription(); } + constructor() { + effect(() => { + alert(this.allowAddingContributorsFromParentProject()); + if (this.allowAddingContributorsFromParentProject()) { + const currentProject = this.currentProject(); + alert(JSON.stringify(currentProject)); + if (currentProject) { + const rootParentId = currentProject.rootParentId ?? currentProject.id; + this.actions.getComponentsTree(rootParentId, currentProject.id, ResourceType.Project); + this.actions.getSubjects(currentProject.id, ResourceType.Project); + const parentProjectId = currentProject.parentId; + if (parentProjectId) { + this.actions.getParentProject(parentProjectId); + } + } + } + }); + } + ngOnDestroy(): void { this.actions.clearUsers(); } From 71f278f6f21eff66e45c728e8f174fb6fc682cbf Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 23:06:16 +0300 Subject: [PATCH 6/9] ENG-9127 show button only for component project with parent --- .../contributors/contributors.component.ts | 6 ++++-- .../add-contributor-dialog.component.html | 10 ++++++---- .../add-contributor-dialog.component.ts | 19 ------------------- src/assets/i18n/en.json | 3 ++- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index d430add4b..7ddd5232e 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -244,7 +244,8 @@ export class ContributorsComponent implements OnInit { openAddContributorDialog() { const addedContributorIds = this.initialContributors().map((x) => x.userId); - const rootParentId = this.resourceDetails().rootParentId ?? this.resourceId(); + const resourceDetails = this.resourceDetails(); + const rootParentId = resourceDetails.rootParentId ?? this.resourceId(); this.loaderService.show(); @@ -264,7 +265,8 @@ export class ContributorsComponent implements OnInit { addedContributorIds, components, resourceName: this.resourceDetails().title, - allowAddingContributorsFromParentProject: this.resourceType() === ResourceType.Project, + allowAddingContributorsFromParentProject: + this.resourceType() === ResourceType.Project && !!resourceDetails.rootParentId, }, }) .onClose.pipe( diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index 60b5b5974..02ecae037 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -66,12 +66,14 @@ } @if (allowAddingContributorsFromParentProject() && this.isSearchState()) { -
+
diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts index 75c954185..215f22ea3 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts @@ -104,25 +104,6 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { this.setSearchSubscription(); } - constructor() { - effect(() => { - alert(this.allowAddingContributorsFromParentProject()); - if (this.allowAddingContributorsFromParentProject()) { - const currentProject = this.currentProject(); - alert(JSON.stringify(currentProject)); - if (currentProject) { - const rootParentId = currentProject.rootParentId ?? currentProject.id; - this.actions.getComponentsTree(rootParentId, currentProject.id, ResourceType.Project); - this.actions.getSubjects(currentProject.id, ResourceType.Project); - const parentProjectId = currentProject.parentId; - if (parentProjectId) { - this.actions.getParentProject(parentProjectId); - } - } - } - }); - } - ngOnDestroy(): void { this.actions.clearUsers(); } diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index e29e85ef0..90b45540d 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -596,7 +596,8 @@ "bibliographicContributor": "Bibliographic Contributor", "addUnregisteredContributor": "Add Unregistered Contributor", "addRegisteredContributor": "Add Registered Contributor", - "unregisteredContributorNotification": "We will notify the user that they have been added to your project" + "unregisteredContributorNotification": "We will notify the user that they have been added to your project", + "addingContributorsFromParentProject": "Import contributors from {{projectName}}" }, "removeDialog": { "title": "Remove contributor", From 2c6f385d74d7dc0b14a501710a45bfd7705bb688 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 23:34:33 +0300 Subject: [PATCH 7/9] check if there was parent project previuosly --- .../features/contributors/contributors.component.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/features/contributors/contributors.component.ts b/src/app/features/contributors/contributors.component.ts index 7ddd5232e..7fef58287 100644 --- a/src/app/features/contributors/contributors.component.ts +++ b/src/app/features/contributors/contributors.component.ts @@ -245,17 +245,18 @@ export class ContributorsComponent implements OnInit { openAddContributorDialog() { const addedContributorIds = this.initialContributors().map((x) => x.userId); const resourceDetails = this.resourceDetails(); - const rootParentId = resourceDetails.rootParentId ?? this.resourceId(); + const resourceId = this.resourceId(); + const rootParentId = resourceDetails.rootParentId ?? resourceId; this.loaderService.show(); this.actions - .getResourceWithChildren(rootParentId, this.resourceId(), this.resourceType()) + .getResourceWithChildren(rootParentId, resourceId, this.resourceType()) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(() => { this.loaderService.hide(); - const components = this.mapNodesToComponentCheckboxItems(this.resourceChildren(), this.resourceId()); + const components = this.mapNodesToComponentCheckboxItems(this.resourceChildren(), resourceId); this.customDialogService .open(AddContributorDialogComponent, { @@ -264,9 +265,11 @@ export class ContributorsComponent implements OnInit { data: { addedContributorIds, components, - resourceName: this.resourceDetails().title, + resourceName: resourceDetails.title, allowAddingContributorsFromParentProject: - this.resourceType() === ResourceType.Project && !!resourceDetails.rootParentId, + this.resourceType() === ResourceType.Project && + resourceDetails.rootParentId && + resourceDetails.rootParentId !== resourceId, }, }) .onClose.pipe( From 9d731dcd42088778c53323f45262766abea56f21 Mon Sep 17 00:00:00 2001 From: mkovalua Date: Fri, 17 Oct 2025 23:54:09 +0300 Subject: [PATCH 8/9] fix CR --- .../add-contributor-dialog.component.html | 1 - .../add-contributor-dialog.component.ts | 14 +------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index 02ecae037..e47b4f8ab 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -74,7 +74,6 @@ 'project.contributors.addDialog.addingContributorsFromParentProject' | translate: { projectName: resourceName() } " - data-test-add-contributor-button >
diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts index 215f22ea3..d299cc01b 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.ts @@ -26,20 +26,13 @@ import { FormControl, FormsModule } from '@angular/forms'; import { DEFAULT_TABLE_PARAMS } from '@osf/shared/constants'; import { AddContributorType, AddDialogState, ResourceType } from '@osf/shared/enums'; import { ComponentCheckboxItemModel, ContributorAddModel, ContributorDialogAddModel } from '@osf/shared/models'; -import { - ClearUsers, - ContributorsSelectors, - FetchSelectedSubjects, - GetResourceWithChildren, - SearchUsers, -} from '@osf/shared/stores'; +import { ClearUsers, ContributorsSelectors, SearchUsers } from '@osf/shared/stores'; import { ComponentsSelectionListComponent } from '../../components-selection-list/components-selection-list.component'; import { CustomPaginatorComponent } from '../../custom-paginator/custom-paginator.component'; import { LoadingSpinnerComponent } from '../../loading-spinner/loading-spinner.component'; import { SearchInputComponent } from '../../search-input/search-input.component'; import { AddContributorItemComponent } from '../add-contributor-item/add-contributor-item.component'; -import { GetParentProject, ProjectOverviewSelectors } from '@osf/features/project/overview/store'; @Component({ selector: 'osf-add-contributor-dialog', @@ -65,9 +58,6 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { private readonly actions = createDispatchMap({ searchUsers: SearchUsers, clearUsers: ClearUsers, - getParentProject: GetParentProject, - getComponentsTree: GetResourceWithChildren, - getSubjects: FetchSelectedSubjects, }); readonly users = select(ContributorsSelectors.getUsers); @@ -97,8 +87,6 @@ export class AddContributorDialogComponent implements OnInit, OnDestroy { readonly hasComponents = computed(() => this.components().length > 0); readonly buttonLabel = computed(() => (this.isComponentsState() ? 'common.buttons.done' : 'common.buttons.next')); - currentProject = select(ProjectOverviewSelectors.getProject); - ngOnInit(): void { this.initializeDialogData(); this.setSearchSubscription(); From e4f10ac0769782c7f6c3fa9eacb4cf0b837486fb Mon Sep 17 00:00:00 2001 From: mkovalua Date: Mon, 20 Oct 2025 12:00:40 +0300 Subject: [PATCH 9/9] add full width button --- .../add-contributor-dialog.component.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html index e47b4f8ab..bd299f5ab 100644 --- a/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html +++ b/src/app/shared/components/contributors/add-contributor-dialog/add-contributor-dialog.component.html @@ -68,6 +68,8 @@ @if (allowAddingContributorsFromParentProject() && this.isSearchState()) {