From 520e25b50ae1ace11cafa6d77fc630b83421280e Mon Sep 17 00:00:00 2001 From: trtshen Date: Thu, 2 Apr 2026 11:55:58 +0800 Subject: [PATCH] [CORE-8194] hide projectbrief from expert in homepage now. --- projects/v3/src/app/pages/home/home.page.html | 2 +- .../v3/src/app/pages/home/home.page.spec.ts | 14 ++++++++++ projects/v3/src/app/pages/home/home.page.ts | 27 ++++++++++--------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/projects/v3/src/app/pages/home/home.page.html b/projects/v3/src/app/pages/home/home.page.html index 464ccee4e..0e85a6f51 100644 --- a/projects/v3/src/app/pages/home/home.page.html +++ b/projects/v3/src/app/pages/home/home.page.html @@ -44,7 +44,7 @@

-
+
{ expect(component.showProjectHub).toBe(false); }); + it('should treat mentor users as expert users', async () => { + storageService.getUser.and.returnValue({ + role: 'mentor', + apikey: 'test-key', + projectId: 1, + teamId: 1, + }); + + await component.updateDashboard(); + + expect(component.isExpert).toBe(true); + expect(component.isParticipant).toBe(false); + }); + it('should call service methods to fetch data', async () => { await component.updateDashboard(); expect(homeService.getMilestones).toHaveBeenCalled(); diff --git a/projects/v3/src/app/pages/home/home.page.ts b/projects/v3/src/app/pages/home/home.page.ts index dc5d1a76a..a1249498e 100644 --- a/projects/v3/src/app/pages/home/home.page.ts +++ b/projects/v3/src/app/pages/home/home.page.ts @@ -37,6 +37,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { isMobile: boolean; isParticipant: boolean; + isExpert: boolean; isExpertWithoutTeam: boolean; pulseCheckIndicatorEnabled: boolean; activityProgresses = {}; @@ -96,10 +97,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { } ngOnInit() { - const role = this.storageService.getUser().role; - const teamId = this.storageService.getUser().teamId; - this.isParticipant = role === 'participant'; - this.isExpertWithoutTeam = role === 'mentor' && !teamId; + this.updateUserRoleState(); this.pulseCheckIndicatorEnabled = this.storageService.getFeature('pulseCheckIndicator'); this.isMobile = this.utils.isMobile(); @@ -110,10 +108,8 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { takeUntil(this.unsubscribe$) ) .subscribe(() => { - // re-evaluate expert without team status when team changes - const currentRole = this.storageService.getUser().role; - const currentTeamId = this.storageService.getUser().teamId; - this.isExpertWithoutTeam = currentRole === 'mentor' && !currentTeamId; + // re-evaluate role state when team changes + this.updateUserRoleState(); }); this.homeService.milestones$ @@ -219,10 +215,7 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { await this.sharedService.refreshJWT(); // refresh JWT token [CORE-6083] // re-evaluate user role and team status after JWT refresh updates teamId - const role = this.storageService.getUser().role; - const teamId = this.storageService.getUser().teamId; - this.isParticipant = role === 'participant'; - this.isExpertWithoutTeam = role === 'mentor' && !teamId; + this.updateUserRoleState(); this.experience = this.storageService.get("experience"); this.showProjectHub = this.storageService.getFeature('showProjectHub'); @@ -283,6 +276,16 @@ export class HomePage implements OnInit, OnDestroy, AfterViewChecked { this.router.navigate(["experiences"]); } + private updateUserRoleState(): void { + const user = this.storageService.getUser() || {}; + const role = user.role; + const teamId = user.teamId; + + this.isParticipant = role === 'participant'; + this.isExpert = role === 'mentor'; + this.isExpertWithoutTeam = this.isExpert && !teamId; + } + switchContent(event) { // update points upon switching to badges tab if (event.detail.value === "badges") {