Skip to content

Commit 6b6c76d

Browse files
authored
Fix/(Ang-812) - Registry components (#508)
* fix(ang-403): added wiki permissions * fix(ang-403): fixed minor bug * fix(ang-403): added permissions for the nav menu * fix(ang-812): fixed view only links registry components page * fix(ang-812): fixed overview toolbar permissions * fix(ang-812): fixed metadata tags permissions
1 parent 2ca2247 commit 6b6c76d

File tree

13 files changed

+110
-103
lines changed

13 files changed

+110
-103
lines changed

src/app/features/analytics/components/view-duplicates/view-duplicates.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<osf-sub-header
22
[title]="'project.analytics.kpi.forks' | translate"
3-
[showButton]="true"
3+
[showButton]="!hasNoPermissions()"
44
[buttonLabel]="'project.overview.actions.forkProjectLabel' | translate"
55
(buttonClick)="handleForkResource()"
66
/>

src/app/features/analytics/components/view-duplicates/view-duplicates.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { IS_SMALL } from '@osf/shared/helpers';
4242
import { ToolbarResource } from '@osf/shared/models';
4343
import { Duplicate } from '@osf/shared/models/duplicates';
4444
import { CustomDialogService } from '@osf/shared/services';
45-
import { ClearDuplicates, DuplicatesSelectors, GetAllDuplicates } from '@osf/shared/stores';
45+
import { ClearDuplicates, CurrentResourceSelectors, DuplicatesSelectors, GetAllDuplicates } from '@osf/shared/stores';
4646

4747
@Component({
4848
selector: 'osf-view-duplicates',
@@ -76,6 +76,7 @@ export class ViewDuplicatesComponent {
7676
duplicates = select(DuplicatesSelectors.getDuplicates);
7777
isDuplicatesLoading = select(DuplicatesSelectors.getDuplicatesLoading);
7878
totalDuplicates = select(DuplicatesSelectors.getDuplicatesTotalCount);
79+
hasNoPermissions = select(CurrentResourceSelectors.hasNoPermissions);
7980

8081
readonly pageSize = 10;
8182
readonly UserPermissions = UserPermissions;

src/app/features/metadata/metadata.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@
7676
[resourceType]="resourceType()"
7777
/>
7878

79-
@if (showRegistrationDoi()) {
79+
@if (isRegistrationType()) {
8080
<osf-metadata-registration-doi [identifiers]="metadata()?.identifiers!"></osf-metadata-registration-doi>
8181
}
8282

8383
<osf-metadata-tags
8484
[tags]="metadata()?.tags || []"
8585
(tagsChanged)="onTagsChanged($event)"
86-
[readonly]="!hasWriteAccess()"
86+
[readonly]="isRegistrationType() ? !hasAdminAccess() : !hasWriteAccess()"
8787
></osf-metadata-tags>
8888

8989
<osf-metadata-subjects

src/app/features/metadata/metadata.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class MetadataComponent implements OnInit {
184184
);
185185
});
186186

187-
showRegistrationDoi = computed(() => this.resourceType() === ResourceType.Registration);
187+
isRegistrationType = computed(() => this.resourceType() === ResourceType.Registration);
188188

189189
hasWriteAccess = computed(() => {
190190
const metadata = this.metadata();

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

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -37,87 +37,89 @@
3737
}
3838
}
3939

40-
<div class="flex ml-auto">
41-
<div class="flex flex-1 flex-column-reverse gap-3 justify-content-end sm:gap-3 sm:flex-row-reverse lg:flex-row">
42-
@if (resource.storage && !isCollectionsRoute()) {
43-
<p class="font-bold mr-2 ml-0 mt-2 sm:ml-2 sm:mt-0 sm:align-self-center storage">
44-
{{ +resource.storage.storageUsage | fileSize }}
45-
</p>
46-
}
47-
48-
<div class="flex gap-2 justify-content-start">
49-
@if (showViewOnlyLinks() && canEdit()) {
50-
<p-button
51-
class="flex"
52-
[pTooltip]="'project.overview.tooltips.viewOnlyLinks' | translate"
53-
tooltipPosition="bottom"
54-
[routerLink]="'../contributors'"
55-
[ariaLabel]="'project.overview.tooltips.viewOnlyLinks' | translate"
56-
>
57-
<span class="font-bold">{{ resource.viewOnlyLinksCount }}</span>
58-
<i class="fas fa-link text-2xl"></i>
59-
</p-button>
40+
@if (!hasNoPermissions()) {
41+
<div class="flex ml-auto">
42+
<div class="flex flex-1 flex-column-reverse gap-3 justify-content-end sm:gap-3 sm:flex-row-reverse lg:flex-row">
43+
@if (resource.storage && !isCollectionsRoute()) {
44+
<p class="font-bold mr-2 ml-0 mt-2 sm:ml-2 sm:mt-0 sm:align-self-center storage">
45+
{{ +resource.storage.storageUsage | fileSize }}
46+
</p>
6047
}
6148

62-
@if (resource.resourceType === ResourceType.Project && !hasViewOnly()) {
63-
<p-button
64-
class="flex"
65-
(click)="forkActionMenu.toggle($event)"
66-
[pTooltip]="'project.overview.tooltips.duplicate' | translate"
67-
tooltipPosition="bottom"
68-
[ariaLabel]="'project.overview.tooltips.duplicate' | translate"
69-
>
70-
<span class="font-bold">{{ resource.forksCount }}</span>
71-
<i class="fas fa-clone text-2xl"></i>
72-
<p-menu appendTo="body" #forkActionMenu [model]="forkActionItems" popup>
73-
<ng-template #item let-item>
74-
<a class="p-menu-item-link">
75-
{{ item.label | translate }}
76-
</a>
77-
</ng-template>
78-
</p-menu>
79-
</p-button>
80-
}
49+
<div class="flex gap-2 justify-content-start">
50+
@if (showViewOnlyLinks() && canEdit()) {
51+
<p-button
52+
class="flex"
53+
[pTooltip]="'project.overview.tooltips.viewOnlyLinks' | translate"
54+
tooltipPosition="bottom"
55+
[routerLink]="'../contributors'"
56+
[ariaLabel]="'project.overview.tooltips.viewOnlyLinks' | translate"
57+
>
58+
<span class="font-bold">{{ resource.viewOnlyLinksCount }}</span>
59+
<i class="fas fa-link text-2xl"></i>
60+
</p-button>
61+
}
8162

82-
@if (!hasViewOnly()) {
83-
<p-button
84-
[pTooltip]="'project.overview.tooltips.bookmarks' | translate"
85-
tooltipPosition="bottom"
86-
class="flex"
87-
(onClick)="toggleBookmark()"
88-
[loading]="isBookmarksLoading() || isBookmarksSubmitting()"
89-
[ariaLabel]="'project.overview.tooltips.bookmarks' | translate"
90-
>
91-
@if (!isBookmarksLoading() && !isBookmarksSubmitting()) {
92-
<i class="text-2xl" [ngClass]="isBookmarked() ? 'fas fa-bookmark' : 'far fa-bookmark'"></i>
93-
}
94-
</p-button>
95-
}
63+
@if (resource.resourceType === ResourceType.Project && !hasViewOnly()) {
64+
<p-button
65+
class="flex"
66+
(click)="forkActionMenu.toggle($event)"
67+
[pTooltip]="'project.overview.tooltips.duplicate' | translate"
68+
tooltipPosition="bottom"
69+
[ariaLabel]="'project.overview.tooltips.duplicate' | translate"
70+
>
71+
<span class="font-bold">{{ resource.forksCount }}</span>
72+
<i class="fas fa-clone text-2xl"></i>
73+
<p-menu appendTo="body" #forkActionMenu [model]="forkActionItems" popup>
74+
<ng-template #item let-item>
75+
<a class="p-menu-item-link">
76+
{{ item.label | translate }}
77+
</a>
78+
</ng-template>
79+
</p-menu>
80+
</p-button>
81+
}
9682

97-
@if (resource.isPublic && !hasViewOnly()) {
98-
<p-button
99-
class="flex"
100-
(onClick)="socialsActionMenu.toggle($event)"
101-
[pTooltip]="'project.overview.tooltips.share' | translate"
102-
tooltipPosition="bottom"
103-
[ariaLabel]="'project.overview.tooltips.share' | translate"
104-
>
105-
<span class="font-bold">{{ socialsActionItems().length }}</span>
106-
<i class="fas fa-share-nodes text-2xl"></i>
107-
<p-menu appendTo="body" #socialsActionMenu [model]="socialsActionItems()" popup>
108-
<ng-template #item let-item>
109-
<a class="p-menu-item-link" [href]="item.url" target="_blank" rel="noopener noreferrer">
110-
<div class="social-link flex align-items-center justify-content-center">
111-
<osf-icon [iconClass]="`${item.icon} fa-sm`"></osf-icon>
112-
</div>
113-
{{ item.label | translate }}
114-
</a>
115-
</ng-template>
116-
</p-menu>
117-
</p-button>
118-
}
83+
@if (!hasViewOnly()) {
84+
<p-button
85+
[pTooltip]="'project.overview.tooltips.bookmarks' | translate"
86+
tooltipPosition="bottom"
87+
class="flex"
88+
(onClick)="toggleBookmark()"
89+
[loading]="isBookmarksLoading() || isBookmarksSubmitting()"
90+
[ariaLabel]="'project.overview.tooltips.bookmarks' | translate"
91+
>
92+
@if (!isBookmarksLoading() && !isBookmarksSubmitting()) {
93+
<i class="text-2xl" [ngClass]="isBookmarked() ? 'fas fa-bookmark' : 'far fa-bookmark'"></i>
94+
}
95+
</p-button>
96+
}
97+
98+
@if (resource.isPublic && !hasViewOnly()) {
99+
<p-button
100+
class="flex"
101+
(onClick)="socialsActionMenu.toggle($event)"
102+
[pTooltip]="'project.overview.tooltips.share' | translate"
103+
tooltipPosition="bottom"
104+
[ariaLabel]="'project.overview.tooltips.share' | translate"
105+
>
106+
<span class="font-bold">{{ socialsActionItems().length }}</span>
107+
<i class="fas fa-share-nodes text-2xl"></i>
108+
<p-menu appendTo="body" #socialsActionMenu [model]="socialsActionItems()" popup>
109+
<ng-template #item let-item>
110+
<a class="p-menu-item-link" [href]="item.url" target="_blank" rel="noopener noreferrer">
111+
<div class="social-link flex align-items-center justify-content-center">
112+
<osf-icon [iconClass]="`${item.icon} fa-sm`"></osf-icon>
113+
</div>
114+
{{ item.label | translate }}
115+
</a>
116+
</ng-template>
117+
</p-menu>
118+
</p-button>
119+
}
120+
</div>
119121
</div>
120122
</div>
121-
</div>
123+
}
122124
</div>
123125
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class OverviewToolbarComponent {
7878
bookmarksCollectionId = select(BookmarksSelectors.getBookmarksCollectionId);
7979
bookmarkedProjects = select(MyResourcesSelectors.getBookmarks);
8080
duplicatedProject = select(ProjectOverviewSelectors.getDuplicatedProject);
81+
hasNoPermissions = select(ProjectOverviewSelectors.hasNoPermissions);
8182
socialsActionItems = computed(() => {
8283
const shareableContent = this.createShareableContent();
8384
return shareableContent ? this.buildSocialActionItems(shareableContent) : [];

src/app/features/project/settings/components/settings-project-affiliation/settings-project-affiliation.component.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ <h3 class="text-xl pb-4">{{ 'myProjects.settings.projectAffiliation' | translate
2626
<p>{{ affiliation.name }}</p>
2727
</div>
2828

29-
<p-button
30-
class="danger-icon-btn"
31-
icon="fas fa-trash"
32-
severity="danger"
33-
text
34-
[ariaLabel]="'common.buttons.delete' | translate"
35-
(onClick)="removeAffiliation(affiliation)"
36-
></p-button>
29+
@if (canEdit()) {
30+
<p-button
31+
class="danger-icon-btn"
32+
icon="fas fa-trash"
33+
severity="danger"
34+
text
35+
[ariaLabel]="'common.buttons.delete' | translate"
36+
(onClick)="removeAffiliation(affiliation)"
37+
></p-button>
38+
}
3739
</div>
3840
}
3941
</div>

src/app/features/project/settings/components/settings-project-affiliation/settings-project-affiliation.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Institution } from '@osf/shared/models';
1818
export class SettingsProjectAffiliationComponent {
1919
affiliations = input<Institution[]>([]);
2020
removed = output<Institution>();
21+
canEdit = input<boolean>(false);
2122

2223
removeAffiliation(affiliation: Institution) {
2324
this.removed.emit(affiliation);

src/app/features/project/settings/settings.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<osf-loading-spinner />
66
} @else {
77
<div class="flex flex-column flex-1 gap-4 w-full bg-white py-4 px-3 md:px-5 xl:px-4">
8-
@if (canWrite()) {
8+
@if (hasWriteAccess()) {
99
<osf-settings-project-form-card
1010
(submitForm)="submitForm($event)"
1111
(deleteProject)="deleteProject()"
@@ -17,7 +17,7 @@
1717
[locationText]="'myProjects.settings.storageLocationMessage' | translate"
1818
></osf-settings-storage-location-card>
1919

20-
@if (isAdmin()) {
20+
@if (hasAdminAccess()) {
2121
<osf-settings-view-only-links-card
2222
id="view-only-links"
2323
[tableData]="viewOnlyLinks()"
@@ -48,6 +48,7 @@
4848
/>
4949

5050
<osf-settings-project-affiliation
51+
[canEdit]="hasWriteAccess()"
5152
[affiliations]="projectDetails().affiliatedInstitutions"
5253
(removed)="removeAffiliation($event)"
5354
></osf-settings-project-affiliation>

src/app/features/project/settings/settings.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export class SettingsComponent implements OnInit {
9797
title = signal('');
9898

9999
userPermissions = computed(() => this.projectDetails()?.currentUserPermissions || []);
100-
isAdmin = computed(() => this.userPermissions().includes(UserPermissions.Admin));
101-
canWrite = computed(() => this.userPermissions().includes(UserPermissions.Write));
100+
hasAdminAccess = computed(() => this.userPermissions().includes(UserPermissions.Admin));
101+
hasWriteAccess = computed(() => this.userPermissions().includes(UserPermissions.Write));
102102

103103
constructor() {
104104
this.setupEffects();
@@ -255,7 +255,7 @@ export class SettingsComponent implements OnInit {
255255
effect(() => {
256256
const id = this.projectId();
257257

258-
if (id && this.isAdmin()) {
258+
if (id && this.hasAdminAccess()) {
259259
this.actions.getViewOnlyLinks(id, ResourceType.Project);
260260
}
261261
});

0 commit comments

Comments
 (0)