mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add more to strict nulls (#11871)
* add more to strict nulls * maintain error handling properly * fix lint
This commit is contained in:
@@ -60,9 +60,9 @@ export const ACCOUNT_VIEW_CONTAINER = Registry.as<IViewContainersRegistry>(ViewC
|
||||
}, ViewContainerLocation.Dialog);
|
||||
|
||||
class AccountPanel extends ViewPane {
|
||||
public index: number;
|
||||
private accountList: List<azdata.Account>;
|
||||
private tenantList: List<Tenant>;
|
||||
public index?: number;
|
||||
private accountList?: List<azdata.Account>;
|
||||
private tenantList?: List<Tenant>;
|
||||
|
||||
|
||||
constructor(
|
||||
@@ -93,24 +93,24 @@ class AccountPanel extends ViewPane {
|
||||
}
|
||||
|
||||
public get length(): number {
|
||||
return this.accountList.length;
|
||||
return this.accountList!.length;
|
||||
}
|
||||
|
||||
public focus() {
|
||||
this.accountList.domFocus();
|
||||
this.accountList!.domFocus();
|
||||
}
|
||||
|
||||
public updateAccounts(accounts: azdata.Account[]) {
|
||||
this.accountList.splice(0, this.accountList.length, accounts);
|
||||
this.accountList!.splice(0, this.accountList!.length, accounts);
|
||||
}
|
||||
|
||||
public setSelection(indexes: number[]) {
|
||||
this.accountList.setSelection(indexes);
|
||||
this.updateTenants(this.accountList.getSelection[0]);
|
||||
this.accountList!.setSelection(indexes);
|
||||
this.updateTenants(this.accountList!.getSelectedElements()[0]);
|
||||
}
|
||||
|
||||
private updateTenants(account: azdata.Account) {
|
||||
this.tenantList.splice(0, this.tenantList.length, account?.properties?.tenants ?? []);
|
||||
this.tenantList!.splice(0, this.tenantList!.length, account.properties?.tenants ?? []);
|
||||
}
|
||||
|
||||
public getActions(): IAction[] {
|
||||
@@ -134,12 +134,12 @@ export class AccountDialog extends Modal {
|
||||
// MEMBER VARIABLES ////////////////////////////////////////////////////
|
||||
private _providerViewsMap = new Map<string, IProviderViewUiComponent>();
|
||||
|
||||
private _closeButton: Button;
|
||||
private _addAccountButton: Button;
|
||||
private _splitView: SplitView;
|
||||
private _container: HTMLElement;
|
||||
private _splitViewContainer: HTMLElement;
|
||||
private _noaccountViewContainer: HTMLElement;
|
||||
private _closeButton?: Button;
|
||||
private _addAccountButton?: Button;
|
||||
private _splitView?: SplitView;
|
||||
private _container?: HTMLElement;
|
||||
private _splitViewContainer?: HTMLElement;
|
||||
private _noaccountViewContainer?: HTMLElement;
|
||||
|
||||
// EVENTING ////////////////////////////////////////////////////////////
|
||||
private _onAddAccountErrorEmitter: Emitter<string>;
|
||||
@@ -199,8 +199,8 @@ export class AccountDialog extends Modal {
|
||||
}
|
||||
|
||||
// MODAL OVERRIDE METHODS //////////////////////////////////////////////
|
||||
protected layout(height?: number): void {
|
||||
this._splitView.layout(DOM.getContentHeight(this._container));
|
||||
protected layout(_height?: number): void {
|
||||
this._splitView!.layout(DOM.getContentHeight(this._container!));
|
||||
}
|
||||
|
||||
public render() {
|
||||
@@ -230,7 +230,7 @@ export class AccountDialog extends Modal {
|
||||
this._register(this._addAccountButton.onDidClick(async () => {
|
||||
const vals = Iterable.consume(this._providerViewsMap.values())[0];
|
||||
|
||||
let pickedValue: string;
|
||||
let pickedValue: string | undefined;
|
||||
if (vals.length === 0) {
|
||||
this._notificationService.error(localize('accountDialog.noCloudsRegistered', "You have no clouds enabled. Go to Settings -> Search Azure Account Configuration -> Enable at least one cloud"));
|
||||
return;
|
||||
@@ -262,8 +262,8 @@ export class AccountDialog extends Modal {
|
||||
|
||||
private registerListeners(): void {
|
||||
// Theme styler
|
||||
this._register(attachButtonStyler(this._closeButton, this._themeService));
|
||||
this._register(attachButtonStyler(this._addAccountButton, this._themeService));
|
||||
this._register(attachButtonStyler(this._closeButton!, this._themeService));
|
||||
this._register(attachButtonStyler(this._addAccountButton!, this._themeService));
|
||||
}
|
||||
|
||||
/* Overwrite escape key behavior */
|
||||
@@ -292,14 +292,14 @@ export class AccountDialog extends Modal {
|
||||
}
|
||||
|
||||
private showNoAccountContainer() {
|
||||
this._splitViewContainer.hidden = true;
|
||||
this._noaccountViewContainer.hidden = false;
|
||||
this._addAccountButton.focus();
|
||||
this._splitViewContainer!.hidden = true;
|
||||
this._noaccountViewContainer!.hidden = false;
|
||||
this._addAccountButton!.focus();
|
||||
}
|
||||
|
||||
private showSplitView() {
|
||||
this._splitViewContainer.hidden = false;
|
||||
this._noaccountViewContainer.hidden = true;
|
||||
this._splitViewContainer!.hidden = false;
|
||||
this._noaccountViewContainer!.hidden = true;
|
||||
if (Iterable.consume(this._providerViewsMap.values()).length > 0) {
|
||||
const firstView = this._providerViewsMap.values().next().value;
|
||||
if (firstView instanceof AccountPanel) {
|
||||
@@ -373,19 +373,19 @@ export class AccountDialog extends Modal {
|
||||
|
||||
attachPanelStyler(providerView, this._themeService);
|
||||
|
||||
const insertIndex = this._splitView.length;
|
||||
const insertIndex = this._splitView!.length;
|
||||
providerView.render();
|
||||
|
||||
// Append the list view to the split view
|
||||
this._splitView.addView(providerView, Sizing.Distribute, insertIndex);
|
||||
this._splitView!.addView(providerView, Sizing.Distribute, insertIndex);
|
||||
providerView.index = insertIndex;
|
||||
|
||||
this._splitView.layout(DOM.getContentHeight(this._container));
|
||||
this._splitView!.layout(DOM.getContentHeight(this._container!));
|
||||
|
||||
// Set the initial items of the list
|
||||
providerView.updateAccounts(newProvider.initialAccounts);
|
||||
|
||||
if (newProvider.initialAccounts.length > 0 && this._splitViewContainer.hidden) {
|
||||
if (newProvider.initialAccounts.length > 0 && this._splitViewContainer!.hidden) {
|
||||
this.showSplitView();
|
||||
}
|
||||
|
||||
@@ -403,8 +403,8 @@ export class AccountDialog extends Modal {
|
||||
}
|
||||
|
||||
// Remove the list view from the split view
|
||||
this._splitView.removeView(providerView.view.index);
|
||||
this._splitView.layout(DOM.getContentHeight(this._container));
|
||||
this._splitView!.removeView(providerView.view.index!);
|
||||
this._splitView!.layout(DOM.getContentHeight(this._container!));
|
||||
|
||||
// Remove the list view from our internal map
|
||||
this._providerViewsMap.delete(removedProvider.id);
|
||||
@@ -418,11 +418,11 @@ export class AccountDialog extends Modal {
|
||||
}
|
||||
providerMapping.view.updateAccounts(args.accountList);
|
||||
|
||||
if (args.accountList.length > 0 && this._splitViewContainer.hidden) {
|
||||
if (args.accountList.length > 0 && this._splitViewContainer!.hidden) {
|
||||
this.showSplitView();
|
||||
}
|
||||
|
||||
if (this.isEmptyLinkedAccount() && this._noaccountViewContainer.hidden) {
|
||||
if (this.isEmptyLinkedAccount() && this._noaccountViewContainer!.hidden) {
|
||||
this.showNoAccountContainer();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user