Skip to content

Commit 580cdbf

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/sign-up
2 parents 2b2b425 + b5cdae0 commit 580cdbf

File tree

93 files changed

+1175
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1175
-227
lines changed

src/app/core/components/nav-menu/nav-menu.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
</div>
5151
}
5252
}
53-
5453
@if (item.id === 'registry-details' && isRegistryRoute()) {
55-
<p-panelMenu [model]="registrationMenuItems" [multiple]="false" class="border-none">
54+
<p-panelMenu [model]="registrationMenuItems()" [multiple]="false" class="border-none">
5655
<ng-template #item let-item>
5756
<a
58-
[routerLink]="item.routerLink ? ['/registries', currentResourceId(), item.routerLink] : null"
57+
[routerLink]="item.routerLink"
5958
[routerLinkActive]="item.routerLink ? 'active' : ''"
59+
[queryParams]="item.queryParams"
6060
[routerLinkActiveOptions]="{ exact: true }"
6161
class="nav-link flex align-items-center"
6262
(click)="goToLink(item)"

src/app/core/components/nav-menu/nav-menu.component.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import { Component, computed, inject, output } from '@angular/core';
1111
import { toSignal } from '@angular/core/rxjs-interop';
1212
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive } from '@angular/router';
1313

14-
import { PROJECT_MENU_ITEMS, REGISTRATION_MENU_ITEMS } from '@core/constants';
14+
import { MODERATION_MENU_ITEM, PROJECT_MENU_ITEMS, REGISTRATION_MENU_ITEMS } from '@core/constants';
1515
import { NavigationService } from '@core/services';
16+
import { ProviderSelectors } from '@osf/core/store/provider';
17+
import { UserSelectors } from '@osf/core/store/user';
1618
import { AuthSelectors } from '@osf/features/auth/store';
1719
import { IconComponent } from '@osf/shared/components';
1820

