Skip to content

Commit 16105dc

Browse files
committed
address pr comments
1 parent 3cfa943 commit 16105dc

File tree

6 files changed

+35
-43
lines changed

6 files changed

+35
-43
lines changed

tensorboard/webapp/widgets/data_table/BUILD

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ tf_ng_module(
153153
"//tensorboard/webapp/widgets/range_input:types",
154154
"@npm//@angular/common",
155155
"@npm//@angular/core",
156-
"@npm//@angular/forms",
157156
],
158157
)
159158

@@ -179,6 +178,8 @@ tf_ts_library(
179178
":data_table",
180179
":filter_dialog",
181180
":types",
181+
"//tensorboard/webapp/angular:expect_angular_cdk_testing",
182+
"//tensorboard/webapp/angular:expect_angular_cdk_testing_testbed",
182183
"//tensorboard/webapp/angular:expect_angular_core_testing",
183184
"//tensorboard/webapp/angular:expect_angular_material_checkbox",
184185
"//tensorboard/webapp/angular:expect_angular_platform_browser_animations",

tensorboard/webapp/widgets/data_table/filter_dialog_component.ng.html

-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
</div>
3131
<div
3232
*ngFor="let value of getPossibleValues(); index"
33-
mat-menu-item
34-
class="filter-menu-checkbox-row"
35-
role="menuitemcheckbox"
3633
(click)="$event.stopPropagation()"
3734
>
3835
<mat-checkbox
@@ -48,7 +45,6 @@
4845
(click)="$event.stopPropagation()"
4946
class="range-input-container"
5047
disableRipple
51-
mat-menu-item
5248
>
5349
<tb-range-input
5450
[min]="filter.minValue"

tensorboard/webapp/widgets/data_table/filter_dialog_component.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ limitations under the License.
3737
}
3838

3939
.no-matches {
40-
// 24px is the width of the checkbox so the text should match the
40+
// 12px is the width of the checkbox so the text should match the
4141
// indentation of the selectable filters.
42-
padding: 8px 24px;
42+
padding: 8px 12px;
4343
}
4444
}

tensorboard/webapp/widgets/data_table/filter_dialog_module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ limitations under the License.
1616
import {NgModule} from '@angular/core';
1717
import {FilterDialog} from './filter_dialog_component';
1818
import {CommonModule} from '@angular/common';
19-
import {FormsModule} from '@angular/forms';
2019
import {MatCheckboxModule} from '@angular/material/checkbox';
2120
import {RangeInputModule} from '../range_input/range_input_module';
2221
import {FilterInputModule} from '../filter_input/filter_input_module';
@@ -26,7 +25,6 @@ import {FilterInputModule} from '../filter_input/filter_input_module';
2625
imports: [
2726
CommonModule,
2827
MatCheckboxModule,
29-
FormsModule,
3028
FilterInputModule,
3129
RangeInputModule,
3230
],

tensorboard/webapp/widgets/data_table/filter_dialog_test.ts

+30-22
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,36 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515
import {TestBed} from '@angular/core/testing';
16+
import {HarnessLoader} from '@angular/cdk/testing';
17+
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
1618
import {DataTableModule} from './data_table_module';
1719
import {FilterDialog} from './filter_dialog_component';
1820
import {DiscreteFilter, DomainType, IntervalFilter} from './types';
1921
import {By} from '@angular/platform-browser';
2022
import {RangeInputComponent} from '../range_input/range_input_component';
2123
import {RangeInputModule} from '../range_input/range_input_module';
22-
import {MatLegacyCheckboxModule} from '@angular/material/legacy-checkbox';
24+
import {MatCheckboxModule} from '@angular/material/checkbox';
25+
import {MatCheckboxHarness} from '@angular/material/checkbox/testing';
2326

