Skip to content

Commit c11c8fe

Browse files
committed
fix(dashboard): resolve pr comments
Signed-off-by: Asitha de Silva <asithade@gmail.com>
1 parent faf61c6 commit c11c8fe

File tree

12 files changed

+152
-160
lines changed

12 files changed

+152
-160
lines changed

apps/lfx-one/src/app/layouts/main-layout/main-layout.component.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// SPDX-License-Identifier: MIT
33

44
import { CommonModule } from '@angular/common';
5-
import { Component, effect, inject, signal, WritableSignal } from '@angular/core';
5+
import { Component, inject } from '@angular/core';
6+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
67
import { NavigationEnd, Router, RouterModule } from '@angular/router';
8+
import { AppService } from '@app/shared/services/app.service';
79
import { SidebarComponent } from '@components/sidebar/sidebar.component';
810
import { SidebarMenuItem } from '@lfx-one/shared/interfaces';
911
import { filter } from 'rxjs';
@@ -17,9 +19,10 @@ import { filter } from 'rxjs';
1719
})
1820
export class MainLayoutComponent {
1921
private readonly router = inject(Router);
22+
private readonly appService = inject(AppService);
2023

21-
// Mobile sidebar state
22-
public showMobileSidebar: WritableSignal<boolean> = signal(false);
24+
// Expose mobile sidebar state from service
25+
protected readonly showMobileSidebar = this.appService.showMobileSidebar;
2326

2427
// Sidebar navigation items
2528
protected readonly sidebarItems: SidebarMenuItem[] = [
@@ -87,25 +90,17 @@ export class MainLayoutComponent {
8790

8891
public constructor() {
8992
// Close mobile sidebar on navigation
90-
this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
91-
this.closeMobileSidebar();
92-
});
93-
94-
// Listen for custom event from header
95-
effect(() => {
96-
const handleToggle = () => {
97-
this.showMobileSidebar.set(!this.showMobileSidebar());
98-
};
99-
100-
window.addEventListener('toggleMobileSidebar', handleToggle);
101-
102-
return () => {
103-
window.removeEventListener('toggleMobileSidebar', handleToggle);
104-
};
105-
});
93+
this.router.events
94+
.pipe(
95+
filter((event) => event instanceof NavigationEnd),
96+
takeUntilDestroyed()
97+
)
98+
.subscribe(() => {
99+
this.appService.closeMobileSidebar();
100+
});
106101
}
107102

108103
public closeMobileSidebar(): void {
109-
this.showMobileSidebar.set(false);
104+
this.appService.closeMobileSidebar();
110105
}
111106
}

apps/lfx-one/src/app/modules/pages/dashboard/components/my-meetings/my-meetings.component.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to LFX. -->
22
<!-- SPDX-License-Identifier: MIT -->
33

4-
<lfx-card data-testid="section-my-meetings" styleClass="hover:shadow-lg transition-shadow h-full flex flex-col">
4+
<lfx-card data-testid="dashboard-my-meetings-card" styleClass="hover:shadow-lg transition-shadow h-full flex flex-col">
55
<ng-template #header>
66
<div class="flex items-center gap-3 p-6 border-b border-gray-100">
77
<div class="w-12 h-12 rounded-lg bg-gray-50 flex items-center justify-center">
@@ -12,9 +12,11 @@ <h2 class="text-base font-display font-medium text-gray-900">My Meetings</h2>
1212
</ng-template>
1313

