Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions src/app/toolbar.ng.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<nav [ngClass]="['toolbar', graphState]">
<ng-container *ngFor="let customToggleTemplate of leftAlignedCustomToolbarToggleTemplates">
<div class="cell toggler">
<div
class="cell toggler"
[class.flex]="customToggleTemplate === fillerCustomToolbarToggleTemplate"
>
<ng-container
*ngTemplateOutlet="customToggleTemplate; context: {
nodes,
Expand All @@ -9,7 +12,7 @@
></ng-container>
</div>
</ng-container>
<div *ngIf="rightAlignMainControls" class="flex"></div>
<div *ngIf="fillerCustomToolbarToggleTemplate === null && rightAlignMainControls" class="flex"></div>
<ng-container *ngVar="labelGenerator(this, 'graphState') as label">
<div class="cell state" *ngIf="label !== false">
<workflow-graph-icon icon="info"></workflow-graph-icon>
Expand Down Expand Up @@ -138,7 +141,10 @@
</button>
</div>
<ng-container *ngFor="let customToggleTemplate of customToolbarToggleTemplates">
<div class="cell toggler">
<div
class="cell toggler"
[class.flex]="customToggleTemplate === fillerCustomToolbarToggleTemplate"
>
<ng-container
*ngTemplateOutlet="customToggleTemplate; context: {
nodes,
Expand All @@ -147,9 +153,12 @@
></ng-container>
</div>
</ng-container>
<div *ngIf="!rightAlignMainControls" class="flex"></div>
<div *ngIf="fillerCustomToolbarToggleTemplate === null && !rightAlignMainControls" class="flex"></div>
<ng-container *ngFor="let customToggleTemplate of rightAlignedCustomToolbarToggleTemplates">
<div class="cell toggler">
<div
class="cell toggler"
[class.flex]="customToggleTemplate === fillerCustomToolbarToggleTemplate"
>
<ng-container *ngTemplateOutlet="customToggleTemplate; context: {
nodes,
groups
Expand Down
37 changes: 34 additions & 3 deletions src/app/toolbar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ describe('DagToolbar', () => {
});
});

describe('With filler template', () => {
beforeEach(fakeAsync(() => {
fixture.componentInstance.enableFillerTemplate();
fixture.detectChanges();
}));

it('Renders correctly (screenshot)', async () => {
await screenShot.expectMatch('renders_correctly_with_filler_template');
});
});

it('Calculated node states correctly', () => {
expect(toolbar.graphState).toBe('Runtime');
expect(toolbar.completedSteps).toBe(1);
Expand Down Expand Up @@ -158,33 +169,53 @@ describe('DagToolbar', () => {
[nodes]="nodes" [expanded]="true"
[rightAlignedCustomToolbarToggleTemplates]="rightAlignedTemplates"
[features]="features"
[fillerCustomToolbarToggleTemplate]="fillerTemplate"
></ai-dag-toolbar>
</div>
<ng-template #rightAlignedTemplate>
<button id="rightButton"> Click me</button>
</ng-template>
<ng-template #rectangleTemplate>
<div class="rectangle"></div>
</ng-template>`,
providers: [
// STATE_SERVICE_PROVIDER,
],
styles: [`
.container {
height: 400px;
width: 400px;
height: 100px;
width: 1200px;
background-color: gray;
}
.rectangle {
background-color: red;
min-width: 50px;
flex-grow: 1;
height: 30px;
}`],

// TODO: Make this AOT compatible. See b/352713444
jit: true,

})
class TestComponent {
@ViewChild('dagToolbar', {static: false}) dagToolbar!: DagToolbar;
nodes: DagNode[] = FAKE_DATA;
@ViewChild('rightAlignedTemplate', {static: false})
rightAlignedTemplate?: TemplateRef<{}>;
@ViewChild('rectangleTemplate', {static: false})
rectangleTemplate?: TemplateRef<{}>;

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

fillerTemplate: TemplateRef<{}>|null = null;

enableFillerTemplate() {
this.fillerTemplate = this.rectangleTemplate!;
}

ngAfterViewInit() {
this.rightAlignedTemplates.push(this.rightAlignedTemplate!);
this.rightAlignedTemplates.push(this.rectangleTemplate!);
}

features = {...defaultFeatures, enableShortcuts: true};
Expand Down
10 changes: 10 additions & 0 deletions src/app/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export class DagToolbar {
private $customToolbarToggleTemplates: TemplateRef<any>[] = [];
private $leftAlignedCustomToolbarToggleTemplates: TemplateRef<any>[] = [];
private $rightAlignedCustomToolbarToggleTemplates: TemplateRef<any>[] = [];
private $fillerCustomToolbarToggleTemplate: TemplateRef<any>|null = null;

@Input() enableMinimap = true;
@Output() enableMinimapChange = new EventEmitter();
Expand Down Expand Up @@ -222,6 +223,15 @@ export class DagToolbar {
return this.$rightAlignedCustomToolbarToggleTemplates;
}

@Input('fillerCustomToolbarToggleTemplate')
set fillerCustomToolbarToggleTemplate(template: TemplateRef<any>|null) {
this.$fillerCustomToolbarToggleTemplate = template;
this.cdr.detectChanges();
}
get fillerCustomToolbarToggleTemplate() {
return this.$fillerCustomToolbarToggleTemplate;
}

constructor(
private readonly cdr: ChangeDetectorRef,
private readonly dialog: MatDialog,
Expand Down
Loading