mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -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:
@@ -8,10 +8,10 @@ import 'vs/css!./media/breadcrumb';
|
||||
import { Component, Inject, forwardRef, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { toDisposableSubscription } from 'sql/base/node/rxjsUtils';
|
||||
import { IBreadcrumbService, MenuItem } from './interfaces';
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
|
||||
|
||||
@Component({
|
||||
selector: 'breadcrumb',
|
||||
@@ -40,7 +40,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy {
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.disposables.push(toDisposableSubscription(this._breadcrumbService.breadcrumbItem.subscribe((item) => this.updateCrumb(item))));
|
||||
this.disposables.push(subscriptionToDisposable(this._breadcrumbService.breadcrumbItem.subscribe((item) => this.updateCrumb(item))));
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 237 B |
@@ -8,9 +8,9 @@ import {
|
||||
Input, EventEmitter, Output, ViewChild, ElementRef
|
||||
} from '@angular/core';
|
||||
|
||||
import { TabComponent } from 'sql/base/electron-browser/ui/panel/tab.component';
|
||||
import { ScrollableDirective } from 'sql/base/electron-browser/ui/scrollable/scrollable.directive';
|
||||
import { subscriptionToDisposable } from 'sql/base/node/lifecycle';
|
||||
import { TabComponent } from 'sql/base/browser/ui/panel/tab.component';
|
||||
import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive';
|
||||
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
|
||||
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
@@ -10,7 +10,7 @@ import { TabComponent } from './tab.component';
|
||||
import { TabHeaderComponent } from './tabHeader.component';
|
||||
import { PanelComponent } from './panel.component';
|
||||
|
||||
import { ScrollableModule } from 'sql/base/electron-browser/ui/scrollable/scrollable.module';
|
||||
import { ScrollableModule } from 'sql/base/browser/ui/scrollable/scrollable.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, ScrollableModule],
|
||||
@@ -8,7 +8,7 @@ import { Directive, Inject, forwardRef, ElementRef, Input } from '@angular/core'
|
||||
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { getContentHeight, addDisposableListener, EventType, getContentWidth } from 'vs/base/browser/dom';
|
||||
import { AngularDisposable } from 'sql/base/node/lifecycle';
|
||||
import { AngularDisposable } from 'sql/base/browser/lifecycle';
|
||||
|
||||
@Directive({
|
||||
selector: '[scrollable]'
|
||||
@@ -1,83 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {
|
||||
Component, Inject, forwardRef, ElementRef, OnInit, Input,
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
} from '@angular/core';
|
||||
|
||||
import { InputBox as vsInputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import { AngularDisposable } from 'sql/base/node/lifecycle';
|
||||
|
||||
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
|
||||
@Component({
|
||||
selector: 'input-box',
|
||||
template: ''
|
||||
})
|
||||
export class InputBox extends AngularDisposable implements OnInit, OnChanges {
|
||||
private _inputbox: vsInputBox;
|
||||
|
||||
@Input() min: string;
|
||||
@Input() max: string;
|
||||
@Input() type: string;
|
||||
@Input() placeholder: string;
|
||||
@Input('aria-label') ariaLabel: string;
|
||||
@Input() value: string;
|
||||
|
||||
@Output() onDidChange = new EventEmitter<string | number>();
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(IThemeService) private themeService: IThemeService,
|
||||
@Inject(IContextViewService) private contextViewService: IContextViewService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this._inputbox = new vsInputBox(this._el.nativeElement, this.contextViewService, {
|
||||
min: this.min,
|
||||
max: this.max,
|
||||
type: this.type,
|
||||
placeholder: this.placeholder,
|
||||
ariaLabel: this.ariaLabel
|
||||
});
|
||||
if (this.value) {
|
||||
this._inputbox.value = this.value;
|
||||
}
|
||||
this._inputbox.onDidChange(e => {
|
||||
switch (this.type) {
|
||||
case 'number':
|
||||
if (e) {
|
||||
this.onDidChange.emit(Number(e));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this.onDidChange.emit(e);
|
||||
}
|
||||
});
|
||||
this._register(attachInputBoxStyler(this._inputbox, this.themeService));
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (this._inputbox) {
|
||||
if (changes['min']) {
|
||||
this._inputbox.inputElement.min = this.min;
|
||||
}
|
||||
if (changes['max']) {
|
||||
this._inputbox.inputElement.max = this.max;
|
||||
}
|
||||
if (changes['type']) {
|
||||
this._inputbox.inputElement.type = this.type;
|
||||
}
|
||||
if (changes['placeholder']) {
|
||||
this._inputbox.inputElement.placeholder = this.placeholder;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export function toDisposableSubscription(sub: Subscription): IDisposable {
|
||||
return {
|
||||
dispose: () => {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
};
|
||||
}
|
||||
42
src/sql/base/test/browser/ui/table/gridFormatters.test.ts
Normal file
42
src/sql/base/test/browser/ui/table/gridFormatters.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as SharedServices from 'sql/base/browser/ui/table/formatters';
|
||||
|
||||
const testText = '<div>test text</div>';
|
||||
|
||||
suite('Grid shared services tests', () => {
|
||||
test('textFormatter should encode HTML when formatting a DBCellValue object', () => {
|
||||
// If I format a DBCellValue object that contains HTML
|
||||
let cellValue = new SharedServices.DBCellValue();
|
||||
cellValue.displayValue = testText;
|
||||
cellValue.isNull = false;
|
||||
let formattedHtml = SharedServices.textFormatter(undefined, undefined, cellValue, undefined, undefined);
|
||||
let hyperlink = SharedServices.hyperLinkFormatter(undefined, undefined, cellValue, undefined, undefined);
|
||||
|
||||
// Then the result is HTML for a span element containing the cell value's display value as plain text
|
||||
verifyFormattedHtml(formattedHtml, testText);
|
||||
});
|
||||
|
||||
test('textFormatter should encode HTML when formatting a string', () => {
|
||||
// If I format a string that contains HTML
|
||||
let formattedHtml = SharedServices.textFormatter(undefined, undefined, testText, undefined, undefined);
|
||||
|
||||
// Then the result is HTML for a span element containing the given text as plain text
|
||||
verifyFormattedHtml(formattedHtml, testText);
|
||||
});
|
||||
});
|
||||
|
||||
function verifyFormattedHtml(formattedHtml: string, expectedText: string): void {
|
||||
// Create an element containing the span returned by the format call
|
||||
let element = document.createElement('div');
|
||||
element.innerHTML = formattedHtml;
|
||||
let spanElement = element.children[0];
|
||||
|
||||
// Verify that the span element's text, not its innerHTML, matches the expected text
|
||||
assert.equal(spanElement.textContent, testText);
|
||||
assert.notEqual(spanElement.innerHTML, testText);
|
||||
}
|
||||
Reference in New Issue
Block a user