mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 17:22:59 -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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { ICellMagicMapper } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { ILanguageMagic } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
const defaultKernel = '*';
|
||||
export class CellMagicMapper implements ICellMagicMapper {
|
||||
@@ -38,7 +39,7 @@ export class CellMagicMapper implements ICellMagicMapper {
|
||||
searchText = searchText.toLowerCase();
|
||||
let kernelMagics = this.kernelToMagicMap.get(kernelId) || [];
|
||||
if (kernelMagics) {
|
||||
return kernelMagics.find(m => m.magic.toLowerCase() === searchText);
|
||||
return find(kernelMagics, m => m.magic.toLowerCase() === searchText);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { IConnectionManagementService } from 'sql/platform/connection/common/con
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class NotebookContexts {
|
||||
|
||||
@@ -88,13 +89,13 @@ export class NotebookContexts {
|
||||
// Filter active connections by their provider ids to match kernel's supported connection providers
|
||||
else if (activeConnections.length > 0) {
|
||||
let connections = activeConnections.filter(connection => {
|
||||
return connProviderIds.includes(connection.providerName);
|
||||
return connProviderIds.some(x => x === connection.providerName);
|
||||
});
|
||||
if (connections && connections.length > 0) {
|
||||
defaultConnection = connections[0];
|
||||
if (profile && profile.options) {
|
||||
if (connections.find(connection => connection.serverName === profile.serverName)) {
|
||||
defaultConnection = connections.find(connection => connection.serverName === profile.serverName);
|
||||
if (find(connections, connection => connection.serverName === profile.serverName)) {
|
||||
defaultConnection = find(connections, connection => connection.serverName === profile.serverName);
|
||||
}
|
||||
}
|
||||
} else if (connections.length === 0) {
|
||||
@@ -128,11 +129,11 @@ export class NotebookContexts {
|
||||
if (specs) {
|
||||
// find the saved kernel (if it exists)
|
||||
if (displayName) {
|
||||
defaultKernel = specs.kernels.find((kernel) => kernel.display_name === displayName);
|
||||
defaultKernel = find(specs.kernels, (kernel) => kernel.display_name === displayName);
|
||||
}
|
||||
// if no saved kernel exists, use the default KernelSpec
|
||||
if (!defaultKernel) {
|
||||
defaultKernel = specs.kernels.find((kernel) => kernel.name === specs.defaultKernel);
|
||||
defaultKernel = find(specs.kernels, (kernel) => kernel.name === specs.defaultKernel);
|
||||
}
|
||||
if (defaultKernel) {
|
||||
return defaultKernel;
|
||||
|
||||
@@ -26,6 +26,8 @@ import { keys } from 'vs/base/common/map';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
/*
|
||||
* Used to control whether a message in a dialog/wizard is displayed as an error,
|
||||
@@ -110,18 +112,18 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
}
|
||||
|
||||
public get notebookManager(): INotebookManager {
|
||||
let manager = this.notebookManagers.find(manager => manager.providerId === this._providerId);
|
||||
let manager = find(this.notebookManagers, manager => manager.providerId === this._providerId);
|
||||
if (!manager) {
|
||||
// Note: this seems like a less than ideal scenario. We should ideally pass in the "correct" provider ID and allow there to be a default,
|
||||
// instead of assuming in the NotebookModel constructor that the option is either SQL or Jupyter
|
||||
manager = this.notebookManagers.find(manager => manager.providerId === DEFAULT_NOTEBOOK_PROVIDER);
|
||||
manager = find(this.notebookManagers, manager => manager.providerId === DEFAULT_NOTEBOOK_PROVIDER);
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public getNotebookManager(providerId: string): INotebookManager {
|
||||
if (providerId) {
|
||||
return this.notebookManagers.find(manager => manager.providerId === providerId);
|
||||
return find(this.notebookManagers, manager => manager.providerId === providerId);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -337,7 +339,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
}
|
||||
|
||||
public findCellIndex(cellModel: ICellModel): number {
|
||||
return this._cells.findIndex((cell) => cell.equals(cellModel));
|
||||
return firstIndex(this._cells, (cell) => cell.equals(cellModel));
|
||||
}
|
||||
|
||||
public addCell(cellType: CellType, index?: number): ICellModel {
|
||||
@@ -389,7 +391,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
if (this.inErrorState || !this._cells) {
|
||||
return;
|
||||
}
|
||||
let index = this._cells.findIndex((cell) => cell.equals(cellModel));
|
||||
let index = firstIndex(this._cells, (cell) => cell.equals(cellModel));
|
||||
if (index > -1) {
|
||||
this._cells.splice(index, 1);
|
||||
this._contentChangedEmitter.fire({
|
||||
@@ -440,7 +442,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
public async startSession(manager: INotebookManager, displayName?: string, setErrorStateOnFail?: boolean): Promise<void> {
|
||||
if (displayName && this._standardKernels) {
|
||||
let standardKernel = this._standardKernels.find(kernel => kernel.displayName === displayName);
|
||||
let standardKernel = find(this._standardKernels, kernel => kernel.displayName === displayName);
|
||||
this._defaultKernel = displayName ? { name: standardKernel.name, display_name: standardKernel.displayName } : this._defaultKernel;
|
||||
}
|
||||
if (this._defaultKernel) {
|
||||
@@ -527,16 +529,16 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
private isValidConnection(profile: IConnectionProfile | connection.Connection) {
|
||||
if (this._standardKernels) {
|
||||
let standardKernels = this._standardKernels.find(kernel => this._defaultKernel && kernel.displayName === this._defaultKernel.display_name);
|
||||
let standardKernels = find(this._standardKernels, kernel => this._defaultKernel && kernel.displayName === this._defaultKernel.display_name);
|
||||
let connectionProviderIds = standardKernels ? standardKernels.connectionProviderIds : undefined;
|
||||
return profile && connectionProviderIds && connectionProviderIds.find(provider => provider === profile.providerName) !== undefined;
|
||||
return profile && connectionProviderIds && find(connectionProviderIds, provider => provider === profile.providerName) !== undefined;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public getStandardKernelFromName(name: string): notebookUtils.IStandardKernelWithProvider {
|
||||
if (name && this._standardKernels) {
|
||||
let kernel = this._standardKernels.find(kernel => kernel.name.toLowerCase() === name.toLowerCase());
|
||||
let kernel = find(this._standardKernels, kernel => kernel.name.toLowerCase() === name.toLowerCase());
|
||||
return kernel;
|
||||
}
|
||||
return undefined;
|
||||
@@ -544,7 +546,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
public getStandardKernelFromDisplayName(displayName: string): notebookUtils.IStandardKernelWithProvider {
|
||||
if (displayName && this._standardKernels) {
|
||||
let kernel = this._standardKernels.find(kernel => kernel.displayName.toLowerCase() === displayName.toLowerCase());
|
||||
let kernel = find(this._standardKernels, kernel => kernel.displayName.toLowerCase() === displayName.toLowerCase());
|
||||
return kernel;
|
||||
}
|
||||
return undefined;
|
||||
@@ -592,7 +594,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
if (language) {
|
||||
let mimeTypePrefix = 'x-';
|
||||
if (language.includes(mimeTypePrefix)) {
|
||||
if (language.indexOf(mimeTypePrefix) > -1) {
|
||||
language = language.replace(mimeTypePrefix, '');
|
||||
} else if (language.toLowerCase() === 'ipython') {
|
||||
// Special case ipython because in many cases this is defined as the code mirror mode for python notebooks
|
||||
@@ -673,8 +675,8 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
if (spec) {
|
||||
// Ensure that the kernel we try to switch to is a valid kernel; if not, use the default
|
||||
let kernelSpecs = this.getKernelSpecs();
|
||||
if (kernelSpecs && kernelSpecs.length > 0 && kernelSpecs.findIndex(k => k.display_name === spec.display_name) < 0) {
|
||||
spec = kernelSpecs.find(spec => spec.name === this.notebookManager.sessionManager.specs.defaultKernel);
|
||||
if (kernelSpecs && kernelSpecs.length > 0 && firstIndex(kernelSpecs, k => k.display_name === spec.display_name) < 0) {
|
||||
spec = find(kernelSpecs, spec => spec.name === this.notebookManager.sessionManager.specs.defaultKernel);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -686,7 +688,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
public async changeContext(title: string, newConnection?: ConnectionProfile, hideErrorMessage?: boolean): Promise<void> {
|
||||
try {
|
||||
if (!newConnection) {
|
||||
newConnection = this._activeContexts.otherConnections.find((connection) => connection.title === title);
|
||||
newConnection = find(this._activeContexts.otherConnections, (connection) => connection.title === title);
|
||||
}
|
||||
if ((!newConnection) && (this._activeContexts.defaultConnection.title === title)) {
|
||||
newConnection = this._activeContexts.defaultConnection;
|
||||
@@ -743,7 +745,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
private getKernelSpecFromDisplayName(displayName: string): nb.IKernelSpec {
|
||||
displayName = this.sanitizeDisplayName(displayName);
|
||||
let kernel: nb.IKernelSpec = this.specs.kernels.find(k => k.display_name.toLowerCase() === displayName.toLowerCase());
|
||||
let kernel: nb.IKernelSpec = find(this.specs.kernels, k => k.display_name.toLowerCase() === displayName.toLowerCase());
|
||||
if (!kernel) {
|
||||
return undefined; // undefined is handled gracefully in the session to default to the default kernel
|
||||
} else if (!kernel.name) {
|
||||
@@ -760,7 +762,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
this._savedKernelInfo.display_name = displayName;
|
||||
}
|
||||
if (this._standardKernels) {
|
||||
let standardKernel = this._standardKernels.find(kernel => kernel.displayName === displayName || displayName.startsWith(kernel.displayName));
|
||||
let standardKernel = find(this._standardKernels, kernel => kernel.displayName === displayName || startsWith(displayName, kernel.displayName));
|
||||
if (standardKernel && this._savedKernelInfo.name && this._savedKernelInfo.name !== standardKernel.name) {
|
||||
this._savedKernelInfo.name = standardKernel.name;
|
||||
this._savedKernelInfo.display_name = standardKernel.displayName;
|
||||
@@ -774,7 +776,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
if (!specs || !specs.kernels) {
|
||||
return kernel.name;
|
||||
}
|
||||
let newKernel = this.notebookManager.sessionManager.specs.kernels.find(k => k.name === kernel.name);
|
||||
let newKernel = find(this.notebookManager.sessionManager.specs.kernels, k => k.name === kernel.name);
|
||||
let newKernelDisplayName;
|
||||
if (newKernel) {
|
||||
newKernelDisplayName = newKernel.display_name;
|
||||
@@ -930,7 +932,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
// so that connections can be tracked accordingly throughout ADS:
|
||||
// let connectionUri = Utils.generateUri(connection, 'notebook');
|
||||
private async disconnectNotebookConnection(conn: ConnectionProfile): Promise<void> {
|
||||
if (this.notebookOptions.connectionService.getConnectionUri(conn).includes(uriPrefixes.notebook)) {
|
||||
if (this.notebookOptions.connectionService.getConnectionUri(conn).indexOf(uriPrefixes.notebook) > -1) {
|
||||
let uri = this._notebookOptions.connectionService.getConnectionUri(conn);
|
||||
await this.notebookOptions.connectionService.disconnect(uri).catch(e => this.logService.error(e));
|
||||
}
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { FindMatch } from 'vs/editor/common/model';
|
||||
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
|
||||
import { NotebookContentChange, INotebookModel } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
|
||||
import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel';
|
||||
import { repeat } from 'vs/base/common/strings';
|
||||
|
||||
export class NotebookTextFileModel {
|
||||
// save active cell's line/column in editor model for the beginning of the source property
|
||||
@@ -97,7 +95,7 @@ export class NotebookTextFileModel {
|
||||
endColumn: computedEndColumn
|
||||
};
|
||||
// Need to subtract one because we're going from 1-based to 0-based
|
||||
let startSpaces: string = ' '.repeat(cellGuidRange.startColumn - 1);
|
||||
let startSpaces: string = repeat(' ', cellGuidRange.startColumn - 1);
|
||||
// The text here transforms a string from 'This is a string\n this is another string' to:
|
||||
// This is a string
|
||||
// this is another string
|
||||
@@ -237,7 +235,7 @@ export class NotebookTextFileModel {
|
||||
if (this._activeCellGuid === cellGuid) {
|
||||
outputsBegin = this._outputBeginRange;
|
||||
}
|
||||
if (!outputsBegin || !textEditorModel.textEditorModel.getLineContent(outputsBegin.startLineNumber).trim().includes('output')) {
|
||||
if (!outputsBegin || !(textEditorModel.textEditorModel.getLineContent(outputsBegin.startLineNumber).trim().indexOf('output') > -1)) {
|
||||
this.updateOutputBeginRange(textEditorModel, cellGuid);
|
||||
outputsBegin = this._outputBeginRange;
|
||||
if (!outputsBegin) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ICellModel } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
|
||||
export const clusterEndpointsProperty = 'clusterEndpoints';
|
||||
@@ -25,7 +27,7 @@ export function getProvidersForFileName(fileName: string, notebookService: INote
|
||||
let fileExt = path.extname(fileName);
|
||||
let providers: string[];
|
||||
// First try to get provider for actual file type
|
||||
if (fileExt && fileExt.startsWith('.')) {
|
||||
if (fileExt && startsWith(fileExt, '.')) {
|
||||
fileExt = fileExt.slice(1, fileExt.length);
|
||||
providers = notebookService.getProvidersForFileType(fileExt);
|
||||
}
|
||||
@@ -46,7 +48,7 @@ export function getStandardKernelsForProvider(providerId: string, notebookServic
|
||||
}
|
||||
let standardKernels = notebookService.getStandardKernelsForProvider(providerId);
|
||||
standardKernels.forEach(kernel => {
|
||||
Object.assign(<IStandardKernelWithProvider>kernel, {
|
||||
assign(<IStandardKernelWithProvider>kernel, {
|
||||
name: kernel.name,
|
||||
connectionProviderIds: kernel.connectionProviderIds,
|
||||
notebookProvider: providerId
|
||||
@@ -118,7 +120,7 @@ export function convertVscodeResourceToFileInSubDirectories(htmlContent: string,
|
||||
let pathEndIndex = htmlContentCopy.indexOf('\" ', pathStartIndex);
|
||||
let filePath = htmlContentCopy.substring(pathStartIndex, pathEndIndex);
|
||||
// If the asset is in the same folder or a subfolder, replace 'vscode-resource:' with 'file:', so the image is visible
|
||||
if (!path.relative(path.dirname(cellModel.notebookModel.notebookUri.fsPath), filePath).includes('..')) {
|
||||
if (!(path.relative(path.dirname(cellModel.notebookModel.notebookUri.fsPath), filePath).indexOf('..') > -1)) {
|
||||
// ok to change from vscode-resource: to file:
|
||||
htmlContent = htmlContent.replace('vscode-resource:' + filePath, 'file:' + filePath);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { IBootstrapParams } from 'sql/workbench/services/bootstrap/common/bootstrapParams';
|
||||
import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||
@@ -330,7 +331,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
|
||||
if (DEFAULT_NOTEBOOK_PROVIDER === providerInfo.providerId) {
|
||||
let providers = notebookUtils.getProvidersForFileName(this._notebookParams.notebookUri.fsPath, this.notebookService);
|
||||
let tsqlProvider = providers.find(provider => provider === SQL_NOTEBOOK_PROVIDER);
|
||||
let tsqlProvider = find(providers, provider => provider === SQL_NOTEBOOK_PROVIDER);
|
||||
providerInfo.providerId = tsqlProvider ? SQL_NOTEBOOK_PROVIDER : providers[0];
|
||||
}
|
||||
if (DEFAULT_NOTEBOOK_PROVIDER === providerInfo.providerId) {
|
||||
@@ -393,7 +394,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
}
|
||||
|
||||
findCellIndex(cellModel: ICellModel): number {
|
||||
return this._model.cells.findIndex((cell) => cell.id === cellModel.id);
|
||||
return firstIndex(this._model.cells, (cell) => cell.id === cellModel.id);
|
||||
}
|
||||
|
||||
private setViewInErrorState(error: any): any {
|
||||
@@ -515,7 +516,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
private addPrimaryContributedActions(primary: IAction[]) {
|
||||
for (let action of primary) {
|
||||
// Need to ensure that we don't add the same action multiple times
|
||||
let foundIndex = this._providerRelatedActions.findIndex(act => act.id === action.id);
|
||||
let foundIndex = firstIndex(this._providerRelatedActions, act => act.id === action.id);
|
||||
if (foundIndex < 0) {
|
||||
this._actionBar.addAction(action);
|
||||
this._providerRelatedActions.push(action);
|
||||
@@ -566,7 +567,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
public async runCell(cell: ICellModel): Promise<boolean> {
|
||||
await this.modelReady;
|
||||
let uriString = cell.cellUri.toString();
|
||||
if (this._model.cells.findIndex(c => c.cellUri.toString() === uriString) > -1) {
|
||||
if (firstIndex(this._model.cells, c => c.cellUri.toString() === uriString) > -1) {
|
||||
this.selectCell(cell);
|
||||
return cell.runCell(this.notificationService, this.connectionManagementService);
|
||||
} else {
|
||||
@@ -582,10 +583,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
let startIndex = 0;
|
||||
let endIndex = codeCells.length;
|
||||
if (!isUndefinedOrNull(startCell)) {
|
||||
startIndex = codeCells.findIndex(c => c.id === startCell.id);
|
||||
startIndex = firstIndex(codeCells, c => c.id === startCell.id);
|
||||
}
|
||||
if (!isUndefinedOrNull(endCell)) {
|
||||
endIndex = codeCells.findIndex(c => c.id === endCell.id);
|
||||
endIndex = firstIndex(codeCells, c => c.id === endCell.id);
|
||||
}
|
||||
for (let i = startIndex; i < endIndex; i++) {
|
||||
let cellStatus = await this.runCell(codeCells[i]);
|
||||
@@ -601,7 +602,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
try {
|
||||
await this.modelReady;
|
||||
let uriString = cell.cellUri.toString();
|
||||
if (this._model.cells.findIndex(c => c.cellUri.toString() === uriString) > -1) {
|
||||
if (firstIndex(this._model.cells, c => c.cellUri.toString() === uriString) > -1) {
|
||||
this.selectCell(cell);
|
||||
// Clear outputs of the requested cell if cell type is code cell.
|
||||
// If cell is markdown cell, clearOutputs() is a no-op
|
||||
@@ -671,7 +672,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
|
||||
navigateToSection(id: string): void {
|
||||
id = id.toLowerCase();
|
||||
let section = this.getSectionElements().find(s => s.relativeUri && s.relativeUri.toLowerCase() === id);
|
||||
let section = find(this.getSectionElements(), s => s.relativeUri && s.relativeUri.toLowerCase() === id);
|
||||
if (section) {
|
||||
// Scroll this section to the top of the header instead of just bringing header into view.
|
||||
let scrollTop = jQuery(section.headerEl).offset().top;
|
||||
|
||||
@@ -27,6 +27,7 @@ import { getErrorMessage } from 'vs/base/common/errors';
|
||||
import { INotebookModel } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
import { TreeUpdateUtils } from 'sql/workbench/parts/objectExplorer/browser/treeUpdateUtils';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
const msgLoading = localize('loading', "Loading kernels...");
|
||||
const msgChanging = localize('changing', "Changing kernel...");
|
||||
@@ -343,7 +344,7 @@ export class KernelsDropdown extends SelectBox {
|
||||
let standardKernel = this.model.getStandardKernelFromName(kernel.name);
|
||||
|
||||
if (kernels && standardKernel) {
|
||||
let index = kernels.findIndex((kernel => kernel === standardKernel.displayName));
|
||||
let index = firstIndex(kernels, kernel => kernel === standardKernel.displayName);
|
||||
this.setOptions(kernels, index);
|
||||
}
|
||||
} else if (this.model.clientSession.isInErrorState) {
|
||||
@@ -430,7 +431,7 @@ export class AttachToDropdown extends SelectBox {
|
||||
let kernelDisplayName: string;
|
||||
if (this.model.clientSession && this.model.clientSession.kernel && this.model.clientSession.kernel.name) {
|
||||
let currentKernelName = this.model.clientSession.kernel.name.toLowerCase();
|
||||
let currentKernelSpec = this.model.specs.kernels.find(kernel => kernel.name && kernel.name.toLowerCase() === currentKernelName);
|
||||
let currentKernelSpec = find(this.model.specs.kernels, kernel => kernel.name && kernel.name.toLowerCase() === currentKernelName);
|
||||
if (currentKernelSpec) {
|
||||
kernelDisplayName = currentKernelSpec.display_name;
|
||||
}
|
||||
@@ -455,7 +456,7 @@ export class AttachToDropdown extends SelectBox {
|
||||
connections.unshift(msgSelectConnection);
|
||||
}
|
||||
else {
|
||||
if (!connections.includes(msgAddNewConnection)) {
|
||||
if (!find(connections, x => x === msgAddNewConnection)) {
|
||||
connections.push(msgAddNewConnection);
|
||||
}
|
||||
}
|
||||
@@ -466,11 +467,11 @@ export class AttachToDropdown extends SelectBox {
|
||||
|
||||
private loadWithSelectConnection(connections: string[]): string[] {
|
||||
if (connections && connections.length > 0) {
|
||||
if (!connections.includes(msgSelectConnection)) {
|
||||
if (!find(connections, x => x === msgSelectConnection)) {
|
||||
connections.unshift(msgSelectConnection);
|
||||
}
|
||||
|
||||
if (!connections.includes(msgAddNewConnection)) {
|
||||
if (!find(connections, x => x === msgAddNewConnection)) {
|
||||
connections.push(msgAddNewConnection);
|
||||
}
|
||||
this.setOptions(connections, 0);
|
||||
@@ -515,7 +516,7 @@ export class AttachToDropdown extends SelectBox {
|
||||
if (connections.length === 1) {
|
||||
return connections[0];
|
||||
} else {
|
||||
return this.model.contexts.otherConnections.find((c) => selection === c.title);
|
||||
return find(this.model.contexts.otherConnections, (c) => selection === c.title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,7 +564,7 @@ export class AttachToDropdown extends SelectBox {
|
||||
//To ignore n/a after we have at least one valid connection
|
||||
attachToConnections = attachToConnections.filter(val => val !== msgSelectConnection);
|
||||
|
||||
let index = attachToConnections.findIndex((connection => connection === connectedServer));
|
||||
let index = firstIndex(attachToConnections, connection => connection === connectedServer);
|
||||
this.setOptions([]);
|
||||
this.setOptions(attachToConnections);
|
||||
if (!index || index < 0 || index >= attachToConnections.length) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as azdata from 'azdata';
|
||||
|
||||
import { IGridDataProvider, getResultsString } from 'sql/platform/query/common/gridDataProvider';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -33,6 +33,8 @@ import { ISerializationService, SerializeDataParams } from 'sql/platform/seriali
|
||||
import { SaveResultAction } from 'sql/workbench/parts/query/browser/actions';
|
||||
import { ResultSerializer, SaveResultsResponse } from 'sql/workbench/parts/query/common/resultSerializer';
|
||||
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
@Component({
|
||||
selector: GridOutputComponent.SELECTOR,
|
||||
@@ -190,7 +192,7 @@ class DataResourceDataProvider implements IGridDataProvider {
|
||||
this.rows = source.data.map(row => {
|
||||
let rowData: azdata.DbCellValue[] = [];
|
||||
Object.keys(row).forEach((val, index) => {
|
||||
let displayValue = String(Object.values(row)[index]);
|
||||
let displayValue = String(values(row)[index]);
|
||||
// Since the columns[0] represents the row number, start at 1
|
||||
rowData.push({
|
||||
displayValue: displayValue,
|
||||
@@ -292,7 +294,7 @@ class DataResourceDataProvider implements IGridDataProvider {
|
||||
return result;
|
||||
};
|
||||
|
||||
let serializeRequestParams: SerializeDataParams = <SerializeDataParams>Object.assign(serializer.getBasicSaveParameters(format), <Partial<SerializeDataParams>>{
|
||||
let serializeRequestParams: SerializeDataParams = <SerializeDataParams>assign(serializer.getBasicSaveParameters(format), <Partial<SerializeDataParams>>{
|
||||
saveFormat: format,
|
||||
columns: columns,
|
||||
filePath: filePath,
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ReadonlyJSONObject } from 'sql/workbench/parts/notebook/common/models/j
|
||||
import { MimeModel } from 'sql/workbench/parts/notebook/browser/models/mimemodel';
|
||||
import * as types from 'vs/base/common/types';
|
||||
import { ICellModel } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export type FactoryIdentifier = string;
|
||||
|
||||
@@ -146,10 +147,10 @@ class MimeComponentRegistry implements IMimeComponentRegistry {
|
||||
|
||||
public getAllCtors(): Array<Type<IMimeComponent>> {
|
||||
let addedCtors = [];
|
||||
let ctors = Object.values(this._componentDefinitions)
|
||||
let ctors = values(this._componentDefinitions)
|
||||
.map((c: IMimeComponentDefinition) => c.ctor)
|
||||
.filter(ctor => {
|
||||
let shouldAdd = !addedCtors.find((ctor2) => ctor === ctor2);
|
||||
let shouldAdd = !addedCtors.some((ctor2) => ctor === ctor2);
|
||||
if (shouldAdd) {
|
||||
addedCtors.push(ctor);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class NotebookMarkdownRenderer {
|
||||
const withInnerHTML = new Promise(c => signalInnerHTML = c);
|
||||
|
||||
let notebookFolder = path.dirname(this._notebookURI.fsPath) + '/';
|
||||
if (!this._baseUrls.includes(notebookFolder)) {
|
||||
if (!this._baseUrls.some(x => x === notebookFolder)) {
|
||||
this._baseUrls.push(notebookFolder);
|
||||
}
|
||||
const renderer = new marked.Renderer({ baseUrl: notebookFolder });
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import * as sanitizeHtml from 'sanitize-html';
|
||||
import { raw } from 'sql/base/common/strings';
|
||||
|
||||
export interface ISanitizer {
|
||||
/**
|
||||
@@ -74,14 +75,14 @@ class CssProp {
|
||||
private static readonly B = {
|
||||
angle: `(${CssProp.N.number}(deg|rad|grad|turn)|0)`,
|
||||
frequency: `${CssProp.N.number}(Hz|kHz)`,
|
||||
ident: String.raw`-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`,
|
||||
ident: raw`-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`,
|
||||
len_or_perc: `(0|${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc|%))`,
|
||||
length: `(${CssProp.N.number}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`,
|
||||
length_pos: `(${CssProp.N.number_pos}(px|em|rem|ex|in|cm|mm|pt|pc)|0)`,
|
||||
percentage: `${CssProp.N.number}%`,
|
||||
percentage_pos: `${CssProp.N.number_pos}%`,
|
||||
percentage_zero_hundred: `${CssProp.N.number_zero_hundred}%`,
|
||||
string: String.raw`(\"([^\n\r\f\\"]|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\")|(\'([^\n\r\f\\']|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\')`,
|
||||
string: raw`(\"([^\n\r\f\\"]|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\")|(\'([^\n\r\f\\']|\\\n|\r\n|\r|\f|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*\')`,
|
||||
time: `${CssProp.N.number}(s|ms)`,
|
||||
url: `url\\(.*?\\)`,
|
||||
z_index: `[+-]?[0-9]{1,7}`
|
||||
@@ -115,8 +116,8 @@ class CssProp {
|
||||
private static readonly _COLOR = {
|
||||
hex: `\\#(0x)?[0-9a-f]+`,
|
||||
name: `aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|transparent|violet|wheat|white|whitesmoke|yellow|yellowgreen`,
|
||||
rgb: String.raw`rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)`,
|
||||
rgba: String.raw`rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(${
|
||||
rgb: raw`rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)`,
|
||||
rgba: raw`rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(${
|
||||
CssProp.N.integer_zero_ff
|
||||
}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred})\s*\)`
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@ import { MouseWheelSupport } from 'sql/base/browser/ui/table/plugins/mousewheelT
|
||||
import { AutoColumnSize } from 'sql/base/browser/ui/table/plugins/autoSizeColumns.plugin';
|
||||
import { AdditionalKeyBindings } from 'sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin';
|
||||
import { RESULTS_GRID_DEFAULTS } from 'sql/workbench/parts/query/common/resultsGridContribution';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
/**
|
||||
* Render DataResource as a grid into a host node.
|
||||
@@ -89,7 +90,7 @@ export function transformData(rows: any[], columns: Slick.Column<any>[]): { [key
|
||||
return rows.map(row => {
|
||||
let dataWithSchema = {};
|
||||
Object.keys(row).forEach((val, index) => {
|
||||
let displayValue = String(Object.values(row)[index]);
|
||||
let displayValue = String(values(row)[index]);
|
||||
// Since the columns[0] represents the row number, start at 1
|
||||
dataWithSchema[columns[index + 1].field] = {
|
||||
displayValue: displayValue,
|
||||
|
||||
@@ -34,6 +34,8 @@ import { nb } from 'azdata';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { INotebookEditor, INotebookManager } from 'sql/workbench/services/notebook/browser/notebookService';
|
||||
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
|
||||
class ServiceAccessor {
|
||||
@@ -548,7 +550,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(10 + i * 21), ' ],');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(14 + i * 21), ' "outputs": [');
|
||||
assert.equal(notebookEditorModel.editorModel.textEditorModel.getLineContent(25 + i * 21), ' "execution_count": 0');
|
||||
assert(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21).startsWith(' }'));
|
||||
assert(startsWith(notebookEditorModel.editorModel.textEditorModel.getLineContent(26 + i * 21), ' }'));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -856,7 +858,7 @@ suite('Notebook Editor Model', function (): void {
|
||||
});
|
||||
|
||||
async function createNewNotebookModel() {
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
|
||||
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>><unknown>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
notebookModel = new NotebookModel(options, undefined, logService, undefined, undefined);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
|
||||
@@ -266,7 +267,7 @@ suite('Cell Model', function (): void {
|
||||
|
||||
let modelJson = model.toJSON();
|
||||
assert(!isUndefinedOrNull(modelJson.metadata.tags));
|
||||
assert(!modelJson.metadata.tags.includes('hide_input'));
|
||||
assert(!modelJson.metadata.tags.some(x => x === 'hide_input'));
|
||||
|
||||
contents.metadata = {
|
||||
tags: ['hide_input']
|
||||
@@ -281,7 +282,7 @@ suite('Cell Model', function (): void {
|
||||
|
||||
modelJson = model.toJSON();
|
||||
assert(!isUndefinedOrNull(modelJson.metadata.tags));
|
||||
assert(modelJson.metadata.tags.includes('hide_input'));
|
||||
assert(modelJson.metadata.tags.some(x => x === 'hide_input'));
|
||||
|
||||
contents.metadata = {
|
||||
tags: ['not_a_real_tag']
|
||||
@@ -289,7 +290,7 @@ suite('Cell Model', function (): void {
|
||||
model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
modelJson = model.toJSON();
|
||||
assert(!isUndefinedOrNull(modelJson.metadata.tags));
|
||||
assert(!modelJson.metadata.tags.includes('hide_input'));
|
||||
assert(!modelJson.metadata.tags.some(x => x === 'hide_input'));
|
||||
|
||||
contents.metadata = {
|
||||
tags: ['not_a_real_tag', 'hide_input']
|
||||
@@ -297,7 +298,7 @@ suite('Cell Model', function (): void {
|
||||
model = factory.createCell(contents, { notebook: notebookModel, isTrusted: false });
|
||||
modelJson = model.toJSON();
|
||||
assert(!isUndefinedOrNull(modelJson.metadata.tags));
|
||||
assert(modelJson.metadata.tags.includes('hide_input'));
|
||||
assert(modelJson.metadata.tags.some(x => x === 'hide_input'));
|
||||
});
|
||||
|
||||
test('Should emit event after collapsing cell', async function (): Promise<void> {
|
||||
@@ -551,15 +552,15 @@ suite('Cell Model', function (): void {
|
||||
let content = JSON.stringify(cell.toJSON(), undefined, ' ');
|
||||
let contentSplit = content.split('\n');
|
||||
assert.equal(contentSplit.length, 9);
|
||||
assert(contentSplit[0].trim().startsWith('{'));
|
||||
assert(contentSplit[1].trim().startsWith('"cell_type": "code",'));
|
||||
assert(contentSplit[2].trim().startsWith('"source": ""'));
|
||||
assert(contentSplit[3].trim().startsWith('"metadata": {'));
|
||||
assert(contentSplit[4].trim().startsWith('"azdata_cell_guid": "'));
|
||||
assert(contentSplit[5].trim().startsWith('}'));
|
||||
assert(contentSplit[6].trim().startsWith('"outputs": []'));
|
||||
assert(contentSplit[7].trim().startsWith('"execution_count": 0'));
|
||||
assert(contentSplit[8].trim().startsWith('}'));
|
||||
assert(startsWith(contentSplit[0].trim(), '{'));
|
||||
assert(startsWith(contentSplit[1].trim(), '"cell_type": "code",'));
|
||||
assert(startsWith(contentSplit[2].trim(), '"source": ""'));
|
||||
assert(startsWith(contentSplit[3].trim(), '"metadata": {'));
|
||||
assert(startsWith(contentSplit[4].trim(), '"azdata_cell_guid": "'));
|
||||
assert(startsWith(contentSplit[5].trim(), '}'));
|
||||
assert(startsWith(contentSplit[6].trim(), '"outputs": []'));
|
||||
assert(startsWith(contentSplit[7].trim(), '"execution_count": 0'));
|
||||
assert(startsWith(contentSplit[8].trim(), '}'));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import { LocalContentManager } from 'sql/workbench/services/notebook/common/loca
|
||||
import { NotebookManagerStub } from './common';
|
||||
import { NotebookModel } from 'sql/workbench/parts/notebook/browser/models/notebookModel';
|
||||
import { ModelFactory } from 'sql/workbench/parts/notebook/browser/models/modelFactory';
|
||||
import { IClientSession, ICellModel, INotebookModelOptions, NotebookContentChange } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { IClientSession, INotebookModelOptions, NotebookContentChange } from 'sql/workbench/parts/notebook/browser/models/modelInterfaces';
|
||||
import { ClientSession } from 'sql/workbench/parts/notebook/browser/models/clientSession';
|
||||
import { CellTypes, NotebookChangeType } from 'sql/workbench/parts/notebook/common/models/contracts';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
@@ -30,6 +30,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
@@ -238,7 +239,7 @@ suite('notebook model', function (): void {
|
||||
sessionReady.resolve();
|
||||
let actualSession: IClientSession = undefined;
|
||||
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
let options: INotebookModelOptions = assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options, undefined, logService, undefined, undefined);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { TreeItemCollapsibleState } from 'vs/workbench/common/views';
|
||||
import { localize } from 'vs/nls';
|
||||
import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||
import { UserCancelledConnectionError } from 'sql/base/common/errors';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export const SERVICE_ID = 'oeShimService';
|
||||
export const IOEShimService = createDecorator<IOEShimService>(SERVICE_ID);
|
||||
@@ -170,7 +171,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
||||
const database = node.getDatabaseName();
|
||||
if (database) {
|
||||
databaseChanged = true;
|
||||
updatedPayload = Object.assign(updatedPayload, parentNode.payload);
|
||||
updatedPayload = assign(updatedPayload, parentNode.payload);
|
||||
updatedPayload.databaseName = node.getDatabaseName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import { IQueryManagementService } from 'sql/platform/query/common/queryManageme
|
||||
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
|
||||
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { firstIndex, find } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* Provides actions for the server tree elements
|
||||
@@ -94,7 +95,7 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
||||
const options = { arg: undefined, shouldForwardArgs: true };
|
||||
const groups = menu.getActions(options);
|
||||
let insertIndex: number | undefined = 0;
|
||||
const queryIndex = groups.findIndex(v => {
|
||||
const queryIndex = firstIndex(groups, v => {
|
||||
if (v[0] === '0_query') {
|
||||
return true;
|
||||
} else {
|
||||
@@ -194,7 +195,7 @@ export class ServerTreeActionProvider extends ContributableActionProvider {
|
||||
|
||||
private isScriptableObject(context: ObjectExplorerContext): boolean {
|
||||
if (context.treeNode) {
|
||||
if (NodeType.SCRIPTABLE_OBJECTS.includes(context.treeNode.nodeTypeId)) {
|
||||
if (find(NodeType.SCRIPTABLE_OBJECTS, x => x === context.treeNode.nodeTypeId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
private findParentElement(container: HTMLElement, className: string): HTMLElement {
|
||||
let currentElement = container;
|
||||
while (currentElement) {
|
||||
if (currentElement.className.includes(className)) {
|
||||
if (currentElement.className.indexOf(className) > -1) {
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
|
||||
@@ -35,6 +35,7 @@ import { ServerTreeActionProvider } from 'sql/workbench/parts/objectExplorer/bro
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { isHidden } from 'sql/base/browser/dom';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
/**
|
||||
* ServerTreeview implements the dynamic tree view.
|
||||
@@ -192,7 +193,7 @@ export class ServerTreeView extends Disposable {
|
||||
public isObjectExplorerConnectionUri(uri: string): boolean {
|
||||
let isBackupRestoreUri: boolean = uri.indexOf(ConnectionUtils.ConnectionUriBackupIdAttributeName) >= 0 ||
|
||||
uri.indexOf(ConnectionUtils.ConnectionUriRestoreIdAttributeName) >= 0;
|
||||
return uri && uri.startsWith(ConnectionUtils.uriPrefixes.default) && !isBackupRestoreUri;
|
||||
return uri && startsWith(uri, ConnectionUtils.uriPrefixes.default) && !isBackupRestoreUri;
|
||||
}
|
||||
|
||||
private async handleAddConnectionProfile(newProfile: IConnectionProfile): Promise<void> {
|
||||
@@ -416,7 +417,7 @@ export class ServerTreeView extends Disposable {
|
||||
|
||||
private checkIncludes(searchString: string, candidate: string): boolean {
|
||||
if (candidate && searchString) {
|
||||
return candidate.toLocaleUpperCase().includes(searchString);
|
||||
return candidate.toLocaleUpperCase().indexOf(searchString) > -1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import { IClipboardService } from 'sql/platform/clipboard/common/clipboardServic
|
||||
import { CellSelectionModel } from 'sql/base/browser/ui/table/plugins/cellSelectionModel.plugin';
|
||||
import { handleCopyRequest } from 'sql/workbench/parts/profiler/browser/profilerCopyHandler';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
class BasicView implements IView {
|
||||
public get element(): HTMLElement {
|
||||
@@ -233,7 +234,7 @@ export class ProfilerEditor extends BaseEditor {
|
||||
this._viewTemplateSelector.setAriaLabel(nls.localize('profiler.viewSelectAccessibleName', "Select View"));
|
||||
this._register(this._viewTemplateSelector.onDidSelect(e => {
|
||||
if (this.input) {
|
||||
this.input.viewTemplate = this._viewTemplates.find(i => i.name === e.selected);
|
||||
this.input.viewTemplate = find(this._viewTemplates, i => i.name === e.selected);
|
||||
}
|
||||
}));
|
||||
let viewTemplateContainer = document.createElement('div');
|
||||
@@ -458,7 +459,7 @@ export class ProfilerEditor extends BaseEditor {
|
||||
if (input.viewTemplate) {
|
||||
this._viewTemplateSelector.selectWithOptionName(input.viewTemplate.name);
|
||||
} else {
|
||||
input.viewTemplate = this._viewTemplates.find(i => i.name === 'Standard View');
|
||||
input.viewTemplate = find(this._viewTemplates, i => i.name === 'Standard View');
|
||||
}
|
||||
|
||||
this._actionBar.context = input;
|
||||
|
||||
@@ -26,6 +26,7 @@ import { ProfilerFilter, ProfilerFilterClause, ProfilerFilterClauseOperator, IPr
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
const ClearText: string = localize('profilerFilterDialog.clear', "Clear all");
|
||||
@@ -220,7 +221,7 @@ export class ProfilerFilterDialog extends Modal {
|
||||
|
||||
private addClauseRow(setInitialValue: boolean, field?: string, operator?: string, value?: string): void {
|
||||
const columns = this._input.columns.map(column => column.name);
|
||||
if (field && !columns.includes(field)) {
|
||||
if (field && !find(columns, x => x === field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +270,7 @@ export class ProfilerFilterDialog extends Modal {
|
||||
}
|
||||
|
||||
private removeRow(clauseId: string) {
|
||||
const idx = this._clauseRows.findIndex((entry) => { return entry.id === clauseId; });
|
||||
const idx = firstIndex(this._clauseRows, (entry) => { return entry.id === clauseId; });
|
||||
if (idx !== -1) {
|
||||
this._clauseRows[idx].row.remove();
|
||||
this._clauseRows.splice(idx, 1);
|
||||
|
||||
@@ -23,6 +23,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { FilterData } from 'sql/workbench/services/profiler/browser/profilerFilter';
|
||||
import { uriPrefixes } from 'sql/platform/connection/common/utils';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ProfilerInput extends EditorInput implements IProfilerSession {
|
||||
|
||||
@@ -69,7 +70,7 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
||||
let ret = new Array<number>();
|
||||
for (let i = 0; i < this._columns.length; i++) {
|
||||
let colVal = val[this._columns[i]];
|
||||
if (colVal && colVal.toLocaleLowerCase().includes(exp.toLocaleLowerCase())) {
|
||||
if (colVal && colVal.toLocaleLowerCase().indexOf(exp.toLocaleLowerCase()) > -1) {
|
||||
ret.push(i);
|
||||
}
|
||||
}
|
||||
@@ -213,11 +214,11 @@ export class ProfilerInput extends EditorInput implements IProfilerSession {
|
||||
this._notificationService.error(nls.localize("profiler.sessionCreationError", "Error while starting new session"));
|
||||
} else {
|
||||
this._sessionName = params.sessionName;
|
||||
let sessionTemplate = this._profilerService.getSessionTemplates().find((template) => {
|
||||
let sessionTemplate = find(this._profilerService.getSessionTemplates(), (template) => {
|
||||
return template.name === params.templateName;
|
||||
});
|
||||
if (!types.isUndefinedOrNull(sessionTemplate)) {
|
||||
let newView = this._profilerService.getViewTemplates().find((view) => {
|
||||
let newView = find(this._profilerService.getViewTemplates(), (view) => {
|
||||
return view.name === sessionTemplate.defaultView;
|
||||
});
|
||||
if (!types.isUndefinedOrNull(newView)) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { range } from 'vs/base/common/arrays';
|
||||
import { range, find } from 'vs/base/common/arrays';
|
||||
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
|
||||
import { Disposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
@@ -184,7 +184,7 @@ export class GridPanel extends Disposable {
|
||||
|
||||
if (this.configurationService.getValue<boolean>('sql.results.streaming')) {
|
||||
for (let set of resultsToUpdate) {
|
||||
let table = this.tables.find(t => t.resultSet.batchId === set.batchId && t.resultSet.id === set.id);
|
||||
let table = find(this.tables, t => t.resultSet.batchId === set.batchId && t.resultSet.id === set.id);
|
||||
if (table) {
|
||||
table.updateResult(set);
|
||||
} else {
|
||||
@@ -206,12 +206,12 @@ export class GridPanel extends Disposable {
|
||||
|
||||
for (let set of resultSet) {
|
||||
// ensure we aren't adding a resultSet that is already visible
|
||||
if (this.tables.find(t => t.resultSet.batchId === set.batchId && t.resultSet.id === set.id)) {
|
||||
if (find(this.tables, t => t.resultSet.batchId === set.batchId && t.resultSet.id === set.id)) {
|
||||
continue;
|
||||
}
|
||||
let tableState: GridTableState;
|
||||
if (this.state) {
|
||||
tableState = this.state.tableStates.find(e => e.batchId === set.batchId && e.resultId === set.id);
|
||||
tableState = find(this.state.tableStates, e => e.batchId === set.batchId && e.resultId === set.id);
|
||||
}
|
||||
if (!tableState) {
|
||||
tableState = new GridTableState(set.id, set.batchId);
|
||||
@@ -262,7 +262,7 @@ export class GridPanel extends Disposable {
|
||||
}
|
||||
|
||||
private maximizeTable(tableid: string): void {
|
||||
if (!this.tables.find(t => t.id === tableid)) {
|
||||
if (!find(this.tables, t => t.id === tableid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ export class GridPanel extends Disposable {
|
||||
this._state = val;
|
||||
if (this.state) {
|
||||
this.tables.map(t => {
|
||||
let state = this.state.tableStates.find(s => s.batchId === t.resultSet.batchId && s.resultId === t.resultSet.id);
|
||||
let state = find(this.state.tableStates, s => s.batchId === t.resultSet.batchId && s.resultId === t.resultSet.id);
|
||||
if (!state) {
|
||||
this.state.tableStates.push(t.state);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import { EditDataEditor } from 'sql/workbench/parts/editData/browser/editDataEdi
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
const singleQuote = '\'';
|
||||
|
||||
@@ -368,7 +369,7 @@ export class RunQueryShortcutAction extends Action {
|
||||
}
|
||||
|
||||
private getColumnIndex(columnInfo: azdata.IDbColumn[], columnName: string): number {
|
||||
return columnInfo ? columnInfo.findIndex(c => c.columnName === columnName) : undefined;
|
||||
return columnInfo ? firstIndex(columnInfo, c => c.columnName === columnName) : undefined;
|
||||
}
|
||||
|
||||
private canQueryProcMetadata(editor: QueryEditor): boolean {
|
||||
|
||||
@@ -187,7 +187,7 @@ export class QueryEditor extends BaseEditor {
|
||||
this.setTaskbarContent();
|
||||
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectedKeys.includes('workbench.enablePreviewFeatures')) {
|
||||
if (e.affectsConfiguration('workbench.enablePreviewFeatures')) {
|
||||
this.setTaskbarContent();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -23,6 +23,8 @@ import { dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { attachTabbedPanelStyler } from 'sql/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
class MessagesView extends Disposable implements IPanelView {
|
||||
private messagePanel: MessagePanel;
|
||||
@@ -234,7 +236,7 @@ export class QueryResultsView extends Disposable {
|
||||
this.input.state.activeTab = this.resultsTab.identifier;
|
||||
}));
|
||||
this.runnerDisposables.add(runner.onQueryEnd(() => {
|
||||
if (runner.messages.find(v => v.isError)) {
|
||||
if (runner.messages.some(v => v.isError)) {
|
||||
this._panelView.showTab(this.messagesTab.identifier);
|
||||
}
|
||||
}));
|
||||
@@ -266,7 +268,7 @@ export class QueryResultsView extends Disposable {
|
||||
this.dynamicModelViewTabs = [];
|
||||
|
||||
this.input.state.visibleTabs.forEach(tabId => {
|
||||
if (tabId.startsWith('querymodelview;')) {
|
||||
if (startsWith(tabId, 'querymodelview;')) {
|
||||
// tab id format is 'tab type;title;model view id'
|
||||
let parts = tabId.split(';');
|
||||
if (parts.length === 3) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
@@ -19,7 +19,7 @@ import { IQueryModelService } from 'sql/platform/query/common/queryModel';
|
||||
import { ISelectionData, ExecutionPlanOptions } from 'azdata';
|
||||
import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel';
|
||||
import { IResolvedTextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { FileEditorInput } from 'vs/workbench/contrib/files/common/editors/fileEditorInput';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
|
||||
const MAX_SIZE = 13;
|
||||
|
||||
@@ -29,7 +29,7 @@ function trimTitle(title: string): string {
|
||||
const length = title.length;
|
||||
const diff = length - MAX_SIZE;
|
||||
|
||||
if (Math.sign(diff) <= 0) {
|
||||
if (diff <= 0) {
|
||||
return title;
|
||||
} else {
|
||||
const start = (length / 2) - (diff / 2);
|
||||
@@ -183,7 +183,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
|
||||
if (this._configurationService) {
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectedKeys.includes('sql.showConnectionInfoInTitle')) {
|
||||
if (e.affectsConfiguration('sql.showConnectionInfoInTitle')) {
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
}));
|
||||
@@ -361,6 +361,6 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
}
|
||||
|
||||
public get isSharedSession(): boolean {
|
||||
return !!(this.uri && this.uri.startsWith('vsls:'));
|
||||
return !!(this.uri && startsWith(this.uri, 'vsls:'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ export class RestoreDialog extends Modal {
|
||||
|
||||
let isSame = false;
|
||||
if (this.viewModel.selectedBackupSets && this.viewModel.selectedBackupSets.length === selectedFiles.length) {
|
||||
isSame = this.viewModel.selectedBackupSets.some(item => selectedFiles.includes(item));
|
||||
isSame = this.viewModel.selectedBackupSets.some(item => selectedFiles.some(x => x === item));
|
||||
}
|
||||
|
||||
if (!isSame) {
|
||||
|
||||
@@ -25,7 +25,7 @@ export class SqlTelemetryContribution extends Disposable implements IWorkbenchCo
|
||||
commandService.onWillExecuteCommand(
|
||||
(e: ICommandEvent) => {
|
||||
// Filter out high-frequency events
|
||||
if (!['type', 'cursorUp', 'cursorDown', 'cursorRight', 'cursorLeft', 'deleteLeft', 'deleteRight'].find(id => id === e.commandId)) {
|
||||
if (!['type', 'cursorUp', 'cursorDown', 'cursorRight', 'cursorLeft', 'deleteLeft', 'deleteRight'].some(id => id === e.commandId)) {
|
||||
telemetryService.sendActionEvent(TelemetryView.Shell, 'adsCommandExecuted', e.commandId);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -20,6 +20,8 @@ import { Deferred } from 'sql/base/common/promise';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export class AccountManagementService implements IAccountManagementService {
|
||||
// CONSTANTS ///////////////////////////////////////////////////////////
|
||||
@@ -166,7 +168,7 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
}
|
||||
if (result.accountModified) {
|
||||
// Find the updated account and splice the updated on in
|
||||
let indexToRemove: number = provider.accounts.findIndex(account => {
|
||||
let indexToRemove: number = firstIndex(provider.accounts, account => {
|
||||
return account.key.accountId === result.changedAccount.key.accountId;
|
||||
});
|
||||
if (indexToRemove >= 0) {
|
||||
@@ -184,7 +186,7 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
* @returns Registered account providers
|
||||
*/
|
||||
public getAccountProviderMetadata(): Thenable<azdata.AccountProviderMetadata[]> {
|
||||
return Promise.resolve(Object.values(this._providers).map(provider => provider.metadata));
|
||||
return Promise.resolve(values(this._providers).map(provider => provider.metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +243,7 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
return result;
|
||||
}
|
||||
|
||||
let indexToRemove: number = provider.accounts.findIndex(account => {
|
||||
let indexToRemove: number = firstIndex(provider.accounts, account => {
|
||||
return account.key.accountId === accountKey.accountId;
|
||||
});
|
||||
|
||||
@@ -423,7 +425,7 @@ export class AccountManagementService implements IAccountManagementService {
|
||||
|
||||
private spliceModifiedAccount(provider: AccountProviderWithMetadata, modifiedAccount: azdata.Account) {
|
||||
// Find the updated account and splice the updated one in
|
||||
let indexToRemove: number = provider.accounts.findIndex(account => {
|
||||
let indexToRemove: number = firstIndex(provider.accounts, account => {
|
||||
return account.key.accountId === modifiedAccount.key.accountId;
|
||||
});
|
||||
if (indexToRemove >= 0) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import { BackupDialog } from 'sql/workbench/parts/backup/browser/backupDialog';
|
||||
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
|
||||
import { IBackupService, TaskExecutionMode } from 'sql/platform/backup/common/backupService';
|
||||
import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class BackupUiService implements IBackupUiService {
|
||||
public _serviceBrand: undefined;
|
||||
@@ -50,7 +51,7 @@ export class BackupUiService implements IBackupUiService {
|
||||
}
|
||||
|
||||
private getOptions(provider: string): azdata.ServiceOption[] {
|
||||
let feature = this._capabilitiesService.getLegacyCapabilities(this._currentProvider).features.find(f => f.featureName === 'backup');
|
||||
let feature = find(this._capabilitiesService.getLegacyCapabilities(this._currentProvider).features, f => f.featureName === 'backup');
|
||||
if (feature) {
|
||||
return feature.optionsMetadata;
|
||||
} else {
|
||||
|
||||
@@ -13,10 +13,11 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
import { entries } from 'sql/base/common/objects';
|
||||
import { toObject } from 'sql/base/common/map';
|
||||
import { IConnectionProviderRegistry, Extensions as ConnectionExtensions } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
import { ICapabilitiesService, ProviderFeatures, clientCapabilities, ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { entries } from 'sql/base/common/collections';
|
||||
|
||||
const connectionRegistry = Registry.as<IConnectionProviderRegistry>(ConnectionExtensions.ConnectionProviderContributions);
|
||||
|
||||
@@ -77,7 +78,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
||||
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => {
|
||||
const connectionProvider = 'connectionProvider';
|
||||
extensionService.getExtensions().then(i => {
|
||||
let extension = i.find(c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||
let extension = find(i, c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||
if (extension && extension.contributes
|
||||
&& extension.contributes[connectionProvider]
|
||||
&& extension.contributes[connectionProvider].providerId) {
|
||||
@@ -91,7 +92,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
||||
private cleanupProviders(): void {
|
||||
let knownProviders = Object.keys(connectionRegistry.providers);
|
||||
for (let key in this.capabilities.connectionProviderCache) {
|
||||
if (!knownProviders.includes(key)) {
|
||||
if (!knownProviders.some(x => x === key)) {
|
||||
this._providers.delete(key);
|
||||
delete this.capabilities.connectionProviderCache[key];
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import { ConnectionWidget } from 'sql/workbench/services/connection/browser/conn
|
||||
import { IServerGroupController } from 'sql/platform/serverGroup/common/serverGroupController';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ConnectionProviderProperties } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ConnectionController implements IConnectionComponentController {
|
||||
private _advancedController: AdvancedPropertiesController;
|
||||
@@ -139,7 +141,7 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
} else {
|
||||
defaultGroupId = Utils.defaultGroupId;
|
||||
}
|
||||
allGroups.push(Object.assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
|
||||
allGroups.push(assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
|
||||
allGroups.push(this._connectionWidget.NoneServerGroup);
|
||||
connectionGroupRoot.forEach(cpg => cpg.dispose());
|
||||
return allGroups;
|
||||
@@ -149,7 +151,7 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
this._connectionWidget.updateServerGroup(this.getAllServerGroups(providers));
|
||||
this._model = connectionInfo;
|
||||
this._model.providerName = this._providerName;
|
||||
let appNameOption = this._providerOptions.find(option => option.specialValueType === ConnectionOptionSpecialType.appName);
|
||||
let appNameOption = find(this._providerOptions, option => option.specialValueType === ConnectionOptionSpecialType.appName);
|
||||
if (appNameOption) {
|
||||
let appNameKey = appNameOption.name;
|
||||
this._model.options[appNameKey] = Constants.applicationName;
|
||||
|
||||
@@ -14,7 +14,6 @@ import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { entries } from 'sql/base/common/objects';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService';
|
||||
@@ -30,6 +29,8 @@ import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { CmsConnectionController } from 'sql/workbench/services/connection/browser/cmsConnectionController';
|
||||
import { entries } from 'sql/base/common/collections';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface IConnectionValidateResult {
|
||||
isValid: boolean;
|
||||
@@ -136,7 +137,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
if (keys && keys.length > 0) {
|
||||
if (this._params && this._params.providers && this._params.providers.length > 0) {
|
||||
//Filter providers from master keys.
|
||||
filteredKeys = keys.filter(key => this._params.providers.includes(key));
|
||||
filteredKeys = keys.filter(key => this._params.providers.some(x => x === key));
|
||||
}
|
||||
if (filteredKeys && filteredKeys.length > 0) {
|
||||
defaultProvider = filteredKeys[0];
|
||||
@@ -307,7 +308,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
});
|
||||
}
|
||||
if (!isProviderInParams) {
|
||||
this._currentProviderType = Object.keys(this._providerNameToDisplayNameMap).find((key) =>
|
||||
this._currentProviderType = find(Object.keys(this._providerNameToDisplayNameMap), (key) =>
|
||||
this._providerNameToDisplayNameMap[key] === input.selectedProviderDisplayName &&
|
||||
key !== Constants.cmsProviderName
|
||||
);
|
||||
@@ -472,7 +473,7 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
// this solves the most common "hard error" that we've noticed
|
||||
const helpLink = 'https://aka.ms/sqlopskerberos';
|
||||
let actions: IAction[] = [];
|
||||
if (!platform.isWindows && types.isString(message) && message.toLowerCase().includes('kerberos') && message.toLowerCase().includes('kinit')) {
|
||||
if (!platform.isWindows && types.isString(message) && message.toLowerCase().indexOf('kerberos') > -1 && message.toLowerCase().indexOf('kinit') > -1) {
|
||||
message = [
|
||||
localize('kerberosErrorStart', "Connection failed due to Kerberos error."),
|
||||
localize('kerberosHelpLink', "Help configuring Kerberos is available at {0}", helpLink),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user