Skip to content

Commit 3e27ccd

Browse files
Googlercopybara-github
authored andcommitted
Show view switcher in the control bar under CLL on graph experiment.
PiperOrigin-RevId: 740735248
1 parent 15bcf7e commit 3e27ccd

5 files changed

Lines changed: 58 additions & 8 deletions

File tree

-2.38 KB
Loading
9.76 KB
Loading

src/app/toolbar.ng.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<nav [ngClass]="['toolbar', graphState]">
22
<ng-container *ngFor="let customToggleTemplate of leftAlignedCustomToolbarToggleTemplates">
3-
<div class="cell toggler">
3+
<div
4+
class="cell toggler"
5+
[class.flex]="customToggleTemplate == fillerCustomToolbarToggleTemplate"
6+
>
47
<ng-container
58
*ngTemplateOutlet="customToggleTemplate; context: {
69
nodes,
@@ -9,7 +12,7 @@
912
></ng-container>
1013
</div>
1114
</ng-container>
12-
<div *ngIf="rightAlignMainControls" class="flex"></div>
15+
<div *ngIf="fillerCustomToolbarToggleTemplate == null && rightAlignMainControls" class="flex"></div>
1316
<ng-container *ngVar="labelGenerator(this, 'graphState') as label">
1417
<div class="cell state" *ngIf="label !== false">
1518
<workflow-graph-icon icon="info"></workflow-graph-icon>
@@ -138,7 +141,10 @@
138141
</button>
139142
</div>
140143
<ng-container *ngFor="let customToggleTemplate of customToolbarToggleTemplates">
141-
<div class="cell toggler">
144+
<div
145+
class="cell toggler"
146+
[class.flex]="customToggleTemplate == fillerCustomToolbarToggleTemplate"
147+
>
142148
<ng-container
143149
*ngTemplateOutlet="customToggleTemplate; context: {
144150
nodes,
@@ -147,9 +153,12 @@
147153
></ng-container>
148154
</div>
149155
</ng-container>
150-
<div *ngIf="!rightAlignMainControls" class="flex"></div>
156+
<div *ngIf="fillerCustomToolbarToggleTemplate == null && !rightAlignMainControls" class="flex"></div>
151157
<ng-container *ngFor="let customToggleTemplate of rightAlignedCustomToolbarToggleTemplates">
152-
<div class="cell toggler">
158+
<div
159+
class="cell toggler"
160+
[class.flex]="customToggleTemplate == fillerCustomToolbarToggleTemplate"
161+
>
153162
<ng-container *ngTemplateOutlet="customToggleTemplate; context: {
154163
nodes,
155164
groups

src/app/toolbar.spec.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ describe('DagToolbar', () => {
8686
});
8787
});
8888

89+
describe('With filler template', () => {
90+
beforeEach(fakeAsync(() => {
91+
fixture.componentInstance.enableFillerTemplate();
92+
fixture.detectChanges();
93+
}));
94+
95+
it('Renders correctly (screenshot)', async () => {
96+
await screenShot.expectMatch('renders_correctly_with_filler_template');
97+
});
98+
});
99+
89100
it('Calculated node states correctly', () => {
90101
expect(toolbar.graphState).toBe('Runtime');
91102
expect(toolbar.completedSteps).toBe(1);
@@ -158,33 +169,53 @@ describe('DagToolbar', () => {
158169
[nodes]="nodes" [expanded]="true"
159170
[rightAlignedCustomToolbarToggleTemplates]="rightAlignedTemplates"
160171
[features]="features"
172+
[fillerCustomToolbarToggleTemplate]="fillerTemplate"
161173
></ai-dag-toolbar>
162174
</div>
163175
<ng-template #rightAlignedTemplate>
164176
<button id="rightButton"> Click me</button>
177+
</ng-template>
178+
<ng-template #rectangleTemplate>
179+
<div class="rectangle"></div>
165180
</ng-template>`,
166181
providers: [
167182
// STATE_SERVICE_PROVIDER,
168183
],
169184
styles: [`
170185
.container {
171-
height: 400px;
172-
width: 400px;
186+
height: 100px;
187+
width: 1200px;
188+
background-color: gray;
189+
}
190+
.rectangle {
191+
background-color: red;
192+
min-width: 50px;
193+
flex-grow: 1;
194+
height: 30px;
173195
}`],
196+
174197
// TODO: Make this AOT compatible. See b/352713444
175198
jit: true,
176-
177199
})
178200
class TestComponent {
179201
@ViewChild('dagToolbar', {static: false}) dagToolbar!: DagToolbar;
180202
nodes: DagNode[] = FAKE_DATA;
181203
@ViewChild('rightAlignedTemplate', {static: false})
182204
rightAlignedTemplate?: TemplateRef<{}>;
205+
@ViewChild('rectangleTemplate', {static: false})
206+
rectangleTemplate?: TemplateRef<{}>;
183207

184208
rightAlignedTemplates: Array<TemplateRef<{}>> = [];
185209

210+
fillerTemplate: TemplateRef<{}>|null = null;
211+
212+
enableFillerTemplate() {
213+
this.fillerTemplate = this.rectangleTemplate!;
214+
}
215+
186216
ngAfterViewInit() {
187217
this.rightAlignedTemplates.push(this.rightAlignedTemplate!);
218+
this.rightAlignedTemplates.push(this.rectangleTemplate!);
188219
}
189220

190221
features = {...defaultFeatures, enableShortcuts: true};

src/app/toolbar.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class DagToolbar {
134134
private $customToolbarToggleTemplates: TemplateRef<any>[] = [];
135135
private $leftAlignedCustomToolbarToggleTemplates: TemplateRef<any>[] = [];
136136
private $rightAlignedCustomToolbarToggleTemplates: TemplateRef<any>[] = [];
137+
private $fillerCustomToolbarToggleTemplate: TemplateRef<any>|null = null;
137138

138139
@Input() enableMinimap = true;
139140
@Output() enableMinimapChange = new EventEmitter();
@@ -222,6 +223,15 @@ export class DagToolbar {
222223
return this.$rightAlignedCustomToolbarToggleTemplates;
223224
}
224225

226+
@Input('fillerCustomToolbarToggleTemplate')
227+
set fillerCustomToolbarToggleTemplate(template: TemplateRef<any>|null) {
228+
this.$fillerCustomToolbarToggleTemplate = template;
229+
this.cdr.detectChanges();
230+
}
231+
get fillerCustomToolbarToggleTemplate() {
232+
return this.$fillerCustomToolbarToggleTemplate;
233+
}
234+
225235
constructor(
226236
private readonly cdr: ChangeDetectorRef,
227237
private readonly dialog: MatDialog,

0 commit comments

Comments
 (0)