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
7 changes: 7 additions & 0 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ 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 Down Expand Up @@ -153,6 +155,11 @@ export const routes: Routes = [
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
117 changes: 72 additions & 45 deletions src/app/core/components/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,53 +1,80 @@
<nav class="nav-menu">
<p-panelMenu [model]="mainMenuItems()" [multiple]="false">
<ng-template #item let-item>
<a
[routerLink]="item.routerLink"
routerLinkActive="active"
[routerLinkActiveOptions]="{
exact: item.label !== 'navigation.myProjects' ? item.useExactMatch : true,
}"
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"
[iconClass]="item.expanded ? `fas fa-chevron-down fa-sm` : `fas fa-chevron-right fa-sm`"
></osf-icon>
@if (item.label !== 'navigation.registriesSubRoutes.registryDetails') {
<a
[routerLink]="item.routerLink"
routerLinkActive="active"
[routerLinkActiveOptions]="{
exact: item.label !== 'navigation.myProjects' ? item.useExactMatch : true,
}"
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"
[iconClass]="item.expanded ? `fas fa-chevron-down fa-sm` : `fas fa-chevron-right fa-sm`"
></osf-icon>
}
</a>

@if (item.label === 'navigation.myProjects' && 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"
[routerLinkActive]="item.routerLink ? 'active' : ''"
[routerLinkActiveOptions]="{ exact: true }"
class="nav-link flex align-items-center"
(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"
[iconClass]="item.expanded ? `fas fa-chevron-down fa-sm` : `fas fa-chevron-right fa-sm`"
></osf-icon>
}
</a>
</ng-template>
</p-panelMenu>
</div>
}
</a>
}

@if (item.label === 'navigation.myProjects' && 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"
[routerLinkActive]="item.routerLink ? 'active' : ''"
[routerLinkActiveOptions]="{ exact: true }"
class="nav-link flex align-items-center"
(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"
[iconClass]="item.expanded ? `fas fa-chevron-down fa-sm` : `fas fa-chevron-right fa-sm`"
></osf-icon>
}
</a>
</ng-template>
</p-panelMenu>
</div>
@if (item.label === 'navigation.registriesSubRoutes.registryDetails' && isRegistryRoute()) {
<p-panelMenu [model]="registrationMenuItems" [multiple]="false" class="border-none">
<ng-template #item let-item>
<a
[routerLink]="item.routerLink ? ['/my-projects', currentProjectId(), item.routerLink] : null"
[routerLinkActive]="item.routerLink ? 'active' : ''"
[routerLinkActiveOptions]="{ exact: true }"
class="nav-link flex align-items-center"
(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"
[iconClass]="item.expanded ? `fas fa-chevron-down fa-sm` : `fas fa-chevron-right fa-sm`"
></osf-icon>
}
</a>
</ng-template>
</p-panelMenu>
}
</ng-template>
</p-panelMenu>
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/components/nav-menu/nav-menu.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
border-radius: mix.rem(8px);
font-weight: 700;
}

::ng-deep li[aria-label="navigation.registriesSubRoutes.registryDetails"] {
border-left-color: transparent !important;
}
}
7 changes: 6 additions & 1 deletion src/app/core/components/nav-menu/nav-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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 } from '@core/constants';
import { NAV_ITEMS, PROJECT_MENU_ITEMS, REGISTRATION_MENU_ITEMS } from '@core/constants';
import { IconComponent } from '@osf/shared/components';
import { NavItem } from '@osf/shared/models';

