mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 01:25:36 -05:00
Inital platform relayering (#6385)
* moving test files and inital refactoring * relayer extension host code * fix imports * make insights work * relayer dashboard * relayer notebooks * moveing more code around * formatting * accept angular as browser * fix serializer * add missing files * remove declarations from extensions * fix build errors * more relayering * change urls to relative to help code relayering * remove layering to prep for merge * fix hygiene errors * fix hygiene errors * fix tests
This commit is contained in:
58
src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts
Normal file
58
src/sql/base/browser/ui/breadcrumb/breadcrumb.component.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/breadcrumb';
|
||||
|
||||
import { Component, Inject, forwardRef, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { IBreadcrumbService, MenuItem } from './interfaces';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
|
||||
|
||||
@Component({
|
||||
selector: 'breadcrumb',
|
||||
template: `
|
||||
<span style="display: flex; flex-flow: row; align-items: center; margin: 10px">
|
||||
<ng-template ngFor let-item let-first="first" let-last="last" [ngForOf]="menuItems">
|
||||
<span style="padding: 5px; display: flex; align-items: center">
|
||||
<span *ngIf="item.icon" class="icon" style="display: inline-block; margin-right: 5px" [ngClass]="item.icon"></span>
|
||||
<span *ngIf="first">{{item.label}}</span>
|
||||
<span *ngIf="last" style="">{{item.label}}</span>
|
||||
<a class="router-link" *ngIf="!last && !first" (click)="route(item.routerLink)" >{{item.label}}</a>
|
||||
</span>
|
||||
<span *ngIf="!last" class="icon chevron-right"></span>
|
||||
</ng-template>
|
||||
</span>
|
||||
`
|
||||
})
|
||||
export class BreadcrumbComponent implements OnInit, OnDestroy {
|
||||
protected menuItems: MenuItem[] = []; // used by angular template
|
||||
private disposables: Array<IDisposable> = new Array();
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => IBreadcrumbService)) private _breadcrumbService: IBreadcrumbService,
|
||||
@Inject(forwardRef(() => Router)) private _router: Router,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.disposables.push(subscriptionToDisposable(this._breadcrumbService.breadcrumbItem.subscribe((item) => this.updateCrumb(item))));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.disposables.forEach(item => item.dispose());
|
||||
}
|
||||
|
||||
private updateCrumb(items: MenuItem[]) {
|
||||
this.menuItems = items;
|
||||
this._changeRef.detectChanges();
|
||||
}
|
||||
|
||||
public route(link: any[]): void {
|
||||
this._router.navigate(link);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user