Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"@angular/compiler-cli": "^19.2.0",
"@commitlint/cli": "^19.7.1",
"@commitlint/config-conventional": "^19.7.1",
"@types/jasmine": "~5.1.0",
"@types/jest": "^29.5.14",
"@types/markdown-it": "^14.1.2",
"angular-eslint": "19.1.0",
Expand All @@ -74,7 +73,6 @@
"eslint-plugin-unused-imports": "^4.1.4",
"fantasticon": "^3.0.0",
"husky": "^9.1.7",
"jasmine-core": "~5.6.0",
"jest": "^29.7.0",
"jest-preset-angular": "^14.5.5",
"lint-staged": "^15.4.3",
Expand Down
101 changes: 36 additions & 65 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { provideStates } from '@ngxs/store';

import { Routes } from '@angular/router';

import { RegistryOverviewState } from '@osf/features/registry/store/registry-overview';

import { MyProfileResourceFiltersOptionsState } from './features/my-profile/components/filters/store';
import { MyProfileResourceFiltersState } from './features/my-profile/components/my-profile-resource-filters/store';
import { MyProfileState } from './features/my-profile/store';
Expand All @@ -22,78 +20,52 @@ export const routes: Routes = [
redirectTo: 'home',
},
{
path: 'sign-up',
loadComponent: () =>
import('./features/auth/pages/sign-up/sign-up.component').then((mod) => mod.SignUpComponent),
data: { skipBreadcrumbs: true },
},
{
path: 'forgot-password',
loadComponent: () =>
import('./features/auth/pages/forgot-password/forgot-password.component').then(
(mod) => mod.ForgotPasswordComponent
),
path: 'home',
loadComponent: () => import('./features/home/home.component').then((mod) => mod.HomeComponent),
data: { skipBreadcrumbs: true },
},
{
path: 'reset-password',
path: 'home-logged-out',
loadComponent: () =>
import('./features/auth/pages/reset-password/reset-password.component').then(
(mod) => mod.ResetPasswordComponent
import('@osf/features/home/pages/home-logged-out/home-logged-out.component').then(
(mod) => mod.HomeLoggedOutComponent
),
data: { skipBreadcrumbs: true },
},
{
path: 'home',
path: 'confirm/:userId/:token',
loadComponent: () => import('./features/home/home.component').then((mod) => mod.HomeComponent),
data: { skipBreadcrumbs: true },
},
{
path: 'home-logged-out',
path: 'sign-up',
loadComponent: () =>
import('@osf/features/home/pages/home-logged-out/home-logged-out.component').then(
(mod) => mod.HomeLoggedOutComponent
),
import('./features/auth/pages/sign-up/sign-up.component').then((mod) => mod.SignUpComponent),
data: { skipBreadcrumbs: true },
},
{
path: 'support',
loadComponent: () => import('./features/support/support.component').then((mod) => mod.SupportComponent),
},
{
path: 'terms-of-use',
path: 'forgot-password',
loadComponent: () =>
import('./features/static/terms-of-use/terms-of-use.component').then((mod) => mod.TermsOfUseComponent),
import('./features/auth/pages/forgot-password/forgot-password.component').then(
(mod) => mod.ForgotPasswordComponent
),
data: { skipBreadcrumbs: true },
},
{
path: 'privacy-policy',
path: 'reset-password',
loadComponent: () =>
import('./features/static/privacy-policy/privacy-policy.component').then((mod) => mod.PrivacyPolicyComponent),
import('./features/auth/pages/reset-password/reset-password.component').then(
(mod) => mod.ResetPasswordComponent
),
data: { skipBreadcrumbs: true },
},
{
path: 'collections',
loadChildren: () => import('./features/collections/collections.routes').then((mod) => mod.collectionsRoutes),
},
{
path: 'meetings',
loadComponent: () => import('./features/meetings/meetings.component').then((mod) => mod.MeetingsComponent),
children: [
{
path: '',
pathMatch: 'full',
loadComponent: () =>
import('@osf/features/meetings/pages/meetings-landing/meetings-landing.component').then(
(mod) => mod.MeetingsLandingComponent
),
},
{
path: ':id',
loadComponent: () =>
import('@osf/features/meetings/pages/meeting-details/meeting-details.component').then(
(mod) => mod.MeetingDetailsComponent
),
},
],
loadChildren: () => import('./features/meetings/meetings.routes').then((mod) => mod.meetingsRoutes),
},
{
path: 'my-projects',
Expand All @@ -104,11 +76,6 @@ export const routes: Routes = [
path: 'my-projects/:id',
loadChildren: () => import('./features/project/project.routes').then((mod) => mod.projectRoutes),
},
{
path: 'registries',
loadChildren: () => import('./features/registries/registries.routes').then((mod) => mod.registriesRoutes),
},

{
path: 'settings',
loadChildren: () => import('./features/settings/settings.routes').then((mod) => mod.settingsRoutes),
Expand All @@ -134,9 +101,22 @@ export const routes: Routes = [
loadChildren: () => import('./features/institutions/institutions.routes').then((r) => r.routes),
},
{
path: 'confirm/:userId/:token',
loadComponent: () => import('./features/home/home.component').then((mod) => mod.HomeComponent),
data: { skipBreadcrumbs: true },
path: 'registries',
loadChildren: () => import('./features/registries/registries.routes').then((mod) => mod.registriesRoutes),
},
{
path: 'registries/:id',
loadChildren: () => import('./features/registry/registry.routes').then((mod) => mod.registryRoutes),
},
{
path: 'terms-of-use',
loadComponent: () =>
import('./features/static/terms-of-use/terms-of-use.component').then((mod) => mod.TermsOfUseComponent),
},
{
path: 'privacy-policy',
loadComponent: () =>
import('./features/static/privacy-policy/privacy-policy.component').then((mod) => mod.PrivacyPolicyComponent),
},
{
path: 'forbidden',
Expand All @@ -145,20 +125,11 @@ export const routes: Routes = [
data: { skipBreadcrumbs: true },
},
{
path: 'request-access/:projectId',
path: 'request-access/:id',
loadComponent: () =>
import('./core/components/request-access/request-access.component').then((mod) => mod.RequestAccessComponent),
data: { skipBreadcrumbs: true },
},
{
path: 'registries',
loadChildren: () => import('./features/registries/registries.routes').then((mod) => mod.registriesRoutes),
},
{
path: 'registries/my-registrations/:registrationId',
loadChildren: () => import('./features/registry/registry.routes').then((mod) => mod.registryRoutes),
providers: [provideStates([RegistryOverviewState])],
},
{
path: '**',
loadComponent: () =>
Expand Down
14 changes: 7 additions & 7 deletions src/app/core/components/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<nav class="nav-menu">
<p-panelMenu [model]="mainMenuItems()" [multiple]="false">
<p-panelMenu [model]="menuItems" [multiple]="false">
<ng-template #item let-item>
@if (item.label !== 'navigation.registriesSubRoutes.registryDetails') {
<a
[routerLink]="item.routerLink"
routerLinkActive="active"
[routerLinkActiveOptions]="{
exact: item.label !== 'navigation.myProjects' ? item.useExactMatch : true,
}"
[routerLinkActiveOptions]="item.routerLinkActiveOptions"
class="nav-link flex align-items-center"
[class.mt-5]="item.label === 'navigation.settings' || item.label === 'navigation.myProjects'"
(click)="goToLink(item)"
>
@if (item.icon) {
<osf-icon [iconClass]="`nav-icon ${item.icon}`"></osf-icon>
}

<span>{{ item.label | translate }}</span>

@if (item.items) {
<osf-icon
class="ml-auto pt-1"
Expand All @@ -24,12 +24,12 @@
}
</a>

@if (item.label === 'navigation.myProjects' && isProjectRoute()) {
@if (item.label === 'navigation.myProjects' && !isRegistryRoute() && isProjectRoute()) {
<div class="ml-4">
<p-panelMenu [model]="myProjectMenuItems" [multiple]="false">
<ng-template #item let-item>
<a
[routerLink]="item.routerLink ? ['/my-projects', currentProjectId(), item.routerLink] : null"
[routerLink]="item.routerLink ? ['/my-projects', currentResourceId(), item.routerLink] : null"
[routerLinkActive]="item.routerLink ? 'active' : ''"
[routerLinkActiveOptions]="{ exact: true }"
class="nav-link flex align-items-center"
Expand All @@ -56,7 +56,7 @@
<p-panelMenu [model]="registrationMenuItems" [multiple]="false" class="border-none">
<ng-template #item let-item>
<a
[routerLink]="item.routerLink ? ['/my-projects', currentProjectId(), item.routerLink] : null"
[routerLink]="item.routerLink ? ['/registries', currentResourceId(), item.routerLink] : null"
[routerLinkActive]="item.routerLink ? 'active' : ''"
[routerLinkActiveOptions]="{ exact: true }"
class="nav-link flex align-items-center"
Expand Down
44 changes: 9 additions & 35 deletions src/app/core/components/nav-menu/nav-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { Component, computed, inject, output } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive } from '@angular/router';

import { NAV_ITEMS, PROJECT_MENU_ITEMS, REGISTRATION_MENU_ITEMS } from '@core/constants';
import { MENU_ITEMS, PROJECT_MENU_ITEMS, REGISTRATION_MENU_ITEMS } from '@core/constants';
import { IconComponent } from '@osf/shared/components';
import { NavItem } from '@osf/shared/models';

@Component({
selector: 'osf-nav-menu',
Expand All @@ -22,7 +21,8 @@ import { NavItem } from '@osf/shared/models';
export class NavMenuComponent {
private readonly router = inject(Router);
private readonly route = inject(ActivatedRoute);
protected readonly navItems = NAV_ITEMS;

protected readonly menuItems = MENU_ITEMS;
protected readonly myProjectMenuItems = PROJECT_MENU_ITEMS;
protected readonly registrationMenuItems = REGISTRATION_MENU_ITEMS;

Expand All @@ -38,48 +38,22 @@ export class NavMenuComponent {
}
);

protected readonly currentProjectId = computed(() => this.currentRoute().projectId);
protected readonly isProjectRoute = computed(() => !!this.currentProjectId());
protected readonly currentResourceId = computed(() => this.currentRoute().resourceId);
protected readonly isProjectRoute = computed(() => !!this.currentResourceId());
protected readonly isCollectionsRoute = computed(() => this.currentRoute().isCollectionsWithId);
protected readonly isRegistryRoute = computed(() => this.currentRoute().isRegistryRoute);

protected readonly mainMenuItems = computed(() => {
const filteredItems = this.isCollectionsRoute()
? this.navItems
: this.navItems.filter((item) => item.path !== '/collections');

return filteredItems.map((item) => this.convertToMenuItem(item));
});

private convertToMenuItem(item: NavItem): MenuItem {
const currentUrl = this.router.url;
const isExpanded =
item.isCollapsible &&
(currentUrl.startsWith(item.path) ||
(item.items?.some((subItem) => currentUrl.startsWith(subItem.path)) ?? false));

return {
label: item.label,
icon: item.icon ? `osf-icon-${item.icon}` : '',
expanded: isExpanded,
routerLink: item.isCollapsible ? undefined : item.path,
items: item.items?.map((subItem) => this.convertToMenuItem(subItem)),
};
}

private getRouteInfo() {
const url = this.router.url;
const urlSegments = url.split('/').filter((segment) => segment);
const urlSegments = this.router.url.split('/').filter((segment) => segment);

const projectId = this.route.firstChild?.snapshot.params['id'] || null;
const resourceId = this.route.firstChild?.snapshot.params['id'] || null;
const section = this.route.firstChild?.firstChild?.snapshot.url[0]?.path || 'overview';

const isCollectionsWithId = urlSegments[0] === 'collections' && urlSegments[1] && urlSegments[1] !== '';
const isRegistryRoute =
urlSegments[0] === 'registries' && urlSegments[1] === 'my-registrations' && !!urlSegments[2];
const isRegistryRoute = urlSegments[0] === 'registries' && !!urlSegments[2];

return {
projectId,
resourceId,
section,
isCollectionsWithId,
isRegistryRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class RequestAccessComponent {
comment = model('');

private readonly route = inject(ActivatedRoute);
private readonly projectId = toSignal(this.route?.params.pipe(map((params) => params['projectId'])) ?? of(undefined));
private readonly id = toSignal(this.route?.params.pipe(map((params) => params['id'])) ?? of(undefined));

private readonly requestAccessService = inject(RequestAccessService);
private readonly router = inject(Router);
Expand All @@ -36,7 +36,7 @@ export class RequestAccessComponent {

requestAccess() {
this.loaderService.show();
this.requestAccessService.requestAccessToProject(this.projectId(), this.comment()).subscribe({
this.requestAccessService.requestAccessToProject(this.id(), this.comment()).subscribe({
next: () => {
this.loaderService.hide();
this.router.navigate(['/']);
Expand Down
Loading