@@ -8,7 +8,14 @@ import {
8
8
QueryList
9
9
} from '@angular/core' ;
10
10
import { ActivatedRoute } from '@angular/router' ;
11
- import { Color , FeatureState , NavigationParams , NavigationParamsType , NavigationService } from '@hypertrace/common' ;
11
+ import {
12
+ Color ,
13
+ FeatureState ,
14
+ NavigationParams ,
15
+ NavigationParamsType ,
16
+ NavigationService ,
17
+ queryListAndChanges$
18
+ } from '@hypertrace/common' ;
12
19
import { merge , Observable } from 'rxjs' ;
13
20
import { distinctUntilChanged , map , startWith , tap } from 'rxjs/operators' ;
14
21
import { NavigableTabComponent } from './navigable-tab.component' ;
@@ -20,7 +27,7 @@ import { NavigableTabComponent } from './navigable-tab.component';
20
27
template : `
21
28
<div class="tab-group">
22
29
<nav mat-tab-nav-bar *htLetAsync="this.activeTab$ as activeTab" disableRipple>
23
- <ng-container *ngFor="let tab of this.tabs">
30
+ <ng-container *ngFor="let tab of this.tabs$ | async ">
24
31
<ng-container *ngIf="!tab.hidden">
25
32
<div class="tab-button" *htIfFeature="tab.featureFlags | htFeature as featureState">
26
33
<ht-link
@@ -53,19 +60,21 @@ import { NavigableTabComponent } from './navigable-tab.component';
53
60
} )
54
61
export class NavigableTabGroupComponent implements AfterContentInit {
55
62
@ContentChildren ( NavigableTabComponent )
56
- public tabs ! : QueryList < NavigableTabComponent > ;
63
+ private readonly tabs ! : QueryList < NavigableTabComponent > ;
57
64
58
65
@Output ( )
59
66
public readonly tabChange : EventEmitter < string | undefined > = new EventEmitter < string | undefined > ( ) ;
60
67
61
68
public activeTab$ ?: Observable < NavigableTabComponent | undefined > ;
69
+ public tabs$ ! : Observable < NavigableTabComponent [ ] > ;
62
70
63
71
public constructor (
64
72
public readonly navigationService : NavigationService ,
65
73
private readonly activatedRoute : ActivatedRoute
66
74
) { }
67
75
68
76
public ngAfterContentInit ( ) : void {
77
+ this . tabs$ = queryListAndChanges$ ( this . tabs ) . pipe ( map ( list => list . toArray ( ) ) ) ;
69
78
this . activeTab$ = merge ( this . navigationService . navigation$ , this . tabs . changes ) . pipe (
70
79
startWith ( undefined ) ,
71
80
map ( ( ) => this . findActiveTab ( ) ) ,
0 commit comments