Skip to content

Commit c46a622

Browse files
authored
feat(ui): enhance components with optional inputs and shared types (#177)
- Add optional field inputs to data copilot component for selective parameter inclusion - Refactor RSVP details component to always redirect to step 5 instead of modal - Create shared ComponentSeverity and BadgeSeverity types to eliminate duplication - Add conditional create group button visibility in committee dashboard based on permissions LFXV2-799 Signed-off-by: Asitha de Silva <[email protected]>
1 parent ea70510 commit c46a622

File tree

23 files changed

+102
-64
lines changed

23 files changed

+102
-64
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
data-testid="mobile-sidebar-drawer">
2020
<ng-template #header>
2121
<div class="flex items-center gap-3">
22-
<img src="/images/lfx-one-logo.svg" alt="LFX Logo" class="w-auto h-5" />
22+
<a [routerLink]="['/']" class="flex items-center">
23+
<img src="/images/lfx-one-logo.svg" alt="LFX Logo" class="w-auto h-5" />
24+
</a>
2325
</div>
2426
</ng-template>
2527
<lfx-sidebar [items]="sidebarItems()" [footerItems]="sidebarFooterItems()" [showProjectSelector]="true" [mobile]="true"></lfx-sidebar>

apps/lfx-one/src/app/modules/committees/committee-dashboard/committee-dashboard.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SelectComponent } from '@components/select/select.component';
1212
import { COMMITTEE_LABEL } from '@lfx-one/shared/constants';
1313
import { Committee, ProjectContext } from '@lfx-one/shared/interfaces';
1414
import { CommitteeService } from '@services/committee.service';
15+
import { FeatureFlagService } from '@services/feature-flag.service';
1516
import { PersonaService } from '@services/persona.service';
1617
import { ProjectContextService } from '@services/project-context.service';
1718
import { MessageService } from 'primeng/api';
@@ -31,6 +32,7 @@ export class CommitteeDashboardComponent {
3132
private readonly projectContextService = inject(ProjectContextService);
3233
private readonly committeeService = inject(CommitteeService);
3334
private readonly personaService = inject(PersonaService);
35+
private readonly featureFlagService = inject(FeatureFlagService);
3436
private readonly router = inject(Router);
3537
private readonly messageService = inject(MessageService);
3638

@@ -53,6 +55,8 @@ export class CommitteeDashboardComponent {
5355

5456
// Permission signals
5557
public isMaintainer: Signal<boolean>;
58+
public isFoundationContext: Signal<boolean>;
59+
public foundationCreateCommitteeFlag: Signal<boolean>;
5660
public canCreateGroup: Signal<boolean>;
5761

5862
// Statistics calculations
@@ -67,7 +71,13 @@ export class CommitteeDashboardComponent {
6771

6872
// Initialize permission checks
6973
this.isMaintainer = computed(() => this.personaService.currentPersona() === 'maintainer');
70-
this.canCreateGroup = computed(() => this.isMaintainer());
74+
this.isFoundationContext = computed(() => !this.projectContextService.selectedProject() && !!this.projectContextService.selectedFoundation());
75+
this.foundationCreateCommitteeFlag = this.featureFlagService.getBooleanFlag('foundation-create-committee', false);
76+
this.canCreateGroup = computed(() => {
77+
const isMaintainerAndNotFoundation = this.isMaintainer() && !this.isFoundationContext();
78+
const hasFeatureFlag = this.foundationCreateCommitteeFlag();
79+
return isMaintainerAndNotFoundation || hasFeatureFlag;
80+
});
7181

7282
// Initialize state
7383
this.committeesLoading = signal<boolean>(true);

apps/lfx-one/src/app/modules/committees/committee-view/committee-view.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ButtonComponent } from '@components/button/button.component';
99
import { CardComponent } from '@components/card/card.component';
1010
import { MenuComponent } from '@components/menu/menu.component';
1111
import { TagComponent } from '@components/tag/tag.component';
12-
import { Committee, CommitteeMember, COMMITTEE_CATEGORY_SEVERITY } from '@lfx-one/shared';
12+
import { Committee, COMMITTEE_CATEGORY_SEVERITY, CommitteeMember, ComponentSeverity } from '@lfx-one/shared';
1313
import { CommitteeService } from '@services/committee.service';
1414
import { ProjectContextService } from '@services/project-context.service';
1515
import { ConfirmationService, MenuItem, MessageService } from 'primeng/api';
@@ -59,7 +59,7 @@ export class CommitteeViewComponent {
5959
public formattedCreatedDate: Signal<string>;
6060
public formattedUpdatedDate: Signal<string>;
6161
public refresh: BehaviorSubject<void>;
62-
public categorySeverity: Signal<'info' | 'success' | 'warn' | 'danger' | 'secondary' | 'contrast'>;
62+
public categorySeverity: Signal<ComponentSeverity>;
6363

6464
public constructor() {
6565
// Initialize all class variables

apps/lfx-one/src/app/modules/committees/components/committee-table/committee-table.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { RouterLink } from '@angular/router';
77
import { ButtonComponent } from '@components/button/button.component';
88
import { CardComponent } from '@components/card/card.component';
99
import { TagComponent } from '@components/tag/tag.component';
10-
import { Committee, COMMITTEE_CATEGORY_SEVERITY } from '@lfx-one/shared';
10+
import { Committee, COMMITTEE_CATEGORY_SEVERITY, ComponentSeverity } from '@lfx-one/shared';
1111
import { CommitteeService } from '@services/committee.service';
1212
import { ConfirmationService, MessageService } from 'primeng/api';
1313
import { ConfirmDialogModule } from 'primeng/confirmdialog';
@@ -47,7 +47,7 @@ export class CommitteeTableComponent {
4747
public readonly refresh = output<void>();
4848

4949
// Helper method for category severity
50-
public getCategorySeverity(category: string): 'info' | 'success' | 'warn' | 'danger' | 'secondary' | 'contrast' {
50+
public getCategorySeverity(category: string): ComponentSeverity {
5151
return COMMITTEE_CATEGORY_SEVERITY[category] || 'secondary';
5252
}
5353

apps/lfx-one/src/app/modules/committees/components/member-card/member-card.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AvatarComponent } from '@components/avatar/avatar.component';
77
import { BadgeComponent } from '@components/badge/badge.component';
88
import { ButtonComponent } from '@components/button/button.component';
99
import { MenuComponent } from '@components/menu/menu.component';
10-
import { Committee, CommitteeMember } from '@lfx-one/shared/interfaces';
10+
import { BadgeSeverity, Committee, CommitteeMember } from '@lfx-one/shared';
1111
import { Tooltip } from 'primeng/tooltip';
1212

1313
@Component({
@@ -45,15 +45,15 @@ export class MemberCardComponent {
4545
return 'M';
4646
});
4747

48-
public readonly roleBadgeSeverity = computed<'secondary' | 'success' | 'info' | 'warn' | 'danger' | 'contrast'>(() => {
48+
public readonly roleBadgeSeverity = computed<BadgeSeverity>(() => {
4949
const role = this.member().role?.name?.toLowerCase();
5050
if (role === 'chair' || role === 'chairperson') return 'info';
5151
if (role === 'vice chair' || role === 'vice-chair') return 'success';
5252
if (role === 'secretary') return 'contrast';
5353
return 'secondary';
5454
});
5555

56-
public readonly votingStatusBadgeSeverity = computed<'secondary' | 'success' | 'info' | 'warn' | 'danger' | 'contrast'>(() => {
56+
public readonly votingStatusBadgeSeverity = computed<BadgeSeverity>(() => {
5757
const status = this.member().voting?.status?.toLowerCase();
5858
if (status === 'voting') return 'success';
5959
if (status === 'non-voting') return 'warn';

apps/lfx-one/src/app/modules/dashboards/components/dashboard-meeting-card/dashboard-meeting-card.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TagComponent } from '@components/tag/tag.component';
1010
import {
1111
buildJoinUrlWithParams,
1212
canJoinMeeting,
13+
ComponentSeverity,
1314
DEFAULT_MEETING_TYPE_CONFIG,
1415
Meeting,
1516
MEETING_TYPE_CONFIGS,
@@ -45,11 +46,11 @@ export class DashboardMeetingCardComponent {
4546
const config = type ? (MEETING_TYPE_CONFIGS[type] ?? DEFAULT_MEETING_TYPE_CONFIG) : DEFAULT_MEETING_TYPE_CONFIG;
4647

4748
// Map text color to severity
48-
let severity: 'info' | 'success' | 'warn' | 'danger' | 'secondary' | 'contrast' = 'secondary';
49+
let severity: ComponentSeverity = 'secondary';
4950
if (config.textColor.includes('red')) severity = 'danger';
5051
else if (config.textColor.includes('blue')) severity = 'info';
5152
else if (config.textColor.includes('green')) severity = 'success';
52-
else if (config.textColor.includes('purple')) severity = 'contrast';
53+
else if (config.textColor.includes('purple')) severity = 'primary';
5354
else if (config.textColor.includes('amber')) severity = 'warn';
5455

5556
return {

apps/lfx-one/src/app/modules/dashboards/components/foundation-health/foundation-health.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h2>{{ title() }}</h2>
1515
data-testid="foundation-health-filters"></lfx-filter-pills>
1616

1717
<!-- Data Copilot Button -->
18-
<lfx-data-copilot></lfx-data-copilot>
18+
<lfx-data-copilot [includeOrganizationId]="false" [includeOrganizationName]="false"></lfx-data-copilot>
1919
</div>
2020
</div>
2121

apps/lfx-one/src/app/modules/meetings/components/meeting-card/meeting-card.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ <h3 class="text-base font-medium text-gray-900 leading-tight tracking-tight" dat
255255
[meeting]="meeting()"
256256
[currentOccurrence]="currentOccurrence()"
257257
[pastMeeting]="pastMeeting()"
258-
[showAddModal]="!pastMeeting()"
258+
[showAddButton]="!pastMeeting()"
259259
[additionalRegistrantsCount]="additionalRegistrantsCount()">
260260
</lfx-meeting-rsvp-details>
261261
} @else if (!pastMeeting()) {

apps/lfx-one/src/app/modules/meetings/components/meeting-card/meeting-card.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import { Clipboard, ClipboardModule } from '@angular/cdk/clipboard';
55
import { CommonModule } from '@angular/common';
66
import { Component, computed, effect, inject, Injector, input, OnInit, output, runInInjectionContext, signal, Signal, WritableSignal } from '@angular/core';
7-
import { Router } from '@angular/router';
87
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
8+
import { Router } from '@angular/router';
99
import {
1010
MeetingDeleteConfirmationComponent,
1111
MeetingDeleteResult,
@@ -24,6 +24,7 @@ import { environment } from '@environments/environment';
2424
import {
2525
buildJoinUrlWithParams,
2626
canJoinMeeting,
27+
ComponentSeverity,
2728
DEFAULT_MEETING_TYPE_CONFIG,
2829
getCurrentOrNextOccurrence,
2930
Meeting,
@@ -120,7 +121,7 @@ export class MeetingCardComponent implements OnInit {
120121
public readonly enabledFeaturesCount: Signal<number> = this.initEnabledFeaturesCount();
121122
public readonly meetingTypeBadge: Signal<{
122123
badgeClass: string;
123-
severity: 'info' | 'success' | 'warn' | 'danger' | 'secondary' | 'contrast';
124+
severity: ComponentSeverity;
124125
icon?: string;
125126
text: string;
126127
} | null> = this.initMeetingTypeBadge();
@@ -558,7 +559,7 @@ export class MeetingCardComponent implements OnInit {
558559

559560
private initMeetingTypeBadge(): Signal<{
560561
badgeClass: string;
561-
severity: 'info' | 'success' | 'warn' | 'danger' | 'secondary' | 'contrast';
562+
severity: ComponentSeverity;
562563
icon?: string;
563564
text: string;
564565
} | null> {
@@ -576,7 +577,7 @@ export class MeetingCardComponent implements OnInit {
576577
case 'marketing':
577578
return { badgeClass: 'bg-green-100 text-green-500', severity: 'success', icon: 'fa-light fa-chart-line-up', text: meetingType };
578579
case 'technical':
579-
return { badgeClass: 'bg-purple-100 text-purple-500', severity: 'contrast', icon: 'fa-light fa-code', text: meetingType };
580+
return { badgeClass: 'bg-purple-100 text-purple-500', severity: 'primary', icon: 'fa-light fa-code', text: meetingType };
580581
case 'legal':
581582
return { badgeClass: 'bg-amber-100 text-amber-500', severity: 'warn', icon: 'fa-light fa-scale-balanced', text: meetingType };
582583
default:

apps/lfx-one/src/app/modules/meetings/components/meeting-rsvp-details/meeting-rsvp-details.component.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,7 @@
88
<i class="fa-light fa-users text-xs"></i>
99
<span>{{ pastMeeting() ? 'Attendees' : 'People Invited' }}</span>
1010
</div>
11-
@if (showAddLink()) {
12-
<lfx-button
13-
icon="fa-light fa-user-plus text-xs"
14-
label="Add"
15-
size="small"
16-
severity="secondary"
17-
[attr.data-testid]="'add-participant-button'"
18-
[routerLink]="editLink() || []">
19-
</lfx-button>
20-
}
21-
@if (showAddModal()) {
11+
@if (showAddButton()) {
2212
<lfx-button
2313
icon="fa-light fa-user-plus text-xs"
2414
label="Add"

0 commit comments

Comments
 (0)