2427
describe('filter dialog', () => {
28+
let rootLoader: HarnessLoader;
29+
2530
beforeEach(async () => {
2631
await TestBed.configureTestingModule({
2732
declarations: [FilterDialog],
28-
imports: [DataTableModule, RangeInputModule, MatLegacyCheckboxModule],
33+
imports: [DataTableModule, RangeInputModule, MatCheckboxModule],
2934
}).compileComponents();
3035
});
3136

3237
function createComponent(input: {filter: DiscreteFilter | IntervalFilter}) {
3338
const fixture = TestBed.createComponent(FilterDialog);
3439
fixture.componentInstance.filter = input.filter;
40+
rootLoader = TestbedHarnessEnvironment.documentRootLoader(fixture);
3541
fixture.detectChanges();
3642
return fixture;
3743
}
3844

39-
it('dispatches event when an interval filter value is changed', () => {
45+
it('dispatches event when an interval filter value is changed', async () => {
4046
const fixture = createComponent({
4147
filter: {
4248
type: DomainType.INTERVAL,
@@ -66,16 +72,15 @@ describe('filter dialog', () => {
6672
fixture.componentInstance.includeUndefinedToggled,
6773
'emit'
6874
);
69-
const includeUndefinedCheckbox = Array.from(
70-
fixture.debugElement.queryAll(By.css('mat-checkbox'))
71-
).find((elem) =>
72-
elem.nativeElement.innerHTML.includes('Include Undefined')
73-
)!;
74-
includeUndefinedCheckbox.query(By.css('label')).nativeElement.click();
75+
76+
const includeUndefinedCheckbox = await rootLoader.getHarness(
77+
MatCheckboxHarness.with({label: 'Include Undefined'})
78+
);
79+
await includeUndefinedCheckbox.check();
7580
expect(includeUndefinedSpy).toHaveBeenCalled();
7681
});
7782

78-
it('dispatches event when an discrete filter value is changed', () => {
83+
it('dispatches event when an discrete filter value is changed', async () => {
7984
const fixture = createComponent({
8085
filter: {
8186
type: DomainType.DISCRETE,
@@ -84,29 +89,32 @@ describe('filter dialog', () => {
8489
filterValues: [2, 4, 6],
8590
},
8691
});
87-
const discreteFilterChagnedSpy = spyOn(
92+
const discreteFilterChangedSpy = spyOn(
8893
fixture.componentInstance.discreteFilterChanged,
8994
'emit'
9095
);
96+
const checkbox = await rootLoader.getHarness(
97+
MatCheckboxHarness.with({label: '2'})
98+
);
99+
await checkbox.uncheck();
91100
fixture.debugElement
92101
.query(By.css('mat-checkbox label'))
93102
.nativeElement.click();
94-
expect(discreteFilterChagnedSpy).toHaveBeenCalled();
103+
expect(discreteFilterChangedSpy).toHaveBeenCalled();
95104

96105
const includeUndefinedSpy = spyOn(
97106
fixture.componentInstance.includeUndefinedToggled,
98107
'emit'
99108
);
100-
const includeUndefinedCheckbox = Array.from(
101-
fixture.debugElement.queryAll(By.css('mat-checkbox'))
102-
).find((elem) =>
103-
elem.nativeElement.innerHTML.includes('Include Undefined')
104-
)!;
105-
includeUndefinedCheckbox.query(By.css('label')).nativeElement.click();
109+
110+
const includeUndefinedCheckbox = await rootLoader.getHarness(
111+
MatCheckboxHarness.with({label: 'Include Undefined'})
112+
);
113+
await includeUndefinedCheckbox.check();
106114
expect(includeUndefinedSpy).toHaveBeenCalled();
107115
});
108116

109-
it('filters discrete values', () => {
117+
it('filters discrete values', async () => {
110118
const fixture = createComponent({
111119
filter: {
112120
type: DomainType.DISCRETE,
@@ -116,19 +124,19 @@ describe('filter dialog', () => {
116124
},
117125
});
118126
expect(
119-
fixture.debugElement.queryAll(By.css('mat-checkbox')).length
127+
(await rootLoader.getAllHarnesses(MatCheckboxHarness)).length
120128
).toEqual(5); // 4 options + the include undefined checkbox
121129

122130
fixture.componentInstance.discreteValueFilter = 'ba';
123131
fixture.detectChanges();
124132
expect(
125-
fixture.debugElement.queryAll(By.css('mat-checkbox')).length
133+
(await rootLoader.getAllHarnesses(MatCheckboxHarness)).length
126134
).toEqual(3); // 2 options + the include undefined checkbox
127135

128136
fixture.componentInstance.discreteValueFilter = 'nothing matches me';
129137
fixture.detectChanges();
130138
expect(
131-
fixture.debugElement.queryAll(By.css('mat-checkbox')).length
139+
(await rootLoader.getAllHarnesses(MatCheckboxHarness)).length
132140
).toEqual(1); // 0 options + the include undefined checkbox
133141
expect(fixture.nativeElement.innerHTML).toContain('No Matching Values');
134142
});

tensorboard/webapp/widgets/data_table/types.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
1615
/**
1716
* This enum defines the columns available in the data table. The
1817
* ScalarCardComponent must know which piece of data is associated with each
@@ -60,12 +59,6 @@ export interface DiscreteFilter {
6059
filterValues: DiscreteFilterValues;
6160
}
6261

63-
export interface DiscreteFilterChange {
64-
hparamName: string;
65-
includeUndefined: boolean;
66-
filterValues: DiscreteFilterValues;
67-
}
68-
6962
export interface IntervalFilter {
7063
type: DomainType.INTERVAL;
7164
includeUndefined: boolean;
@@ -76,11 +69,6 @@ export interface IntervalFilter {
7669
filterUpperValue: number;
7770
}
7871

79-
export interface FilterAddedEvent {
80-
header: ColumnHeader;
81-
value: IntervalFilter | DiscreteFilter;
82-
}
83-
8472
export interface ColumnHeader {
8573
type: ColumnHeaderType;
8674
name: string;
@@ -91,6 +79,7 @@ export interface ColumnHeader {
9179
removable?: boolean;
9280
sortable?: boolean;
9381
movable?: boolean;
82+
filterable?: boolean;
9483
}
9584

9685
export enum SortingOrder {

0 commit comments

Comments
 (0)