Skip to content

Commit b9a0802

Browse files
authored
[ANG-1100] Fix VOL for components (#669)
* fix(components): fixed vol for components * fix(parent): fixed parent vol
1 parent d72215f commit b9a0802

File tree

8 files changed

+42
-35
lines changed

8 files changed

+42
-35
lines changed

src/app/features/project/overview/components/overview-components/overview-components.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h2 class="flex align-items-center gap-2">
2626
</a>
2727
</h2>
2828

29-
@if (isCurrentUserContributor(component)) {
29+
@if (component.currentUserIsContributor) {
3030
<div>
3131
<p-button
3232
severity="contrast"
@@ -59,7 +59,7 @@ <h2 class="flex align-items-center gap-2">
5959

6060
<osf-contributors-list
6161
[contributors]="component.contributors"
62-
[anonymous]="hasViewOnly() && anonymous()"
62+
[anonymous]="anonymous()"
6363
></osf-contributors-list>
6464
</div>
6565

src/app/features/project/overview/components/overview-components/overview-components.component.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import { Button } from 'primeng/button';
66
import { Menu } from 'primeng/menu';
77
import { Skeleton } from 'primeng/skeleton';
88

9-
import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
9+
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
1010
import { Router } from '@angular/router';
1111

12-
import { UserSelectors } from '@core/store/user';
1312
import { ContributorsListComponent, IconComponent, TruncatedTextComponent } from '@osf/shared/components';
1413
import { ResourceType, UserPermissions } from '@osf/shared/enums';
15-
import { hasViewOnlyParam } from '@osf/shared/helpers';
1614
import { CustomDialogService, LoaderService } from '@osf/shared/services';
1715
import { GetResourceWithChildren } from '@osf/shared/stores';
1816
import { ComponentOverview } from '@shared/models';
@@ -36,16 +34,13 @@ export class OverviewComponentsComponent {
3634
canEdit = input.required<boolean>();
3735
anonymous = input<boolean>(false);
3836

39-
currentUser = select(UserSelectors.getCurrentUser);
40-
currentUserId = computed(() => this.currentUser()?.id);
4137
components = select(ProjectOverviewSelectors.getComponents);
4238
isComponentsLoading = select(ProjectOverviewSelectors.getComponentsLoading);
4339
project = select(ProjectOverviewSelectors.getProject);
44-
hasViewOnly = computed(() => hasViewOnlyParam(this.router));
4540

46-
actions = createDispatchMap({
47-
getComponentsTree: GetResourceWithChildren,
48-
});
41+
actions = createDispatchMap({ getComponentsTree: GetResourceWithChildren });
42+
43+
readonly UserPermissions = UserPermissions;
4944

5045
readonly componentActionItems = (component: ComponentOverview) => {
5146
const baseItems = [
@@ -71,14 +66,6 @@ export class OverviewComponentsComponent {
7166

7267
return baseItems;
7368
};
74-
readonly UserPermissions = UserPermissions;
75-
76-
get isCurrentUserContributor() {
77-
return (component: ComponentOverview) => {
78-
const userId = this.currentUserId();
79-
return userId ? component.contributors.some((contributor) => contributor.userId === userId) : false;
80-
};
81-
}
8269

8370
handleMenuAction(action: string, componentId: string): void {
8471
switch (action) {

src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ <h2>{{ 'project.overview.parentProject' | translate }}</h2>
1111
<div class="flex justify-content-between align-items-center">
1212
<h2 class="flex align-items-center gap-2">
1313
<osf-icon [iconClass]="project().isPublic ? 'fas fa-lock-open' : 'fas fa-lock'"></osf-icon>
14-
<a class="node-title" [href]="project().id">{{ project().title }}</a>
14+
<a class="node-title cursor-pointer" (click)="navigateToParent()">{{ project().title }}</a>
1515
</h2>
16-
@if (isCurrentUserContributor()) {
16+
17+
@if (project().currentUserIsContributor) {
1718
<div>
1819
<p-button
1920
severity="contrast"
@@ -42,10 +43,16 @@ <h2 class="flex align-items-center gap-2">
4243
</div>
4344

4445
<div class="node-name flex flex-wrap gap-2">
45-
<osf-contributors-list [contributors]="project().contributors"></osf-contributors-list>
46+
<p class="font-bold">{{ 'common.labels.contributors' | translate }}:</p>
47+
48+
<osf-contributors-list
49+
[contributors]="project().contributors"
50+
[anonymous]="anonymous()"
51+
></osf-contributors-list>
4652
</div>
53+
4754
@if (project().description) {
48-
<osf-truncated-text [text]="project().description" />
55+
<osf-truncated-text [text]="('resourceCard.labels.descriptionBold' | translate) + project().description" />
4956
}
5057
</div>
5158
}

src/app/features/project/overview/components/overview-parent-project/overview-parent-project.component.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import { ProjectOverview } from '../../models';
2222
changeDetection: ChangeDetectionStrategy.OnPush,
2323
})
2424
export class OverviewParentProjectComponent {
25-
isLoading = input<boolean>(false);
2625
project = input.required<ProjectOverview>();
26+
anonymous = input<boolean>(false);
27+
isLoading = input<boolean>(false);
28+
29+
router = inject(Router);
2730

28-
private router = inject(Router);
2931
currentUser = select(UserSelectors.getCurrentUser);
3032

3133
menuItems = [
@@ -39,18 +41,21 @@ export class OverviewParentProjectComponent {
3941
},
4042
];
4143

42-
get isCurrentUserContributor() {
43-
return () => {
44-
const userId = this.currentUser()?.id;
45-
return userId ? this.project()?.contributors.some((contributor) => contributor.userId === userId) : false;
46-
};
44+
navigateToParent(): void {
45+
const url = this.router.serializeUrl(
46+
this.router.createUrlTree(['/', this.project().id], { queryParamsHandling: 'preserve' })
47+
);
48+
49+
window.open(url, '_self');
4750
}
4851

4952
handleMenuAction(action: string): void {
5053
const projectId = this.project()?.id;
54+
5155
if (!projectId) {
5256
return;
5357
}
58+
5459
switch (action) {
5560
case 'manageContributors':
5661
this.router.navigate([projectId, 'contributors']);

src/app/features/project/overview/project-overview.component.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/>
2222
</div>
2323

24-
<div class="flex flex-wrap gap-4 bg-white h-full p-3 flex-column-reverse sm:p-4 lg:flex-row">
24+
<div class="flex flex-wrap gap-4 bg-white h-full p-3 flex-column sm:p-4 lg:flex-row">
2525
@if (isCollectionsRoute()) {
2626
<p-button
2727
link
@@ -46,7 +46,7 @@
4646
<osf-view-only-link-message />
4747
}
4848

49-
<div class="flex flex-column gap-4 left-section">
49+
<div class="flex flex-column gap-4 left-section flex-order-2 lg:flex-order-1">
5050
@if (isWikiEnabled()) {
5151
<osf-overview-wiki [resourceId]="currentProject()!.id" />
5252
}
@@ -56,8 +56,13 @@
5656
[components]="components()"
5757
[areComponentsLoading]="areComponentsLoading()"
5858
/>
59+
5960
@if (parentProject()) {
60-
<osf-overview-parent-project [project]="parentProject()!" [isLoading]="isParentProjectLoading()" />
61+
<osf-overview-parent-project
62+
[project]="parentProject()!"
63+
[isLoading]="isParentProjectLoading()"
64+
[anonymous]="isAnonymous()"
65+
/>
6166
}
6267

6368
<osf-project-components [canEdit]="hasWriteAccess() && !isCollectionsRoute()" [anonymous]="isAnonymous()" />
@@ -75,7 +80,7 @@
7580
<osf-recent-activity-list [pageSize]="activityPageSize" />
7681
</div>
7782

78-
<div class="flex flex-column right-section p-4">
83+
<div class="flex flex-column right-section p-4 flex-order-1 lg:flex-order-2">
7984
<osf-resource-metadata
8085
[currentResource]="resourceOverview()"
8186
(customCitationUpdated)="onCustomCitationUpdated($event)"

src/app/features/project/overview/project-overview.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ export class ProjectOverviewComponent implements OnInit {
404404
private setupAddonsEffects(): void {
405405
effect(() => {
406406
const currentProject = this.currentProject();
407-
if (currentProject && !this.addonsResourceReference().length) {
407+
408+
if (currentProject) {
408409
this.actions.getAddonsResourceReference(currentProject.id);
409410
}
410411
});

src/app/shared/mappers/components/components.mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class ComponentsMapper {
1010
title: response.attributes.title,
1111
description: response.attributes.description,
1212
public: response.attributes.public,
13+
currentUserIsContributor: response.attributes.current_user_is_contributor,
1314
contributors: ContributorsMapper.getContributors(response?.embeds?.bibliographic_contributors?.data),
1415
currentUserPermissions: response.attributes?.current_user_permissions || [],
1516
parentId: response.relationships.parent?.data?.id,

src/app/shared/models/components/components.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface ComponentOverview {
99
description: string;
1010
public: boolean;
1111
contributors: ContributorModel[];
12+
currentUserIsContributor: boolean;
1213
currentUserPermissions: UserPermissions[];
1314
parentId?: string;
1415
}

0 commit comments

Comments
 (0)