Skip to content

Commit 525af46

Browse files
Merge branch 'main' into sort-icon
2 parents 431caef + 9fa4519 commit 525af46

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

projects/components/src/select/select-option.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export class SelectOptionComponent<V> implements OnChanges, SelectOption<V> {
1515
@Input()
1616
public label!: string;
1717

18+
@Input()
19+
public selectedLabel?: string;
20+
1821
@Input()
1922
public style: SelectOptionStyle = SelectOptionStyle.Default;
2023

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export interface SelectOption<V> {
22
value: V;
33
label: string;
4+
selectedLabel?: string;
45
icon?: string;
56
iconColor?: string;
67
}

projects/components/src/select/select.component.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ describe('Select Component', () => {
2727
const selectionOptions = [
2828
{ label: 'first', value: 'first-value' },
2929
{ label: 'second', value: 'second-value' },
30-
{ label: 'third', value: 'third-value' }
30+
{ label: 'third', value: 'third-value', selectedLabel: 'Third Value!!!' }
3131
];
3232

33-
test('should display intial selection', fakeAsync(() => {
33+
test('should display initial selection', fakeAsync(() => {
3434
spectator = hostFactory(
3535
`
3636
<ht-select [selected]="selected">
@@ -127,7 +127,7 @@ describe('Select Component', () => {
127127
spectator = hostFactory(
128128
`
129129
<ht-select [selected]="selected" (selectedChange)="onChange($event)">
130-
<ht-select-option *ngFor="let option of options" [label]="option.label" [value]="option.value">
130+
<ht-select-option *ngFor="let option of options" [label]="option.label" [value]="option.value" [selectedLabel]="option.selectedLabel">
131131
</ht-select-option>
132132
</ht-select>`,
133133
{
@@ -140,14 +140,15 @@ describe('Select Component', () => {
140140
);
141141

142142
spectator.tick();
143+
expect(spectator.query('.trigger-content')).toHaveText(selectionOptions[1].label);
143144
spectator.click('.trigger-content');
144145

145146
const optionElements = spectator.queryAll('.select-option', { root: true });
146147
spectator.click(optionElements[2]);
147148

148149
expect(onChange).toHaveBeenCalledTimes(1);
149150
expect(onChange).toHaveBeenCalledWith(selectionOptions[2].value);
150-
expect(spectator.element).toHaveText(selectionOptions[2].label);
151+
expect(spectator.query('.trigger-content')).toHaveText(selectionOptions[2].selectedLabel!);
151152
flush();
152153
}));
153154

projects/components/src/select/select.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ import { SelectSize } from './select-size';
5454
>
5555
<ht-icon *ngIf="this.icon" class="trigger-prefix-icon" [icon]="this.icon" [size]="this.iconSize">
5656
</ht-icon>
57-
<ht-label class="trigger-label" [label]="selected?.label || this.placeholder"> </ht-label>
57+
<ht-label class="trigger-label" [label]="selected?.selectedLabel || selected?.label || this.placeholder">
58+
</ht-label>
5859
<ht-icon class="trigger-icon" icon="${IconType.ChevronDown}" size="${IconSize.ExtraSmall}"> </ht-icon>
5960
</div>
6061
<div

projects/distributed-tracing/src/shared/dashboard/dashboard-wrapper/navigable-dashboard.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
2-
import { TypedSimpleChanges } from '@hypertrace/common';
2+
import { Dictionary, TypedSimpleChanges } from '@hypertrace/common';
33
import { Filter } from '@hypertrace/components';
44
import { DashboardPersistenceService } from '@hypertrace/dashboards';
55
import { Dashboard, ModelJson } from '@hypertrace/hyperdash';
@@ -37,10 +37,13 @@ import { GraphQlFilterDataSourceModel } from '../data/graphql/filter/graphql-fil
3737
})
3838
export class NavigableDashboardComponent implements OnChanges {
3939
@Input()
40-
public readonly defaultJson?: ModelJson;
40+
public navLocation?: string | null;
4141

4242
@Input()
43-
public navLocation?: string | null;
43+
public defaultJson?: ModelJson;
44+
45+
@Input()
46+
public variables?: Dictionary<unknown>;
4447

4548
@Input()
4649
public filterConfig?: NavigableDashboardFilterConfig;
@@ -89,6 +92,7 @@ export class NavigableDashboardComponent implements OnChanges {
8992

9093
public onDashboardReady(dashboard: Dashboard): void {
9194
this.dashboard = dashboard;
95+
this.applyVariablesToDashboard(this.dashboard, this.variables);
9296
this.applyFiltersToDashboard(dashboard, this.explicitFilters);
9397
this.dashboardReady.emit(dashboard);
9498
}
@@ -100,6 +104,12 @@ export class NavigableDashboardComponent implements OnChanges {
100104
}
101105
}
102106

107+
public applyVariablesToDashboard(dashboard: Dashboard, variables: Dictionary<unknown> = {}): void {
108+
for (const key of Object.keys(variables)) {
109+
dashboard.setVariable(key, variables[key]);
110+
}
111+
}
112+
103113
public applyFiltersToDashboard(dashboard: Dashboard, explicitFilters: Filter[]): void {
104114
const rootDataSource = dashboard.getRootDataSource<GraphQlFilterDataSourceModel>();
105115
rootDataSource

0 commit comments

Comments
 (0)