Skip to content

Commit f249374

Browse files
authored
Linked Time: Conditionally remove fob deselect button (#6016)
* Motivation for features / changes It does not make sense for a prospective fob to have a deselect button * Technical description of changes Add a prop to the card fob component which controls the appearance of the deselect button. * Screenshots of UI changes None * Detailed steps to verify changes work correctly (as executed by you) There should be no changes.
1 parent 9921d64 commit f249374

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

tensorboard/webapp/widgets/card_fob/card_fob_component.ng.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
(keydown.enter)="stepTyped($event)"
2828
(keydown.shift.enter)="$event.preventDefault()"
2929
></span>
30-
<button aria-label="Deselect fob" (click)="fobRemoved.emit()">
30+
<button
31+
*ngIf="allowRemoval"
32+
aria-label="Deselect fob"
33+
(click)="fobRemoved.emit()"
34+
>
3135
<mat-icon svgIcon="close_24px"></mat-icon>
3236
</button>
3337
</div>

tensorboard/webapp/widgets/card_fob/card_fob_component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export class CardFobComponent {
3636

3737
@Input() step!: number;
3838

39+
@Input() allowRemoval?: boolean = true;
40+
3941
@Output() stepChanged = new EventEmitter<number | null>();
4042
@Output() fobRemoved = new EventEmitter();
4143

tensorboard/webapp/widgets/card_fob/card_fob_test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {AxisDirection} from './card_fob_types';
2626
#Fob
2727
[axisDirection]="axisDirection"
2828
[step]="step"
29+
[allowRemoval]="allowRemoval"
2930
(stepChanged)="stepChanged($event)"
3031
></card-fob>
3132
`,
@@ -36,6 +37,7 @@ class TestableFobComponent {
3637

3738
@Input() step!: number;
3839
@Input() axisDirection!: AxisDirection;
40+
@Input() allowRemoval: boolean = true;
3941

4042
@Input() stepChanged!: (newStep: number) => void;
4143
}
@@ -52,13 +54,17 @@ describe('card fob', () => {
5254

5355
function createFobComponent(input: {
5456
step?: number;
57+
allowRemoval?: boolean;
5558
axisDirection?: AxisDirection;
5659
}): ComponentFixture<TestableFobComponent> {
5760
const fixture = TestBed.createComponent(TestableFobComponent);
5861
fixture.componentInstance.step = input.step ? input.step : 1;
5962
fixture.componentInstance.axisDirection = input.axisDirection
6063
? input.axisDirection
6164
: AxisDirection.HORIZONTAL;
65+
if (input.allowRemoval !== undefined) {
66+
fixture.componentInstance.allowRemoval = input.allowRemoval;
67+
}
6268

6369
stepChangedSpy = jasmine.createSpy();
6470
fixture.componentInstance.stepChanged = stepChangedSpy;
@@ -74,6 +80,14 @@ describe('card fob', () => {
7480
expect(stepSpan.nativeElement.innerText).toBe('3');
7581
});
7682

83+
it('does not render deselect button when allowRemoval is false', () => {
84+
const fixture = createFobComponent({
85+
allowRemoval: false,
86+
});
87+
fixture.detectChanges();
88+
expect(fixture.debugElement.query(By.css('button'))).toBeNull();
89+
});
90+
7791
it('emits stepChange when pressing enter key', () => {
7892
const fixture = createFobComponent({});
7993
fixture.detectChanges();

0 commit comments

Comments
 (0)