Revert "Remove typings and replace missing methods with vscodes (#8217)" (#8240)

This reverts commit 22a427f934.
This commit is contained in:
Elliot Boschwitz
2019-11-06 11:33:55 -08:00
committed by GitHub
parent 3b1eaca58e
commit e801a04bcf
184 changed files with 43388 additions and 634 deletions

View File

@@ -17,8 +17,6 @@ import { ConnectionWidget } from 'sql/workbench/services/connection/browser/conn
import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController';
import { ILogService } from 'vs/platform/log/common/log';
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
import { assign } from 'vs/base/common/objects';
import { find } from 'vs/base/common/arrays';
export class ConnectionController implements IConnectionComponentController {
private _advancedController: AdvancedPropertiesController;
@@ -141,7 +139,7 @@ export class ConnectionController implements IConnectionComponentController {
} else {
defaultGroupId = Utils.defaultGroupId;
}
allGroups.push(assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
allGroups.push(Object.assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
allGroups.push(this._connectionWidget.NoneServerGroup);
connectionGroupRoot.forEach(cpg => cpg.dispose());
return allGroups;
@@ -151,7 +149,7 @@ export class ConnectionController implements IConnectionComponentController {
this._connectionWidget.updateServerGroup(this.getAllServerGroups(providers));
this._model = connectionInfo;
this._model.providerName = this._providerName;
let appNameOption = find(this._providerOptions, option => option.specialValueType === ConnectionOptionSpecialType.appName);
let appNameOption = this._providerOptions.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
if (appNameOption) {
let appNameKey = appNameOption.name;
this._model.options[appNameKey] = Constants.applicationName;

View File

@@ -14,6 +14,7 @@ import * as Constants from 'sql/platform/connection/common/constants';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
import { entries } from 'sql/base/common/objects';
import { Deferred } from 'sql/base/common/promise';
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
@@ -29,8 +30,6 @@ import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
import { entries } from 'sql/base/common/collections';
import { find } from 'vs/base/common/arrays';
export interface IConnectionValidateResult {
isValid: boolean;
@@ -137,7 +136,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
if (keys && keys.length > 0) {
if (this._params && this._params.providers && this._params.providers.length > 0) {
//Filter providers from master keys.
filteredKeys = keys.filter(key => this._params.providers.some(x => x === key));
filteredKeys = keys.filter(key => this._params.providers.includes(key));
}
if (filteredKeys && filteredKeys.length > 0) {
defaultProvider = filteredKeys[0];
@@ -308,7 +307,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
});
}
if (!isProviderInParams) {
this._currentProviderType = find(Object.keys(this._providerNameToDisplayNameMap), (key) =>
this._currentProviderType = Object.keys(this._providerNameToDisplayNameMap).find((key) =>
this._providerNameToDisplayNameMap[key] === input.selectedProviderDisplayName &&
key !== Constants.cmsProviderName
);
@@ -473,7 +472,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
// this solves the most common "hard error" that we've noticed
const helpLink = 'https://aka.ms/sqlopskerberos';
let actions: IAction[] = [];
if (!platform.isWindows && types.isString(message) && message.toLowerCase().indexOf('kerberos') > -1 && message.toLowerCase().indexOf('kinit') > -1) {
if (!platform.isWindows && types.isString(message) && message.toLowerCase().includes('kerberos') && message.toLowerCase().includes('kinit')) {
message = [
localize('kerberosErrorStart', "Connection failed due to Kerberos error."),
localize('kerberosHelpLink', "Help configuring Kerberos is available at {0}", helpLink),

View File

@@ -121,7 +121,7 @@ export class ConnectionDialogWidget extends Modal {
if (this._newConnectionParams && this._newConnectionParams.providers) {
const validProviderNames = Object.keys(this.providerNameToDisplayNameMap).filter(x => this.includeProvider(x, this._newConnectionParams));
if (validProviderNames && validProviderNames.length > 0) {
filteredProviderDisplayNames = filteredProviderDisplayNames.filter(x => validProviderNames.some(
filteredProviderDisplayNames = filteredProviderDisplayNames.filter(x => validProviderNames.find(
v => this.providerNameToDisplayNameMap[v] === x) !== undefined
);
}
@@ -134,7 +134,7 @@ export class ConnectionDialogWidget extends Modal {
}
private includeProvider(providerName: string, params?: INewConnectionParams): Boolean {
return params === undefined || params.providers === undefined || params.providers.some(x => x === providerName);
return params === undefined || params.providers === undefined || params.providers.find(x => x === providerName) !== undefined;
}
protected renderBody(container: HTMLElement): void {

View File

@@ -26,6 +26,7 @@ import { IAngularEventingService, AngularEventType } from 'sql/platform/angularE
import * as QueryConstants from 'sql/workbench/parts/query/common/constants';
import { Deferred } from 'sql/base/common/promise';
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
import { values, entries } from 'sql/base/common/objects';
import { IConnectionProviderRegistry, Extensions as ConnectionProviderExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
import { IAccountManagementService, AzureResource } from 'sql/platform/accounts/common/interfaces';
@@ -49,10 +50,6 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { Memento } from 'vs/workbench/common/memento';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { entries } from 'sql/base/common/collections';
import { find } from 'vs/base/common/arrays';
import { values } from 'vs/base/common/collections';
import { assign } from 'vs/base/common/objects';
export class ConnectionManagementService extends Disposable implements IConnectionManagementService {
@@ -716,7 +713,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}
let accounts = await this._accountManagementService.getAccountsForProvider('azurePublicCloud');
if (accounts && accounts.length > 0) {
let account = find(accounts, account => account.key.accountId === connection.userName);
let account = accounts.find(account => account.key.accountId === connection.userName);
if (account) {
if (account.isStale) {
try {
@@ -732,11 +729,11 @@ export class ConnectionManagementService extends Disposable implements IConnecti
if (tenantId && tokensByTenant[tenantId]) {
token = tokensByTenant[tenantId].token;
} else {
let tokens = values(tokensByTenant);
let tokens = Object.values(tokensByTenant);
if (tokens.length === 0) {
return false;
}
token = values(tokensByTenant)[0].token;
token = Object.values(tokensByTenant)[0].token;
}
connection.options['azureAccountToken'] = token;
connection.options['password'] = '';
@@ -748,7 +745,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
// Request Senders
private async sendConnectRequest(connection: interfaces.IConnectionProfile, uri: string): Promise<boolean> {
let connectionInfo = assign({}, {
let connectionInfo = Object.assign({}, {
options: connection.options
});
@@ -988,7 +985,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
];
return this._quickInputService.pick(choices.map(x => x.key), { placeHolder: nls.localize('cancelConnectionConfirmation', "Are you sure you want to cancel this connection?"), ignoreFocusLost: true }).then((choice) => {
let confirm = find(choices, x => x.key === choice);
let confirm = choices.find(x => x.key === choice);
return confirm && confirm.value;
});
}
@@ -1242,13 +1239,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti
}
public getActiveConnectionCredentials(profileId: string): { [name: string]: string } {
let profile = find(this.getActiveConnections(), connectionProfile => connectionProfile.id === profileId);
let profile = this.getActiveConnections().find(connectionProfile => connectionProfile.id === profileId);
if (!profile) {
return undefined;
}
// Find the password option for the connection provider
let passwordOption = find(this._capabilitiesService.getCapabilities(profile.providerName).connection.connectionOptions,
let passwordOption = this._capabilitiesService.getCapabilities(profile.providerName).connection.connectionOptions.find(
option => option.specialValueType === ConnectionOptionSpecialType.password);
if (!passwordOption) {
return undefined;
@@ -1329,7 +1326,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti
const connections = this.getActiveConnections();
const connectionExists: (conn: ConnectionProfile) => boolean = (conn) => {
return find(connections, existingConnection => existingConnection.id === conn.id) !== undefined;
return connections.find(existingConnection => existingConnection.id === conn.id) !== undefined;
};
if (!activeConnectionsOnly) {

View File

@@ -35,7 +35,6 @@ import { endsWith, startsWith } from 'vs/base/common/strings';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { find } from 'vs/base/common/arrays';
export class ConnectionWidget extends lifecycle.Disposable {
private _previousGroupOption: string;
@@ -382,7 +381,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
if (this._refreshCredentialsLink) {
this._register(DOM.addDisposableListener(this._refreshCredentialsLink, DOM.EventType.CLICK, async () => {
let account = find(this._azureAccountList, account => account.key.accountId === this._azureAccountDropdown.value);
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
if (account) {
await this._accountManagementService.refreshAccount(account);
await this.fillInAzureAccountOptions();
@@ -471,7 +470,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
}
private updateRefreshCredentialsLink(): void {
let chosenAccount = find(this._azureAccountList, account => account.key.accountId === this._azureAccountDropdown.value);
let chosenAccount = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
if (chosenAccount && chosenAccount.isStale) {
DOM.removeClass(this._tableContainer, 'hide-refresh-link');
} else {
@@ -492,7 +491,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
await this.fillInAzureAccountOptions();
// If a new account was added find it and select it, otherwise select the first account
let newAccount = find(this._azureAccountList, option => !oldAccountIds.some(oldId => oldId === option.key.accountId));
let newAccount = this._azureAccountList.find(option => !oldAccountIds.some(oldId => oldId === option.key.accountId));
if (newAccount) {
this._azureAccountDropdown.selectWithOptionName(newAccount.key.accountId);
} else {
@@ -504,7 +503,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
// Display the tenant select box if needed
const hideTenantsClassName = 'hide-azure-tenants';
let selectedAccount = find(this._azureAccountList, account => account.key.accountId === this._azureAccountDropdown.value);
let selectedAccount = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
if (selectedAccount && selectedAccount.properties.tenants && selectedAccount.properties.tenants.length > 1) {
// There are multiple tenants available so let the user select one
let options = selectedAccount.properties.tenants.map(tenant => tenant.displayName);
@@ -523,7 +522,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
private onAzureTenantSelected(tenantIndex: number): void {
this._azureTenantId = undefined;
let account = find(this._azureAccountList, account => account.key.accountId === this._azureAccountDropdown.value);
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
if (account && account.properties.tenants) {
let tenant = account.properties.tenants[tenantIndex];
if (tenant) {
@@ -534,7 +533,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
private serverNameChanged(serverName: string) {
this.setConnectButton();
if (serverName.toLocaleLowerCase().indexOf('database.windows.net') > -1) {
if (serverName.toLocaleLowerCase().includes('database.windows.net')) {
this._callbacks.onSetAzureTimeOut();
}
}
@@ -638,7 +637,7 @@ export class ConnectionWidget extends lifecycle.Disposable {
this._azureAccountDropdown.selectWithOptionName(this.getModelValue(connectionInfo.userName));
await this.onAzureAccountSelected();
let tenantId = connectionInfo.azureTenantId;
let account = find(this._azureAccountList, account => account.key.accountId === this._azureAccountDropdown.value);
let account = this._azureAccountList.find(account => account.key.accountId === this._azureAccountDropdown.value);
if (account && account.properties.tenants.length > 1) {
let tenant = account.properties.tenants.find(tenant => tenant.id === tenantId);
if (tenant) {
@@ -835,19 +834,19 @@ export class ConnectionWidget extends lifecycle.Disposable {
private findGroupId(groupFullName: string): string {
let group: IConnectionProfileGroup;
if (ConnectionProfileGroup.isRoot(groupFullName)) {
group = find(this._serverGroupOptions, g => ConnectionProfileGroup.isRoot(g.name));
group = this._serverGroupOptions.find(g => ConnectionProfileGroup.isRoot(g.name));
if (group === undefined) {
group = find(this._serverGroupOptions, g => g.name === this.DefaultServerGroup.name);
group = this._serverGroupOptions.find(g => g.name === this.DefaultServerGroup.name);
}
} else {
group = find(this._serverGroupOptions, g => g.name === groupFullName);
group = this._serverGroupOptions.find(g => g.name === groupFullName);
}
return group ? group.id : undefined;
}
private getMatchingAuthType(displayName: string): AuthenticationType {
const authType = this._authTypeMap[this._providerName];
return authType ? find(authType, authType => this.getAuthTypeDisplayName(authType) === displayName) : undefined;
return authType ? authType.find(authType => this.getAuthTypeDisplayName(authType) === displayName) : undefined;
}
public closeDatabaseDropdown(): void {