Expand All @@ -24,6 +24,7 @@ export class NavMenuComponent {
private readonly route = inject(ActivatedRoute);
protected readonly navItems = NAV_ITEMS;
protected readonly myProjectMenuItems = PROJECT_MENU_ITEMS;
protected readonly registrationMenuItems = REGISTRATION_MENU_ITEMS;

closeMenu = output<void>();

Expand All @@ -40,6 +41,7 @@ export class NavMenuComponent {
protected readonly currentProjectId = computed(() => this.currentRoute().projectId);
protected readonly isProjectRoute = computed(() => !!this.currentProjectId());
protected readonly isCollectionsRoute = computed(() => this.currentRoute().isCollectionsWithId);
protected readonly isRegistryRoute = computed(() => this.currentRoute().isRegistryRoute);

protected readonly mainMenuItems = computed(() => {
const filteredItems = this.isCollectionsRoute()
Expand Down Expand Up @@ -73,11 +75,14 @@ export class NavMenuComponent {
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];

return {
projectId,
section,
isCollectionsWithId,
isRegistryRoute,
};
}

Expand Down
28 changes: 28 additions & 0 deletions src/app/core/constants/nav-items.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ export const NAV_ITEMS: NavItem[] = [
label: 'navigation.registriesSubRoutes.overview',
useExactMatch: false,
},
{
path: '/my-registrations',
label: 'navigation.registriesSubRoutes.myRegistrations',
useExactMatch: false,
},
{
path: '/registry-overview',
label: 'navigation.registriesSubRoutes.registryDetails',
useExactMatch: false,
},
],
},
{
Expand Down Expand Up @@ -165,3 +175,21 @@ export const PROJECT_MENU_ITEMS: MenuItem[] = [
],
},
];

export const REGISTRATION_MENU_ITEMS: MenuItem[] = [
{
label: 'navigation.registration.details',
icon: 'osf-icon-my-projects',
expanded: true,
items: [
{ label: 'navigation.registration.overview', routerLink: 'overview' },
{ label: 'navigation.registration.metadata', routerLink: 'metadata' },
{ label: 'navigation.registration.files', routerLink: 'files' },
{ label: 'navigation.registration.resources', routerLink: 'resources' },
{ label: 'navigation.registration.wiki', routerLink: 'wiki' },
{ label: 'navigation.registration.components', routerLink: 'components' },
{ label: 'navigation.registration.links', routerLink: 'links' },
{ label: 'navigation.registration.analytics', routerLink: 'analytics' },
],
},
];
28 changes: 28 additions & 0 deletions src/app/features/collections/services/collections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,32 @@ export class CollectionsService {
})
);
}

addRegistrationToBookmarks(bookmarksId: string, registryId: string): Observable<void> {
const url = `${environment.apiUrl}/collections/${bookmarksId}/relationships/linked_registrations/`;
const payload = {
data: [
{
type: 'linked_registrations',
id: registryId,
},
],
};

return this.#jsonApiService.post<void>(url, payload);
}

removeRegistrationFromBookmarks(bookmarksId: string, registryId: string): Observable<void> {
const url = `${environment.apiUrl}/collections/${bookmarksId}/relationships/linked_registrations/`;
const payload = {
data: [
{
type: 'linked_registrations',
id: registryId,
},
],
};

return this.#jsonApiService.delete(url, payload);
}
Comment on lines +160 to +187
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why registration in collection service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we had adding and removeing projects to bookmarks collection so I've also added adding\removing registrations to the same place

}
15 changes: 9 additions & 6 deletions src/app/features/collections/store/collections.actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CollectionsFilters } from '@osf/features/collections/models';
import { ResourceType } from '@shared/enums';

export class GetCollectionProvider {
static readonly type = '[Collections] Get Collection Provider';
Expand All @@ -16,21 +17,23 @@ export class GetBookmarksCollectionId {
static readonly type = '[Collections] Get Bookmarks Collection Id';
}

export class AddProjectToBookmarks {
static readonly type = '[Collections] Add Project To Bookmarks';
export class AddResourceToBookmarks {
static readonly type = '[Collections] Add Resource To Bookmarks';

constructor(
public bookmarksId: string,
public projectId: string
public resourceId: string,
public resourceType: ResourceType
) {}
}

export class RemoveProjectFromBookmarks {
static readonly type = '[Collections] Remove Project From Bookmarks';
export class RemoveResourceFromBookmarks {
static readonly type = '[Collections] Remove Resource From Bookmarks';

constructor(
public bookmarksId: string,
public projectId: string
public resourceId: string,
public resourceType: ResourceType
) {}
}

Expand Down
Loading