Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { IconType } from '@hypertrace/assets-library';
import { Color, NavigationService } from '@hypertrace/common';
Expand All @@ -25,7 +25,7 @@ import { IconSize } from '../icon/icon-size';
<hr *ngSwitchCase="'${NavItemType.Divider}'" class="nav-divider" />

<ng-container *ngSwitchCase="'${NavItemType.Link}'">
<ht-nav-item [config]="item" [active]="item === activeItem" [collapsed]="this.collapsed"> </ht-nav-item>
<ht-nav-item [config]="item" [active]="item === activeItem" [collapsed]="this.collapsed"></ht-nav-item>
</ng-container>
</ng-container>
</ng-container>
Expand All @@ -48,7 +48,7 @@ import { IconSize } from '../icon/icon-size';
</nav>
`
})
export class NavigationListComponent {
export class NavigationListComponent implements OnChanges {
@Input()
public navItems: NavItemConfig[] = [];

Expand All @@ -64,12 +64,14 @@ export class NavigationListComponent {
@Output()
public readonly collapsedChange: EventEmitter<boolean> = new EventEmitter();

public readonly activeItem$: Observable<NavItemLinkConfig | undefined>;
public activeItem$?: Observable<NavItemLinkConfig | undefined>;

public constructor(
private readonly navigationService: NavigationService,
private readonly activatedRoute: ActivatedRoute
) {
) {}

public ngOnChanges(): void {
this.activeItem$ = this.navigationService.navigation$.pipe(
startWith(this.navigationService.getCurrentActivatedRoute()),
map(() => this.findActiveItem(this.navItems))
Expand Down