Skip to content

Commit 0ad5c72

Browse files
committed
fix(left-menu): updated my resources
1 parent 92e02c1 commit 0ad5c72

File tree

6 files changed

+94
-75
lines changed

6 files changed

+94
-75
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive } f
1414
import { MENU_ITEMS } from '@core/constants';
1515
import { filterMenuItems, updateMenuItems } from '@osf/core/helpers';
1616
import { RouteContext } from '@osf/core/models';
17-
import { ProviderSelectors } from '@osf/core/store/provider';
1817
import { AuthSelectors } from '@osf/features/auth/store';
1918
import { IconComponent } from '@osf/shared/components';
2019
import { WrapFnPipe } from '@osf/shared/pipes';
@@ -33,8 +32,6 @@ export class NavMenuComponent {
3332

3433
private readonly isAuthenticated = select(AuthSelectors.isAuthenticated);
3534

36-
protected readonly provider = select(ProviderSelectors.getCurrentProvider);
37-
3835
protected readonly mainMenuItems = computed(() => {
3936
const isAuthenticated = this.isAuthenticated();
4037
const filtered = filterMenuItems(MENU_ITEMS, isAuthenticated);
@@ -46,6 +43,7 @@ export class NavMenuComponent {
4643
isRegistry: this.isRegistryRoute(),
4744
isPreprint: this.isPreprintRoute(),
4845
isCollections: this.isCollectionsRoute() || false,
46+
currentUrl: this.router.url,
4947
};
5048

5149
const items = updateMenuItems(filtered, routeContext);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export const MENU_ITEMS: MenuItem[] = [
189189
routerLink: '/my-registrations',
190190
label: 'navigation.registriesSubRoutes.myRegistrations',
191191
visible: false,
192-
routerLinkActiveOptions: { exact: true },
192+
routerLinkActiveOptions: { exact: false },
193193
},
194194
{
195195
id: 'my-preprints',

src/app/core/helpers/nav-menu.helper.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export function filterMenuItems(items: MenuItem[], isAuthenticated: boolean): Me
3232

3333
export function updateMenuItems(menuItems: MenuItem[], ctx: RouteContext): MenuItem[] {
3434
return menuItems.map((item) => {
35+
if (item.id === 'my-resources') {
36+
return updateMyResourcesMenuItem(item, ctx);
37+
}
38+
3539
if (item.id === 'projects') {
3640
return updateProjectMenuItem(item, ctx);
3741
}
@@ -52,6 +56,19 @@ export function updateMenuItems(menuItems: MenuItem[], ctx: RouteContext): MenuI
5256
});
5357
}
5458

59+
function updateMyResourcesMenuItem(item: MenuItem, ctx: RouteContext): MenuItem {
60+
const currentUrl = ctx.currentUrl || '';
61+
const isMyResourcesActive =
62+
currentUrl.startsWith('/my-projects') ||
63+
currentUrl.startsWith('/my-registrations') ||
64+
currentUrl.startsWith('/my-preprints');
65+
66+
return {
67+
...item,
68+
expanded: isMyResourcesActive,
69+
};
70+
}
71+
5572
function updateProjectMenuItem(item: MenuItem, ctx: RouteContext): MenuItem {
5673
const hasProject = ctx.isProject && !!ctx.resourceId;
5774
const items = (item.items || []).map((subItem) => {

src/app/core/models/route-context.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export interface RouteContext {
55
isRegistry: boolean;
66
isPreprint: boolean;
77
isCollections: boolean;
8+
currentUrl?: string;
89
}
Lines changed: 72 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,76 @@
1-
<osf-sub-header
2-
[title]="'preprints.myPreprints.title' | translate"
3-
[icon]="'preprints'"
4-
[showButton]="true"
5-
[buttonLabel]="'preprints.addPreprint' | translate: { preprintWord: 'preprint' | titlecase }"
6-
(buttonClick)="addPreprintBtnClicked()"
7-
/>
8-
9-
<section class="flex-1 flex flex-column bg-white p-3 md:p-4">
10-
<osf-search-input
11-
class="w-full"
12-
[control]="searchControl"
13-
[placeholder]="'preprints.myPreprints.searchPlaceholder' | translate"
1+
<div class="xl:flex xl:flex-column xl:mt-6 flex-1">
2+
<osf-sub-header
3+
[title]="'preprints.myPreprints.title' | translate"
4+
[icon]="'preprints'"
5+
[showButton]="true"
6+
[buttonLabel]="'preprints.addPreprint' | translate: { preprintWord: 'preprint' | titlecase }"
7+
(buttonClick)="addPreprintBtnClicked()"
148
/>
159

16-
<p-table
17-
class="mt-4"
18-
[value]="areMyPreprintsLoading() ? skeletonData : preprints()"
19-
[rows]="tableParams().rows"
20-
[first]="tableParams().firstRowIndex"
21-
[rowsPerPageOptions]="tableParams().rowsPerPageOptions"
22-
[paginator]="true"
23-
[totalRecords]="tableParams().totalRecords"
24-
paginatorDropdownAppendTo="body"
25-
[resizableColumns]="true"
26-
[autoLayout]="true"
27-
[scrollable]="true"
28-
[sortMode]="'single'"
29-
[lazy]="true"
30-
[lazyLoadOnInit]="true"
31-
(onPage)="onPageChange($event)"
32-
(onSort)="onSort($event)"
33-
[sortField]="sortColumn()"
34-
[sortOrder]="sortOrder() === 0 ? 1 : -1"
35-
[customSort]="true"
36-
[resetPageOnSort]="false"
37-
>
38-
<ng-template #header>
39-
<tr>
40-
<th pSortableColumn="title">
41-
{{ 'preprints.myPreprints.table.titleLabel' | translate }}
42-
<p-sortIcon field="title" />
43-
</th>
44-
<th>{{ 'preprints.myPreprints.table.contributorsLabel' | translate }}</th>
45-
<th pSortableColumn="dateModified">
46-
{{ 'preprints.myPreprints.table.modifiedLabel' | translate }}
47-
<p-sortIcon field="dateModified" />
48-
</th>
49-
</tr>
50-
</ng-template>
51-
<ng-template #body let-item>
52-
@if (item?.id) {
53-
<tr class="cursor-pointer" (click)="navigateToPreprintDetails(item)">
54-
<td>{{ item.title }}</td>
55-
<td>
56-
<osf-list-info-shortener [data]="item.contributors" />
57-
</td>
58-
<td>{{ item.dateModified | date: 'MMM d, y, h:mm a' }}</td>
10+
<section class="flex-1 flex flex-column bg-white p-3 md:p-4">
11+
<osf-search-input
12+
class="w-full"
13+
[control]="searchControl"
14+
[placeholder]="'preprints.myPreprints.searchPlaceholder' | translate"
15+
/>
16+
17+
<p-table
18+
class="mt-4"
19+
[value]="areMyPreprintsLoading() ? skeletonData : preprints()"
20+
[rows]="tableParams().rows"
21+
[first]="tableParams().firstRowIndex"
22+
[rowsPerPageOptions]="tableParams().rowsPerPageOptions"
23+
[paginator]="true"
24+
[totalRecords]="tableParams().totalRecords"
25+
paginatorDropdownAppendTo="body"
26+
[resizableColumns]="true"
27+
[autoLayout]="true"
28+
[scrollable]="true"
29+
[sortMode]="'single'"
30+
[lazy]="true"
31+
[lazyLoadOnInit]="true"
32+
(onPage)="onPageChange($event)"
33+
(onSort)="onSort($event)"
34+
[sortField]="sortColumn()"
35+
[sortOrder]="sortOrder() === 0 ? 1 : -1"
36+
[customSort]="true"
37+
[resetPageOnSort]="false"
38+
>
39+
<ng-template #header>
40+
<tr>
41+
<th pSortableColumn="title">
42+
{{ 'preprints.myPreprints.table.titleLabel' | translate }}
43+
<p-sortIcon field="title" />
44+
</th>
45+
<th>{{ 'preprints.myPreprints.table.contributorsLabel' | translate }}</th>
46+
<th pSortableColumn="dateModified">
47+
{{ 'preprints.myPreprints.table.modifiedLabel' | translate }}
48+
<p-sortIcon field="dateModified" />
49+
</th>
5950
</tr>
60-
} @else {
61-
<tr class="loading-row">
62-
<td colspan="4">
63-
<p-skeleton width="100%" height="3.3rem" borderRadius="0" />
64-
</td>
51+
</ng-template>
52+
<ng-template #body let-item>
53+
@if (item?.id) {
54+
<tr class="cursor-pointer" (click)="navigateToPreprintDetails(item)">
55+
<td>{{ item.title }}</td>
56+
<td>
57+
<osf-list-info-shortener [data]="item.contributors" />
58+
</td>
59+
<td>{{ item.dateModified | date: 'MMM d, y, h:mm a' }}</td>
60+
</tr>
61+
} @else {
62+
<tr class="loading-row">
63+
<td colspan="4">
64+
<p-skeleton width="100%" height="3.3rem" borderRadius="0" />
65+
</td>
66+
</tr>
67+
}
68+
</ng-template>
69+
<ng-template pTemplate="emptymessage">
70+
<tr>
71+
<td colspan="4" class="text-center">{{ 'common.search.noResultsFound' | translate }}</td>
6572
</tr>
66-
}
67-
</ng-template>
68-
<ng-template pTemplate="emptymessage">
69-
<tr>
70-
<td colspan="4" class="text-center">{{ 'common.search.noResultsFound' | translate }}</td>
71-
</tr>
72-
</ng-template>
73-
</p-table>
74-
</section>
73+
</ng-template>
74+
</p-table>
75+
</section>
76+
</div>

src/app/features/registries/pages/my-registrations/my-registrations.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="subheader flex flex-column">
1+
<section class="flex flex-column flex-1 xl:mt-6">
22
<div class="flex flex-column align-items-start">
33
<osf-sub-header
44
[title]="'navigation.registriesSubRoutes.myRegistrations' | translate"
@@ -8,6 +8,7 @@
88
(buttonClick)="goToCreateRegistration()"
99
/>
1010
</div>
11+
1112
<div class="flex-column flex flex-1 w-full">
1213
<p-tabs [value]="selectedTab()" (valueChange)="selectedTab.set(+$event)" class="flex-1">
1314
@if (!isMobile()) {

0 commit comments

Comments
 (0)