Skip to content

Commit 0e86804

Browse files
committed
TT-52 feat: add toggle flag
1 parent ed579b6 commit 0e86804

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/app/modules/shared/components/sidebar/sidebar.component.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {ItemSidebar} from './models/item-sidebar.model';
44
import {NavigationStart, Router} from '@angular/router';
55
import {Observable} from 'rxjs';
66
import {filter} from 'rxjs/operators';
7+
import { FeatureManagerService } from '../../feature-toggles/feature-toggle-manager.service';
78

89
@Component({
910
selector: 'app-sidebar',
@@ -15,7 +16,11 @@ export class SidebarComponent implements OnInit {
1516
itemsSidebar: ItemSidebar[] = [];
1617
navStart;
1718

18-
constructor(private azureAdB2CService: AzureAdB2CService, private router: Router) {
19+
constructor(
20+
private azureAdB2CService: AzureAdB2CService,
21+
private router: Router,
22+
private featureManagerService : FeatureManagerService,
23+
) {
1924
this.navStart = this.router.events.pipe(
2025
filter(evt => evt instanceof NavigationStart)
2126
) as Observable<NavigationStart>;
@@ -24,6 +29,7 @@ export class SidebarComponent implements OnInit {
2429
ngOnInit(): void {
2530
this.toggleSideBar();
2631
this.getSidebarItems();
32+
this.toggleListTechnologies(this.itemsSidebar);
2733
this.highlightMenuOption(this.router.routerState.snapshot.url);
2834
this.navStart.subscribe(evt => {
2935
this.highlightMenuOption(evt.url);
@@ -46,7 +52,6 @@ export class SidebarComponent implements OnInit {
4652
{route: '/activities-management', icon: 'fas fa-file-alt', text: 'Activities', active: false},
4753
{route: '/customers-management', icon: 'fas fa-user', text: 'Customers', active: false},
4854
{route: '/users', icon: 'fas fa-user', text: 'Users', active: false},
49-
{route: '/technology-report', icon: 'fas fa-user', text: 'Technology Report', active: false},
5055
];
5156
} else {
5257
this.itemsSidebar = [
@@ -56,6 +61,23 @@ export class SidebarComponent implements OnInit {
5661
}
5762
}
5863

64+
toggleListTechnologies(itemsSidebar: ItemSidebar[]){
65+
this.featureManagerService
66+
.isToggleEnabledForUser('ui-list-technologies')
67+
.subscribe((enabled) => {
68+
console.log('enabled?:', enabled);
69+
if (enabled === true){
70+
const listTechnologiesItem = {
71+
route: '/technology-report',
72+
icon: 'fas fa-user',
73+
text: 'Technology Report',
74+
active: false
75+
};
76+
itemsSidebar.push(listTechnologiesItem);
77+
};
78+
});
79+
}
80+
5981
highlightMenuOption(route) {
6082
this.itemsSidebar.map(item => item.active = false);
6183
this.itemsSidebar.filter(item => item.route === route).map(item => item.active = true);

0 commit comments

Comments
 (0)