mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 01:25:36 -05:00
Remove typings and replace missing methods with vscodes (#8217)
* remove typings and replace missing methods with vscodes * fix strict-null-checks * fix tests
This commit is contained in:
@@ -18,6 +18,7 @@ import * as types from 'vs/base/common/types';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IPanelOptions {
|
||||
/**
|
||||
@@ -202,7 +203,7 @@ export class PanelComponent extends Disposable {
|
||||
* Select on the next tab
|
||||
*/
|
||||
public selectOnNextTab(): void {
|
||||
let activeIndex = this._tabs.toArray().findIndex(i => i === this._activeTab);
|
||||
let activeIndex = firstIndex(this._tabs.toArray(), i => i === this._activeTab);
|
||||
let nextTabIndex = activeIndex + 1;
|
||||
if (nextTabIndex === this._tabs.length) {
|
||||
nextTabIndex = 0;
|
||||
@@ -211,7 +212,7 @@ export class PanelComponent extends Disposable {
|
||||
}
|
||||
|
||||
private findAndRemoveTabFromMRU(tab: TabComponent): void {
|
||||
let mruIndex = this._mru.findIndex(i => i === tab);
|
||||
let mruIndex = firstIndex(this._mru, i => i === tab);
|
||||
|
||||
if (mruIndex !== -1) {
|
||||
// Remove old index
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import * as map from 'vs/base/common/map';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export interface ITabbedPanelStyles {
|
||||
titleActiveForeground?: Color;
|
||||
@@ -171,11 +172,11 @@ export class TabbedPanel extends Disposable {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
if (event.equals(KeyCode.RightArrow)) {
|
||||
let currentIndex = this._tabOrder.findIndex(x => x === tab.tab.identifier);
|
||||
let currentIndex = firstIndex(this._tabOrder, x => x === tab.tab.identifier);
|
||||
this.focusNextTab(currentIndex + 1);
|
||||
}
|
||||
if (event.equals(KeyCode.LeftArrow)) {
|
||||
let currentIndex = this._tabOrder.findIndex(x => x === tab.tab.identifier);
|
||||
let currentIndex = firstIndex(this._tabOrder, x => x === tab.tab.identifier);
|
||||
this.focusNextTab(currentIndex - 1);
|
||||
}
|
||||
if (event.equals(KeyCode.Tab)) {
|
||||
@@ -191,8 +192,7 @@ export class TabbedPanel extends Disposable {
|
||||
|
||||
const insertBefore = !isUndefinedOrNull(index) ? this.tabList.children.item(index) : undefined;
|
||||
if (insertBefore) {
|
||||
this._tabOrder.copyWithin(index! + 1, index!);
|
||||
this._tabOrder[index!] = tab.tab.identifier;
|
||||
this._tabOrder.splice(index!, 0, tab.tab.identifier);
|
||||
this.tabList.insertBefore(tabHeaderElement, insertBefore);
|
||||
} else {
|
||||
this.tabList.append(tabHeaderElement);
|
||||
@@ -267,7 +267,7 @@ export class TabbedPanel extends Disposable {
|
||||
}
|
||||
actualTab.disposables.dispose();
|
||||
this._tabMap.delete(tab);
|
||||
let index = this._tabOrder.findIndex(t => t === tab);
|
||||
let index = firstIndex(this._tabOrder, t => t === tab);
|
||||
this._tabOrder.splice(index, 1);
|
||||
if (this._shownTabId === tab) {
|
||||
this._shownTabId = undefined;
|
||||
|
||||
@@ -136,7 +136,7 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
this.workingFilters = columnDef.filterValues.slice(0);
|
||||
|
||||
for (let i = 0; i < filterItems.length; i++) {
|
||||
const filtered = _.contains(this.workingFilters, filterItems[i]);
|
||||
const filtered = this.workingFilters.some(x => x === filterItems[i]);
|
||||
|
||||
filterOptions += '<label><input type="checkbox" value="' + i + '"'
|
||||
+ (filtered ? ' checked="checked"' : '')
|
||||
@@ -184,7 +184,7 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
let filterOptions = '<label><input type="checkbox" value="-1" />(Select All)</label>';
|
||||
|
||||
for (let i = 0; i < filterItems.length; i++) {
|
||||
const filtered = _.contains(this.workingFilters, filterItems[i]);
|
||||
const filtered = this.workingFilters.some(x => x === filterItems[i]);
|
||||
if (filterItems[i] && filterItems[i].indexOf('Error:') < 0) {
|
||||
filterOptions += '<label><input type="checkbox" value="' + i + '"'
|
||||
+ (filtered ? ' checked="checked"' : '')
|
||||
@@ -282,7 +282,7 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
workingFilters.length = 0;
|
||||
}
|
||||
} else {
|
||||
const index = _.indexOf(workingFilters, filterItems[value]);
|
||||
const index = workingFilters.indexOf(filterItems[value]);
|
||||
|
||||
if ($checkbox.prop('checked') && index < 0) {
|
||||
workingFilters.push(filterItems[value]);
|
||||
@@ -326,7 +326,7 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
for (let i = 0; i < dataView.getLength(); i++) {
|
||||
const value = dataView.getItem(i)[column.field!];
|
||||
|
||||
if (!_.contains(seen, value)) {
|
||||
if (!seen.some(x => x === value)) {
|
||||
seen.push(value);
|
||||
}
|
||||
}
|
||||
@@ -346,18 +346,18 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
const itemValue = !value ? '' : value;
|
||||
const lowercaseFilter = filter.toString().toLowerCase();
|
||||
const lowercaseVal = itemValue.toString().toLowerCase();
|
||||
if (!_.contains(seen, value) && lowercaseVal.indexOf(lowercaseFilter) > -1) {
|
||||
if (!seen.some(x => x === value) && lowercaseVal.indexOf(lowercaseFilter) > -1) {
|
||||
seen.push(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!_.contains(seen, value)) {
|
||||
if (!seen.some(x => x === value)) {
|
||||
seen.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _.sortBy(seen, (v) => { return v; });
|
||||
return seen.sort((v) => { return v; });
|
||||
}
|
||||
|
||||
private getAllFilterValues(data: Array<Slick.SlickData>, column: Slick.Column<T>) {
|
||||
@@ -365,12 +365,12 @@ export class HeaderFilter<T extends Slick.SlickData> {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const value = data[i][column.field!];
|
||||
|
||||
if (!_.contains(seen, value)) {
|
||||
if (!seen.some(x => x === value)) {
|
||||
seen.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
return _.sortBy(seen, (v) => { return v; });
|
||||
return seen.sort((v) => { return v; });
|
||||
}
|
||||
|
||||
private handleMenuItemClick(e: JQuery.Event<HTMLElement, null>, command: string, columnDef: Slick.Column<T>) {
|
||||
|
||||
8
src/sql/base/common/collections.ts
Normal file
8
src/sql/base/common/collections.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function entries<K>(o: Record<string, K>): [string, K][] {
|
||||
return Object.keys(o).map(k => [k, o[k]]);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Alterable version of the vs memorize function; to unmemoize use unmemoize
|
||||
*/
|
||||
export function memoize(target: any, key: string, descriptor: any) {
|
||||
let fnKey: string | null = null;
|
||||
let fn: Function | null = null;
|
||||
|
||||
if (typeof descriptor.value === 'function') {
|
||||
fnKey = 'value';
|
||||
fn = descriptor.value;
|
||||
|
||||
if (fn!.length !== 0) {
|
||||
console.warn('Memoize should only be used in functions with zero parameters');
|
||||
}
|
||||
} else if (typeof descriptor.get === 'function') {
|
||||
fnKey = 'get';
|
||||
fn = descriptor.get;
|
||||
}
|
||||
|
||||
if (!fn) {
|
||||
throw new Error('not supported');
|
||||
}
|
||||
|
||||
const memoizeKey = `$memoize$${key}`;
|
||||
|
||||
descriptor[fnKey!] = function (...args: any[]) {
|
||||
if (!this.hasOwnProperty(memoizeKey)) {
|
||||
Object.defineProperty(this, memoizeKey, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
value: fn!.apply(this, args)
|
||||
});
|
||||
}
|
||||
|
||||
return this[memoizeKey];
|
||||
};
|
||||
}
|
||||
|
||||
export function unmemoize(target: Object, key: string) {
|
||||
const memoizeKey = `$memoize$${key}`;
|
||||
if (target.hasOwnProperty(memoizeKey)) {
|
||||
delete target[memoizeKey];
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,3 @@ export function mixin(destination: any, source: any, overwrite: boolean = true,
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
||||
export function entries<T>(o: { [key: string]: T }): [string, T][] {
|
||||
return Object.keys(o).map(k => [k, o[k]] as [string, T]);
|
||||
}
|
||||
|
||||
export function values<T>(o: { [key: string]: T }): T[] {
|
||||
return Object.keys(o).map(k => o[k]);
|
||||
}
|
||||
|
||||
@@ -19,3 +19,20 @@ export function escape(html: string): string {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// gotten from https://github.com/59naga/string-raw/blob/master/src/index.js
|
||||
export function raw(callSite: any, ...substitutions: any[]): string {
|
||||
let template;
|
||||
try {
|
||||
template = Array.from(callSite.raw);
|
||||
} catch (e) {
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
|
||||
return template.map((chunk, i) => {
|
||||
if (callSite.raw.length <= i) {
|
||||
return chunk;
|
||||
}
|
||||
return substitutions[i - 1] ? substitutions[i - 1] + chunk : chunk;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ export class Dropdown extends Disposable {
|
||||
}
|
||||
|
||||
private _inputValidator(value: string): IMessage | null {
|
||||
if (!this._input.hasFocus() && !this._tree.isDOMFocused() && this._dataSource.options && !this._dataSource.options.find(i => i.value === value)) {
|
||||
if (!this._input.hasFocus() && !this._tree.isDOMFocused() && this._dataSource.options && !this._dataSource.options.some(i => i.value === value)) {
|
||||
if (this._options.strictSelection && this._options.errorMessage) {
|
||||
return {
|
||||
content: this._options.errorMessage,
|
||||
|
||||
@@ -96,7 +96,7 @@ export class DropdownFilter extends TreeDefaults.DefaultFilter {
|
||||
public filterString: string;
|
||||
|
||||
public isVisible(tree: tree.ITree | undefined, element: Resource): boolean {
|
||||
return element.value.toLowerCase().includes(this.filterString.toLowerCase());
|
||||
return element.value.toLowerCase().indexOf(this.filterString.toLowerCase()) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ suite('TableDataView', () => {
|
||||
const ret = new Array<number>();
|
||||
for (let i = 0; i < columnCount; i++) {
|
||||
const colVal = val[getColumnName(i)];
|
||||
if (colVal && colVal.toLocaleLowerCase().includes(exp.toLocaleLowerCase())) {
|
||||
if (colVal && colVal.toLocaleLowerCase().indexOf(exp.toLocaleLowerCase()) > -1) {
|
||||
ret.push(i);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,7 @@ suite('TableDataView', () => {
|
||||
const ret = new Array<number>();
|
||||
for (let i = 0; i < columnCount; i++) {
|
||||
const colVal = val[getColumnName(i)];
|
||||
if (colVal && colVal.toLocaleLowerCase().includes(exp.toLocaleLowerCase())) {
|
||||
if (colVal && colVal.toLocaleLowerCase().indexOf(exp.toLocaleLowerCase()) > -1) {
|
||||
ret.push(i);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ suite('TableDataView', () => {
|
||||
const ret = new Array<number>();
|
||||
for (let i = 0; i < columnCount; i++) {
|
||||
const colVal = val[getColumnName(i)];
|
||||
if (colVal && colVal.toLocaleLowerCase().includes(exp.toLocaleLowerCase())) {
|
||||
if (colVal && colVal.toLocaleLowerCase().indexOf(exp.toLocaleLowerCase()) > -1) {
|
||||
ret.push(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class EventVerifierSingle<T> {
|
||||
private _eventArgument: T;
|
||||
@@ -64,13 +65,13 @@ export class EventVerifierMultiple<T> {
|
||||
public assertFired(expectedArgument?: T) {
|
||||
assert.ok(this.eventFired);
|
||||
if (expectedArgument) {
|
||||
assert.ok(this._eventArguments.includes(expectedArgument));
|
||||
assert.ok(this._eventArguments.some(x => x === expectedArgument));
|
||||
}
|
||||
}
|
||||
|
||||
public assertNotFired(expectedArgument?: T) {
|
||||
if (expectedArgument) {
|
||||
assert.ok(!this._eventArguments.includes(expectedArgument));
|
||||
assert.ok(!this._eventArguments.some(x => x === expectedArgument));
|
||||
} else {
|
||||
assert.ok(!this.eventFired);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import * as azdata from 'azdata';
|
||||
import { AccountAdditionResult } from 'sql/platform/accounts/common/eventTypes';
|
||||
import { IAccountStore } from 'sql/platform/accounts/common/interfaces';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export default class AccountStore implements IAccountStore {
|
||||
// CONSTANTS ///////////////////////////////////////////////////////////
|
||||
@@ -23,7 +24,7 @@ export default class AccountStore implements IAccountStore {
|
||||
return this.readFromMemento()
|
||||
.then(accounts => {
|
||||
// Determine if account exists and proceed accordingly
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, newAccount.key));
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, newAccount.key));
|
||||
return match < 0
|
||||
? this.addToAccountList(accounts, newAccount)
|
||||
: this.updateAccountList(accounts, newAccount.key, matchAccount => AccountStore.mergeAccounts(newAccount, matchAccount));
|
||||
@@ -100,7 +101,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private addToAccountList(accounts: azdata.Account[], accountToAdd: azdata.Account): AccountListOperationResult {
|
||||
// Check if the entry already exists
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
|
||||
if (match >= 0) {
|
||||
// Account already exists, we won't do anything
|
||||
return {
|
||||
@@ -125,7 +126,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private removeFromAccountList(accounts: azdata.Account[], accountToRemove: azdata.AccountKey): AccountListOperationResult {
|
||||
// Check if the entry exists
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToRemove));
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToRemove));
|
||||
if (match >= 0) {
|
||||
// Account exists, remove it from the account list
|
||||
accounts.splice(match, 1);
|
||||
@@ -142,7 +143,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private updateAccountList(accounts: azdata.Account[], accountToUpdate: azdata.AccountKey, updateOperation: (account: azdata.Account) => void): AccountListOperationResult {
|
||||
// Check if the entry exists
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToUpdate));
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToUpdate));
|
||||
if (match < 0) {
|
||||
// Account doesn't exist, we won't do anything
|
||||
return {
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface IAccountManagementService {
|
||||
addAccount(providerId: string): Thenable<void>;
|
||||
getAccountProviderMetadata(): Thenable<azdata.AccountProviderMetadata[]>;
|
||||
getAccountsForProvider(providerId: string): Thenable<azdata.Account[]>;
|
||||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}>;
|
||||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{ [key: string]: { token: string } }>;
|
||||
removeAccount(accountKey: azdata.AccountKey): Thenable<boolean>;
|
||||
refreshAccount(account: azdata.Account): Thenable<azdata.Account>;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
const GROUPS_CONFIG_KEY = 'datasource.connectionGroups';
|
||||
const CONNECTIONS_CONFIG_KEY = 'datasource.connections';
|
||||
@@ -43,7 +44,7 @@ export class ConnectionConfig {
|
||||
|
||||
if (user) {
|
||||
if (workspace) {
|
||||
user = user.filter(x => workspace.find(f => this.isSameGroupName(f, x)) === undefined);
|
||||
user = user.filter(x => find(workspace, f => this.isSameGroupName(f, x)) === undefined);
|
||||
allGroups = allGroups.concat(workspace);
|
||||
}
|
||||
allGroups = allGroups.concat(user);
|
||||
@@ -71,12 +72,12 @@ export class ConnectionConfig {
|
||||
let newProfile = ConnectionProfile.convertToProfileStore(this._capabilitiesService, connectionProfile);
|
||||
|
||||
// Remove the profile if already set
|
||||
let sameProfileInList = profiles.find(value => {
|
||||
let sameProfileInList = find(profiles, value => {
|
||||
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
||||
return providerConnectionProfile.matches(connectionProfile);
|
||||
});
|
||||
if (sameProfileInList) {
|
||||
let profileIndex = profiles.findIndex(value => value === sameProfileInList);
|
||||
let profileIndex = firstIndex(profiles, value => value === sameProfileInList);
|
||||
newProfile.id = sameProfileInList.id;
|
||||
connectionProfile.id = sameProfileInList.id;
|
||||
profiles[profileIndex] = newProfile;
|
||||
@@ -123,7 +124,7 @@ export class ConnectionConfig {
|
||||
return Promise.resolve(profileGroup.id);
|
||||
} else {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let sameNameGroup = groups ? groups.find(group => group.name === profileGroup.name) : undefined;
|
||||
let sameNameGroup = groups ? find(groups, group => group.name === profileGroup.name) : undefined;
|
||||
if (sameNameGroup) {
|
||||
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
|
||||
return Promise.reject(errMessage);
|
||||
@@ -276,7 +277,7 @@ export class ConnectionConfig {
|
||||
*/
|
||||
public canChangeConnectionConfig(profile: ConnectionProfile, newGroupID: string): boolean {
|
||||
let profiles = this.getConnections(true);
|
||||
let existingProfile = profiles.find(p => p.getConnectionInfoId() === profile.getConnectionInfoId()
|
||||
let existingProfile = find(profiles, p => p.getConnectionInfoId() === profile.getConnectionInfoId()
|
||||
&& p.groupId === newGroupID);
|
||||
return existingProfile === undefined;
|
||||
}
|
||||
@@ -328,7 +329,7 @@ export class ConnectionConfig {
|
||||
|
||||
public editGroup(source: ConnectionProfileGroup): Promise<void> {
|
||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).user;
|
||||
let sameNameGroup = groups ? groups.find(group => group.name === source.name && group.id !== source.id) : undefined;
|
||||
let sameNameGroup = groups ? find(groups, group => group.name === source.name && group.id !== source.id) : undefined;
|
||||
if (sameNameGroup) {
|
||||
let errMessage: string = nls.localize('invalidServerName', "A server group with the same name already exists.");
|
||||
return Promise.reject(errMessage);
|
||||
@@ -369,7 +370,7 @@ export class ConnectionConfig {
|
||||
color: color,
|
||||
description: description
|
||||
} as IConnectionProfileGroup;
|
||||
let found = groupTree.find(group => this.isSameGroupName(group, newGroup));
|
||||
let found = find(groupTree, group => this.isSameGroupName(group, newGroup));
|
||||
if (found) {
|
||||
if (index === groupNames.length - 1) {
|
||||
newGroupId = found.id;
|
||||
|
||||
@@ -14,6 +14,7 @@ import { isString } from 'vs/base/common/types';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { ConnectionOptionSpecialType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
// Concrete implementation of the IConnectionProfile interface
|
||||
|
||||
@@ -46,7 +47,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
let capabilities = this.capabilitiesService.getCapabilities(model.providerName);
|
||||
if (capabilities && capabilities.connection && capabilities.connection.connectionOptions) {
|
||||
const options = capabilities.connection.connectionOptions;
|
||||
let appNameOption = options.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
|
||||
let appNameOption = find(options, option => option.specialValueType === ConnectionOptionSpecialType.appName);
|
||||
if (appNameOption) {
|
||||
let appNameKey = appNameOption.name;
|
||||
this.options[appNameKey] = Constants.applicationName;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IConnectionProfileGroup {
|
||||
id: string;
|
||||
@@ -47,7 +49,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
});
|
||||
}
|
||||
|
||||
return Object.assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
|
||||
return assign({}, { name: this.name, id: this.id, parentId: this.parentId, children: subgroups, color: this.color, description: this.description });
|
||||
}
|
||||
|
||||
public get groupName(): string {
|
||||
@@ -85,7 +87,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
*/
|
||||
public get hasValidConnections(): boolean {
|
||||
if (this.connections) {
|
||||
let invalidConnections = this.connections.find(c => !c.isConnectionOptionsValid);
|
||||
let invalidConnections = find(this.connections, c => !c.isConnectionOptionsValid);
|
||||
if (invalidConnections !== undefined) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -14,6 +14,9 @@ import { join } from 'vs/base/common/path';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import * as azdata from 'azdata';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ConnectionStatusManager {
|
||||
|
||||
@@ -35,8 +38,8 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
}
|
||||
|
||||
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo {
|
||||
return Object.values(this._connections).find((connection: ConnectionManagementInfo) => connection.connectionProfile.id === profileId);
|
||||
public findConnectionByProfileId(profileId: string): ConnectionManagementInfo | undefined {
|
||||
return find(values(this._connections), connection => connection.connectionProfile.id === profileId);
|
||||
}
|
||||
|
||||
public findConnectionProfile(connectionProfile: IConnectionProfile): ConnectionManagementInfo | undefined {
|
||||
@@ -190,7 +193,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
private isSharedSession(fileUri: string): boolean {
|
||||
return !!(fileUri && fileUri.startsWith('vsls:'));
|
||||
return !!(fileUri && startsWith(fileUri, 'vsls:'));
|
||||
}
|
||||
|
||||
public isConnected(id: string): boolean {
|
||||
@@ -205,7 +208,7 @@ export class ConnectionStatusManager {
|
||||
}
|
||||
|
||||
public isDefaultTypeUri(uri: string): boolean {
|
||||
return !!(uri && uri.startsWith(Utils.uriPrefixes.default));
|
||||
return !!(uri && startsWith(uri, Utils.uriPrefixes.default));
|
||||
}
|
||||
|
||||
public getProviderIdFromUri(ownerUri: string): string {
|
||||
@@ -225,12 +228,12 @@ export class ConnectionStatusManager {
|
||||
* Get a list of the active connection profiles managed by the status manager
|
||||
*/
|
||||
public getActiveConnectionProfiles(providers?: string[]): ConnectionProfile[] {
|
||||
let profiles = Object.values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
|
||||
let profiles = values(this._connections).map((connectionInfo: ConnectionManagementInfo) => connectionInfo.connectionProfile);
|
||||
// Remove duplicate profiles that may be listed multiple times under different URIs by filtering for profiles that don't have the same ID as an earlier profile in the list
|
||||
profiles = profiles.filter((profile, index) => profiles.findIndex(otherProfile => otherProfile.id === profile.id) === index);
|
||||
profiles = profiles.filter((profile, index) => firstIndex(profiles, otherProfile => otherProfile.id === profile.id) === index);
|
||||
|
||||
if (providers) {
|
||||
profiles = profiles.filter(f => providers.includes(f.providerName));
|
||||
profiles = profiles.filter(f => find(providers, x => x === f.providerName));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const MAX_CONNECTIONS_DEFAULT = 25;
|
||||
|
||||
@@ -150,7 +151,7 @@ export class ConnectionStore {
|
||||
public getRecentlyUsedConnections(providers?: string[]): ConnectionProfile[] {
|
||||
let mru = this.mru.slice();
|
||||
if (providers && providers.length > 0) {
|
||||
mru = mru.filter(c => providers.includes(c.providerName));
|
||||
mru = mru.filter(c => find(providers, x => x === c.providerName));
|
||||
}
|
||||
return this.convertConfigValuesToConnectionProfiles(mru);
|
||||
}
|
||||
@@ -277,7 +278,7 @@ export class ConnectionStore {
|
||||
if (!withoutConnections) {
|
||||
profilesInConfiguration = this.connectionConfig.getConnections(true);
|
||||
if (providers && providers.length > 0) {
|
||||
profilesInConfiguration = profilesInConfiguration.filter(x => providers.includes(x.providerName));
|
||||
profilesInConfiguration = profilesInConfiguration.filter(x => find(providers, p => p === x.providerName));
|
||||
}
|
||||
}
|
||||
const groups = this.connectionConfig.getAllGroups();
|
||||
@@ -313,9 +314,9 @@ export class ConnectionStore {
|
||||
return result;
|
||||
}
|
||||
|
||||
public getGroupFromId(groupId: string): IConnectionProfileGroup {
|
||||
public getGroupFromId(groupId: string): IConnectionProfileGroup | undefined {
|
||||
const groups = this.connectionConfig.getAllGroups();
|
||||
return groups.find(group => group.id === groupId);
|
||||
return find(groups, group => group.id === groupId);
|
||||
}
|
||||
|
||||
private getMaxRecentConnectionsCount(): number {
|
||||
|
||||
@@ -10,6 +10,8 @@ import * as azdata from 'azdata';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ICapabilitiesService, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
|
||||
|
||||
@@ -94,7 +96,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
|
||||
public clone(): ProviderConnectionInfo {
|
||||
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
|
||||
instance.options = Object.assign({}, this.options);
|
||||
instance.options = assign({}, this.options);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -196,9 +198,9 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
return false;
|
||||
}
|
||||
|
||||
let optionMetadata = this._serverCapabilities.connectionOptions.find(
|
||||
option => option.specialValueType === ConnectionOptionSpecialType.password);
|
||||
let isPasswordRequired: boolean = optionMetadata.isRequired;
|
||||
let optionMetadata = find(this._serverCapabilities.connectionOptions,
|
||||
option => option.specialValueType === ConnectionOptionSpecialType.password)!; // i guess we are going to assume there is a password field
|
||||
let isPasswordRequired = optionMetadata.isRequired;
|
||||
if (this.providerName === Constants.mssqlProviderName) {
|
||||
isPasswordRequired = this.authenticationType === ProviderConnectionInfo.SqlAuthentication && optionMetadata.isRequired;
|
||||
}
|
||||
@@ -267,7 +269,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
|
||||
public getSpecialTypeOptionName(type: string): string | undefined {
|
||||
if (this._serverCapabilities) {
|
||||
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
|
||||
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === type);
|
||||
return !!optionMetadata ? optionMetadata.name : undefined;
|
||||
} else {
|
||||
return type.toString();
|
||||
@@ -282,7 +284,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
}
|
||||
|
||||
public get authenticationTypeDisplayName(): string {
|
||||
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === ConnectionOptionSpecialType.authType);
|
||||
let optionMetadata = find(this._serverCapabilities.connectionOptions, o => o.specialValueType === ConnectionOptionSpecialType.authType);
|
||||
let authType = this.authenticationType;
|
||||
let displayName: string = authType;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import * as TypeMoq from 'typemoq';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { deepClone, deepFreeze } from 'vs/base/common/objects';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
suite('ConnectionConfig', () => {
|
||||
let capabilitiesService: TypeMoq.Mock<ICapabilitiesService>;
|
||||
@@ -210,7 +211,7 @@ suite('ConnectionConfig', () => {
|
||||
}
|
||||
|
||||
for (let group of groups1) {
|
||||
let g2 = groups2.find(g => g.name === group.name);
|
||||
let g2 = find(groups2, g => g.name === group.name);
|
||||
// if we couldn't find the group it means they must not be equal
|
||||
if (!g2) {
|
||||
return false;
|
||||
@@ -373,12 +374,12 @@ suite('ConnectionConfig', () => {
|
||||
let allConnections = config.getConnections(false);
|
||||
assert.equal(allConnections.length, testConnections.length);
|
||||
allConnections.forEach(connection => {
|
||||
let userConnection = testConnections.find(u => u.options['serverName'] === connection.serverName);
|
||||
let userConnection = find(testConnections, u => u.options['serverName'] === connection.serverName);
|
||||
if (userConnection !== undefined) {
|
||||
assert.notEqual(connection.id, connection.getOptionsKey());
|
||||
assert.ok(!!connection.id);
|
||||
} else {
|
||||
let workspaceConnection = workspaceConnections.find(u => u.options['serverName'] === connection.serverName);
|
||||
let workspaceConnection = find(workspaceConnections, u => u.options['serverName'] === connection.serverName);
|
||||
assert.notEqual(connection.id, connection.getOptionsKey());
|
||||
assert.equal(workspaceConnection.id, connection.id);
|
||||
}
|
||||
@@ -394,7 +395,7 @@ suite('ConnectionConfig', () => {
|
||||
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
|
||||
assert.ok(!!result);
|
||||
assert.equal(result.groups.length, testGroups.length + 2, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'new-group2');
|
||||
let newGroup = find(result.groups, g => g.name === 'new-group2');
|
||||
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
@@ -407,7 +408,7 @@ suite('ConnectionConfig', () => {
|
||||
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
|
||||
assert.ok(!!result);
|
||||
assert.equal(result.groups.length, testGroups.length + 1, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'g2-5');
|
||||
let newGroup = find(result.groups, g => g.name === 'g2-5');
|
||||
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
@@ -420,7 +421,7 @@ suite('ConnectionConfig', () => {
|
||||
let result: ISaveGroupResult = config.saveGroup(groups, newGroups, color, newGroups);
|
||||
assert.ok(!!result);
|
||||
assert.equal(result.groups.length, testGroups.length, 'The result groups length is invalid');
|
||||
let newGroup = result.groups.find(g => g.name === 'g2-1');
|
||||
let newGroup = find(result.groups, g => g.name === 'g2-1');
|
||||
assert.equal(result.newGroupId, newGroup.id, 'The groups id is invalid');
|
||||
});
|
||||
|
||||
@@ -530,7 +531,7 @@ suite('ConnectionConfig', () => {
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
let editedGroup = editedGroups.find(group => group.id === 'g2');
|
||||
let editedGroup = find(editedGroups, group => group.id === 'g2');
|
||||
assert.ok(!!editedGroup);
|
||||
assert.equal(editedGroup.name, 'g-renamed');
|
||||
});
|
||||
@@ -547,7 +548,7 @@ suite('ConnectionConfig', () => {
|
||||
assert.fail();
|
||||
} catch (e) {
|
||||
let groups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
let originalGroup = groups.find(g => g.id === 'g2');
|
||||
let originalGroup = find(groups, g => g.id === 'g2');
|
||||
assert.ok(!!originalGroup);
|
||||
assert.equal(originalGroup.name, 'g2');
|
||||
}
|
||||
@@ -565,7 +566,7 @@ suite('ConnectionConfig', () => {
|
||||
let editedGroups = configurationService.inspect<IConnectionProfileGroup[]>('datasource.connectionGroups').user;
|
||||
|
||||
assert.equal(editedGroups.length, testGroups.length);
|
||||
let editedGroup = editedGroups.find(group => group.id === 'g2');
|
||||
let editedGroup = find(editedGroups, group => group.id === 'g2');
|
||||
assert.ok(!!editedGroup);
|
||||
assert.equal(editedGroup.parentId, 'g3');
|
||||
});
|
||||
@@ -622,7 +623,7 @@ suite('ConnectionConfig', () => {
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
|
||||
// two
|
||||
assert.equal(editedConnections.length, _testConnections.length);
|
||||
let editedConnection = editedConnections.find(con => con.id === 'server3-2');
|
||||
let editedConnection = find(editedConnections, con => con.id === 'server3-2');
|
||||
assert.ok(!!editedConnection);
|
||||
assert.equal(editedConnection.groupId, 'g3');
|
||||
}
|
||||
@@ -658,7 +659,7 @@ suite('ConnectionConfig', () => {
|
||||
|
||||
let editedConnections = configurationService.inspect<IConnectionProfileStore[]>('datasource.connections').user;
|
||||
assert.equal(editedConnections.length, testConnections.length);
|
||||
let editedConnection = editedConnections.find(con => con.id === 'server3');
|
||||
let editedConnection = find(editedConnections, con => con.id === 'server3');
|
||||
assert.ok(!!editedConnection);
|
||||
assert.equal(editedConnection.groupId, 'newid');
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/ap
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
suite('SQL ConnectionProfileInfo tests', () => {
|
||||
let msSQLCapabilities: ConnectionProviderProperties;
|
||||
@@ -187,7 +188,7 @@ suite('SQL ConnectionProfileInfo tests', () => {
|
||||
});
|
||||
|
||||
test('createFromStoredProfile should set the id to new guid if not set in stored profile', () => {
|
||||
let savedProfile = Object.assign({}, storedProfile, { id: undefined });
|
||||
let savedProfile = assign({}, storedProfile, { id: undefined });
|
||||
let connectionProfile = ConnectionProfile.createFromStoredProfile(savedProfile, capabilitiesService);
|
||||
assert.equal(savedProfile.groupId, connectionProfile.groupId);
|
||||
assert.deepEqual(savedProfile.providerName, connectionProfile.providerName);
|
||||
|
||||
@@ -13,11 +13,12 @@ import { TestConfigurationService } from 'sql/platform/connection/test/common/te
|
||||
import { TestCredentialsService } from 'sql/platform/credentials/test/common/testCredentialsService';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { deepClone, deepFreeze } from 'vs/base/common/objects';
|
||||
import { deepClone, deepFreeze, assign } from 'vs/base/common/objects';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { InMemoryStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
suite('ConnectionStore', () => {
|
||||
let defaultNamedProfile: IConnectionProfile = deepFreeze({
|
||||
@@ -153,7 +154,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
for (let i = 0; i < numCreds; i++) {
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
@@ -189,7 +190,7 @@ suite('ConnectionStore', () => {
|
||||
// Then expect the only 1 instance of that connection to be listed in the MRU
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + 1 });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(defaultNamedConnectionProfile);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
@@ -211,13 +212,13 @@ suite('ConnectionStore', () => {
|
||||
// Given we save 1 connection with password and multiple other connections without
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const integratedCred = Object.assign({}, defaultNamedProfile, {
|
||||
const integratedCred = assign({}, defaultNamedProfile, {
|
||||
serverName: defaultNamedProfile.serverName + 'Integrated',
|
||||
authenticationType: 'Integrated',
|
||||
userName: '',
|
||||
password: ''
|
||||
});
|
||||
const noPwdCred = Object.assign({}, defaultNamedProfile, {
|
||||
const noPwdCred = assign({}, defaultNamedProfile, {
|
||||
serverName: defaultNamedProfile.serverName + 'NoPwd',
|
||||
password: ''
|
||||
});
|
||||
@@ -232,7 +233,7 @@ suite('ConnectionStore', () => {
|
||||
// Then verify that since its password based we save the password
|
||||
assert.equal(credentialsService.credentials.size, 1);
|
||||
assert.strictEqual(recentCredential.password, defaultNamedProfile.password);
|
||||
assert.ok(recentCredential.credentialId.includes('Profile'), 'Expect credential to be marked as an Profile cred');
|
||||
assert.ok(recentCredential.credentialId.indexOf('Profile') > -1, 'Expect credential to be marked as an Profile cred');
|
||||
assert.ok(!current[0].password);
|
||||
// When add integrated auth connection
|
||||
const integratedCredConnectionProfile = new ConnectionProfile(capabilitiesService, integratedCred);
|
||||
@@ -312,7 +313,7 @@ suite('ConnectionStore', () => {
|
||||
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { providerName: providerName });
|
||||
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { providerName: providerName });
|
||||
|
||||
assert.ok(!connectionStore.isPasswordRequired(connectionProfile));
|
||||
});
|
||||
@@ -323,7 +324,7 @@ suite('ConnectionStore', () => {
|
||||
const credentialsService = new TestCredentialsService();
|
||||
|
||||
const password: string = 'asdf!@#$';
|
||||
const connectionProfile: IConnectionProfile = Object.assign({}, defaultNamedProfile, { password });
|
||||
const connectionProfile: IConnectionProfile = assign({}, defaultNamedProfile, { password });
|
||||
|
||||
const connectionStore = new ConnectionStore(storageService, configurationService,
|
||||
credentialsService, capabilitiesService);
|
||||
@@ -393,7 +394,7 @@ suite('ConnectionStore', () => {
|
||||
const profile = deepClone(defaultNamedProfile);
|
||||
profile.options['password'] = profile.password;
|
||||
profile.id = 'testId';
|
||||
let expectedProfile = Object.assign({}, profile);
|
||||
let expectedProfile = assign({}, profile);
|
||||
expectedProfile.password = '';
|
||||
expectedProfile.options['password'] = '';
|
||||
expectedProfile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, expectedProfile).toIConnectionProfile();
|
||||
@@ -406,7 +407,7 @@ suite('ConnectionStore', () => {
|
||||
const configurationService = new TestConfigurationService();
|
||||
const credentialsService = new TestCredentialsService();
|
||||
|
||||
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, Object.assign({}, defaultNamedProfile, { password: undefined }));
|
||||
const profile = ConnectionProfile.fromIConnectionProfile(capabilitiesService, assign({}, defaultNamedProfile, { password: undefined }));
|
||||
|
||||
const credId = `Microsoft.SqlTools|itemtype:Profile|id:${profile.getConnectionInfoId()}`;
|
||||
const password: string = 'asdf!@#$';
|
||||
@@ -453,7 +454,7 @@ suite('ConnectionStore', () => {
|
||||
const connectionGroups = connectionStore.getConnectionProfileGroups();
|
||||
|
||||
for (const group of connectionGroups) {
|
||||
const foundGroup = groups.find(g => g.id === group.id);
|
||||
const foundGroup = find(groups, g => g.id === group.id);
|
||||
assert.ok(foundGroup);
|
||||
}
|
||||
});
|
||||
@@ -467,7 +468,7 @@ suite('ConnectionStore', () => {
|
||||
credentialsService, capabilitiesService);
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
await connectionStore.addRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
@@ -475,7 +476,7 @@ suite('ConnectionStore', () => {
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const cred = Object.assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const cred = assign({}, defaultNamedProfile, { serverName: defaultNamedProfile.serverName + i });
|
||||
const connectionProfile = new ConnectionProfile(capabilitiesService, cred);
|
||||
connectionStore.removeRecentConnection(connectionProfile);
|
||||
const current = connectionStore.getRecentlyUsedConnections();
|
||||
|
||||
@@ -10,6 +10,7 @@ import * as assert from 'assert';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { TestCapabilitiesService } from 'sql/platform/capabilities/test/common/testCapabilitiesService';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
suite('SQL ProviderConnectionInfo tests', () => {
|
||||
let msSQLCapabilities: any;
|
||||
@@ -202,7 +203,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
test('constructor should initialize the options given a valid model with options', () => {
|
||||
let options = {};
|
||||
options['encrypt'] = 'test value';
|
||||
let conn2 = Object.assign({}, connectionProfile, { options: options });
|
||||
let conn2 = assign({}, connectionProfile, { options: options });
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, conn2);
|
||||
|
||||
assert.equal(conn.connectionName, conn2.connectionName);
|
||||
@@ -223,7 +224,7 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
test('getOptionsKey should create different id for different server names', () => {
|
||||
let conn = new ProviderConnectionInfo(capabilitiesService, connectionProfile);
|
||||
let conn2 = new ProviderConnectionInfo(capabilitiesService, Object.assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
||||
let conn2 = new ProviderConnectionInfo(capabilitiesService, assign({}, connectionProfile, { serverName: connectionProfile.serverName + '1' }));
|
||||
|
||||
assert.notEqual(conn.getOptionsKey(), conn2.getOptionsKey());
|
||||
});
|
||||
@@ -260,4 +261,4 @@ suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
assert.equal(expectedProviderId, actual);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
let connections: ConnectionStatusManager;
|
||||
let capabilitiesService: TestCapabilitiesService;
|
||||
@@ -171,7 +172,7 @@ suite('SQL ConnectionStatusManager tests', () => {
|
||||
let expectedConnectionId = 'new id';
|
||||
connections.addConnection(connectionProfile, connection1Id);
|
||||
|
||||
let updatedConnection = Object.assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
|
||||
let updatedConnection = assign({}, connectionProfile, { groupId: expected, getOptionsKey: () => connectionProfile.getOptionsKey() + expected, id: expectedConnectionId });
|
||||
let actualId = connections.updateConnectionProfile(updatedConnection, connection1Id);
|
||||
|
||||
let newId = Utils.generateUri(updatedConnection);
|
||||
@@ -246,7 +247,7 @@ suite('SQL ConnectionStatusManager tests', () => {
|
||||
|
||||
test('getActiveConnectionProfiles should return a list of all the unique connections that the status manager knows about', () => {
|
||||
// Add duplicate connections
|
||||
let newConnection = Object.assign({}, connectionProfile);
|
||||
let newConnection = assign({}, connectionProfile);
|
||||
newConnection.id = 'test_id';
|
||||
newConnection.serverName = 'new_server_name';
|
||||
newConnection.options['databaseDisplayName'] = newConnection.databaseName;
|
||||
|
||||
@@ -8,6 +8,7 @@ import * as platform from 'vs/platform/registry/common/platform';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IInsightData } from 'sql/workbench/parts/charts/browser/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export type InsightIdentifier = string;
|
||||
|
||||
@@ -107,7 +108,7 @@ class InsightRegistry implements IInsightRegistry {
|
||||
}
|
||||
|
||||
public getAllCtors(): Array<Type<IInsightsView>> {
|
||||
return Object.values(this._idToCtor);
|
||||
return values(this._idToCtor);
|
||||
}
|
||||
|
||||
public getAllIds(): Array<string> {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ModelComponentTypes } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
import * as platform from 'vs/platform/registry/common/platform';
|
||||
import { IComponent } from 'sql/workbench/browser/modelComponents/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export type ComponentIdentifier = string;
|
||||
|
||||
@@ -46,7 +47,7 @@ class ComponentRegistry implements IComponentRegistry {
|
||||
}
|
||||
|
||||
public getAllCtors(): Array<Type<IComponent>> {
|
||||
return Object.values(this._idToCtor);
|
||||
return values(this._idToCtor);
|
||||
}
|
||||
|
||||
public getAllIds(): Array<string> {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class JobManagementUtilities {
|
||||
|
||||
@@ -41,7 +42,7 @@ export class JobManagementUtilities {
|
||||
}
|
||||
|
||||
public static convertToNextRun(date: string) {
|
||||
if (date.includes('1/1/0001')) {
|
||||
if (find(date, x => x === '1/1/0001')) {
|
||||
return nls.localize('agentUtilities.notScheduled', "Not Scheduled");
|
||||
} else {
|
||||
return date;
|
||||
@@ -49,7 +50,7 @@ export class JobManagementUtilities {
|
||||
}
|
||||
|
||||
public static convertToLastRun(date: string) {
|
||||
if (date.includes('1/1/0001')) {
|
||||
if (find(date, x => x === '1/1/0001')) {
|
||||
return nls.localize('agentUtilities.neverRun', "Never Run");
|
||||
} else {
|
||||
return date;
|
||||
@@ -57,7 +58,7 @@ export class JobManagementUtilities {
|
||||
}
|
||||
|
||||
public static setRunnable(icon: HTMLElement, index: number) {
|
||||
if (icon.className.includes('non-runnable')) {
|
||||
if (find(icon.className, x => x === 'non-runnable')) {
|
||||
icon.className = icon.className.slice(0, index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export const SERVICE_ID = 'queryManagementService';
|
||||
|
||||
@@ -173,7 +174,7 @@ export class QueryManagementService implements IQueryManagementService {
|
||||
provider: providerId,
|
||||
};
|
||||
if (runOptions) {
|
||||
data = Object.assign({}, data, {
|
||||
data = assign({}, data, {
|
||||
displayEstimatedQueryPlan: runOptions.displayEstimatedQueryPlan,
|
||||
displayActualQueryPlan: runOptions.displayActualQueryPlan
|
||||
});
|
||||
|
||||
@@ -27,6 +27,7 @@ import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { IGridDataProvider, getResultsString } from 'sql/platform/query/common/gridDataProvider';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IEditSessionReadyEvent {
|
||||
ownerUri: string;
|
||||
@@ -346,7 +347,7 @@ export default class QueryRunner extends Disposable {
|
||||
}
|
||||
// handle getting queryPlanxml if we need too
|
||||
// check if this result has show plan, this needs work, it won't work for any other provider
|
||||
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
|
||||
let hasShowPlan = !!find(result.resultSetSummary.columnInfo, e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
|
||||
if (hasShowPlan) {
|
||||
this._isQueryPlan = true;
|
||||
|
||||
@@ -373,7 +374,7 @@ export default class QueryRunner extends Disposable {
|
||||
batchSet = this._batchSets[resultSet.batchId];
|
||||
// handle getting queryPlanxml if we need too
|
||||
// check if this result has show plan, this needs work, it won't work for any other provider
|
||||
let hasShowPlan = !!result.resultSetSummary.columnInfo.find(e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
|
||||
let hasShowPlan = !!find(result.resultSetSummary.columnInfo, e => e.columnName === 'Microsoft SQL Server 2005 XML Showplan');
|
||||
if (hasShowPlan) {
|
||||
this._isQueryPlan = true;
|
||||
this.getQueryRows(0, 1, result.resultSetSummary.batchId, result.resultSetSummary.id).then(e => {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* Service that collects the results of executed queries
|
||||
@@ -41,7 +42,7 @@ export class QueryHistoryService extends Disposable implements IQueryHistoryServ
|
||||
this._captureEnabled = !!this._configurationService.getValue<boolean>('queryHistory.captureEnabled');
|
||||
|
||||
this._register(this._configurationService.onDidChangeConfiguration((e: IConfigurationChangeEvent) => {
|
||||
if (e.affectedKeys.includes('queryHistory.captureEnabled')) {
|
||||
if (find(e.affectedKeys, x => x === 'queryHistory.captureEnabled')) {
|
||||
this.updateCaptureEnabled();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -24,6 +24,7 @@ import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilitie
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { invalidProvider } from 'sql/base/common/errors';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class RestoreService implements IRestoreService {
|
||||
|
||||
@@ -272,7 +273,7 @@ export class RestoreDialogController implements IRestoreDialogController {
|
||||
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
|
||||
|
||||
if (providerCapabilities) {
|
||||
let restoreMetadataProvider = providerCapabilities.features.find(f => f.featureName === this._restoreFeature);
|
||||
let restoreMetadataProvider = find(providerCapabilities.features, f => f.featureName === this._restoreFeature);
|
||||
if (restoreMetadataProvider) {
|
||||
options = restoreMetadataProvider.optionsMetadata;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import * as azdata from 'azdata';
|
||||
import { localize } from 'vs/nls';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const SERVICE_ID = 'serializationService';
|
||||
|
||||
@@ -95,7 +96,7 @@ export class SerializationService implements ISerializationService {
|
||||
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);
|
||||
|
||||
if (providerCapabilities) {
|
||||
return providerCapabilities.features.find(f => f.featureName === SERVICE_ID);
|
||||
return find(providerCapabilities.features, f => f.featureName === SERVICE_ID);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@@ -13,6 +13,7 @@ import { localize } from 'vs/nls';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const SERVICE_ID = 'taskHistoryService';
|
||||
export const ITaskService = createDecorator<ITaskService>(SERVICE_ID);
|
||||
@@ -226,7 +227,7 @@ export class TaskService implements ITaskService {
|
||||
|
||||
private getTaskInQueue(taskId: string): TaskNode | undefined {
|
||||
if (this._taskQueue.hasChildren) {
|
||||
return this._taskQueue.children.find(x => x.id === taskId);
|
||||
return find(this._taskQueue.children, x => x.id === taskId);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { IAdsTelemetryService, ITelemetryInfo, ITelemetryEvent, ITelemetryConnectionInfo, ITelemetryEventMeasures, ITelemetryEventProperties } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
|
||||
class TelemetryEventImpl implements ITelemetryEvent {
|
||||
@@ -33,17 +34,17 @@ class TelemetryEventImpl implements ITelemetryEvent {
|
||||
}
|
||||
|
||||
public withAdditionalProperties(additionalProperties: ITelemetryEventProperties): ITelemetryEvent {
|
||||
Object.assign(this._properties, additionalProperties);
|
||||
assign(this._properties, additionalProperties);
|
||||
return this;
|
||||
}
|
||||
|
||||
public withAdditionalMeasurements(additionalMeasurements: ITelemetryEventMeasures): ITelemetryEvent {
|
||||
Object.assign(this._measurements, additionalMeasurements);
|
||||
assign(this._measurements, additionalMeasurements);
|
||||
return this;
|
||||
}
|
||||
|
||||
public withConnectionInfo(connectionInfo: ITelemetryConnectionInfo): ITelemetryEvent {
|
||||
Object.assign(this._properties,
|
||||
assign(this._properties,
|
||||
{
|
||||
authenticationType: connectionInfo.authenticationType,
|
||||
providerName: connectionInfo.providerName,
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadAccountManagement)
|
||||
export class MainThreadAccountManagement extends Disposable implements MainThreadAccountManagementShape {
|
||||
@@ -36,7 +38,7 @@ export class MainThreadAccountManagement extends Disposable implements MainThrea
|
||||
return;
|
||||
}
|
||||
|
||||
const providerMetadataIndex = Object.values(this._providerMetadata).findIndex((providerMetadata: azdata.AccountProviderMetadata) => providerMetadata.id === e.providerId);
|
||||
const providerMetadataIndex = firstIndex(values(this._providerMetadata), (providerMetadata: azdata.AccountProviderMetadata) => providerMetadata.id === e.providerId);
|
||||
if (providerMetadataIndex === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { MainThreadDashboardWebviewShape, SqlMainContext, ExtHostDashboardWebvie
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IDashboardViewService, IDashboardWebview } from 'sql/platform/dashboard/browser/dashboardViewService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadDashboardWebview)
|
||||
export class MainThreadDashboardWebview implements MainThreadDashboardWebviewShape {
|
||||
@@ -23,7 +24,7 @@ export class MainThreadDashboardWebview implements MainThreadDashboardWebviewSha
|
||||
) {
|
||||
this._proxy = context.getProxy(SqlExtHostContext.ExtHostDashboardWebviews);
|
||||
viewService.onRegisteredWebview(e => {
|
||||
if (this.knownWidgets.includes(e.id)) {
|
||||
if (find(this.knownWidgets, x => x === e.id)) {
|
||||
let handle = MainThreadDashboardWebview._handlePool++;
|
||||
this._dialogs.set(handle, e);
|
||||
this._proxy.$registerWidget(handle, e.id, e.connection, e.serverInfo);
|
||||
|
||||
@@ -25,6 +25,7 @@ import { ISerializationService } from 'sql/platform/serialization/common/seriali
|
||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
/**
|
||||
* Main thread class for handling data protocol management registration.
|
||||
@@ -521,7 +522,7 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
}
|
||||
|
||||
public $onObjectExplorerNodeExpanded(providerId: string, expandResponse: azdata.ObjectExplorerExpandInfo): void {
|
||||
let expandInfo: NodeExpandInfoWithProviderId = Object.assign({ providerId: providerId }, expandResponse);
|
||||
let expandInfo: NodeExpandInfoWithProviderId = assign({ providerId: providerId }, expandResponse);
|
||||
this._objectExplorerService.onNodeExpanded(expandInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IModelViewService } from 'sql/platform/modelComponents/browser/modelViewService';
|
||||
import { IItemConfig, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IModelView } from 'sql/platform/model/browser/modelViewService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadModelView)
|
||||
@@ -29,7 +30,7 @@ export class MainThreadModelView extends Disposable implements MainThreadModelVi
|
||||
super();
|
||||
this._proxy = _context.getProxy(SqlExtHostContext.ExtHostModelView);
|
||||
viewService.onRegisteredModelView(view => {
|
||||
if (this.knownWidgets.includes(view.id)) {
|
||||
if (find(this.knownWidgets, x => x === view.id)) {
|
||||
let handle = MainThreadModelView._handlePool++;
|
||||
this._dialogs.set(handle, view);
|
||||
this._proxy.$registerWidget(handle, view.id, view.connection, view.serverInfo);
|
||||
|
||||
@@ -33,6 +33,7 @@ import { viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
|
||||
import { notebookModeId } from 'sql/workbench/browser/customInputConverter';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
class MainThreadNotebookEditor extends Disposable {
|
||||
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||
@@ -372,7 +373,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let cell: ICellModel;
|
||||
if (cellUri) {
|
||||
let uriString = URI.revive(cellUri).toString();
|
||||
cell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
cell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
// If it's markdown what should we do? Show notification??
|
||||
} else {
|
||||
// Use the active cell in this case, or 1st cell if there's none active
|
||||
@@ -394,11 +395,11 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let endCell: ICellModel;
|
||||
if (startCellUri) {
|
||||
let uriString = URI.revive(startCellUri).toString();
|
||||
startCell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
startCell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
}
|
||||
if (endCellUri) {
|
||||
let uriString = URI.revive(endCellUri).toString();
|
||||
endCell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
endCell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
}
|
||||
return editor.runAllCells(startCell, endCell);
|
||||
}
|
||||
@@ -412,7 +413,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let cell: ICellModel;
|
||||
if (cellUri) {
|
||||
let uriString = URI.revive(cellUri).toString();
|
||||
cell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
cell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
// If it's markdown what should we do? Show notification??
|
||||
} else {
|
||||
// Use the active cell in this case, or 1st cell if there's none active
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
import { AzureResource } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
private _handlePool: number = 0;
|
||||
@@ -94,7 +96,7 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
return this.$getAllAccounts().then(() => {
|
||||
for (const handle in this._accounts) {
|
||||
const providerHandle = parseInt(handle);
|
||||
if (this._accounts[handle].findIndex((acct) => acct.key.accountId === account.key.accountId) !== -1) {
|
||||
if (firstIndex(this._accounts[handle], (acct) => acct.key.accountId === account.key.accountId) !== -1) {
|
||||
return this._withProvider(providerHandle, (provider: azdata.AccountProvider) => provider.getSecurityToken(account, resource));
|
||||
}
|
||||
}
|
||||
@@ -115,7 +117,7 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: AccountProviderWithMetadata) => {
|
||||
let matchingProviderIndex = firstIndex(values(this._providers), (provider: AccountProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { SqlMainContext, MainThreadDataProtocolShape, ExtHostDataProtocolShape }
|
||||
import { DataProviderType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IURITransformer } from 'vs/base/common/uriIpc';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
|
||||
@@ -71,7 +72,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
if (!providersForType) {
|
||||
return undefined;
|
||||
}
|
||||
return providersForType.find(provider => provider.providerId === providerId) as T;
|
||||
return find(providersForType, provider => provider.providerId === providerId) as T;
|
||||
}
|
||||
|
||||
public getProvidersByType<T extends azdata.DataProvider>(providerType: azdata.DataProviderType): T[] {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { deepClone, assign } from 'vs/base/common/objects';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as azdata from 'azdata';
|
||||
import { SqlMainContext, ExtHostModelViewShape, MainThreadModelViewShape, ExtHostModelViewTreeViewsShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { IItemConfig, ModelComponentTypes, IComponentShape, IComponentEventArgs, ComponentEventType, ColumnSizingMode } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
class ModelBuilderImpl implements azdata.ModelBuilder {
|
||||
private nextComponentId: number;
|
||||
@@ -269,7 +270,7 @@ class ComponentBuilderImpl<T extends azdata.Component> implements azdata.Compone
|
||||
|
||||
withProperties<U>(properties: U): azdata.ComponentBuilder<T> {
|
||||
// Keep any properties that may have been set during initial object construction
|
||||
this._component.properties = Object.assign({}, this._component.properties, properties);
|
||||
this._component.properties = assign({}, this._component.properties, properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -343,7 +344,7 @@ class FormContainerBuilder extends GenericContainerBuilder<azdata.FormContainer,
|
||||
});
|
||||
}
|
||||
|
||||
return new InternalItemConfig(componentWrapper, Object.assign({}, itemLayout, {
|
||||
return new InternalItemConfig(componentWrapper, assign({}, itemLayout || {}, {
|
||||
title: formComponent.title,
|
||||
actions: actions,
|
||||
isFormComponent: true,
|
||||
@@ -409,8 +410,8 @@ class FormContainerBuilder extends GenericContainerBuilder<azdata.FormContainer,
|
||||
let result: boolean = false;
|
||||
if (componentGroup && componentGroup.components !== undefined) {
|
||||
let firstComponent = componentGroup.components[0];
|
||||
let index = this._component.itemConfigs.findIndex(x => x.component.id === firstComponent.component.id);
|
||||
if (index) {
|
||||
let index = firstIndex(this._component.itemConfigs, x => x.component.id === firstComponent.component.id);
|
||||
if (index !== -1) {
|
||||
result = this._component.removeItemAt(index - 1);
|
||||
}
|
||||
componentGroup.components.forEach(element => {
|
||||
@@ -606,7 +607,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public removeItem(item: azdata.Component): boolean {
|
||||
let index = this.itemConfigs.findIndex(c => c.component.id === item.id);
|
||||
let index = firstIndex(this.itemConfigs, c => c.component.id === item.id);
|
||||
if (index >= 0 && index < this.itemConfigs.length) {
|
||||
return this.removeItemAt(index);
|
||||
}
|
||||
@@ -638,7 +639,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public updateProperties(properties: { [key: string]: any }): Thenable<void> {
|
||||
this.properties = Object.assign(this.properties, properties);
|
||||
this.properties = assign(this.properties, properties);
|
||||
return this.notifyPropertyChanged();
|
||||
}
|
||||
|
||||
@@ -647,7 +648,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public updateCssStyles(cssStyles: { [key: string]: string }): Thenable<void> {
|
||||
this.properties.CSSStyles = Object.assign(this.properties.CSSStyles || {}, cssStyles);
|
||||
this.properties.CSSStyles = assign(this.properties.CSSStyles || {}, cssStyles);
|
||||
return this.notifyPropertyChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import * as azdata from 'azdata';
|
||||
import * as vsTreeExt from 'vs/workbench/api/common/extHostTreeViews';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape {
|
||||
private _proxy: MainThreadModelViewShape;
|
||||
@@ -163,7 +164,7 @@ export class ExtHostTreeView<T> extends vsTreeExt.ExtHostTreeView<T> {
|
||||
protected createTreeNode(element: T, extensionTreeItem: azdata.TreeComponentItem, parent?: vsTreeExt.TreeNode): vsTreeExt.TreeNode {
|
||||
let node = super.createTreeNode(element, extensionTreeItem, parent);
|
||||
if (node.item) {
|
||||
node.item = Object.assign(node.item, { checked: extensionTreeItem.checked, enabled: extensionTreeItem.enabled });
|
||||
node.item = assign(node.item, { checked: extensionTreeItem.checked, enabled: extensionTreeItem.enabled });
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { MainThreadNotebookDocumentsAndEditorsShape } from 'sql/workbench/api/co
|
||||
import { ExtHostNotebookDocumentData } from 'sql/workbench/api/common/extHostNotebookDocumentData';
|
||||
import { CellRange, ISingleNotebookEditOperation, ICellRange } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { HideInputTag } from 'sql/workbench/parts/notebook/browser/models/cell';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface INotebookEditOperation {
|
||||
range: azdata.nb.CellRange;
|
||||
@@ -91,7 +92,7 @@ export class NotebookEditorEdit {
|
||||
value.metadata = { tags: [HideInputTag] };
|
||||
} else if (!value.metadata.tags) {
|
||||
value.metadata.tags = [HideInputTag];
|
||||
} else if (!value.metadata.tags.includes(HideInputTag)) {
|
||||
} else if (!find(value.metadata.tags, x => x === HideInputTag)) {
|
||||
value.metadata.tags.push(HideInputTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
MainThreadResourceProviderShape,
|
||||
SqlMainContext,
|
||||
} from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export class ExtHostResourceProvider extends ExtHostResourceProviderShape {
|
||||
private _handlePool: number = 0;
|
||||
@@ -36,7 +38,7 @@ export class ExtHostResourceProvider extends ExtHostResourceProviderShape {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: ResourceProviderWithMetadata) => {
|
||||
let matchingProviderIndex = firstIndex(values(this._providers), (provider: ResourceProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import { NotebookInput } from 'sql/workbench/parts/notebook/browser/models/noteb
|
||||
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
////// Exported public functions/vars
|
||||
|
||||
@@ -217,11 +218,11 @@ function hasFileExtension(extensions: string[], input: EditorInput, checkUntitle
|
||||
let lastPeriodIndex = input.getName().lastIndexOf('.');
|
||||
if (lastPeriodIndex > -1) {
|
||||
let extension: string = input.getName().substr(lastPeriodIndex + 1).toUpperCase();
|
||||
return !!extensions.find(x => x === extension);
|
||||
return !!find(extensions, x => x === extension);
|
||||
}
|
||||
|
||||
// Check for untitled file type
|
||||
if (checkUntitledFileType && input.getName().includes(untitledFilePrefix)) {
|
||||
if (checkUntitledFileType && find(input.getName(), x => x === untitledFilePrefix)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export const MODAL_SHOWING_KEY = 'modalShowing';
|
||||
export const MODAL_SHOWING_CONTEXT = new RawContextKey<Array<string>>(MODAL_SHOWING_KEY, []);
|
||||
@@ -419,7 +420,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
* @param onSelect The callback to call when the button is selected
|
||||
*/
|
||||
protected findFooterButton(label: string): Button {
|
||||
return this._footerButtons.find(e => {
|
||||
return find(this._footerButtons, e => {
|
||||
try {
|
||||
return e && e.element.innerText === label;
|
||||
} catch {
|
||||
@@ -433,7 +434,7 @@ export abstract class Modal extends Disposable implements IThemable {
|
||||
* @param label Label on the button
|
||||
*/
|
||||
protected removeFooterButton(label: string): void {
|
||||
let buttonIndex = this._footerButtons.findIndex(e => {
|
||||
let buttonIndex = firstIndex(this._footerButtons, e => {
|
||||
return e && e.element && e.element.innerText === label;
|
||||
});
|
||||
if (buttonIndex > -1 && buttonIndex < this._footerButtons.length) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import * as types from 'vs/base/common/types';
|
||||
import * as azdata from 'azdata';
|
||||
import { localize } from 'vs/nls';
|
||||
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
export interface IOptionElement {
|
||||
optionWidget: any;
|
||||
@@ -150,7 +151,7 @@ export function findElement(container: HTMLElement, className: string): HTMLElem
|
||||
let elementBuilder = container;
|
||||
while (elementBuilder) {
|
||||
let htmlElement = elementBuilder;
|
||||
if (htmlElement.className.startsWith(className)) {
|
||||
if (startsWith(htmlElement.className, className)) {
|
||||
break;
|
||||
}
|
||||
elementBuilder = elementBuilder.firstChild as HTMLElement;
|
||||
|
||||
@@ -19,6 +19,8 @@ import { URI } from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
import { EventType, addDisposableListener } from 'vs/base/browser/dom';
|
||||
import { IKeyboardEvent, StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { endsWith } from 'vs/base/common/strings';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
export type IUserFriendlyIcon = string | URI | { light: string | URI; dark: string | URI };
|
||||
@@ -192,9 +194,9 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
|
||||
|
||||
public convertSizeToNumber(size: number | string): number {
|
||||
if (size && typeof (size) === 'string') {
|
||||
if (size.toLowerCase().endsWith('px')) {
|
||||
if (endsWith(size.toLowerCase(), 'px')) {
|
||||
return +size.replace('px', '');
|
||||
} else if (size.toLowerCase().endsWith('em')) {
|
||||
} else if (endsWith(size.toLowerCase(), 'em')) {
|
||||
return +size.replace('em', '') * 11;
|
||||
}
|
||||
} else if (!size) {
|
||||
@@ -217,7 +219,7 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
|
||||
return defaultValue;
|
||||
}
|
||||
let convertedSize: string = size ? size.toString() : defaultValue;
|
||||
if (!convertedSize.toLowerCase().endsWith('px') && !convertedSize.toLowerCase().endsWith('%')) {
|
||||
if (!endsWith(convertedSize.toLowerCase(), 'px') && !endsWith(convertedSize.toLowerCase(), '%')) {
|
||||
convertedSize = convertedSize + 'px';
|
||||
}
|
||||
return convertedSize;
|
||||
@@ -308,7 +310,7 @@ export abstract class ContainerBase<T> extends ComponentBase {
|
||||
if (!componentDescriptor) {
|
||||
return false;
|
||||
}
|
||||
let index = this.items.findIndex(item => item.descriptor.id === componentDescriptor.id && item.descriptor.type === componentDescriptor.type);
|
||||
let index = firstIndex(this.items, item => item.descriptor.id === componentDescriptor.id && item.descriptor.type === componentDescriptor.type);
|
||||
if (index >= 0) {
|
||||
this.items.splice(index, 1);
|
||||
this._changeRef.detectChanges();
|
||||
|
||||
@@ -14,6 +14,7 @@ import * as azdata from 'azdata';
|
||||
import { ComponentBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { IComponent, IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/workbench/browser/modelComponents/interfaces';
|
||||
import { ISelectData } from 'vs/base/browser/ui/selectBox/selectBox';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export enum DeclarativeDataType {
|
||||
@@ -112,7 +113,7 @@ export default class DeclarativeTableComponent extends ComponentBase implements
|
||||
let column: azdata.DeclarativeTableColumn = this.columns[cell];
|
||||
if (column.categoryValues) {
|
||||
if (typeof e === 'string') {
|
||||
let category = column.categoryValues.find(c => c.displayName === e);
|
||||
let category = find(column.categoryValues, c => c.displayName === e);
|
||||
if (category) {
|
||||
this.onCellDataChanged(category.name, row, cell);
|
||||
} else {
|
||||
@@ -167,7 +168,7 @@ export default class DeclarativeTableComponent extends ComponentBase implements
|
||||
let column: azdata.DeclarativeTableColumn = this.columns[cell];
|
||||
let cellData = this.data[row][cell];
|
||||
if (cellData && column.categoryValues) {
|
||||
let category = column.categoryValues.find(v => v.name === cellData);
|
||||
let category = find(column.categoryValues, v => v.name === cellData);
|
||||
if (category) {
|
||||
return category.displayName;
|
||||
} else if (this.isEditableSelectBox(cell)) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
@Component({
|
||||
selector: 'modelview-dropdown',
|
||||
@@ -155,7 +156,7 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
||||
private getSelectedValue(): string {
|
||||
if (this.values && this.values.length > 0 && this.valuesHaveDisplayName()) {
|
||||
let selectedValue = <azdata.CategoryValue>this.value || <azdata.CategoryValue>this.values[0];
|
||||
let valueCategory = (<azdata.CategoryValue[]>this.values).find(v => v.name === selectedValue.name);
|
||||
let valueCategory = find(<azdata.CategoryValue[]>this.values, v => v.name === selectedValue.name);
|
||||
return valueCategory && valueCategory.displayName;
|
||||
} else {
|
||||
if (!this.value && this.values && this.values.length > 0) {
|
||||
@@ -167,7 +168,7 @@ export default class DropDownComponent extends ComponentBase implements ICompone
|
||||
|
||||
private setSelectedValue(newValue: string): void {
|
||||
if (this.values && this.valuesHaveDisplayName()) {
|
||||
let valueCategory = (<azdata.CategoryValue[]>this.values).find(v => v.displayName === newValue);
|
||||
let valueCategory = find((<azdata.CategoryValue[]>this.values), v => v.displayName === newValue);
|
||||
this.value = valueCategory;
|
||||
} else {
|
||||
this.value = newValue;
|
||||
|
||||
@@ -14,6 +14,7 @@ import { FormLayout, FormItemLayout } from 'azdata';
|
||||
|
||||
import { ContainerBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { CommonServiceInterface } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface TitledFormItemLayout {
|
||||
title: string;
|
||||
@@ -189,7 +190,7 @@ export default class FormContainer extends ContainerBase<FormItemLayout> impleme
|
||||
let itemConfig = item.config;
|
||||
if (itemConfig && itemConfig.actions) {
|
||||
let resultItems = itemConfig.actions.map(x => {
|
||||
let actionComponent = items.find(i => i.descriptor.id === x);
|
||||
let actionComponent = find(items, i => i.descriptor.id === x);
|
||||
return <FormItem>actionComponent;
|
||||
});
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { IComponent, IComponentDescriptor, IModelStore } from 'sql/workbench/bro
|
||||
import { GroupLayout, GroupContainerProperties } from 'azdata';
|
||||
|
||||
import { ContainerBase } from 'sql/workbench/browser/modelComponents/componentBase';
|
||||
import { endsWith } from 'vs/base/common/strings';
|
||||
|
||||
@Component({
|
||||
selector: 'modelview-groupContainer',
|
||||
@@ -85,7 +86,7 @@ export default class GroupContainer extends ContainerBase<GroupLayout> implement
|
||||
private getContainerWidth(): string {
|
||||
if (this._containerLayout && this._containerLayout.width) {
|
||||
let width: string = this._containerLayout.width.toString();
|
||||
if (!width.endsWith('%') && !width.toLowerCase().endsWith('px')) {
|
||||
if (!endsWith(width, '%') && !endsWith(width.toLowerCase(), 'px')) {
|
||||
width = width + 'px';
|
||||
}
|
||||
return width;
|
||||
|
||||
@@ -23,6 +23,7 @@ import { inputBackground, inputBorder } from 'vs/platform/theme/common/colorRegi
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
@Component({
|
||||
selector: 'modelview-inputBox',
|
||||
@@ -86,7 +87,7 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
|
||||
this.registerInput(this._input, () => !this.multiline);
|
||||
}
|
||||
if (this._textareaContainer) {
|
||||
let textAreaInputOptions = Object.assign({}, inputOptions, { flexibleHeight: true, type: 'textarea' });
|
||||
let textAreaInputOptions = assign({}, inputOptions, { flexibleHeight: true, type: 'textarea' });
|
||||
this._textAreaInput = new InputBox(this._textareaContainer.nativeElement, this.contextViewService, textAreaInputOptions);
|
||||
this.onkeydown(this._textAreaInput.inputElement, (e: StandardKeyboardEvent) => {
|
||||
if (this.tryHandleKeyEvent(e)) {
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
import { IModelStore, IComponentDescriptor, IComponent } from './interfaces';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { entries } from 'sql/base/common/objects';
|
||||
import { entries } from 'sql/base/common/collections';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
class ComponentDescriptor implements IComponentDescriptor {
|
||||
constructor(public readonly id: string, public readonly type: string) {
|
||||
@@ -65,7 +66,7 @@ export class ModelStore implements IModelStore {
|
||||
}
|
||||
|
||||
validate(component: IComponent): Thenable<boolean> {
|
||||
let componentId = entries(this._componentMappings).find(([id, mappedComponent]) => component === mappedComponent)[0];
|
||||
let componentId = find(entries(this._componentMappings), ([id, mappedComponent]) => component === mappedComponent)[0];
|
||||
return Promise.all(this._validationCallbacks.map(callback => callback(componentId))).then(validations => validations.every(validation => validation === true));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { TreeViewDataProvider } from 'sql/workbench/browser/modelComponents/tree
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
class Root implements ITreeComponentItem {
|
||||
label = {
|
||||
@@ -90,7 +91,7 @@ export default class TreeComponent extends ComponentBase implements IComponent,
|
||||
}
|
||||
|
||||
if (this._tree) {
|
||||
for (const item of Object.values(itemsToRefreshByHandle)) {
|
||||
for (const item of values(itemsToRefreshByHandle)) {
|
||||
this._tree.refresh(<ITreeComponentItem>item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/browser/m
|
||||
import { AngularDisposable } from 'sql/base/browser/lifecycle';
|
||||
import { ModelStore } from 'sql/workbench/browser/modelComponents/modelStore';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
const componentRegistry = <IComponentRegistry>Registry.as(Extensions.ComponentContribution);
|
||||
|
||||
@@ -125,7 +126,7 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
|
||||
registerEvent(componentId: string) {
|
||||
this.queueAction(componentId, (component) => {
|
||||
this._register(component.registerEventHandler(e => {
|
||||
let modelViewEvent: IModelViewEventArgs = Object.assign({
|
||||
let modelViewEvent: IModelViewEventArgs = assign({
|
||||
componentId: componentId,
|
||||
isRootComponent: componentId === this.rootDescriptor.id
|
||||
}, e);
|
||||
|
||||
@@ -49,6 +49,7 @@ import { ITreeItem, ITreeView } from 'sql/workbench/common/views';
|
||||
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerViewTreeShim';
|
||||
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/browser/nodeContext';
|
||||
import { UserCancelledConnectionError } from 'sql/base/common/errors';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export class CustomTreeViewPanel extends ViewletPanel {
|
||||
|
||||
@@ -947,7 +948,7 @@ class TreeMenus extends Disposable implements IDisposable {
|
||||
}
|
||||
|
||||
private mergeActions(actions: IAction[][]): IAction[] {
|
||||
return actions.reduce((p, c) => p.concat(...c.filter(a => p.findIndex(x => x.id === a.id) === -1)), [] as IAction[]);
|
||||
return actions.reduce((p, c) => p.concat(...c.filter(a => firstIndex(p, x => x.id === a.id) === -1)), [] as IAction[]);
|
||||
}
|
||||
|
||||
private getActions(menuId: MenuId, context: { key: string, value: string }): { primary: IAction[]; secondary: IAction[]; } {
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { tocData as vstocData, ITOCEntry } from 'vs/workbench/contrib/preferences/browser/settingsLayout';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
// Copy existing table of contents and append
|
||||
export const tocData: ITOCEntry = Object.assign({}, vstocData);
|
||||
export const tocData: ITOCEntry = assign({}, vstocData);
|
||||
let sqlTocItems: ITOCEntry[] = [{
|
||||
id: 'data',
|
||||
label: localize('data', "Data"),
|
||||
|
||||
@@ -23,6 +23,7 @@ import { attachDropdownStyler } from 'sql/platform/theme/common/styler';
|
||||
import { AddAccountAction, RefreshAccountAction } from 'sql/platform/accounts/common/accountActions';
|
||||
import { AccountPickerListRenderer, AccountListDelegate } from 'sql/workbench/parts/accounts/browser/accountListRenderer';
|
||||
import { AccountPickerViewModel } from 'sql/platform/accounts/common/accountPickerViewModel';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export class AccountPicker extends Disposable {
|
||||
public static ACCOUNTPICKERLIST_HEIGHT = 47;
|
||||
@@ -199,7 +200,7 @@ export class AccountPicker extends Disposable {
|
||||
// find selected index
|
||||
let selectedIndex: number | undefined;
|
||||
if (selectedElements.length > 0 && accounts.length > 0) {
|
||||
selectedIndex = accounts.findIndex((account) => {
|
||||
selectedIndex = firstIndex(accounts, (account) => {
|
||||
return (account.key.accountId === selectedElements[0].key.accountId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IFileDialogService, FileFilter } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export interface IChartActionContext {
|
||||
options: IInsightOptions;
|
||||
@@ -50,7 +51,7 @@ export class CreateInsightAction extends Action {
|
||||
let queryFile: string = uri.fsPath;
|
||||
let query: string = undefined;
|
||||
let type = {};
|
||||
let options = Object.assign({}, context.options);
|
||||
let options = assign({}, context.options);
|
||||
delete options.type;
|
||||
type[context.options.type] = options;
|
||||
// create JSON
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
||||
import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { IInsightOptions, DataDirection, DataType, LegendPosition, ChartType, InsightType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
const insightRegistry = Registry.as<IInsightRegistry>(Extensions.InsightContribution);
|
||||
|
||||
@@ -66,7 +67,7 @@ const labelFirstColumnInput: IChartOption = {
|
||||
const legendInput: IChartOption = {
|
||||
label: localize('legendLabel', "Legend Position"),
|
||||
type: ControlType.combo,
|
||||
options: Object.values(LegendPosition),
|
||||
options: values(LegendPosition),
|
||||
configEntry: 'legendPosition',
|
||||
default: LegendPosition.Top
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
import { ChartState, IInsightOptions, ChartType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import * as nls from 'vs/nls';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
declare class Proxy {
|
||||
constructor(object, handler);
|
||||
@@ -105,7 +106,7 @@ export class ChartView extends Disposable implements IPanelView {
|
||||
const self = this;
|
||||
this.options = new Proxy(this.options, {
|
||||
get: function (target, key, receiver) {
|
||||
return Reflect.get(target, key, receiver);
|
||||
return target[key];
|
||||
},
|
||||
set: function (target, key, value, receiver) {
|
||||
let change = false;
|
||||
@@ -113,10 +114,10 @@ export class ChartView extends Disposable implements IPanelView {
|
||||
change = true;
|
||||
}
|
||||
|
||||
let result = Reflect.set(target, key, value, receiver);
|
||||
let result = target[key] = value;
|
||||
// mirror the change in our state
|
||||
if (self.state) {
|
||||
Reflect.set(self.state.options, key, value);
|
||||
self.state.options[key] = value;
|
||||
}
|
||||
|
||||
if (change) {
|
||||
@@ -250,7 +251,7 @@ export class ChartView extends Disposable implements IPanelView {
|
||||
this.updateActionbar();
|
||||
for (let key in this.optionMap) {
|
||||
if (this.optionMap.hasOwnProperty(key)) {
|
||||
let option = ChartOptions[this.options.type].find(e => e.configEntry === key);
|
||||
let option = find(ChartOptions[this.options.type], e => e.configEntry === key);
|
||||
if (option && option.if) {
|
||||
if (option.if(this.options)) {
|
||||
DOM.show(this.optionMap[key].element);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Chart as ChartJs } from 'chart.js';
|
||||
import * as chartjs from 'chart.js';
|
||||
|
||||
import { mixin } from 'sql/base/common/objects';
|
||||
import { localize } from 'vs/nls';
|
||||
@@ -13,10 +13,12 @@ import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
import { IInsight, IInsightData, IPointDataSet, customMixin } from './interfaces';
|
||||
import { IInsightOptions, DataDirection, ChartType, LegendPosition, DataType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const noneLineGraphs = [ChartType.Doughnut, ChartType.Pie];
|
||||
|
||||
const timeSeriesScales: ChartJs.ChartOptions = {
|
||||
const timeSeriesScales: chartjs.ChartOptions = {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'time',
|
||||
@@ -42,7 +44,7 @@ const defaultOptions: IInsightOptions = {
|
||||
export class Graph implements IInsight {
|
||||
private _options: IInsightOptions;
|
||||
private canvas: HTMLCanvasElement;
|
||||
private chartjs: ChartJs;
|
||||
private chartjs: chartjs;
|
||||
private _data: IInsightData;
|
||||
|
||||
private originalType: ChartType;
|
||||
@@ -91,7 +93,7 @@ export class Graph implements IInsight {
|
||||
}
|
||||
this._data = data;
|
||||
let labels: Array<string>;
|
||||
let chartData: Array<ChartJs.ChartDataSets>;
|
||||
let chartData: Array<Chart.ChartDataSets>;
|
||||
|
||||
if (this.options.dataDirection === DataDirection.Horizontal) {
|
||||
if (this.options.labelFirstColumn) {
|
||||
@@ -114,7 +116,7 @@ export class Graph implements IInsight {
|
||||
dataSetMap[legend].data.push({ x: row[1], y: Number(row[2]) });
|
||||
}
|
||||
});
|
||||
chartData = Object.values(dataSetMap);
|
||||
chartData = values(dataSetMap);
|
||||
} else {
|
||||
if (this.options.dataDirection === DataDirection.Horizontal) {
|
||||
if (this.options.labelFirstColumn) {
|
||||
@@ -160,10 +162,10 @@ export class Graph implements IInsight {
|
||||
this.chartjs.config.type = this.options.type;
|
||||
// we don't want to include lables for timeSeries
|
||||
this.chartjs.data.labels = this.originalType === 'timeSeries' ? [] : labels;
|
||||
this.chartjs.options = this.transformOptions(this.options);
|
||||
this.chartjs.config.options = this.transformOptions(this.options);
|
||||
this.chartjs.update(0);
|
||||
} else {
|
||||
this.chartjs = new ChartJs(this.canvas.getContext('2d'), {
|
||||
this.chartjs = new chartjs.Chart(this.canvas.getContext('2d'), {
|
||||
data: {
|
||||
// we don't want to include lables for timeSeries
|
||||
labels: this.originalType === 'timeSeries' ? [] : labels,
|
||||
@@ -175,8 +177,8 @@ export class Graph implements IInsight {
|
||||
}
|
||||
}
|
||||
|
||||
private transformOptions(options: IInsightOptions): ChartJs.ChartOptions {
|
||||
let retval: ChartJs.ChartOptions = {};
|
||||
private transformOptions(options: IInsightOptions): Chart.ChartOptions {
|
||||
let retval: Chart.ChartOptions = {};
|
||||
retval.maintainAspectRatio = false;
|
||||
|
||||
let foregroundColor = this._theme.getColor(colors.editorForeground);
|
||||
@@ -189,7 +191,7 @@ export class Graph implements IInsight {
|
||||
if (options) {
|
||||
retval.scales = {};
|
||||
// we only want to include axis if it is a axis based graph type
|
||||
if (!noneLineGraphs.includes(options.type as ChartType)) {
|
||||
if (!find(noneLineGraphs, x => x === options.type as ChartType)) {
|
||||
retval.scales.xAxes = [{
|
||||
scaleLabel: {
|
||||
fontColor: foreground,
|
||||
@@ -262,8 +264,8 @@ export class Graph implements IInsight {
|
||||
}
|
||||
}
|
||||
|
||||
retval.legend = <ChartJs.ChartLegendOptions>{
|
||||
position: options.legendPosition as ChartJs.PositionType,
|
||||
retval.legend = <Chart.ChartLegendOptions>{
|
||||
position: options.legendPosition as Chart.PositionType,
|
||||
display: options.legendPosition !== LegendPosition.None,
|
||||
labels: {
|
||||
fontColor: foreground
|
||||
|
||||
@@ -9,6 +9,7 @@ import { $ } from 'vs/base/browser/dom';
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { IInsightOptions, InsightType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import * as nls from 'vs/nls';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
export interface IConfig extends IInsightOptions {
|
||||
encoding?: string;
|
||||
@@ -69,7 +70,7 @@ export class ImageInsight implements IInsight {
|
||||
|
||||
private static _hexToBase64(hexVal: string) {
|
||||
|
||||
if (hexVal.startsWith('0x')) {
|
||||
if (startsWith(hexVal, '0x')) {
|
||||
hexVal = hexVal.slice(2);
|
||||
}
|
||||
// should be able to be replaced with new Buffer(hexVal, 'hex').toString('base64')
|
||||
|
||||
@@ -13,6 +13,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { Dimension, clearNode } from 'vs/base/browser/dom';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { IInsightOptions, ChartType, DataDirection, InsightType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const defaultOptions: IInsightOptions = {
|
||||
type: ChartType.Bar,
|
||||
@@ -47,7 +48,7 @@ export class Insight {
|
||||
this._options = deepClone(val);
|
||||
if (this.insight) {
|
||||
// check to see if we need to change the insight type
|
||||
if (!this.insight.types.includes(this.options.type)) {
|
||||
if (!find(this.insight.types, x => x === this.options.type)) {
|
||||
this.buildInsight();
|
||||
} else {
|
||||
this.insight.options = this.options;
|
||||
@@ -84,17 +85,17 @@ export class Insight {
|
||||
}
|
||||
}
|
||||
public get isCopyable(): boolean {
|
||||
return Graph.types.includes(this.options.type as ChartType);
|
||||
return !!find(Graph.types, x => x === this.options.type as ChartType);
|
||||
}
|
||||
|
||||
private findctor(type: ChartType | InsightType): IInsightCtor {
|
||||
if (Graph.types.includes(type as ChartType)) {
|
||||
if (find(Graph.types, x => x === type as ChartType)) {
|
||||
return Graph;
|
||||
} else if (ImageInsight.types.includes(type as InsightType)) {
|
||||
} else if (find(ImageInsight.types, x => x === type as InsightType)) {
|
||||
return ImageInsight;
|
||||
} else if (TableInsight.types.includes(type as InsightType)) {
|
||||
} else if (find(TableInsight.types, x => x === type as InsightType)) {
|
||||
return TableInsight;
|
||||
} else if (CountInsight.types.includes(type as InsightType)) {
|
||||
} else if (find(CountInsight.types, x => x === type as InsightType)) {
|
||||
return CountInsight;
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface IPointDataSet {
|
||||
data: Array<{ x: number | string, y: number }>;
|
||||
label?: string;
|
||||
fill: boolean;
|
||||
backgroundColor?: Color;
|
||||
backgroundColor?: string;
|
||||
}
|
||||
|
||||
export function customMixin(destination: any, source: any, overwrite?: boolean): any {
|
||||
|
||||
@@ -30,6 +30,7 @@ import { openNewQuery } from 'sql/workbench/parts/query/browser/queryActions';
|
||||
import { IURLService, IURLHandler } from 'vs/platform/url/common/url';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const connectAuthority = 'connect';
|
||||
|
||||
@@ -242,7 +243,7 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution,
|
||||
if (groups && groups.length > 0) {
|
||||
let rootGroup = groups[0];
|
||||
let connections = ConnectionProfileGroup.getConnectionsInGroup(rootGroup);
|
||||
match = connections.find((c) => this.matchProfile(profile, c));
|
||||
match = find(connections, (c) => this.matchProfile(profile, c));
|
||||
}
|
||||
return match ? match : profile;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import { DashboardInput } from 'sql/workbench/parts/dashboard/browser/dashboardI
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* Workbench action to clear the recent connnections list
|
||||
@@ -83,7 +84,7 @@ export class ClearRecentConnectionsAction extends Action {
|
||||
];
|
||||
|
||||
self._quickInputService.pick(choices.map(x => x.key), { placeHolder: nls.localize('ClearRecentlyUsedLabel', "Clear List"), ignoreFocusLost: true }).then((choice) => {
|
||||
let confirm = choices.find(x => x.key === choice);
|
||||
let confirm = find(choices, x => x.key === choice);
|
||||
resolve(confirm && confirm.value);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,9 @@ import { NAV_SECTION, validateNavSectionContributionAndRegisterIcon } from 'sql/
|
||||
import { WIDGETS_CONTAINER, validateWidgetContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardWidgetContainer.contribution';
|
||||
import { GRID_CONTAINER, validateGridContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardGridContainer.contribution';
|
||||
import { WEBVIEW_CONTAINER } from 'sql/workbench/parts/dashboard/browser/containers/dashboardWebviewContainer.contribution';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { NavSectionConfig } from 'sql/workbench/parts/dashboard/browser/core/dashboardWidget';
|
||||
|
||||
const containerTypes = [
|
||||
WIDGETS_CONTAINER,
|
||||
@@ -24,7 +27,7 @@ export type IUserFriendlyIcon = string | { light: string; dark: string; };
|
||||
|
||||
export interface IDashboardContainerContrib {
|
||||
id: string;
|
||||
container: object;
|
||||
container: Record<string, NavSectionConfig[]>;
|
||||
}
|
||||
|
||||
const containerSchema: IJSONSchema = {
|
||||
@@ -73,9 +76,9 @@ ExtensionsRegistry.registerExtensionPoint<IDashboardContainerContrib | IDashboar
|
||||
|
||||
let result = true;
|
||||
const containerkey = Object.keys(container)[0];
|
||||
const containerValue = Object.values(container)[0];
|
||||
const containerValue = values(container)[0];
|
||||
|
||||
const containerTypeFound = containerTypes.find(c => (c === containerkey));
|
||||
const containerTypeFound = find(containerTypes, c => c === containerkey);
|
||||
if (!containerTypeFound) {
|
||||
extension.collector.error(localize('dashboardTab.contribution.unKnownContainerType', "Unknown container type defines in dashboard container for extension."));
|
||||
return;
|
||||
|
||||
@@ -17,6 +17,8 @@ import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ScrollbarVisibility } from 'vs/editor/common/standalone/standaloneEnums';
|
||||
import { ScrollableDirective } from 'sql/base/browser/ui/scrollable/scrollable.directive';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { fill } from 'vs/base/common/arrays';
|
||||
|
||||
export interface GridCellConfig {
|
||||
id?: string;
|
||||
@@ -192,7 +194,7 @@ export class DashboardGridContainer extends DashboardTab implements OnDestroy {
|
||||
|
||||
ngOnInit() {
|
||||
if (this.tab.container) {
|
||||
this._contents = Object.values(this.tab.container)[0];
|
||||
this._contents = values(this.tab.container)[0];
|
||||
this._contents.forEach(widget => {
|
||||
if (!widget.row) {
|
||||
widget.row = 0;
|
||||
@@ -214,7 +216,7 @@ export class DashboardGridContainer extends DashboardTab implements OnDestroy {
|
||||
|
||||
private createIndexes(indexes: number[]) {
|
||||
const max = Math.max(...indexes) + 1;
|
||||
return Array(max).fill(0).map((x, i) => i);
|
||||
return fill(max, 0).map((x, i) => i);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as nls from 'vs/nls';
|
||||
|
||||
import { generateDashboardGridLayoutSchema } from 'sql/workbench/parts/dashboard/browser/pages/dashboardPageContribution';
|
||||
import { registerContainerType, registerNavSectionContainerType } from 'sql/platform/dashboard/common/dashboardContainerRegistry';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const GRID_CONTAINER = 'grid-container';
|
||||
|
||||
@@ -25,7 +26,7 @@ export function validateGridContainerContribution(extension: IExtensionPointUser
|
||||
let result = true;
|
||||
gridConfigs.forEach(widgetConfig => {
|
||||
const allKeys = Object.keys(widgetConfig);
|
||||
const widgetOrWebviewKey = allKeys.find(key => key === 'widget' || key === 'webview');
|
||||
const widgetOrWebviewKey = find(allKeys, key => key === 'widget' || key === 'webview');
|
||||
if (!widgetOrWebviewKey) {
|
||||
result = false;
|
||||
extension.collector.error(nls.localize('gridContainer.invalidInputs', "widgets or webviews are expected inside widgets-container for extension."));
|
||||
|
||||
@@ -19,6 +19,8 @@ import * as dashboardHelper from 'sql/workbench/parts/dashboard/browser/core/das
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
@Component({
|
||||
selector: 'dashboard-nav-section',
|
||||
@@ -64,7 +66,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
|
||||
this.tabs = [];
|
||||
let navSectionContainers: NavSectionConfig[] = [];
|
||||
if (this.tab.container) {
|
||||
navSectionContainers = Object.values(this.tab.container)[0];
|
||||
navSectionContainers = values(this.tab.container)[0];
|
||||
let hasIcon = true;
|
||||
navSectionContainers.forEach(navSection => {
|
||||
if (!navSection.iconClass) {
|
||||
@@ -100,7 +102,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
|
||||
|
||||
const key = Object.keys(containerResult.container)[0];
|
||||
if (key === WIDGETS_CONTAINER || key === GRID_CONTAINER) {
|
||||
let configs = <WidgetConfig[]>Object.values(containerResult.container)[0];
|
||||
let configs = <WidgetConfig[]>values(containerResult.container)[0];
|
||||
this._configModifiers.forEach(cb => {
|
||||
configs = cb.apply(this, [configs, this, this.tab.context]);
|
||||
});
|
||||
@@ -127,7 +129,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh
|
||||
}
|
||||
|
||||
private addNewTab(tab: TabConfig): void {
|
||||
const existedTab = this.tabs.find(i => i.id === tab.id);
|
||||
const existedTab = find(this.tabs, i => i.id === tab.id);
|
||||
if (!existedTab) {
|
||||
this.tabs.push(tab);
|
||||
this._cd.detectChanges();
|
||||
|
||||
@@ -16,6 +16,7 @@ import { NavSectionConfig, IUserFriendlyIcon } from 'sql/workbench/parts/dashboa
|
||||
import { registerContainerType, generateNavSectionContainerTypeSchemaProperties } from 'sql/platform/dashboard/common/dashboardContainerRegistry';
|
||||
import { WIDGETS_CONTAINER, validateWidgetContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardWidgetContainer.contribution';
|
||||
import { GRID_CONTAINER, validateGridContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardGridContainer.contribution';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export const NAV_SECTION = 'nav-section';
|
||||
|
||||
@@ -120,7 +121,7 @@ export function validateNavSectionContributionAndRegisterIcon(extension: IExtens
|
||||
}
|
||||
|
||||
const containerKey = Object.keys(section.container)[0];
|
||||
const containerValue = Object.values(section.container)[0];
|
||||
const containerValue = values(section.container)[0];
|
||||
|
||||
switch (containerKey) {
|
||||
case WIDGETS_CONTAINER:
|
||||
|
||||
@@ -13,6 +13,7 @@ import { WidgetContent } from 'sql/workbench/parts/dashboard/browser/contents/wi
|
||||
import { TabChild } from 'sql/base/browser/ui/panel/tab.component';
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
@Component({
|
||||
selector: 'dashboard-widget-container',
|
||||
@@ -38,7 +39,7 @@ export class DashboardWidgetContainer extends DashboardTab implements OnDestroy,
|
||||
|
||||
ngOnInit() {
|
||||
if (this.tab.container) {
|
||||
this.widgets = Object.values(this.tab.container)[0];
|
||||
this.widgets = values(this.tab.container)[0];
|
||||
this._cd.detectChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import * as nls from 'vs/nls';
|
||||
|
||||
import { generateDashboardWidgetSchema } from 'sql/workbench/parts/dashboard/browser/pages/dashboardPageContribution';
|
||||
import { registerContainerType, registerNavSectionContainerType } from 'sql/platform/dashboard/common/dashboardContainerRegistry';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const WIDGETS_CONTAINER = 'widgets-container';
|
||||
|
||||
@@ -25,7 +26,7 @@ export function validateWidgetContainerContribution(extension: IExtensionPointUs
|
||||
let result = true;
|
||||
WidgetConfigs.forEach(widgetConfig => {
|
||||
const allKeys = Object.keys(widgetConfig);
|
||||
const widgetKey = allKeys.find(key => key === 'widget');
|
||||
const widgetKey = find(allKeys, key => key === 'widget');
|
||||
if (!widgetKey) {
|
||||
result = false;
|
||||
extension.collector.error(nls.localize('widgetContainer.invalidInputs', "The list of widgets is expected inside widgets-container for extension."));
|
||||
|
||||
@@ -36,6 +36,7 @@ import { memoize } from 'vs/base/common/decorators';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
const componentMap: { [x: string]: Type<IDashboardWidget> } = {
|
||||
'properties-widget': PropertiesWidgetComponent,
|
||||
@@ -159,7 +160,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit
|
||||
|
||||
// If _config.name is not set, set it to _config.widget.name
|
||||
if (!this._config.name) {
|
||||
const widget = Object.values(this._config.widget)[0];
|
||||
const widget = values(this._config.widget)[0];
|
||||
if (widget.name) {
|
||||
this._config.name = widget.name;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { getContentHeight, addDisposableListener, EventType } from 'vs/base/browser/dom';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* Sorting function for dashboard widgets
|
||||
@@ -208,10 +209,10 @@ export class WidgetContent extends AngularDisposable implements AfterViewInit {
|
||||
this._grid.enableResize();
|
||||
this._grid.enableDrag();
|
||||
this._editDispose.push(this.dashboardService.onDeleteWidget(e => {
|
||||
let index = this.widgets.findIndex(i => i.id === e);
|
||||
let index = firstIndex(this.widgets, i => i.id === e);
|
||||
this.widgets.splice(index, 1);
|
||||
|
||||
index = this.originalConfig.findIndex(i => i.id === e);
|
||||
index = firstIndex(this.originalConfig, i => i.id === e);
|
||||
this.originalConfig.splice(index, 1);
|
||||
|
||||
this._rewriteConfig();
|
||||
@@ -220,7 +221,7 @@ export class WidgetContent extends AngularDisposable implements AfterViewInit {
|
||||
this._editDispose.push(subscriptionToDisposable(this._grid.onResizeStop.subscribe((e: NgGridItem) => {
|
||||
this._onResize.fire();
|
||||
const event = e.getEventOutput();
|
||||
const config = this.originalConfig.find(i => i.id === event.payload.id);
|
||||
const config = find(this.originalConfig, i => i.id === event.payload.id);
|
||||
|
||||
if (!config.gridItemConfig) {
|
||||
config.gridItemConfig = {};
|
||||
@@ -238,7 +239,7 @@ export class WidgetContent extends AngularDisposable implements AfterViewInit {
|
||||
this._onResize.fire();
|
||||
const event = e.getEventOutput();
|
||||
this._items.forEach(i => {
|
||||
const config = this.originalConfig.find(j => j.id === i.getEventOutput().payload.id);
|
||||
const config = find(this.originalConfig, j => j.id === i.getEventOutput().payload.id);
|
||||
if ((config.gridItemConfig && config.gridItemConfig.col) || config.id === event.payload.id) {
|
||||
if (!config.gridItemConfig) {
|
||||
config.gridItemConfig = {};
|
||||
|
||||
@@ -12,6 +12,7 @@ import { IAngularEventingService, AngularEventType, IAngularEvent } from 'sql/pl
|
||||
import { INewDashboardTabDialogService } from 'sql/workbench/services/dashboard/browser/newDashboardTabDialog';
|
||||
import { IDashboardTab } from 'sql/workbench/parts/dashboard/browser/dashboardRegistry';
|
||||
import { subscriptionToDisposable } from 'sql/base/browser/lifecycle';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export class EditDashboardAction extends Action {
|
||||
|
||||
@@ -177,14 +178,14 @@ export class AddFeatureTabAction extends Action {
|
||||
case AngularEventType.NEW_TABS:
|
||||
const openedTabs = <IDashboardTab[]>event.payload.dashboardTabs;
|
||||
openedTabs.forEach(tab => {
|
||||
const existedTab = this._openedTabs.find(i => i === tab);
|
||||
const existedTab = find(this._openedTabs, i => i === tab);
|
||||
if (!existedTab) {
|
||||
this._openedTabs.push(tab);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case AngularEventType.CLOSE_TAB:
|
||||
const index = this._openedTabs.findIndex(i => i.id === event.payload.id);
|
||||
const index = firstIndex(this._openedTabs, i => i.id === event.payload.id);
|
||||
this._openedTabs.splice(index, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import { IDashboardContainerRegistry, Extensions as DashboardContainerExtensions
|
||||
import { SingleConnectionManagementService } from 'sql/workbench/services/bootstrap/browser/commonServiceInterface.service';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const dashboardcontainerRegistry = Registry.as<IDashboardContainerRegistry>(DashboardContainerExtensions.dashboardContainerContributions);
|
||||
const containerTypes = [
|
||||
@@ -163,7 +164,7 @@ function hasCompatibleProvider(provider: string | string[], contextKeyService: I
|
||||
const connectionProvider = contextKeyService.getContextKeyValue<string>(Constants.connectionProviderContextKey);
|
||||
if (connectionProvider) {
|
||||
const providers = (provider instanceof Array) ? provider : [provider];
|
||||
const matchingProvider = providers.find((p) => p === connectionProvider || p === Constants.anyProviderName);
|
||||
const matchingProvider = find(providers, (p) => p === connectionProvider || p === Constants.anyProviderName);
|
||||
isCompatible = (matchingProvider !== undefined);
|
||||
} // Else there's no connection context so skip the check
|
||||
return isCompatible;
|
||||
@@ -173,9 +174,9 @@ function hasCompatibleProvider(provider: string | string[], contextKeyService: I
|
||||
* Get registered container if it is specified as the key
|
||||
* @param container dashboard container
|
||||
*/
|
||||
export function getDashboardContainer(container: object, logService: ILogService): { result: boolean, message: string, container: object } {
|
||||
export function getDashboardContainer(container: object, logService: ILogService): { result: boolean, message: string, container: { [key: string]: any } } {
|
||||
const key = Object.keys(container)[0];
|
||||
const containerTypeFound = containerTypes.find(c => (c === key));
|
||||
const containerTypeFound = find(containerTypes, c => (c === key));
|
||||
if (!containerTypeFound) {
|
||||
const dashboardContainer = dashboardcontainerRegistry.getRegisteredContainer(key);
|
||||
if (!dashboardContainer) {
|
||||
|
||||
@@ -37,6 +37,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
const dashboardRegistry = Registry.as<IDashboardRegistry>(DashboardExtensions.DashboardContributions);
|
||||
|
||||
@@ -155,13 +157,13 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
|
||||
this._tabSettingConfigs.forEach(config => {
|
||||
if (config.tabId && types.isBoolean(config.isPinned)) {
|
||||
const tab = allTabs.find(i => i.id === config.tabId);
|
||||
const tab = find(allTabs, i => i.id === config.tabId);
|
||||
if (tab) {
|
||||
if (config.isPinned) {
|
||||
pinnedDashboardTabs.push(tab);
|
||||
} else {
|
||||
// overwrite always show if specify in user settings
|
||||
const index = alwaysShowTabs.findIndex(i => i.id === tab.id);
|
||||
const index = firstIndex(alwaysShowTabs, i => i.id === tab.id);
|
||||
alwaysShowTabs.splice(index, 1);
|
||||
}
|
||||
}
|
||||
@@ -183,7 +185,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
this._cd.detectChanges();
|
||||
|
||||
this._tabsDispose.push(this.dashboardService.onPinUnpinTab(e => {
|
||||
const tabConfig = this._tabSettingConfigs.find(i => i.tabId === e.tabId);
|
||||
const tabConfig = find(this._tabSettingConfigs, i => i.tabId === e.tabId);
|
||||
if (tabConfig) {
|
||||
tabConfig.isPinned = e.isPinned;
|
||||
} else {
|
||||
@@ -211,7 +213,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
actions: []
|
||||
};
|
||||
|
||||
const homeTabIndex = allTabs.findIndex((tab) => tab.isHomeTab === true);
|
||||
const homeTabIndex = firstIndex(allTabs, (tab) => tab.isHomeTab === true);
|
||||
if (homeTabIndex !== undefined && homeTabIndex > -1) {
|
||||
// Have a tab: get its information and copy over to the home tab definition
|
||||
const homeTab = allTabs.splice(homeTabIndex, 1)[0];
|
||||
@@ -234,7 +236,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
if (dashboardTabs && dashboardTabs.length > 0) {
|
||||
const selectedTabs = dashboardTabs.map(v => this.initTabComponents(v)).map(v => {
|
||||
const actions = [];
|
||||
const tabSettingConfig = this._tabSettingConfigs.find(i => i.tabId === v.id);
|
||||
const tabSettingConfig = find(this._tabSettingConfigs, i => i.tabId === v.id);
|
||||
let isPinned = false;
|
||||
if (tabSettingConfig) {
|
||||
isPinned = tabSettingConfig.isPinned;
|
||||
@@ -269,7 +271,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
}
|
||||
const key = Object.keys(containerResult.container)[0];
|
||||
if (key === WIDGETS_CONTAINER || key === GRID_CONTAINER) {
|
||||
let configs = <WidgetConfig[]>Object.values(containerResult.container)[0];
|
||||
let configs = <WidgetConfig[]>values(containerResult.container)[0];
|
||||
this._configModifiers.forEach(cb => {
|
||||
configs = cb.apply(this, [configs, this, this.context]);
|
||||
});
|
||||
@@ -291,7 +293,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
}
|
||||
|
||||
private addNewTab(tab: TabConfig): void {
|
||||
const existedTab = this.tabs.find(i => i.id === tab.id);
|
||||
const existedTab = find(this.tabs, i => i.id === tab.id);
|
||||
if (!existedTab) {
|
||||
this.tabs.push(tab);
|
||||
this._cd.detectChanges();
|
||||
@@ -309,7 +311,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
return [this.propertiesWidget];
|
||||
} else if (types.isArray(properties)) {
|
||||
return properties.map((item) => {
|
||||
const retVal = Object.assign({}, this.propertiesWidget);
|
||||
const retVal = objects.assign({}, this.propertiesWidget);
|
||||
retVal.edition = item.edition;
|
||||
retVal.provider = item.provider;
|
||||
retVal.widget = { 'properties-widget': { properties: item.properties } };
|
||||
@@ -348,7 +350,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig
|
||||
}
|
||||
|
||||
public handleTabClose(tab: TabComponent): void {
|
||||
const index = this.tabs.findIndex(i => i.id === tab.identifier);
|
||||
const index = firstIndex(this.tabs, i => i.id === tab.identifier);
|
||||
this.tabs.splice(index, 1);
|
||||
this.angularEventingService.sendAngularEvent(this.dashboardService.getUnderlyingUri(), AngularEventType.CLOSE_TAB, { id: tab.identifier });
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ import { generateContainerTypeSchemaProperties } from 'sql/platform/dashboard/co
|
||||
import { NAV_SECTION, validateNavSectionContributionAndRegisterIcon } from 'sql/workbench/parts/dashboard/browser/containers/dashboardNavSection.contribution';
|
||||
import { WIDGETS_CONTAINER, validateWidgetContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardWidgetContainer.contribution';
|
||||
import { GRID_CONTAINER, validateGridContainerContribution } from 'sql/workbench/parts/dashboard/browser/containers/dashboardGridContainer.contribution';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export interface IDashboardTabContrib {
|
||||
id: string;
|
||||
title: string;
|
||||
container: object;
|
||||
container: { [key: string]: any };
|
||||
provider: string | string[];
|
||||
when?: string;
|
||||
description?: string;
|
||||
@@ -115,7 +116,7 @@ ExtensionsRegistry.registerExtensionPoint<IDashboardTabContrib | IDashboardTabCo
|
||||
|
||||
let result = true;
|
||||
const containerkey = Object.keys(container)[0];
|
||||
const containerValue = Object.values(container)[0];
|
||||
const containerValue = values(container)[0];
|
||||
|
||||
switch (containerkey) {
|
||||
case WIDGETS_CONTAINER:
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface WidgetConfig {
|
||||
edition: number | Array<number>;
|
||||
when?: string;
|
||||
gridItemConfig?: NgGridItemConfig;
|
||||
widget: Object;
|
||||
widget: { [key: string]: any };
|
||||
background_color?: string;
|
||||
border?: string;
|
||||
fontSize?: string;
|
||||
@@ -51,7 +51,7 @@ export interface NavSectionConfig {
|
||||
title: string;
|
||||
iconClass?: string;
|
||||
icon?: IUserFriendlyIcon;
|
||||
container: object;
|
||||
container: { [key: string]: any };
|
||||
}
|
||||
|
||||
export interface TabSettingConfig {
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ProviderProperties } from 'sql/workbench/parts/dashboard/browser/widget
|
||||
import { DATABASE_DASHBOARD_TABS } from 'sql/workbench/parts/dashboard/browser/pages/databaseDashboardPage.contribution';
|
||||
import { SERVER_DASHBOARD_TABS } from 'sql/workbench/parts/dashboard/browser/pages/serverDashboardPage.contribution';
|
||||
import { DASHBOARD_CONFIG_ID, DASHBOARD_TABS_KEY_PROPERTY } from 'sql/workbench/parts/dashboard/browser/pages/dashboardPageContribution';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const Extensions = {
|
||||
DashboardContributions: 'dashboard.contributions'
|
||||
@@ -24,7 +25,7 @@ export interface IDashboardTab {
|
||||
provider: string | string[];
|
||||
publisher: string;
|
||||
description?: string;
|
||||
container?: object;
|
||||
container?: { [key: string]: any };
|
||||
when?: string;
|
||||
alwaysShow?: boolean;
|
||||
isHomeTab?: boolean;
|
||||
@@ -57,7 +58,7 @@ class DashboardRegistry implements IDashboardRegistry {
|
||||
|
||||
public registerTab(tab: IDashboardTab): void {
|
||||
this._tabs.push(tab);
|
||||
let dashboardConfig = this._configurationRegistry.getConfigurations().find(c => c.id === DASHBOARD_CONFIG_ID);
|
||||
let dashboardConfig = find(this._configurationRegistry.getConfigurations(), c => c.id === DASHBOARD_CONFIG_ID);
|
||||
|
||||
if (dashboardConfig) {
|
||||
let dashboardDatabaseTabProperty = (<IJSONSchema>dashboardConfig.properties[DATABASE_DASHBOARD_TABS].items).properties[DASHBOARD_TABS_KEY_PROPERTY];
|
||||
|
||||
@@ -260,7 +260,7 @@ export class ExplorerFilter implements tree.IFilter {
|
||||
return true;
|
||||
}
|
||||
const filterString = this._filterString.trim().toLowerCase();
|
||||
return element.databaseName.toLowerCase().includes(filterString);
|
||||
return element.databaseName.toLowerCase().indexOf(filterString) > -1;
|
||||
}
|
||||
|
||||
// apply filter for objectmetadatawrapper
|
||||
@@ -275,7 +275,7 @@ export class ExplorerFilter implements tree.IFilter {
|
||||
// determine if a filter is applied
|
||||
let metadataType: MetadataType;
|
||||
|
||||
if (filterString.includes(':')) {
|
||||
if (filterString.indexOf(':') > -1) {
|
||||
const filterArray = filterString.split(':');
|
||||
|
||||
if (filterArray.length > 2) {
|
||||
@@ -305,9 +305,9 @@ export class ExplorerFilter implements tree.IFilter {
|
||||
}
|
||||
|
||||
if (metadataType !== undefined) {
|
||||
return element.metadataType === metadataType && (element.schema + '.' + element.name).toLowerCase().includes(filterString);
|
||||
return element.metadataType === metadataType && (element.schema + '.' + element.name).toLowerCase().indexOf(filterString) > -1;
|
||||
} else {
|
||||
return (element.schema + '.' + element.name).toLowerCase().includes(filterString);
|
||||
return (element.schema + '.' + element.name).toLowerCase().indexOf(filterString) > -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ export class InsightsWidget extends DashboardWidget implements IDashboardWidget,
|
||||
throw new Error('Exactly 1 insight type must be specified');
|
||||
}
|
||||
|
||||
if (!insightRegistry.getAllIds().includes(Object.keys(this.insightConfig.type)[0])) {
|
||||
if (!insightRegistry.getAllIds().some(x => x === Object.keys(this.insightConfig.type)[0])) {
|
||||
throw new Error('The insight type must be a valid registered insight');
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ViewChild } from '@angular/core';
|
||||
import { BaseChartDirective } from 'ng2-charts';
|
||||
import * as chartjs from 'chart.js';
|
||||
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import * as TelemetryUtils from 'sql/platform/telemetry/common/telemetryUtilities';
|
||||
import { memoize, unmemoize } from 'sql/base/common/decorators';
|
||||
import { mixin } from 'sql/base/common/objects';
|
||||
import { defaultChartConfig, IChartConfig, IDataSet } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/interfaces';
|
||||
|
||||
@@ -22,8 +22,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IInsightData, IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces';
|
||||
import { IInsightsView } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { ChartType, LegendPosition } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
|
||||
declare const Chart: any;
|
||||
import { createMemoizer } from 'vs/base/common/decorators';
|
||||
|
||||
@Component({
|
||||
template: ` <div style="display: block; width: 100%; height: 100%; position: relative">
|
||||
@@ -38,6 +37,8 @@ declare const Chart: any;
|
||||
</div>`
|
||||
})
|
||||
export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
protected static readonly MEMOIZER = createMemoizer();
|
||||
|
||||
private _isDataAvailable: boolean = false;
|
||||
protected _hasInit: boolean = false;
|
||||
protected _hasError: boolean = false;
|
||||
@@ -132,8 +133,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
|
||||
@Input() set data(data: IInsightData) {
|
||||
// unmemoize chart data as the data needs to be recalced
|
||||
unmemoize(this, 'chartData');
|
||||
unmemoize(this, 'labels');
|
||||
ChartInsight.MEMOIZER.clear();
|
||||
this._data = this.filterToTopNData(data);
|
||||
if (isValidData(data)) {
|
||||
this._isDataAvailable = true;
|
||||
@@ -172,9 +172,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
|
||||
protected clearMemoize(): void {
|
||||
// unmemoize getters since their result can be changed by a new config
|
||||
unmemoize(this, 'getChartData');
|
||||
unmemoize(this, 'getLabels');
|
||||
unmemoize(this, 'colors');
|
||||
ChartInsight.MEMOIZER.clear();
|
||||
}
|
||||
|
||||
public setConfig(config: IChartConfig) {
|
||||
@@ -189,7 +187,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
|
||||
/* Typescript does not allow you to access getters/setters for super classes.
|
||||
his is a workaround that allows us to still call base getter */
|
||||
@memoize
|
||||
@ChartInsight.MEMOIZER
|
||||
protected getChartData(): Array<IDataSet> {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
@@ -230,7 +228,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
return this.getChartData();
|
||||
}
|
||||
|
||||
@memoize
|
||||
@ChartInsight.MEMOIZER
|
||||
public getLabels(): Array<string> {
|
||||
if (this._config.dataDirection === 'horizontal') {
|
||||
if (this._config.labelFirstColumn) {
|
||||
@@ -248,7 +246,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView {
|
||||
}
|
||||
|
||||
|
||||
@memoize
|
||||
@ChartInsight.MEMOIZER
|
||||
private get colors(): { backgroundColor: string[] }[] {
|
||||
if (this._config && this._config.colorMap) {
|
||||
const backgroundColor = this.labels.map((item) => {
|
||||
@@ -293,12 +291,12 @@ function isValidData(data: IInsightData): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
Chart.pluginService.register({
|
||||
chartjs.Chart.pluginService.register({
|
||||
beforeDraw: function (chart) {
|
||||
if (chart.config.options.viewArea && chart.config.options.viewArea.backgroundColor) {
|
||||
let ctx = chart.chart.ctx;
|
||||
ctx.fillStyle = chart.config.options.viewArea.backgroundColor;
|
||||
ctx.fillRect(0, 0, chart.chart.width, chart.chart.height);
|
||||
if ((chart.config.options as any).viewArea && (chart.config.options as any).viewArea.backgroundColor) {
|
||||
let ctx = (chart as any).chart.ctx;
|
||||
ctx.fillStyle = (chart.config.options as any).viewArea.backgroundColor;
|
||||
ctx.fillRect(0, 0, (chart as any).chart.width, (chart as any).chart.height);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
import { mixin, deepClone } from 'vs/base/common/objects';
|
||||
|
||||
import BarChart, { IBarChartConfig } from './barChart.component';
|
||||
import { memoize, unmemoize } from 'sql/base/common/decorators';
|
||||
import { defaultChartConfig, IDataSet } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/interfaces';
|
||||
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -14,6 +13,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces';
|
||||
import { DataType, ChartType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export interface ILineConfig extends IBarChartConfig {
|
||||
dataType?: DataType;
|
||||
@@ -52,10 +52,10 @@ export default class LineChart extends BarChart {
|
||||
|
||||
protected clearMemoize() {
|
||||
super.clearMemoize();
|
||||
unmemoize(this, 'getDataAsPoint');
|
||||
LineChart.MEMOIZER.clear();
|
||||
}
|
||||
|
||||
@memoize
|
||||
@LineChart.MEMOIZER
|
||||
protected getDataAsPoint(): Array<IPointDataSet> {
|
||||
const dataSetMap: { [label: string]: IPointDataSet } = {};
|
||||
this._data.rows.map(row => {
|
||||
@@ -67,7 +67,7 @@ export default class LineChart extends BarChart {
|
||||
dataSetMap[legend].data.push({ x: Number(row[1]), y: Number(row[2]) });
|
||||
}
|
||||
});
|
||||
return Object.values(dataSetMap);
|
||||
return values(dataSetMap);
|
||||
}
|
||||
|
||||
public get labels(): Array<string> {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import LineChart, { ILineConfig } from './lineChart.component';
|
||||
import { defaultChartConfig } from 'sql/workbench/parts/dashboard/browser/widgets/insights/views/charts/interfaces';
|
||||
|
||||
import { mixin, deepClone } from 'vs/base/common/objects';
|
||||
import { mixin, deepClone, assign } from 'vs/base/common/objects';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -14,6 +14,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IPointDataSet } from 'sql/workbench/parts/charts/browser/interfaces';
|
||||
import { ChartType } from 'sql/workbench/parts/charts/common/interfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
const defaultTimeSeriesConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig;
|
||||
|
||||
@@ -59,7 +60,7 @@ export default class TimeSeriesChart extends LineChart {
|
||||
}
|
||||
};
|
||||
|
||||
this.options = Object.assign({}, mixin(this.options, options));
|
||||
this.options = assign({}, mixin(this.options, options));
|
||||
}
|
||||
|
||||
protected getDataAsPoint(): Array<IPointDataSet> {
|
||||
@@ -73,10 +74,10 @@ export default class TimeSeriesChart extends LineChart {
|
||||
dataSetMap[legend].data.push({ x: row[1], y: Number(row[2]) });
|
||||
|
||||
if (this.chartType === ChartType.Scatter) {
|
||||
dataSetMap[legend].backgroundColor = Color.cyan;
|
||||
dataSetMap[legend].backgroundColor = Color.cyan.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
return Object.values(dataSetMap);
|
||||
return values(dataSetMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ViewChild, OnI
|
||||
import { mixin } from 'vs/base/common/objects';
|
||||
import { IInsightData } from 'sql/workbench/parts/charts/browser/interfaces';
|
||||
import { IInsightsView } from 'sql/platform/dashboard/browser/insightRegistry';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
interface IConfig {
|
||||
encoding?: string;
|
||||
@@ -70,7 +71,7 @@ export default class ImageInsight implements IInsightsView, OnInit {
|
||||
|
||||
private static _hexToBase64(hexVal: string) {
|
||||
|
||||
if (hexVal.startsWith('0x')) {
|
||||
if (startsWith(hexVal, '0x')) {
|
||||
hexVal = hexVal.slice(2);
|
||||
}
|
||||
// should be able to be replaced with new Buffer(hexVal, 'hex').toString('base64')
|
||||
|
||||
@@ -66,11 +66,11 @@ export class TasksWidget extends DashboardWidget implements IDashboardWidget, On
|
||||
if (types.isArray(tasksConfig) && tasksConfig.length > 0) {
|
||||
tasks = tasksConfig.map(i => {
|
||||
if (types.isString(i)) {
|
||||
if (tasks.includes(i)) {
|
||||
if (tasks.some(x => x === i)) {
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
if (tasks.includes(i.name) && contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(i.when))) {
|
||||
if (tasks.some(x => x === i.name) && contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(i.when))) {
|
||||
return i.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { EditUpdateCellResult } from 'azdata';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { deepClone, assign } from 'vs/base/common/objects';
|
||||
export const EDITDATA_SELECTOR: string = 'editdata-component';
|
||||
|
||||
@Component({
|
||||
@@ -337,7 +337,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On
|
||||
|
||||
handleResultSet(self: EditDataComponent, event: any): void {
|
||||
// Clone the data before altering it to avoid impacting other subscribers
|
||||
let resultSet = Object.assign({}, event.data);
|
||||
let resultSet = assign({}, event.data);
|
||||
if (!resultSet.complete) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
const $ = dom.$;
|
||||
|
||||
/**
|
||||
@@ -198,7 +199,7 @@ export class ChangeMaxRowsActionItem extends Disposable implements IActionViewIt
|
||||
}
|
||||
|
||||
public set setCurrentOptionIndex(selection: number) {
|
||||
this._currentOptionsIndex = this._options.findIndex(x => x === selection.toString());
|
||||
this._currentOptionsIndex = firstIndex(this._options, x => x === selection.toString());
|
||||
this._refreshOptions();
|
||||
}
|
||||
|
||||
@@ -216,7 +217,7 @@ export class ChangeMaxRowsActionItem extends Disposable implements IActionViewIt
|
||||
|
||||
private _registerListeners(): void {
|
||||
this._register(this.selectBox.onDidSelect(selection => {
|
||||
this._currentOptionsIndex = this._options.findIndex(x => x === selection.selected);
|
||||
this._currentOptionsIndex = firstIndex(this._options, x => x === selection.selected);
|
||||
this._editor.editDataInput.onRowDropDownSet(Number(selection.selected));
|
||||
}));
|
||||
this._register(attachSelectBoxStyler(this.selectBox, this._themeService));
|
||||
|
||||
@@ -33,6 +33,7 @@ import { IDashboardService } from 'sql/platform/dashboard/browser/dashboardServi
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const DASHBOARD_SELECTOR: string = 'jobhistory-component';
|
||||
|
||||
@@ -200,10 +201,10 @@ export class JobHistoryComponent extends JobManagementView implements OnInit {
|
||||
const self = this;
|
||||
let cachedHistory = self._jobCacheObject.getJobHistory(element.jobID);
|
||||
if (cachedHistory) {
|
||||
self.agentJobHistoryInfo = cachedHistory.find(
|
||||
self.agentJobHistoryInfo = find(cachedHistory,
|
||||
history => self.formatTime(history.runDate) === self.formatTime(element.runDate));
|
||||
} else {
|
||||
self.agentJobHistoryInfo = self._treeController.jobHistories.find(
|
||||
self.agentJobHistoryInfo = find(self._treeController.jobHistories,
|
||||
history => self.formatTime(history.runDate) === self.formatTime(element.runDate));
|
||||
}
|
||||
if (self.agentJobHistoryInfo) {
|
||||
|
||||
@@ -129,7 +129,7 @@ export class JobStepsViewRenderer implements tree.IRenderer {
|
||||
let stepMessageCol: HTMLElement = DOM.$('div');
|
||||
stepMessageCol.className = 'tree-message-col';
|
||||
stepMessageCol.innerText = element.message;
|
||||
if (element.rowID.includes('stepsColumn')) {
|
||||
if (element.rowID.indexOf('stepsColumn') !== -1) {
|
||||
stepNameCol.className += ' step-column-heading';
|
||||
stepIdCol.className += ' step-column-heading';
|
||||
stepMessageCol.className += ' step-column-heading';
|
||||
|
||||
@@ -32,6 +32,7 @@ import { tableBackground, cellBackground, cellBorderColor } from 'sql/platform/t
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { attachButtonStyler } from 'sql/platform/theme/common/styler';
|
||||
import { find, fill } from 'vs/base/common/arrays';
|
||||
|
||||
export const JOBSVIEW_SELECTOR: string = 'jobsview-component';
|
||||
export const ROW_HEIGHT: number = 45;
|
||||
@@ -309,7 +310,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
|
||||
this._table.grid.removeCellCssStyles('error-row' + i.toString());
|
||||
let item = this.dataView.getItemByIdx(i);
|
||||
// current filter
|
||||
if (_.contains(filterValues, item[args.column.field])) {
|
||||
if (find(filterValues, x => x === item[args.column.field])) {
|
||||
// check all previous filters
|
||||
if (this.checkPreviousFilters(item)) {
|
||||
if (item.lastRunOutcome === 'Failed') {
|
||||
@@ -561,7 +562,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
|
||||
private checkPreviousFilters(item): boolean {
|
||||
for (let column in this.filterValueMap) {
|
||||
if (column !== 'start' && this.filterValueMap[column][0].length > 0) {
|
||||
if (!_.contains(this.filterValueMap[column][0], item[JobManagementUtilities.convertColNameToField(column)])) {
|
||||
if (!find(this.filterValueMap[column][0], x => x === item[JobManagementUtilities.convertColNameToField(column)])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -670,7 +671,7 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
|
||||
// if the durations are all 0 secs, show minimal chart
|
||||
// instead of nothing
|
||||
if (zeroDurationJobCount === jobHistories.length) {
|
||||
return Array(jobHistories.length).fill('5px');
|
||||
return fill(jobHistories.length, '5px');
|
||||
} else {
|
||||
return chartHeights;
|
||||
}
|
||||
@@ -703,9 +704,9 @@ export class JobsViewComponent extends JobManagementView implements OnInit, OnDe
|
||||
let filterValues = col.filterValues;
|
||||
if (filterValues && filterValues.length > 0) {
|
||||
if (item._parent) {
|
||||
value = value && _.contains(filterValues, item._parent[col.field]);
|
||||
value = value && find(filterValues, x => x === item._parent[col.field]);
|
||||
} else {
|
||||
value = value && _.contains(filterValues, item[col.field]);
|
||||
value = value && find(filterValues, x => x === item[col.field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export const DASHBOARD_SELECTOR: string = 'notebookhistory-component';
|
||||
export class GridSection {
|
||||
@@ -169,7 +170,7 @@ export class NotebookHistoryComponent extends JobManagementView implements OnIni
|
||||
const self = this;
|
||||
let cachedHistory = self._notebookCacheObject.getNotebookHistory(element.jobID);
|
||||
if (cachedHistory) {
|
||||
self.agentNotebookHistoryInfo = cachedHistory.find(
|
||||
self.agentNotebookHistoryInfo = find(cachedHistory,
|
||||
history => self.formatTime(history.runDate) === self.formatTime(element.runDate));
|
||||
}
|
||||
if (self.agentNotebookHistoryInfo) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { attachButtonStyler } from 'sql/platform/theme/common/styler';
|
||||
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { find, fill } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
export const NOTEBOOKSVIEW_SELECTOR: string = 'notebooksview-component';
|
||||
@@ -317,7 +318,7 @@ export class NotebooksViewComponent extends JobManagementView implements OnInit,
|
||||
this._table.grid.removeCellCssStyles('notebook-error-row' + i.toString());
|
||||
let item = this.dataView.getItemByIdx(i);
|
||||
// current filter
|
||||
if (_.contains(filterValues, item[args.column.field])) {
|
||||
if (!!find(filterValues, x => x === item[args.column.field])) {
|
||||
// check all previous filters
|
||||
if (this.checkPreviousFilters(item)) {
|
||||
if (item.lastRunOutcome === 'Failed') {
|
||||
@@ -610,7 +611,7 @@ export class NotebooksViewComponent extends JobManagementView implements OnInit,
|
||||
private checkPreviousFilters(item): boolean {
|
||||
for (let column in this.filterValueMap) {
|
||||
if (column !== 'start' && this.filterValueMap[column][0].length > 0) {
|
||||
if (!_.contains(this.filterValueMap[column][0], item[JobManagementUtilities.convertColNameToField(column)])) {
|
||||
if (!find(this.filterValueMap[column][0], x => x === item[JobManagementUtilities.convertColNameToField(column)])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -729,7 +730,7 @@ export class NotebooksViewComponent extends JobManagementView implements OnInit,
|
||||
// if the durations are all 0 secs, show minimal chart
|
||||
// instead of nothing
|
||||
if (zeroDurationJobCount === jobHistories.length) {
|
||||
return Array(jobHistories.length).fill('5px');
|
||||
return fill(jobHistories.length, '5px');
|
||||
} else {
|
||||
return chartHeights;
|
||||
}
|
||||
@@ -769,9 +770,9 @@ export class NotebooksViewComponent extends JobManagementView implements OnInit,
|
||||
let filterValues = col.filterValues;
|
||||
if (filterValues && filterValues.length > 0) {
|
||||
if (item._parent) {
|
||||
value = value && _.contains(filterValues, item._parent[col.field]);
|
||||
value = value && find(filterValues, x => x === item._parent[col.field]);
|
||||
} else {
|
||||
value = value && _.contains(filterValues, item[col.field]);
|
||||
value = value && find(filterValues, x => x === item[col.field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import { ICellModel } from 'sql/workbench/parts/notebook/browser/models/modelInt
|
||||
import { ToggleMoreWidgetAction } from 'sql/workbench/parts/dashboard/browser/core/actions';
|
||||
import { CellModel } from 'sql/workbench/parts/notebook/browser/models/cell';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export const HIDDEN_CLASS = 'actionhidden';
|
||||
|
||||
@@ -103,7 +104,7 @@ export class AddCellFromContextAction extends CellActionBase {
|
||||
doRun(context: CellContext): Promise<void> {
|
||||
try {
|
||||
let model = context.model;
|
||||
let index = model.cells.findIndex((cell) => cell.id === context.cell.id);
|
||||
let index = firstIndex(model.cells, (cell) => cell.id === context.cell.id);
|
||||
if (index !== undefined && this.isAfter) {
|
||||
index += 1;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import { optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
let modelId = 0;
|
||||
|
||||
export const HideInputTag = 'hide_input';
|
||||
@@ -112,7 +113,7 @@ export class CellModel implements ICellModel {
|
||||
|
||||
let tagIndex = -1;
|
||||
if (this._metadata.tags) {
|
||||
tagIndex = this._metadata.tags.findIndex(tag => tag === HideInputTag);
|
||||
tagIndex = firstIndex(this._metadata.tags, tag => tag === HideInputTag);
|
||||
}
|
||||
|
||||
if (this._isCollapsed) {
|
||||
@@ -609,7 +610,7 @@ export class CellModel implements ICellModel {
|
||||
this._source = this.getMultilineSource(cell.source);
|
||||
this._metadata = cell.metadata || {};
|
||||
|
||||
if (this._metadata.tags && this._metadata.tags.includes(HideInputTag)) {
|
||||
if (this._metadata.tags && this._metadata.tags.some(x => x === HideInputTag)) {
|
||||
this._isCollapsed = true;
|
||||
} else {
|
||||
this._isCollapsed = false;
|
||||
@@ -665,7 +666,7 @@ export class CellModel implements ICellModel {
|
||||
if (serverInfo) {
|
||||
let endpoints: notebookUtils.IEndpoint[] = notebookUtils.getClusterEndpoints(serverInfo);
|
||||
if (endpoints && endpoints.length > 0) {
|
||||
endpoint = endpoints.find(ep => ep.serviceName.toLowerCase() === notebookUtils.hadoopEndpointNameGateway);
|
||||
endpoint = find(endpoints, ep => ep.serviceName.toLowerCase() === notebookUtils.hadoopEndpointNameGateway);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user