Skip to content

Commit 91e39f8

Browse files
committed
refactor(topbar): use subtle role line in account dropdown header and simplify role resolver with switch
1 parent 469539e commit 91e39f8

3 files changed

Lines changed: 83 additions & 1 deletion

File tree

src/app/core/layout/component/app-topbar/app-topbar.component.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,20 @@
5454
</ng-template>
5555
</div>
5656
</div>
57-
<p-menu #accountMenu [popup]="true" [model]="accountMenuItems" [appendTo]="'body'"></p-menu>
57+
<p-menu #accountMenu [popup]="true" [model]="accountMenuItems" [appendTo]="'body'" styleClass="topbar-account-menu">
58+
<ng-template pTemplate="start">
59+
<div class="topbar-account-menu__header">
60+
<div class="topbar-account-menu__identity">
61+
<p-avatar [label]="currentUserInitials" shape="circle"></p-avatar>
62+
<div>
63+
<strong>{{ currentUserDisplayName }}</strong>
64+
<small>{{ currentUserEmail }}</small>
65+
<small class="topbar-account-menu__role-line">{{ currentRoleLabel }}</small>
66+
</div>
67+
</div>
68+
</div>
69+
</ng-template>
70+
</p-menu>
5871
<p-overlayPanel #notificationsPanel styleClass="topbar-notifications-panel" [showCloseIcon]="true" [appendTo]="'body'" (onShow)="markNotificationsAsRead()">
5972
<div class="topbar-notifications">
6073
<div class="topbar-notifications__header">

src/app/core/layout/component/app-topbar/app-topbar.component.scss

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,60 @@
186186
}
187187
}
188188

189+
:host ::ng-deep .topbar-account-menu {
190+
width: min(22rem, calc(100vw - 2rem));
191+
}
192+
193+
:host ::ng-deep .topbar-account-menu .p-menu-start {
194+
border-bottom: 1px solid var(--surface-border);
195+
margin-bottom: 0.25rem;
196+
}
197+
198+
.topbar-account-menu__header {
199+
padding: 0.7rem 0.85rem;
200+
display: flex;
201+
flex-direction: column;
202+
gap: 0.55rem;
203+
}
204+
205+
.topbar-account-menu__identity {
206+
display: flex;
207+
align-items: center;
208+
gap: 0.6rem;
209+
min-width: 0;
210+
}
211+
212+
.topbar-account-menu__identity > div {
213+
min-width: 0;
214+
display: flex;
215+
flex-direction: column;
216+
gap: 0.08rem;
217+
}
218+
219+
.topbar-account-menu__identity strong,
220+
.topbar-account-menu__identity small {
221+
white-space: nowrap;
222+
overflow: hidden;
223+
text-overflow: ellipsis;
224+
}
225+
226+
.topbar-account-menu__identity strong {
227+
font-size: 0.82rem;
228+
color: var(--text-color);
229+
}
230+
231+
.topbar-account-menu__identity small {
232+
font-size: 0.73rem;
233+
color: var(--text-color-secondary);
234+
}
235+
236+
.topbar-account-menu__role-line {
237+
margin-top: 0.08rem;
238+
font-size: 0.72rem;
239+
color: var(--text-color-secondary);
240+
line-height: 1.2;
241+
}
242+
189243
:host ::ng-deep .topbar-notifications-panel {
190244
width: min(24rem, calc(100vw - 2rem));
191245
}

src/app/core/layout/component/app-topbar/app-topbar.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { LayoutService } from '../../services/layout.service';
1111
import { AuthService } from '../../../../core/auth/services/auth.service';
1212
import { AppPreferencesService } from '../../../preferences/app-preferences.service';
1313
import { ActivityNotificationItem, ActivityNotificationService } from '../../../../core/notifications/activity-notification.service';
14+
import { AppRole } from '../../../../core/auth/models/app-role.model';
1415

1516
@Component({
1617
selector: 'app-topbar',
@@ -161,4 +162,18 @@ export class AppTopbarComponent {
161162

162163
return `${words[0][0] ?? ''}${words[words.length - 1][0] ?? ''}`.toUpperCase();
163164
}
165+
166+
get currentRoleLabel(): string {
167+
switch (true) {
168+
case this.authService.hasRole(AppRole.Administrator):
169+
return 'Administrator';
170+
case this.authService.hasRole(AppRole.ProjectManager):
171+
return 'Project Manager';
172+
case this.authService.hasRole(AppRole.User):
173+
return 'User';
174+
default:
175+
return 'Role';
176+
}
177+
}
178+
164179
}

0 commit comments

Comments
 (0)