Skip to content

Commit 743a42d

Browse files
authored
feat(ui): update persona selector visibility logic (#171)
Update persona selector to show when either persona is not autodetected OR user has role-selector feature flag enabled. This provides more flexibility in controlling persona selector visibility. Changes: - Inject FeatureFlagService into persona-selector component - Add shouldShowSelector computed signal combining both conditions - Update template to use new visibility logic - Remove redundant conditional wrapper in sidebar component LFXV2-777 Signed-off-by: Asitha de Silva <asithade@gmail.com>
1 parent 39e2959 commit 743a42d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

apps/lfx-one/src/app/shared/components/persona-selector/persona-selector.component.html

Lines changed: 1 addition & 1 deletion
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-
@if (!isAutoDetected()) {
4+
@if (shouldShowSelector()) {
55
<div class="persona-selector" data-testid="persona-selector">
66
<lfx-select [form]="form" control="persona" [options]="personaOptions" optionLabel="label" optionValue="value" size="small"></lfx-select>
77
</div>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright The Linux Foundation and each contributor to LFX.
22
// SPDX-License-Identifier: MIT
33

4-
import { Component, inject } from '@angular/core';
4+
import { Component, computed, inject } from '@angular/core';
55
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
66
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
77
import { SelectComponent } from '@components/select/select.component';
88
import { PERSONA_OPTIONS } from '@lfx-one/shared/constants';
99
import { PersonaType } from '@lfx-one/shared/interfaces';
10+
import { FeatureFlagService } from '@services/feature-flag.service';
1011
import { PersonaService } from '@services/persona.service';
1112
import { ProjectContextService } from '@services/project-context.service';
1213

@@ -19,10 +20,16 @@ import { ProjectContextService } from '@services/project-context.service';
1920
export class PersonaSelectorComponent {
2021
private readonly personaService = inject(PersonaService);
2122
private readonly projectContextService = inject(ProjectContextService);
23+
private readonly featureFlagService = inject(FeatureFlagService);
24+
2225
// Persona options available for selection
2326
protected readonly personaOptions = PERSONA_OPTIONS;
2427
// Whether persona is auto-detected (read-only)
2528
protected readonly isAutoDetected = this.personaService.isAutoDetected;
29+
// Feature flag for role selector
30+
protected readonly showRoleSelector = this.featureFlagService.getBooleanFlag('role-selector', true);
31+
// Show selector if not autodetected OR feature flag is enabled
32+
protected readonly shouldShowSelector = computed(() => !this.isAutoDetected() || this.showRoleSelector());
2633

2734
public form: FormGroup;
2835

apps/lfx-one/src/app/shared/components/sidebar/sidebar.component.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
<!-- Bottom Navigation -->
3535
<div class="flex flex-col gap-2 items-start px-3 w-full">
3636
<!-- Persona Selector -->
37-
@if (showRoleSelector()) {
38-
<div class="w-full mb-2">
39-
<lfx-persona-selector></lfx-persona-selector>
40-
</div>
41-
}
37+
<div class="w-full mb-2">
38+
<lfx-persona-selector></lfx-persona-selector>
39+
</div>
4240

4341
@if (footerItems().length > 0) {
4442
@for (item of footerItemsWithTestIds(); track item.label) {

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { BadgeComponent } from '@components/badge/badge.component';
99
import { PersonaSelectorComponent } from '@components/persona-selector/persona-selector.component';
1010
import { ProjectSelectorComponent } from '@components/project-selector/project-selector.component';
1111
import { Project, ProjectContext, SidebarMenuItem } from '@lfx-one/shared/interfaces';
12-
import { FeatureFlagService } from '@services/feature-flag.service';
1312
import { PersonaService } from '@services/persona.service';
1413
import { ProjectContextService } from '@services/project-context.service';
1514
import { ProjectService } from '@services/project.service';
@@ -26,7 +25,6 @@ export class SidebarComponent {
2625
private readonly projectService = inject(ProjectService);
2726
private readonly projectContextService = inject(ProjectContextService);
2827
private readonly personaService = inject(PersonaService);
29-
private readonly featureFlagService = inject(FeatureFlagService);
3028

3129
// Input properties
3230
public readonly items = input.required<SidebarMenuItem[]>();
@@ -35,9 +33,6 @@ export class SidebarComponent {
3533
public readonly styleClass = input<string>('');
3634
public readonly showProjectSelector = input<boolean>(false);
3735

38-
// Feature flags
39-
protected readonly showRoleSelector = this.featureFlagService.getBooleanFlag('role-selector', true);
40-
4136
// Load all projects using toSignal with tap to set default
4237
protected readonly projects = toSignal(
4338
this.projectService.getProjects().pipe(

0 commit comments

Comments
 (0)