1414
<div class="p-6 flex-1 flex flex-col">
15-
<div class="space-y-4 flex-1" data-testid="my-meetings-list">
16-
@for (item of meetings(); track item.title) {
17-
<div class="p-4 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-colors" [attr.data-testid]="'meeting-' + item.title">
15+
<div class="space-y-4 flex-1" data-testid="dashboard-my-meetings-list">
16+
@for (item of meetings(); track item.time) {
17+
<div
18+
class="p-4 bg-white border border-gray-200 rounded-lg hover:border-gray-300 transition-colors"
19+
[attr.data-testid]="'dashboard-my-meetings-item-' + item.title">
1820
<div class="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
1921
<div class="flex items-center gap-3">
2022
<div class="w-10 h-10 rounded-lg bg-green-100 flex items-center justify-center flex-shrink-0">
@@ -26,15 +28,15 @@ <h2 class="text-base font-display font-medium text-gray-900">My Meetings</h2>
2628
</div>
2729
</div>
2830
<div class="flex items-center gap-2 justify-between sm:justify-start w-full sm:w-auto">
29-
<span class="inline-flex items-center gap-1 px-2 py-1 rounded-md bg-gray-100 text-xs text-gray-600" data-testid="meeting-attendees">
31+
<span class="inline-flex items-center gap-1 px-2 py-1 rounded-md bg-gray-100 text-xs text-gray-600" data-testid="dashboard-my-meetings-attendees">
3032
<i class="fa-light fa-users text-xs"></i>
3133
{{ item.attendees }}
3234
</span>
3335
<button
3436
type="button"
3537
(click)="handleJoinMeeting(item)"
3638
class="px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white text-sm font-medium rounded-md transition-colors min-h-[44px] sm:min-h-0"
37-
data-testid="meeting-join-button"
39+
data-testid="dashboard-my-meetings-join-button"
3840
aria-label="Join meeting">
3941
Join
4042
</button>

apps/lfx-one/src/app/modules/pages/dashboard/components/my-meetings/my-meetings.component.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// SPDX-License-Identifier: MIT
33

44
import { CommonModule } from '@angular/common';
5-
import { Component, computed, inject, output, signal } from '@angular/core';
5+
import { Component, computed, inject, output } from '@angular/core';
6+
import { toSignal } from '@angular/core/rxjs-interop';
67
import { MeetingService } from '@app/shared/services/meeting.service';
78
import { CardComponent } from '@components/card/card.component';
89

@@ -17,7 +18,7 @@ import type { Meeting, MeetingItem, MeetingOccurrence } from '@lfx-one/shared/in
1718
})
1819
export class MyMeetingsComponent {
1920
private readonly meetingService = inject(MeetingService);
20-
private readonly allMeetings = signal<Meeting[]>([]);
21+
private readonly allMeetings = toSignal(this.meetingService.getMeetings(), { initialValue: [] });
2122

2223
public readonly joinMeeting = output<MeetingItem>();
2324

@@ -77,13 +78,6 @@ export class MyMeetingsComponent {
7778
}));
7879
});
7980

80-
public constructor() {
81-
// Load meetings when component initializes
82-
this.meetingService.getMeetings().subscribe((meetings) => {
83-
this.allMeetings.set(meetings);
84-
});
85-
}
86-
8781
public handleJoinMeeting(meeting: MeetingItem): void {
8882
this.joinMeeting.emit(meeting);
8983
}

apps/lfx-one/src/app/modules/pages/dashboard/components/my-projects/my-projects.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to LFX. -->
22
<!-- SPDX-License-Identifier: MIT -->
33

4-
<lfx-card data-testid="section-my-projects" styleClass="hover:shadow-lg transition-shadow">
4+
<lfx-card data-testid="dashboard-my-projects-card" styleClass="hover:shadow-lg transition-shadow">
55
<ng-template #header>
66
<div class="flex items-center gap-3 p-6 border-b border-gray-100">
77
<div class="w-12 h-12 rounded-lg bg-gray-50 flex items-center justify-center">
@@ -12,15 +12,15 @@ <h2 class="text-base font-display font-medium text-gray-900">My Projects</h2>
1212
</ng-template>
1313

