From 5a6b6a1f2a710ae0c4fb18c3801039a3d7aa89f2 Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 15 Oct 2025 15:25:05 +0300 Subject: [PATCH 1/2] fix(components): fixed vol for components --- .../overview-components.component.html | 4 +++- .../overview-components.component.ts | 8 ++++++++ .../overview/mappers/project-overview.mapper.ts | 10 +++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.html b/src/app/features/project/overview/components/overview-components/overview-components.component.html index 9d2af3670..9db934712 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.html +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.html @@ -21,7 +21,9 @@

{{ 'project.overview.components.title' | translate }}

- {{ component.title }} + + {{ component.title }} +

@if (isCurrentUserContributor(component)) { diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.ts b/src/app/features/project/overview/components/overview-components/overview-components.component.ts index 06e02e3b8..1f433622e 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.ts +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.ts @@ -101,6 +101,14 @@ export class OverviewComponentsComponent { }); } + navigateToComponent(componentId: string): void { + const url = this.router.serializeUrl( + this.router.createUrlTree(['/', componentId], { queryParamsHandling: 'preserve' }) + ); + + window.open(url, '_self'); + } + private handleDeleteComponent(componentId: string): void { const project = this.project(); if (!project) return; diff --git a/src/app/features/project/overview/mappers/project-overview.mapper.ts b/src/app/features/project/overview/mappers/project-overview.mapper.ts index 2bd0c45c2..2869c9820 100644 --- a/src/app/features/project/overview/mappers/project-overview.mapper.ts +++ b/src/app/features/project/overview/mappers/project-overview.mapper.ts @@ -26,7 +26,7 @@ export class ProjectOverviewMapper { year: response.attributes.node_license.year, } : undefined, - license: response.embeds.license?.data?.attributes as LicenseModel, + license: response.embeds?.license?.data?.attributes as LicenseModel, doi: response.attributes.doi, publicationDoi: response.attributes.publication_doi, analyticsKey: response.attributes.analytics_key, @@ -37,16 +37,16 @@ export class ProjectOverviewMapper { wikiEnabled: response.attributes.wiki_enabled, customCitation: response.attributes.custom_citation, contributors: ContributorsMapper.getContributors(response?.embeds?.bibliographic_contributors?.data), - affiliatedInstitutions: response.embeds.affiliated_institutions + affiliatedInstitutions: response.embeds?.affiliated_institutions ? InstitutionsMapper.fromInstitutionsResponse(response.embeds.affiliated_institutions) : [], - identifiers: response.embeds.identifiers?.data.map((identifier) => ({ + identifiers: response.embeds?.identifiers?.data.map((identifier) => ({ id: identifier.id, type: identifier.type, value: identifier.attributes.value, category: identifier.attributes.category, })), - ...(response.embeds.storage?.data && + ...(response.embeds?.storage?.data && !response.embeds.storage?.errors && { storage: { id: response.embeds.storage.data.id, @@ -55,7 +55,7 @@ export class ProjectOverviewMapper { storageLimitStatus: response.embeds.storage.data.attributes.storage_limit_status, }, }), - supplements: response.embeds.preprints?.data.map((preprint) => ({ + supplements: response.embeds?.preprints?.data.map((preprint) => ({ id: preprint.id, type: preprint.type, title: preprint.attributes.title, From 8be3568c894d0dcaf9f34638fa7a176ef21132f2 Mon Sep 17 00:00:00 2001 From: nsemets Date: Thu, 16 Oct 2025 13:11:57 +0300 Subject: [PATCH 2/2] fix(parent): fixed parent vol --- .../overview-components.component.html | 4 ++-- .../overview-components.component.ts | 21 ++++--------------- .../overview-parent-project.component.html | 15 +++++++++---- .../overview-parent-project.component.ts | 19 ++++++++++------- .../overview/project-overview.component.html | 13 ++++++++---- .../overview/project-overview.component.ts | 3 ++- .../mappers/components/components.mapper.ts | 1 + .../models/components/components.models.ts | 1 + 8 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.html b/src/app/features/project/overview/components/overview-components/overview-components.component.html index 9db934712..14fde2e88 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.html +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.html @@ -26,7 +26,7 @@

- @if (isCurrentUserContributor(component)) { + @if (component.currentUserIsContributor) {
diff --git a/src/app/features/project/overview/components/overview-components/overview-components.component.ts b/src/app/features/project/overview/components/overview-components/overview-components.component.ts index 1f433622e..1bd7164c0 100644 --- a/src/app/features/project/overview/components/overview-components/overview-components.component.ts +++ b/src/app/features/project/overview/components/overview-components/overview-components.component.ts @@ -6,13 +6,11 @@ import { Button } from 'primeng/button'; import { Menu } from 'primeng/menu'; import { Skeleton } from 'primeng/skeleton'; -import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core'; import { Router } from '@angular/router'; -import { UserSelectors } from '@core/store/user'; import { ContributorsListComponent, IconComponent, TruncatedTextComponent } from '@osf/shared/components'; import { ResourceType, UserPermissions } from '@osf/shared/enums'; -import { hasViewOnlyParam } from '@osf/shared/helpers'; import { CustomDialogService, LoaderService } from '@osf/shared/services'; import { GetResourceWithChildren } from '@osf/shared/stores'; import { ComponentOverview } from '@shared/models'; @@ -36,16 +34,13 @@ export class OverviewComponentsComponent { canEdit = input.required(); anonymous = input(false); - currentUser = select(UserSelectors.getCurrentUser); - currentUserId = computed(() => this.currentUser()?.id); components = select(ProjectOverviewSelectors.getComponents); isComponentsLoading = select(ProjectOverviewSelectors.getComponentsLoading); project = select(ProjectOverviewSelectors.getProject); - hasViewOnly = computed(() => hasViewOnlyParam(this.router)); - actions = createDispatchMap({ - getComponentsTree: GetResourceWithChildren, - }); + actions = createDispatchMap({ getComponentsTree: GetResourceWithChildren }); + + readonly UserPermissions = UserPermissions; readonly componentActionItems = (component: ComponentOverview) => { const baseItems = [ @@ -71,14 +66,6 @@ export class OverviewComponentsComponent { return baseItems; }; - readonly UserPermissions = UserPermissions; - - get isCurrentUserContributor() { - return (component: ComponentOverview) => { - const userId = this.currentUserId(); - return userId ? component.contributors.some((contributor) => contributor.userId === userId) : false; - }; - } handleMenuAction(action: string, componentId: string): void { switch (action) { diff --git a/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.html b/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.html index 46a5d262b..ac7c66a10 100644 --- a/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.html +++ b/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.html @@ -11,9 +11,10 @@

{{ 'project.overview.parentProject' | translate }}

- {{ project().title }} + {{ project().title }}

- @if (isCurrentUserContributor()) { + + @if (project().currentUserIsContributor) {
- +

{{ 'common.labels.contributors' | translate }}:

+ +
+ @if (project().description) { - + }
} diff --git a/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.ts b/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.ts index d24232ed1..38bc8177a 100644 --- a/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.ts +++ b/src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.ts @@ -22,10 +22,12 @@ import { ProjectOverview } from '../../models'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class OverviewParentProjectComponent { - isLoading = input(false); project = input.required(); + anonymous = input(false); + isLoading = input(false); + + router = inject(Router); - private router = inject(Router); currentUser = select(UserSelectors.getCurrentUser); menuItems = [ @@ -39,18 +41,21 @@ export class OverviewParentProjectComponent { }, ]; - get isCurrentUserContributor() { - return () => { - const userId = this.currentUser()?.id; - return userId ? this.project()?.contributors.some((contributor) => contributor.userId === userId) : false; - }; + navigateToParent(): void { + const url = this.router.serializeUrl( + this.router.createUrlTree(['/', this.project().id], { queryParamsHandling: 'preserve' }) + ); + + window.open(url, '_self'); } handleMenuAction(action: string): void { const projectId = this.project()?.id; + if (!projectId) { return; } + switch (action) { case 'manageContributors': this.router.navigate([projectId, 'contributors']); diff --git a/src/app/features/project/overview/project-overview.component.html b/src/app/features/project/overview/project-overview.component.html index 373a7dbf2..a31557c6b 100644 --- a/src/app/features/project/overview/project-overview.component.html +++ b/src/app/features/project/overview/project-overview.component.html @@ -21,7 +21,7 @@ />
-
+
@if (isCollectionsRoute()) { } -
+
@if (isWikiEnabled()) { } @@ -56,8 +56,13 @@ [components]="components()" [areComponentsLoading]="areComponentsLoading()" /> + @if (parentProject()) { - + } @@ -75,7 +80,7 @@
-
+
{ const currentProject = this.currentProject(); - if (currentProject && !this.addonsResourceReference().length) { + + if (currentProject) { this.actions.getAddonsResourceReference(currentProject.id); } }); diff --git a/src/app/shared/mappers/components/components.mapper.ts b/src/app/shared/mappers/components/components.mapper.ts index 89b8a9cea..65bc72edc 100644 --- a/src/app/shared/mappers/components/components.mapper.ts +++ b/src/app/shared/mappers/components/components.mapper.ts @@ -10,6 +10,7 @@ export class ComponentsMapper { title: response.attributes.title, description: response.attributes.description, public: response.attributes.public, + currentUserIsContributor: response.attributes.current_user_is_contributor, contributors: ContributorsMapper.getContributors(response?.embeds?.bibliographic_contributors?.data), currentUserPermissions: response.attributes?.current_user_permissions || [], parentId: response.relationships.parent?.data?.id, diff --git a/src/app/shared/models/components/components.models.ts b/src/app/shared/models/components/components.models.ts index 9b3beba22..64869b1ac 100644 --- a/src/app/shared/models/components/components.models.ts +++ b/src/app/shared/models/components/components.models.ts @@ -9,6 +9,7 @@ export interface ComponentOverview { description: string; public: boolean; contributors: ContributorModel[]; + currentUserIsContributor: boolean; currentUserPermissions: UserPermissions[]; parentId?: string; }