Strict Null Checks on platform/accounts (#6735)

* add some patches for strict null

* renable strict null checks

* wip

* finish adding account to strict nulls

* fix backup component

* wip

* fix tests
This commit is contained in:
Anthony Dresser
2019-08-14 20:26:21 -07:00
committed by GitHub
parent 7b8530a21e
commit 4966ed8b42
22 changed files with 153 additions and 161 deletions

View File

@@ -581,8 +581,7 @@ export class ConnectionProfile {
options: { [name: string]: any };
static createFrom(options: any[]): ConnectionProfile {
// create from options
return undefined;
throw new Error('Method not implemented');
}
}

View File

@@ -43,6 +43,10 @@ export interface IModalDialogStyles {
dialogBorder?: Color;
dialogHeaderAndFooterBackground?: Color;
dialogBodyBackground?: Color;
footerBackgroundColor?: Color;
footerBorderTopWidth?: Color;
footerBorderTopStyle?: Color;
footerBorderTopColor?: Color;
}
export interface IModalOptions {
@@ -55,14 +59,6 @@ export interface IModalOptions {
hasSpinner?: boolean;
}
// Needed for angular component dialogs to style modal footer
export class ModalFooterStyle {
public static backgroundColor;
public static borderTopWidth;
public static borderTopStyle;
public static borderTopColor;
}
const defaultOptions: IModalOptions = {
isFlyout: true,
isWide: false,
@@ -93,10 +89,10 @@ export abstract class Modal extends Disposable implements IThemable {
private _lastFocusableElement: HTMLElement;
private _focusedElementBeforeOpen: HTMLElement;
private _dialogForeground: Color;
private _dialogBorder: Color;
private _dialogHeaderAndFooterBackground: Color;
private _dialogBodyBackground: Color;
private _dialogForeground?: Color;
private _dialogBorder?: Color;
private _dialogHeaderAndFooterBackground?: Color;
private _dialogBodyBackground?: Color;
private _modalDialog: HTMLElement;
private _modalHeaderSection: HTMLElement;
@@ -336,12 +332,12 @@ export abstract class Modal extends Disposable implements IThemable {
* Shows the modal and attaches key listeners
*/
protected show() {
this._modalShowingContext.get().push(this._staticKey);
this._modalShowingContext.get()!.push(this._staticKey);
DOM.append(this.layoutService.container, this._bodyContainer);
this.setFocusableElements();
this._keydownListener = DOM.addDisposableListener(document, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
let context = this._modalShowingContext.get();
let context = this._modalShowingContext.get()!;
if (context[context.length - 1] === this._staticKey) {
let event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter)) {
@@ -372,7 +368,7 @@ export abstract class Modal extends Disposable implements IThemable {
* Hides the modal and removes key listeners
*/
protected hide() {
this._modalShowingContext.get().pop();
this._modalShowingContext.get()!.pop();
this._bodyContainer.remove();
if (this._focusedElementBeforeOpen) {
this._focusedElementBeforeOpen.focus();
@@ -438,7 +434,7 @@ export abstract class Modal extends Disposable implements IThemable {
* @param level Severity level of the message
* @param description Description of the message
*/
protected setError(message: string, level: MessageLevel = MessageLevel.Error, description: string = '') {
protected setError(message: string | undefined, level: MessageLevel = MessageLevel.Error, description: string = '') {
if (this._modalOptions.hasErrors) {
this._messageSummaryText = message ? message : '';
this._messageDetailText = description ? description : '';
@@ -461,8 +457,8 @@ export abstract class Modal extends Disposable implements IThemable {
this._messageIcon.title = severityText;
this._messageSeverity.innerText = severityText;
this._messageSummary.innerText = message;
this._messageSummary.title = message;
this._messageSummary.innerText = message!;
this._messageSummary.title = message!;
this._messageDetail.innerText = description;
}
DOM.hide(this._messageDetail);
@@ -491,7 +487,7 @@ export abstract class Modal extends Disposable implements IThemable {
/**
* Return background color of header and footer
*/
protected get headerAndFooterBackground(): string {
protected get headerAndFooterBackground(): string | null {
return this._dialogHeaderAndFooterBackground ? this._dialogHeaderAndFooterBackground.toString() : null;
}
@@ -533,10 +529,8 @@ export abstract class Modal extends Disposable implements IThemable {
const border = this._dialogBorder ? this._dialogBorder.toString() : null;
const headerAndFooterBackground = this._dialogHeaderAndFooterBackground ? this._dialogHeaderAndFooterBackground.toString() : null;
const bodyBackground = this._dialogBodyBackground ? this._dialogBodyBackground.toString() : null;
ModalFooterStyle.backgroundColor = headerAndFooterBackground;
ModalFooterStyle.borderTopWidth = border ? '1px' : null;
ModalFooterStyle.borderTopStyle = border ? 'solid' : null;
ModalFooterStyle.borderTopColor = border;
const footerBorderTopWidth = border ? '1px' : null;
const footerBorderTopStyle = border ? 'solid' : null;
if (this._closeButtonInHeader) {
this._closeButtonInHeader.style.color = foreground;
@@ -567,10 +561,10 @@ export abstract class Modal extends Disposable implements IThemable {
}
if (this._modalFooterSection) {
this._modalFooterSection.style.backgroundColor = ModalFooterStyle.backgroundColor;
this._modalFooterSection.style.borderTopWidth = ModalFooterStyle.borderTopWidth;
this._modalFooterSection.style.borderTopStyle = ModalFooterStyle.borderTopStyle;
this._modalFooterSection.style.borderTopColor = ModalFooterStyle.borderTopColor;
this._modalFooterSection.style.backgroundColor = headerAndFooterBackground;
this._modalFooterSection.style.borderTopWidth = footerBorderTopWidth;
this._modalFooterSection.style.borderTopStyle = footerBorderTopStyle;
this._modalFooterSection.style.borderTopColor = border;
}
}

View File

@@ -10,7 +10,6 @@ import { Button } from 'sql/base/browser/ui/button/button';
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
import { ListBox } from 'sql/base/browser/ui/listBox/listBox';
import { ModalFooterStyle } from 'sql/workbench/browser/modal/modal';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
import { attachButtonStyler, attachListBoxStyler, attachInputBoxStyler, attachSelectBoxStyler, attachCheckboxStyler } from 'sql/platform/theme/common/styler';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
@@ -20,6 +19,7 @@ import * as FileValidationConstants from 'sql/workbench/services/fileBrowser/com
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IFileBrowserDialogController } from 'sql/workbench/services/fileBrowser/common/fileBrowserDialogController';
import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiService';
import * as cr from 'vs/platform/theme/common/colorRegistry';
import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import * as lifecycle from 'vs/base/common/lifecycle';
@@ -32,6 +32,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
import { KeyCode } from 'vs/base/common/keyCodes';
import { ITheme } from 'vs/platform/theme/common/themeService';
export const BACKUP_SELECTOR: string = 'backup-component';
@@ -350,7 +351,7 @@ export class BackupComponent {
this.mediaDescriptionBox.disable();
this.registerListeners();
this.updateTheme();
this.updateTheme(this.themeService.getTheme());
}
ngAfterViewInit() {
@@ -549,17 +550,21 @@ export class BackupComponent {
this.backupRetainDaysChanged(days);
}));
this._toDispose.push(this.themeService.onDidColorThemeChange(e => this.updateTheme()));
this._toDispose.push(this.themeService.onDidColorThemeChange(e => this.updateTheme(e)));
}
// Update theming that is specific to backup dialog
private updateTheme(): void {
private updateTheme(theme: ITheme): void {
// set modal footer style
let footerHtmlElement: HTMLElement = <HTMLElement>this.modalFooterElement.nativeElement;
footerHtmlElement.style.backgroundColor = ModalFooterStyle.backgroundColor;
footerHtmlElement.style.borderTopWidth = ModalFooterStyle.borderTopWidth;
footerHtmlElement.style.borderTopStyle = ModalFooterStyle.borderTopStyle;
footerHtmlElement.style.borderTopColor = ModalFooterStyle.borderTopColor;
const backgroundColor = theme.getColor(cr.foreground);
const border = theme.getColor(cr.contrastBorder) ? theme.getColor(cr.contrastBorder).toString() : null;
const footerBorderTopWidth = border ? '1px' : null;
const footerBorderTopStyle = border ? 'solid' : null;
footerHtmlElement.style.backgroundColor = backgroundColor ? backgroundColor.toString() : null;
footerHtmlElement.style.borderTopWidth = footerBorderTopWidth;
footerHtmlElement.style.borderTopStyle = footerBorderTopStyle;
footerHtmlElement.style.borderTopColor = border;
}
private addButtonClickHandler(button: Button, handler: () => void) {

View File

@@ -10,23 +10,23 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
export class TestResourceProvider implements IResourceProviderService {
_serviceBrand: any;
registerProvider(providerId: string, provider: azdata.ResourceProvider) {
registerProvider(providerId: string, provider: azdata.ResourceProvider): void {
}
unregisterProvider(ProviderId: string) {
unregisterProvider(ProviderId: string): void {
}
createFirewallRule(selectedAccount: azdata.Account, firewallruleInfo: azdata.FirewallRuleInfo, resourceProviderId: string): Promise<azdata.CreateFirewallRuleResponse> {
return undefined;
throw new Error('Method not implemented');
}
handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Promise<IHandleFirewallRuleResult> {
return undefined;
throw new Error('Method not implemented');
}
showFirewallRuleDialog(connection: IConnectionProfile, ipAddress: string, resourceProviderId: string): Promise<boolean> {
return undefined;
return Promise.resolve(true);
}
}
}