1414
<div class="p-6">
15-
<div class="flex flex-col gap-4" data-testid="my-projects-list">
15+
<div class="flex flex-col gap-4" data-testid="dashboard-my-projects-list">
1616
@for (item of projects; track item.name) {
17-
<div class="flex flex-col lg:flex-wrap lg:flex-row lg:gap-0" [attr.data-testid]="'project-' + item.name">
17+
<div class="flex flex-col lg:flex-wrap lg:flex-row lg:gap-0" [attr.data-testid]="'dashboard-my-projects-item-' + item.name">
1818
<!-- Project Logo & Name -->
1919
<div
2020
class="p-4 bg-gray-50 rounded-t-lg lg:rounded-l-lg lg:rounded-r-none lg:rounded-t-lg border border-gray-200 border-b-0 lg:border-b lg:border-r-0 w-full lg:flex-1 lg:min-w-[200px]">
2121
<div class="flex items-center gap-3">
2222
@if (item.logo) {
23-
<img [src]="item.logo" [alt]="item.name + ' logo'" class="w-12 h-12 object-contain flex-shrink-0" data-testid="project-logo" />
23+
<img [src]="item.logo" [alt]="item.name + ' logo'" class="w-12 h-12 object-contain flex-shrink-0" data-testid="dashboard-my-projects-logo" />
2424
} @else {
2525
<div class="w-12 h-12 bg-gray-300 rounded-lg flex items-center justify-center flex-shrink-0">
2626
<i class="fa-light fa-folder text-gray-600 text-xl"></i>

apps/lfx-one/src/app/modules/pages/dashboard/components/pending-actions/pending-actions.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to LFX. -->
22
<!-- SPDX-License-Identifier: MIT -->
33

4-
<lfx-card data-testid="section-pending-actions" styleClass="hover:shadow-lg transition-shadow h-full flex flex-col">
4+
<lfx-card data-testid="dashboard-pending-actions-card" styleClass="hover:shadow-lg transition-shadow h-full flex flex-col">
55
<ng-template #header>
66
<div class="flex items-center gap-3 p-6 border-b border-gray-100">
77
<div class="w-12 h-12 rounded-lg bg-gray-50 flex items-center justify-center">
@@ -12,7 +12,7 @@ <h2 class="text-base font-display font-medium text-gray-900">Pending Actions</h2
1212
</ng-template>
1313

1414
<div class="p-6 flex-1 flex flex-col">
15-
<div class="space-y-4 flex-1" data-testid="pending-actions-list">
15+
<div class="space-y-4 flex-1" data-testid="dashboard-pending-actions-list">
1616
@for (item of pendingActions; track item.text) {
1717
<div
1818
class="p-4 border rounded-lg"
@@ -22,7 +22,7 @@ <h2 class="text-base font-display font-medium text-gray-900">Pending Actions</h2
2222
'bg-green-50 border-green-200': item.color === 'green',
2323
'bg-purple-50 border-purple-200': item.color === 'purple',
2424
}"
25-
[attr.data-testid]="'pending-action-' + item.type">
25+
[attr.data-testid]="'dashboard-pending-actions-item-' + item.type">
2626
<!-- Header with Type and Badge -->
2727
<div class="flex items-start justify-between mb-3">
2828
<div class="flex items-center gap-2">
@@ -48,7 +48,7 @@ <h2 class="text-base font-display font-medium text-gray-900">Pending Actions</h2
4848
</div>
4949
<span
5050
class="inline-flex items-center justify-center rounded-md px-2 py-0.5 text-xs font-medium bg-white text-gray-700 border border-gray-200"
51-
data-testid="pending-action-badge">
51+
data-testid="dashboard-pending-actions-badge">
5252
{{ item.badge }}
5353
</span>
5454
</div>
@@ -78,7 +78,7 @@ <h2 class="text-base font-display font-medium text-gray-900">Pending Actions</h2
7878
'border-green-300 text-green-700 hover:bg-green-100': item.color === 'green',
7979
'border-purple-300 text-purple-700 hover:bg-purple-100': item.color === 'purple',
8080
}"
81-
data-testid="pending-action-button">
81+
data-testid="dashboard-pending-actions-button">
8282
{{ item.buttonText }}
8383
</button>
8484
</div>

apps/lfx-one/src/app/modules/pages/dashboard/components/recent-progress/recent-progress.component.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Copyright The Linux Foundation and each contributor to LFX. -->
22
<!-- SPDX-License-Identifier: MIT -->
33

4-
<lfx-card data-testid="section-recent-progress" styleClass="hover:shadow-lg transition-shadow">
4+
<lfx-card data-testid="dashboard-recent-progress-card" styleClass="hover:shadow-lg transition-shadow">
55
<ng-template #header>
66
<div class="flex items-center justify-between p-6 border-b border-gray-100">
77
<div class="flex items-center gap-3">
@@ -15,15 +15,15 @@ <h2 class="text-base font-display font-medium text-gray-900">Recent Progress</h2
1515
type="button"
1616
(click)="scrollLeft()"
1717
class="w-8 h-8 flex items-center justify-center rounded-full border border-gray-300 text-gray-600 hover:bg-gray-50 transition-colors"
18-
data-testid="recent-progress-scroll-left"
18+
data-testid="dashboard-recent-progress-scroll-left"
1919
aria-label="Scroll left">
2020
<i class="fa-light fa-chevron-left"></i>
2121
</button>
2222
<button
2323
type="button"
2424
(click)="scrollRight()"
2525
class="w-8 h-8 flex items-center justify-center rounded-full border border-gray-300 text-gray-600 hover:bg-gray-50 transition-colors"
26-
data-testid="recent-progress-scroll-right"
26+
data-testid="dashboard-recent-progress-scroll-right"
2727
aria-label="Scroll right">
2828
<i class="fa-light fa-chevron-right"></i>
2929
</button>
@@ -32,18 +32,20 @@ <h2 class="text-base font-display font-medium text-gray-900">Recent Progress</h2
3232
</ng-template>
3333

3434
<div class="p-6">
35-
<div #progressScroll class="flex gap-4 overflow-x-auto pb-2 hide-scrollbar scroll-smooth" data-testid="recent-progress-items">
35+
<div #progressScroll class="flex gap-4 overflow-x-auto pb-2 hide-scrollbar scroll-smooth" data-testid="dashboard-recent-progress-items">
3636
@for (item of progressItems; track item.label) {
37-
<div class="bg-white border border-gray-200 rounded-lg p-4 min-w-[280px] flex-shrink-0" [attr.data-testid]="'progress-item-' + item.label">
37+
<div
38+
class="bg-white border border-gray-200 rounded-lg p-4 min-w-[280px] flex-shrink-0"
39+
[attr.data-testid]="'dashboard-recent-progress-item-' + item.label">
3840
<div class="flex items-center justify-between mb-3">
3941
<div>
4042
<div class="text-sm text-gray-600 mb-1">{{ item.label }}</div>
4143
<div class="text-2xl font-display font-semibold text-gray-900">{{ item.value }}</div>
4244
</div>
4345
@if (item.trend === 'up') {
44-
<i class="fa-light fa-arrow-trend-up text-green-500 text-lg" data-testid="trend-up"></i>
46+
<i class="fa-light fa-arrow-trend-up text-green-500 text-lg" data-testid="dashboard-recent-progress-trend-up"></i>
4547
} @else if (item.trend === 'down') {
46-
<i class="fa-light fa-arrow-trend-down text-red-500 text-lg" data-testid="trend-down"></i>
48+
<i class="fa-light fa-arrow-trend-down text-red-500 text-lg" data-testid="dashboard-recent-progress-trend-down"></i>
4749
}
4850
</div>
4951
<div class="h-20">

apps/lfx-one/src/app/shared/components/header/header.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Router, RouterModule } from '@angular/router';
99
import { AvatarComponent } from '@components/avatar/avatar.component';
1010
import { MenubarComponent } from '@components/menubar/menubar.component';
1111
import { PersonaSelectorComponent } from '@components/persona-selector/persona-selector.component';
12+
import { AppService } from '@app/shared/services/app.service';
1213
import { CombinedProfile, Project } from '@lfx-one/shared/interfaces';
1314
import { ProjectService } from '@services/project.service';
1415
import { UserService } from '@services/user.service';
@@ -44,14 +45,15 @@ import { MenuComponent } from '../menu/menu.component';
4445
export class HeaderComponent {
4546
private readonly router = inject(Router);
4647
private readonly projectService = inject(ProjectService);
48+
private readonly appService = inject(AppService);
4749
public readonly userService = inject(UserService);
4850

4951
// Mobile search state
5052
public showMobileSearch: WritableSignal<boolean> = signal(false);
5153
private readonly mobileSearchInput = viewChild<ElementRef>('mobileSearchInput');
5254

5355
public userProfile: Signal<CombinedProfile | null> = this.initializeUserProfile();
54-
public initials = computed(() => this.userProfile()?.user.first_name?.slice(0));
56+
public initials = computed(() => this.userProfile()?.user.first_name?.slice(0, 1));
5557
public fullName = computed(() => this.userProfile()?.user.first_name + ' ' + this.userProfile()?.user?.last_name);
5658

5759
// Search form
@@ -155,8 +157,7 @@ export class HeaderComponent {
155157
}
156158

157159
protected toggleMobileSidebar(): void {
158-
// Dispatch custom event to toggle sidebar in main-layout
159-
window.dispatchEvent(new CustomEvent('toggleMobileSidebar'));
160+
this.appService.toggleMobileSidebar();
160161
}
161162

162163
private initializeUserProfile(): Signal<CombinedProfile | null> {

0 commit comments

Comments
 (0)