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
8 changes: 7 additions & 1 deletion apps/lfx-one/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AuthContext } from '@lfx-one/shared/interfaces';
import { ToastModule } from 'primeng/toast';

import { FeatureFlagService } from './shared/services/feature-flag.service';
import { PersonaService } from './shared/services/persona.service';
import { SegmentService } from './shared/services/segment.service';
import { UserService } from './shared/services/user.service';

Expand All @@ -19,6 +20,7 @@ import { UserService } from './shared/services/user.service';
})
export class AppComponent {
private readonly userService = inject(UserService);
private readonly personaService = inject(PersonaService);
private readonly segmentService = inject(SegmentService);
private readonly featureFlagService = inject(FeatureFlagService);

Expand All @@ -42,16 +44,20 @@ export class AppComponent {
this.transferState.set(this.serverKey, this.auth);
}

// Hydrate the auth s tate from the server, if it exists, otherwise set it to false and null
// Hydrate the auth state from the server, if it exists, otherwise set it to false and null
this.auth = this.transferState.get(this.serverKey, {
authenticated: false,
user: null,
persona: null,
});

if (this.auth?.authenticated && this.auth.user) {
this.userService.authenticated.set(true);
this.userService.user.set(this.auth.user);

// Initialize persona from backend (auto-detected from committee membership)
this.personaService.initializeFromAuth(this.auth.persona);

// Identify user with Segment tracking (pass entire Auth0 user object)
this.segmentService.identifyUser(this.auth.user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="flex min-h-screen">
<!-- Sidebar - Desktop -->
<div class="hidden lg:block w-64 flex-shrink-0 fixed top-0 left-0">
<lfx-sidebar [items]="sidebarItems()" [footerItems]="sidebarFooterItems" [showProjectSelector]="true"></lfx-sidebar>
<lfx-sidebar [items]="sidebarItems()" [footerItems]="sidebarFooterItems()" [showProjectSelector]="true"></lfx-sidebar>
</div>

<!-- Sidebar - Mobile Overlay -->
Expand All @@ -23,7 +23,7 @@ <h2 class="text-lg font-semibold text-gray-900">Menu</h2>
</button>
</div>
<div class="overflow-y-auto h-[calc(100vh-4rem)]">
<lfx-sidebar [items]="sidebarItems()" [footerItems]="sidebarFooterItems" [showProjectSelector]="true"></lfx-sidebar>
<lfx-sidebar [items]="sidebarItems()" [footerItems]="sidebarFooterItems()" [showProjectSelector]="true"></lfx-sidebar>
</div>
</div>
</div>
Expand Down
37 changes: 27 additions & 10 deletions apps/lfx-one/src/app/layouts/main-layout/main-layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NavigationEnd, Router, RouterModule } from '@angular/router';
import { AppService } from '@app/shared/services/app.service';
import { FeatureFlagService } from '@app/shared/services/feature-flag.service';
import { SidebarComponent } from '@components/sidebar/sidebar.component';
import { environment } from '@environments/environment';
import { COMMITTEE_LABEL } from '@lfx-one/shared/constants';
import { SidebarMenuItem } from '@lfx-one/shared/interfaces';
import { PersonaService } from '@services/persona.service';
Expand Down Expand Up @@ -35,6 +36,7 @@ export class MainLayoutComponent {

// Feature flags
private readonly showProjectsInSidebar = this.featureFlagService.getBooleanFlag('sidebar-projects', false);
private readonly enableProfileClick = this.featureFlagService.getBooleanFlag('sidebar-profile', false);

// Base sidebar navigation items - matching React NavigationSidebar design
private readonly baseSidebarItems: SidebarMenuItem[] = [
Expand Down Expand Up @@ -62,33 +64,48 @@ export class MainLayoutComponent {

// Computed sidebar items based on feature flags
protected readonly sidebarItems = computed(() => {
const items = [...this.baseSidebarItems];
let items = [...this.baseSidebarItems];

// Filter out Projects if feature flag is disabled
if (!this.showProjectsInSidebar()) {
return items.filter((item) => item.label !== 'Projects');
items = items.filter((item) => item.label !== 'Projects');
}

if (this.personaService.currentPersona() === 'board-member') {
return items.filter((item) => item.label !== COMMITTEE_LABEL.plural);
items = items.filter((item) => item.label !== COMMITTEE_LABEL.plural);
}

return items;
});

// Sidebar footer items - matching React NavigationSidebar design
protected readonly sidebarFooterItems: SidebarMenuItem[] = [
{
label: 'Settings',
icon: 'fa-light fa-gear',
routerLink: '/settings',
},
protected readonly sidebarFooterItems = computed(() => [
{
label: 'Profile',
icon: 'fa-light fa-user',
routerLink: '/profile',
disabled: !this.enableProfileClick(), // Disable when feature flag is false
},
];
{
label: 'Support',
icon: 'fa-light fa-question-circle',
url: environment.urls.support,
target: '_blank',
rel: 'noopener noreferrer',
},
{
label: 'Permissions',
icon: 'fa-light fa-shield',
routerLink: '/settings',
},
{
label: 'Logout',
icon: 'fa-light fa-sign-out',
url: '/logout',
target: '_self',
rel: '',
},
]);

public constructor() {
// Close mobile sidebar on navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class CommitteeDashboardComponent {

// Permission signals
public isMaintainer: Signal<boolean>;
public isNonFoundationProjectSelected: Signal<boolean>;
public canCreateGroup: Signal<boolean>;

// Statistics calculations
Expand All @@ -68,8 +67,7 @@ export class CommitteeDashboardComponent {

// Initialize permission checks
this.isMaintainer = computed(() => this.personaService.currentPersona() === 'maintainer');
this.isNonFoundationProjectSelected = computed(() => this.projectContextService.selectedProject() !== null);
this.canCreateGroup = computed(() => this.isMaintainer() && this.isNonFoundationProjectSelected());
this.canCreateGroup = computed(() => this.isMaintainer());
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

UX inconsistency: button enabled but action may fail.

The canCreateGroup signal only checks isMaintainer(), which enables the create button whenever the user is a maintainer. However, openCreateDialog() (lines 109-118) still requires a project or foundation to be selected, showing a warning if absent. This creates a frustrating pattern where a maintainer can see an enabled button but receives a warning upon clicking.

Consider one of these solutions:

  1. If the project-selection requirement should remain, restore the check to maintain consistent UX:
-this.canCreateGroup = computed(() => this.isMaintainer());
+this.canCreateGroup = computed(() => this.isMaintainer() && this.project() !== null);
  1. If the PR objective to "remove project-selection requirement for group creation" means groups can be created without a project/foundation, then remove the check from openCreateDialog() as well (lines 110-118).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.canCreateGroup = computed(() => this.isMaintainer());
this.canCreateGroup = computed(() => this.isMaintainer() && this.project() !== null);


// Initialize state
this.committeesLoading = signal<boolean>(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,68 +48,68 @@ <h2 class="font-['Roboto_Slab'] font-semibold text-[16px]">{{ accountName() }}'s
<p class="text-sm text-gray-500">Loading organization data...</p>
</div>
</div>
} @else {
<div class="overflow-hidden">
<div #carouselScroll class="flex gap-4 overflow-x-auto pb-2 hide-scrollbar scroll-smooth" data-testid="dashboard-involvement-carousel">
@for (metric of primaryMetrics(); track metric.title) {
<!-- Membership Tier Card (Special) -->
@if (metric.isMembershipTier) {
<div
class="p-4 bg-white rounded-lg border border-slate-200 hover:border-[#0094FF] transition-colors cursor-pointer flex-shrink-0 w-80"
[attr.data-testid]="'dashboard-involvement-metric-' + metric.title">
<div class="space-y-3">
<div class="flex items-center gap-1">
<i [class]="metric.icon + ' text-gray-500'" class="w-4 h-4"></i>
<h5 class="text-sm font-medium">{{ metric.title }}</h5>
</div>
}

<div class="overflow-hidden">
<div #carouselScroll class="flex gap-4 overflow-x-auto pb-2 hide-scrollbar scroll-smooth" data-testid="dashboard-involvement-carousel">
@for (metric of primaryMetrics(); track metric.title) {
<!-- Membership Tier Card (Special) -->
@if (metric.isMembershipTier) {
<div
class="p-4 bg-white rounded-lg border border-slate-200 hover:border-[#0094FF] transition-colors cursor-pointer flex-shrink-0 w-80"
[attr.data-testid]="'dashboard-involvement-metric-' + metric.title">
<div class="space-y-3">
<div class="flex items-center gap-1">
<i [class]="metric.icon + ' text-gray-500'" class="w-4 h-4"></i>
<h5 class="text-sm font-medium">{{ metric.title }}</h5>
</div>

<!-- Membership Info -->
<div class="space-y-2">
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Tier</span>
<span class="px-2 py-0.5 text-xs font-medium rounded bg-gradient-to-r from-gray-400 to-gray-300 text-white border border-gray-300">
{{ metric.tier }}
</span>
</div>
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Member Since</span>
<span class="text-sm font-medium">{{ metric.tierSince }}</span>
</div>
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Renewal Date</span>
<span class="text-sm font-medium">{{ metric.nextDue }}</span>
</div>
<!-- Membership Info -->
<div class="space-y-2">
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Tier</span>
<span class="px-2 py-0.5 text-xs font-medium rounded bg-gradient-to-r from-gray-400 to-gray-300 text-white border border-gray-300">
{{ metric.tier }}
</span>
</div>
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Member Since</span>
<span class="text-sm font-medium">{{ metric.tierSince }}</span>
</div>
<div class="flex items-center justify-between">
<span class="text-sm text-gray-500">Renewal Date</span>
<span class="text-sm font-medium">{{ metric.nextDue }}</span>
</div>
</div>
</div>
} @else {
<!-- Regular Card -->
<div class="p-4 bg-white rounded-lg border border-slate-200 flex-shrink-0 w-80" [attr.data-testid]="'dashboard-involvement-metric-' + metric.title">
<div class="space-y-3">
<div class="flex items-center gap-3">
<i [class]="metric.icon + ' text-gray-500'" class="w-4 h-4"></i>
<h5 class="text-sm font-medium">{{ metric.title }}</h5>
</div>
} @else {
<!-- Regular Card -->
<div class="p-4 bg-white rounded-lg border border-slate-200 flex-shrink-0 w-80" [attr.data-testid]="'dashboard-involvement-metric-' + metric.title">
<div class="space-y-3">
<div class="flex items-center gap-3">
<i [class]="metric.icon + ' text-gray-500'" class="w-4 h-4"></i>
<h5 class="text-sm font-medium">{{ metric.title }}</h5>
</div>
@if (metric.chartData) {
<div class="w-full h-16">
<lfx-chart
[type]="metric.title === 'Active Contributors' || metric.title === 'Maintainers' ? 'bar' : 'line'"
[data]="metric.chartData"
[options]="metric.title === 'Active Contributors' || metric.title === 'Maintainers' ? barChartOptions : sparklineChartOptions"
height="100%"></lfx-chart>
</div>
@if (metric.chartData) {
<div class="w-full h-16">
<lfx-chart
[type]="metric.title === 'Active Contributors' || metric.title === 'Maintainers' ? 'bar' : 'line'"
[data]="metric.chartData"
[options]="metric.title === 'Active Contributors' || metric.title === 'Maintainers' ? barChartOptions : sparklineChartOptions"
height="100%"></lfx-chart>
</div>
}
<div class="space-y-1">
<div class="text-xl font-medium">{{ metric.value }}</div>
@if (metric.subtitle) {
<div class="text-xs text-gray-500">{{ metric.subtitle }}</div>
}
<div class="space-y-1">
<div class="text-xl font-medium">{{ metric.value }}</div>
@if (metric.subtitle) {
<div class="text-xs text-gray-500">{{ metric.subtitle }}</div>
}
</div>
</div>
</div>
}
</div>
}
</div>
}
</div>
}
</div>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- Copyright The Linux Foundation and each contributor to LFX. -->
<!-- SPDX-License-Identifier: MIT -->

<div class="persona-selector" data-testid="persona-selector">
<lfx-select [form]="form" control="persona" [options]="personaOptions" optionLabel="label" optionValue="value" size="small"></lfx-select>
</div>
@if (!isAutoDetected()) {
<div class="persona-selector" data-testid="persona-selector">
<lfx-select [form]="form" control="persona" [options]="personaOptions" optionLabel="label" optionValue="value" size="small"></lfx-select>
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class PersonaSelectorComponent {
private readonly projectContextService = inject(ProjectContextService);
// Persona options available for selection
protected readonly personaOptions = PERSONA_OPTIONS;
// Whether persona is auto-detected (read-only)
protected readonly isAutoDetected = this.personaService.isAutoDetected;

public form: FormGroup;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
@if (item.url) {
<a
[href]="item.url"
[target]="item.disabled ? '_self' : '_blank'"
[rel]="item.disabled ? '' : 'noopener noreferrer'"
[target]="item.target || '_blank'"
[rel]="item.rel || 'noopener noreferrer'"
[ngClass]="{
'flex items-center gap-2 px-2 py-2 rounded-lg transition-colors cursor-pointer w-full text-base text-[#45556c] font-normal hover:bg-slate-50': true,
'opacity-50 pointer-events-none cursor-not-allowed': item.disabled,
Expand Down
51 changes: 25 additions & 26 deletions apps/lfx-one/src/app/shared/services/persona.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,42 @@ export class PersonaService {
private readonly router = inject(Router);
private readonly projectContextService = inject(ProjectContextService);

private readonly storageKey = 'lfx-persona';
public readonly currentPersona: WritableSignal<PersonaType>;
public readonly isAutoDetected: WritableSignal<boolean> = signal(false);

public constructor() {
const stored = this.loadStoredPersona();
this.currentPersona = signal<PersonaType>(stored || 'maintainer');
// Default persona - will be overridden by initializeFromAuth if backend provides one
this.currentPersona = signal<PersonaType>('maintainer');
}

/**
* Set the current persona and persist to storage
* Initialize persona from AuthContext (SSR state transfer)
* If persona is provided from backend, it was auto-detected and cannot be changed
*/
public initializeFromAuth(persona: PersonaType | null | undefined): void {
if (persona) {
this.currentPersona.set(persona);
this.isAutoDetected.set(true);
} else {
// No auto-detected persona, allow manual selection
this.isAutoDetected.set(false);
}
}

/**
* Set the current persona
* When switching to board-member, clear child project selection
* Cannot change persona if it was auto-detected from committee membership
*/
public setPersona(persona: PersonaType): void {
// Don't allow changes if persona was auto-detected
if (this.isAutoDetected()) {
console.warn('Cannot change persona - it was automatically determined from committee membership');
return;
}

if (persona !== this.currentPersona()) {
this.currentPersona.set(persona);
this.persistPersona(persona);

// When switching to board-member persona, clear any child project selection
// Board members should only work at the foundation level
Expand All @@ -40,25 +60,4 @@ export class PersonaService {
this.router.navigate(['/']);
}
}

private persistPersona(persona: PersonaType): void {
if (typeof localStorage !== 'undefined') {
localStorage.setItem(this.storageKey, persona);
}
}

private loadStoredPersona(): PersonaType | null {
if (typeof localStorage === 'undefined') {
return null;
}
try {
const stored = localStorage.getItem(this.storageKey);
if (stored) {
return stored as PersonaType;
}
} catch {
// Invalid data in localStorage, ignore
}
return null;
}
}
Loading