@@ -32,7 +34,30 @@ export class NavMenuComponent {
3234
private readonly isAuthenticated = select(AuthSelectors.isAuthenticated);
3335

3436
protected readonly myProjectMenuItems = PROJECT_MENU_ITEMS;
35-
protected readonly registrationMenuItems = REGISTRATION_MENU_ITEMS;
37+
protected readonly registrationMenuItems = computed(() => {
38+
const menu = [...REGISTRATION_MENU_ITEMS];
39+
if (this.isUserModerator()) {
40+
const menuItems = menu[0].items ?? [];
41+
if (!menuItems.some((item) => item.label === MODERATION_MENU_ITEM.label)) {
42+
menuItems.push(MODERATION_MENU_ITEM);
43+
}
44+
}
45+
const withRouterLinks = menu.map((section) => ({
46+
...section,
47+
items: section.items?.map((item) => {
48+
const isModerationPage = item.state && item.state['isModeration'];
49+
const routeId = isModerationPage ? this.provider()?.id : this.currentResourceId();
50+
return {
51+
...item,
52+
routerLink: item.routerLink ? ['/registries', routeId, item.routerLink] : null,
53+
queryParams: isModerationPage ? { resourceId: this.currentResourceId() } : {},
54+
};
55+
}),
56+
}));
57+
return withRouterLinks;
58+
});
59+
protected readonly isUserModerator = select(UserSelectors.isCurrentUserModerator);
60+
protected readonly provider = select(ProviderSelectors.getCurrentProvider);
3661

3762
protected readonly mainMenuItems = computed(() => {
3863
const isAuthenticated = this.isAuthenticated();
@@ -69,14 +94,12 @@ export class NavMenuComponent {
6994

7095
private getRouteInfo() {
7196
const urlSegments = this.router.url.split('/').filter((segment) => segment);
72-
73-
const resourceId = this.route.firstChild?.snapshot.params['id'] || null;
97+
const resourceFromQueryParams = this.route.snapshot.queryParams['resourceId'];
98+
const resourceId = this.route.firstChild?.snapshot.params['id'] || resourceFromQueryParams;
7499
const section = this.route.firstChild?.firstChild?.snapshot.url[0]?.path || 'overview';
75-
76100
const isCollectionsWithId = urlSegments[0] === 'collections' && urlSegments[1] && urlSegments[1] !== '';
77101
const isRegistryRoute = urlSegments[0] === 'registries' && !!urlSegments[2];
78102
const isRegistryRouteDetails = urlSegments[0] === 'registries' && urlSegments[2] === 'overview';
79-
80103
return {
81104
resourceId,
82105
section,

src/app/core/constants/nav-items.constant.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,11 @@ export const REGISTRATION_MENU_ITEMS: MenuItem[] = [
284284
],
285285
},
286286
];
287+
288+
export const MODERATION_MENU_ITEM: MenuItem = {
289+
label: 'navigation.moderation',
290+
routerLink: 'moderation',
291+
state: {
292+
isModeration: true,
293+
},
294+
};

src/app/core/constants/ngxs-states.constant.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { ProviderState } from '@core/store/provider';
12
import { UserState } from '@core/store/user';
2-
import { AuthState } from '@osf/features/auth/store';
33
import { MeetingsState } from '@osf/features/meetings/store';
44
import { ProjectMetadataState } from '@osf/features/project/metadata/store';
55
import { ProjectOverviewState } from '@osf/features/project/overview/store';
@@ -13,9 +13,9 @@ import { MyResourcesState } from '@shared/stores/my-resources';
1313
import { RegionsState } from '@shared/stores/regions';
1414

1515
export const STATES = [
16-
AuthState,
1716
AddonsState,
1817
UserState,
18+
ProviderState,
1919
MyResourcesState,
2020
InstitutionsState,
2121
DeveloperAppsState,

src/app/core/interceptors/auth.interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const authInterceptor: HttpInterceptorFn = (
1111
): Observable<HttpEvent<unknown>> => {
1212
const cookieService = inject(CookieService);
1313
// TODO: remove this after the migration to the new auth approach is complete
14-
const authToken = 'UlO9O9GNKgVzJD7pUeY53jiQTKJ4U2znXVWNvh0KZQruoENuILx0IIYf9LoDz7Duq72EIm';
14+
const authToken = '2rjFZwmdDG4rtKj7hGkEMO6XyHBM2lN7XBbsA1e8OqcFhOWu6Z7fQZiheu9RXtzSeVrgOt';
1515
// UlO9O9GNKgVzJD7pUeY53jiQTKJ4U2znXVWNvh0KZQruoENuILx0IIYf9LoDz7Duq72EIm kyrylo
1616
// 2rjFZwmdDG4rtKj7hGkEMO6XyHBM2lN7XBbsA1e8OqcFhOWu6Z7fQZiheu9RXtzSeVrgOt roman nastyuk
1717
// yZ485nN6MfhqvGrfU4Xk5BEnq0T6LM50nQ6H9VrYaMTaZUQNTuxnIwlp0Wpz879RCsK9GQ NM stage3

src/app/core/models/user.models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface User {
1616
iri?: string;
1717
defaultRegionId: string;
1818
allowIndexing: boolean | undefined;
19+
isModerator?: boolean;
1920
}
2021

2122
export interface UserSettings {

src/app/core/store/provider/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './provider.actions';
2+
export * from './provider.model';
3+
export * from './provider.selectors';
4+
export * from './provider.state';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ProviderModel } from '@osf/shared/models';
2+
3+
export class SetCurrentProvider {
4+
static readonly type = '[Provider] Set Current Provider';
5+
constructor(public provider: ProviderModel) {}
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ProviderModel } from '@osf/shared/models';
2+
3+
export interface ProviderStateModel {
4+
currentProvider: ProviderModel | null;
5+
}
6+
7+
export const PROVIDER_STATE_INITIAL: ProviderStateModel = {
8+
currentProvider: null,
9+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Selector } from '@ngxs/store';
2+
3+
import { ProviderModel } from '@osf/shared/models';
4+
5+
import { ProviderStateModel } from './provider.model';
6+
import { ProviderState } from './provider.state';
7+
8+
export class ProviderSelectors {
9+
@Selector([ProviderState])
10+
static getCurrentProvider(state: ProviderStateModel): ProviderModel | null {
11+
return state.currentProvider;
12+
}
13+
}

0 commit comments

Comments
 (0)