mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 09:38:26 -05:00
Remove unused files in sql and extensions folders (#22444)
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
|
||||
export class RowCache implements IDisposable {
|
||||
dispose(): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export interface IRow {
|
||||
domNode: HTMLElement | null;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,155 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { CancelablePromise, createCancelablePromise } from 'vs/base/common/async';
|
||||
|
||||
class DataWindow<T> {
|
||||
private _data: T[] | undefined;
|
||||
private _length: number = 0;
|
||||
private _offsetFromDataSource: number = -1;
|
||||
|
||||
private dataReady?: CancelablePromise<void>;
|
||||
|
||||
constructor(
|
||||
private loadFunction: (offset: number, count: number) => Promise<T[]>
|
||||
) { }
|
||||
|
||||
dispose() {
|
||||
this._data = undefined;
|
||||
if (this.dataReady) {
|
||||
this.dataReady.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
get start(): number {
|
||||
return this._offsetFromDataSource;
|
||||
}
|
||||
|
||||
get end(): number {
|
||||
return this._offsetFromDataSource + this._length;
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this._length;
|
||||
}
|
||||
|
||||
public contains(dataSourceIndex: number): boolean {
|
||||
return dataSourceIndex >= this.start && dataSourceIndex < this.end;
|
||||
}
|
||||
|
||||
public getItem(index: number): Promise<T> {
|
||||
return this.dataReady!.then(() => this._data![index - this._offsetFromDataSource]);
|
||||
}
|
||||
|
||||
public positionWindow(offset: number, length: number): void {
|
||||
this._offsetFromDataSource = offset;
|
||||
this._length = length;
|
||||
this._data = undefined;
|
||||
|
||||
if (this.dataReady) {
|
||||
this.dataReady.cancel();
|
||||
}
|
||||
|
||||
if (length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dataReady = createCancelablePromise(token => {
|
||||
return this.loadFunction(offset, length).then(data => {
|
||||
if (!token.isCancellationRequested) {
|
||||
this._data = data;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class VirtualizedWindow<T> {
|
||||
private _bufferWindowBefore: DataWindow<T>;
|
||||
private _window: DataWindow<T>;
|
||||
private _bufferWindowAfter: DataWindow<T>;
|
||||
|
||||
constructor(
|
||||
private readonly windowSize: number,
|
||||
private _length: number,
|
||||
loadFn: (offset: number, count: number) => Promise<T[]>
|
||||
) {
|
||||
|
||||
this._bufferWindowBefore = new DataWindow(loadFn);
|
||||
this._window = new DataWindow(loadFn);
|
||||
this._bufferWindowAfter = new DataWindow(loadFn);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._bufferWindowAfter.dispose();
|
||||
this._bufferWindowBefore.dispose();
|
||||
this._window.dispose();
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this._length;
|
||||
}
|
||||
|
||||
set length(length: number) {
|
||||
if (this.length !== length) {
|
||||
const oldLength = this.length;
|
||||
this._length = length;
|
||||
if (this._window.length !== this.windowSize) {
|
||||
this.resetWindowsAroundIndex(oldLength);
|
||||
} else if (this._bufferWindowAfter.length !== this.windowSize) {
|
||||
this._bufferWindowAfter.positionWindow(this._bufferWindowAfter.start, Math.min(this._bufferWindowAfter.start + this.windowSize, this.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getIndex(index: number): Promise<T> {
|
||||
|
||||
if (index < this._bufferWindowBefore.start || index >= this._bufferWindowAfter.end) {
|
||||
this.resetWindowsAroundIndex(index);
|
||||
}
|
||||
// scrolling up
|
||||
else if (this._bufferWindowBefore.contains(index)) {
|
||||
const beforeWindow = this._bufferWindowAfter;
|
||||
this._bufferWindowAfter = this._window;
|
||||
this._window = this._bufferWindowBefore;
|
||||
this._bufferWindowBefore = beforeWindow;
|
||||
// ensure we aren't buffer invalid data
|
||||
const beforeStart = Math.max(0, this._window.start - this.windowSize);
|
||||
// ensure if we got hinder in our start index that we update out length to not overlap
|
||||
const beforeLength = this._window.start - beforeStart;
|
||||
this._bufferWindowBefore.positionWindow(beforeStart, beforeLength);
|
||||
}
|
||||
// scroll down
|
||||
else if (this._bufferWindowAfter.contains(index)) {
|
||||
const afterWindow = this._bufferWindowBefore;
|
||||
this._bufferWindowBefore = this._window;
|
||||
this._window = this._bufferWindowAfter;
|
||||
this._bufferWindowAfter = afterWindow;
|
||||
// ensure we aren't buffer invalid data
|
||||
const afterStart = this._window.end;
|
||||
// ensure if we got hinder in our start index that we update out length to not overlap
|
||||
const afterLength = afterStart + this.windowSize > this.length ? this.length - afterStart : this.windowSize;
|
||||
this._bufferWindowAfter.positionWindow(afterStart, afterLength);
|
||||
}
|
||||
|
||||
// at this point we know the current window will have the index
|
||||
return this._window.getItem(index);
|
||||
}
|
||||
|
||||
private resetWindowsAroundIndex(index: number): void {
|
||||
|
||||
let bufferWindowBeforeStart = Math.max(0, index - this.windowSize * 1.5);
|
||||
let bufferWindowBeforeEnd = Math.max(0, index - this.windowSize / 2);
|
||||
this._bufferWindowBefore.positionWindow(bufferWindowBeforeStart, bufferWindowBeforeEnd - bufferWindowBeforeStart);
|
||||
|
||||
let mainWindowStart = bufferWindowBeforeEnd;
|
||||
let mainWindowEnd = Math.min(mainWindowStart + this.windowSize, this.length);
|
||||
this._window.positionWindow(mainWindowStart, mainWindowEnd - mainWindowStart);
|
||||
|
||||
let bufferWindowAfterStart = mainWindowEnd;
|
||||
let bufferWindowAfterEnd = Math.min(bufferWindowAfterStart + this.windowSize, this.length);
|
||||
this._bufferWindowAfter.positionWindow(bufferWindowAfterStart, bufferWindowAfterEnd - bufferWindowAfterStart);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function defaultFormatter<T>(valueProperty: keyof T): Slick.Formatter<T> {
|
||||
return (row: number, cell: number, value: any, columnDef: Slick.Column<T>, dataContext: Slick.SlickData): string => {
|
||||
return value[valueProperty];
|
||||
};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function isNumber(text: string): boolean {
|
||||
return !isNaN(parseInt(text)) && !isNaN(parseFloat(text));
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as _ from 'sql/base/parts/tree/browser/tree';
|
||||
|
||||
export function isEqualOrParent(tree: _.ITree, element: any, candidateParent: any): boolean {
|
||||
const nav = tree.getNavigator(element);
|
||||
|
||||
do {
|
||||
if (element === candidateParent) {
|
||||
return true;
|
||||
}
|
||||
} while (element = nav.parent()); // eslint-disable-line no-cond-assign
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import * as TreeDefaults from 'sql/base/parts/tree/browser/treeDefaults';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
export class FakeRenderer {
|
||||
class FakeRenderer {
|
||||
|
||||
public getHeight(tree: _.ITree, element: any): number {
|
||||
return 20;
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Table, DefaultStyleController, ITableOptions } from 'sql/base/browser/ui/table/highPerf/tableWidget';
|
||||
import { RawContextKey, IContextKey, ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { DisposableStore, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { createStyleSheet } from 'vs/base/browser/dom';
|
||||
import { attachHighPerfTableStyler as attachTableStyler, defaultHighPerfTableStyles, IHighPerfTableStyleOverrides } from 'sql/platform/theme/common/styler';
|
||||
import { InputFocusedContextKey } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITableDataSource, ITableColumn } from 'sql/base/browser/ui/table/highPerf/table';
|
||||
import { computeStyles } from 'vs/platform/theme/common/styler';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
export const ITableService = createDecorator<ITableService>('tableService');
|
||||
|
||||
export type TableWidget = Table<any>;
|
||||
|
||||
export interface ITableService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
/**
|
||||
* Returns the currently focused table widget if any.
|
||||
*/
|
||||
readonly lastFocusedTable: TableWidget | undefined;
|
||||
}
|
||||
|
||||
interface IRegisteredTable {
|
||||
widget: TableWidget;
|
||||
extraContextKeys?: (IContextKey<boolean>)[];
|
||||
}
|
||||
|
||||
export class TableService implements ITableService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private disposables = new DisposableStore();
|
||||
private tables: IRegisteredTable[] = [];
|
||||
private _lastFocusedWidget: TableWidget | undefined = undefined;
|
||||
|
||||
get lastFocusedTable(): TableWidget | undefined {
|
||||
return this._lastFocusedWidget;
|
||||
}
|
||||
|
||||
constructor(@IThemeService themeService: IThemeService) {
|
||||
// create a shared default tree style sheet for performance reasons
|
||||
const styleController = new DefaultStyleController(createStyleSheet(), '');
|
||||
this.disposables.add(attachTableStyler(styleController, themeService));
|
||||
}
|
||||
|
||||
register(widget: TableWidget, extraContextKeys?: (IContextKey<boolean>)[]): IDisposable {
|
||||
if (this.tables.some(l => l.widget === widget)) {
|
||||
throw new Error('Cannot register the same widget multiple times');
|
||||
}
|
||||
|
||||
// Keep in our tables table
|
||||
const registeredTable: IRegisteredTable = { widget, extraContextKeys };
|
||||
this.tables.push(registeredTable);
|
||||
|
||||
// Check for currently being focused
|
||||
if (widget.getHTMLElement() === document.activeElement) {
|
||||
this._lastFocusedWidget = widget;
|
||||
}
|
||||
|
||||
return combinedDisposable(
|
||||
widget.onDidFocus(() => this._lastFocusedWidget = widget),
|
||||
toDisposable(() => this.tables.splice(this.tables.indexOf(registeredTable), 1)),
|
||||
widget.onDidDispose(() => {
|
||||
this.tables = this.tables.filter(l => l !== registeredTable);
|
||||
if (this._lastFocusedWidget === widget) {
|
||||
this._lastFocusedWidget = undefined;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
const RawWorkbenchTableFocusContextKey = new RawContextKey<boolean>('tableFocus', true);
|
||||
export const WorkbenchTableFocusContextKey = ContextKeyExpr.and(RawWorkbenchTableFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey));
|
||||
export const WorkbenchTableHasSelectionOrFocus = new RawContextKey<boolean>('tableHasSelectionOrFocus', false);
|
||||
export const WorkbenchTableDoubleSelection = new RawContextKey<boolean>('tableDoubleSelection', false);
|
||||
export const WorkbenchTableMultiSelection = new RawContextKey<boolean>('tableMultiSelection', false);
|
||||
export const WorkbenchTableSupportsKeyboardNavigation = new RawContextKey<boolean>('tableSupportsKeyboardNavigation', true);
|
||||
export const WorkbenchTableAutomaticKeyboardNavigationKey = 'tableAutomaticKeyboardNavigation';
|
||||
export const WorkbenchTableAutomaticKeyboardNavigation = new RawContextKey<boolean>(WorkbenchTableAutomaticKeyboardNavigationKey, true);
|
||||
export let didBindWorkbenchTableAutomaticKeyboardNavigation = false;
|
||||
|
||||
function createScopedContextKeyService(contextKeyService: IContextKeyService, widget: TableWidget): IContextKeyService {
|
||||
const result = contextKeyService.createScoped(widget.getHTMLElement());
|
||||
RawWorkbenchTableFocusContextKey.bindTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
export const multiSelectModifierSettingKey = 'workbench.table.multiSelectModifier';
|
||||
export const openModeSettingKey = 'workbench.table.openMode';
|
||||
export const horizontalScrollingKey = 'workbench.table.horizontalScrolling';
|
||||
export const keyboardNavigationSettingKey = 'workbench.table.keyboardNavigation';
|
||||
export const automaticKeyboardNavigationSettingKey = 'workbench.table.automaticKeyboardNavigation';
|
||||
|
||||
function useAltAsMultipleSelectionModifier(configurationService: IConfigurationService): boolean {
|
||||
return configurationService.getValue(multiSelectModifierSettingKey) === 'alt';
|
||||
}
|
||||
|
||||
function toWorkbenchTableOptions<T>(options: ITableOptions<T>): [ITableOptions<T>, IDisposable] {
|
||||
const disposables = new DisposableStore();
|
||||
const result = { ...options };
|
||||
|
||||
return [result, disposables];
|
||||
}
|
||||
|
||||
export interface IWorkbenchTableOptions<T> extends ITableOptions<T> {
|
||||
readonly overrideStyles?: IHighPerfTableStyleOverrides;
|
||||
}
|
||||
|
||||
export class WorkbenchTable<T> extends Table<T> {
|
||||
|
||||
readonly contextKeyService: IContextKeyService;
|
||||
private readonly configurationService: IConfigurationService;
|
||||
|
||||
private tableHasSelectionOrFocus: IContextKey<boolean>;
|
||||
private tableDoubleSelection: IContextKey<boolean>;
|
||||
private tableMultiSelection: IContextKey<boolean>;
|
||||
|
||||
private _useAltAsMultipleSelectionModifier: boolean;
|
||||
|
||||
constructor(
|
||||
user: string,
|
||||
container: HTMLElement,
|
||||
columns: ITableColumn<T, any>[],
|
||||
dataSource: ITableDataSource<T>,
|
||||
options: IWorkbenchTableOptions<T>,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@ITableService tableService: ITableService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
const [workbenchTableOptions, workbenchTableOptionsDisposable] = toWorkbenchTableOptions(options);
|
||||
|
||||
super(user, container, columns, dataSource,
|
||||
{
|
||||
keyboardSupport: false,
|
||||
...computeStyles(themeService.getColorTheme(), defaultHighPerfTableStyles),
|
||||
...workbenchTableOptions
|
||||
}
|
||||
);
|
||||
|
||||
this.disposables.add(workbenchTableOptionsDisposable);
|
||||
|
||||
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);
|
||||
this.configurationService = configurationService;
|
||||
|
||||
this.tableHasSelectionOrFocus = WorkbenchTableHasSelectionOrFocus.bindTo(this.contextKeyService);
|
||||
this.tableDoubleSelection = WorkbenchTableDoubleSelection.bindTo(this.contextKeyService);
|
||||
this.tableMultiSelection = WorkbenchTableMultiSelection.bindTo(this.contextKeyService);
|
||||
|
||||
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
|
||||
|
||||
this.disposables.add(this.contextKeyService);
|
||||
this.disposables.add((tableService as TableService).register(this));
|
||||
|
||||
if (options.overrideStyles) {
|
||||
this.disposables.add(attachTableStyler(this, themeService, options.overrideStyles));
|
||||
}
|
||||
|
||||
this.disposables.add(this.onSelectionChange(() => {
|
||||
const selection = this.getSelection();
|
||||
const focus = this.getFocus();
|
||||
|
||||
this.tableHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
|
||||
this.tableMultiSelection.set(selection.length > 1);
|
||||
this.tableDoubleSelection.set(selection.length === 2);
|
||||
}));
|
||||
this.disposables.add(this.onFocusChange(() => {
|
||||
const selection = this.getSelection();
|
||||
const focus = this.getFocus();
|
||||
|
||||
this.tableHasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
|
||||
}));
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
private registerListeners(): void {
|
||||
this.disposables.add(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(multiSelectModifierSettingKey)) {
|
||||
this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(this.configurationService);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
get useAltAsMultipleSelectionModifier(): boolean {
|
||||
return this._useAltAsMultipleSelectionModifier;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(ITableService, TableService, true);
|
||||
@@ -1,59 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/calloutDialog';
|
||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||
import { IDialogProperties, Modal, DialogWidth, DialogPosition } from 'sql/workbench/browser/modal/modal';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfiguration';
|
||||
|
||||
export abstract class CalloutDialog<T> extends Modal {
|
||||
|
||||
constructor(
|
||||
title: string,
|
||||
width: DialogWidth,
|
||||
dialogProperties: IDialogProperties,
|
||||
dialogPosition: DialogPosition,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@ILayoutService layoutService: ILayoutService,
|
||||
@IAdsTelemetryService telemetryService: IAdsTelemetryService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IClipboardService clipboardService: IClipboardService,
|
||||
@ILogService logService: ILogService,
|
||||
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService
|
||||
) {
|
||||
super(
|
||||
title,
|
||||
TelemetryKeys.ModalDialogName.CalloutDialog,
|
||||
telemetryService,
|
||||
layoutService,
|
||||
clipboardService,
|
||||
themeService,
|
||||
logService,
|
||||
textResourcePropertiesService,
|
||||
contextKeyService,
|
||||
{
|
||||
dialogStyle: 'callout',
|
||||
dialogPosition: dialogPosition,
|
||||
dialogProperties: dialogProperties,
|
||||
width: width
|
||||
});
|
||||
}
|
||||
|
||||
public abstract open(): Promise<T>;
|
||||
|
||||
public cancel(): void {
|
||||
this.hide('cancel');
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
protected layout(height?: number): void {
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ProviderProperties } from 'sql/workbench/contrib/dashboard/browser/dashboardRegistry';
|
||||
import * as nls from 'vs/nls';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
|
||||
const azureEditionDisplayName = nls.localize('azureEdition', "Edition");
|
||||
const azureType = nls.localize('azureType', "Type");
|
||||
|
||||
export const properties: Array<ProviderProperties> = [
|
||||
{
|
||||
provider: mssqlProviderName,
|
||||
flavors: [
|
||||
{
|
||||
flavor: 'on_prem',
|
||||
conditions: [
|
||||
{
|
||||
field: 'isCloud',
|
||||
operator: '!=',
|
||||
value: true
|
||||
}
|
||||
],
|
||||
databaseProperties: [
|
||||
{
|
||||
displayName: nls.localize('recoveryModel', "Recovery Model"),
|
||||
value: 'recoveryModel'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('lastDatabaseBackup', "Last Database Backup"),
|
||||
value: 'lastBackupDate',
|
||||
ignore: [
|
||||
'1/1/0001 12:00:00 AM'
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('lastLogBackup', "Last Log Backup"),
|
||||
value: 'lastLogBackupDate',
|
||||
ignore: [
|
||||
'1/1/0001 12:00:00 AM'
|
||||
]
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('compatibilityLevel', "Compatibility Level"),
|
||||
value: 'compatibilityLevel'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('owner', "Owner"),
|
||||
value: 'owner'
|
||||
}
|
||||
],
|
||||
serverProperties: [
|
||||
{
|
||||
displayName: nls.localize('version', "Version"),
|
||||
value: 'serverVersion'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('edition', "Edition"),
|
||||
value: 'serverEdition'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('computerName', "Computer Name"),
|
||||
value: 'machineName'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('osVersion', "OS Version"),
|
||||
value: 'osVersion'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
flavor: 'cloud',
|
||||
conditions: [
|
||||
{
|
||||
field: 'isCloud',
|
||||
operator: '==',
|
||||
value: true
|
||||
},
|
||||
{
|
||||
field: 'engineEditionId',
|
||||
operator: '!=',
|
||||
value: '11'
|
||||
}
|
||||
],
|
||||
databaseProperties: [
|
||||
{
|
||||
displayName: azureEditionDisplayName,
|
||||
value: 'azureEdition'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('serviceLevelObjective', "Pricing Tier"),
|
||||
value: 'serviceLevelObjective'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('compatibilityLevel', "Compatibility Level"),
|
||||
value: 'compatibilityLevel'
|
||||
},
|
||||
{
|
||||
displayName: nls.localize('owner', "Owner"),
|
||||
value: 'owner'
|
||||
}
|
||||
],
|
||||
serverProperties: [
|
||||
{
|
||||
displayName: nls.localize('version', "Version"),
|
||||
value: 'serverVersion'
|
||||
},
|
||||
{
|
||||
displayName: azureType,
|
||||
value: 'serverEdition'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
flavor: 'on_demand',
|
||||
conditions: [
|
||||
{
|
||||
field: 'engineEditionId',
|
||||
operator: '==',
|
||||
value: '11'
|
||||
}
|
||||
],
|
||||
databaseProperties: [
|
||||
{
|
||||
displayName: nls.localize('compatibilityLevel', "Compatibility Level"),
|
||||
value: 'compatibilityLevel'
|
||||
}
|
||||
],
|
||||
serverProperties: [
|
||||
{
|
||||
displayName: nls.localize('version', "Version"),
|
||||
value: 'serverVersion'
|
||||
},
|
||||
{
|
||||
displayName: azureType,
|
||||
value: 'serverEdition'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -1,141 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService';
|
||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||
import { Modal } from 'sql/workbench/browser/modal/modal';
|
||||
import { attachModalDialogStyler } from 'sql/workbench/common/styler';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { attachInputBoxStyler } from 'sql/platform/theme/common/styler';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IInputOptions, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { INotebookView } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
|
||||
import { attachButtonStyler } from 'vs/platform/theme/common/styler';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfiguration';
|
||||
|
||||
export class ViewOptionsModal extends Modal {
|
||||
private _submitButton: Button;
|
||||
private _cancelButton: Button;
|
||||
private _viewNameInput: InputBox;
|
||||
|
||||
constructor(
|
||||
private _view: INotebookView,
|
||||
@ILogService logService: ILogService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@ILayoutService layoutService: ILayoutService,
|
||||
@IClipboardService clipboardService: IClipboardService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IAdsTelemetryService telemetryService: IAdsTelemetryService,
|
||||
@IContextViewService private _contextViewService: IContextViewService,
|
||||
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
|
||||
) {
|
||||
super(
|
||||
localize("viewOptionsModal.title", "Configure View"),
|
||||
'ViewOptionsModal',
|
||||
telemetryService,
|
||||
layoutService,
|
||||
clipboardService,
|
||||
themeService,
|
||||
logService,
|
||||
textResourcePropertiesService,
|
||||
contextKeyService,
|
||||
{ hasErrors: true, hasSpinner: true }
|
||||
);
|
||||
}
|
||||
|
||||
protected renderBody(container: HTMLElement): void {
|
||||
const formWrapper = DOM.$<HTMLDivElement>('div#notebookviews-options-form');
|
||||
formWrapper.style.padding = '10px';
|
||||
|
||||
DOM.append(container, formWrapper);
|
||||
|
||||
this._viewNameInput = this.createNameInput(formWrapper);
|
||||
|
||||
}
|
||||
|
||||
protected layout(height: number): void {
|
||||
|
||||
}
|
||||
|
||||
protected createNameInput(container: HTMLElement): InputBox {
|
||||
return this.createInputBoxHelper(container, localize('viewOptionsModal.name', "View Name"), this._view.name, {
|
||||
validationOptions: {
|
||||
validation: (value: string) => {
|
||||
if (!value) {
|
||||
return ({ type: MessageType.ERROR, content: localize('viewOptionsModal.missingRequireField', "This field is required.") });
|
||||
}
|
||||
if (this._view.name !== value && !this._view.nameAvailable(value)) {
|
||||
return ({ type: MessageType.ERROR, content: localize('viewOptionsModal.nameTaken', "This view name has already been taken.") });
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
ariaLabel: localize('viewOptionsModal.name', "View Name")
|
||||
});
|
||||
}
|
||||
|
||||
private createInputBoxHelper(container: HTMLElement, label: string, defaultValue: string = '', options?: IInputOptions): InputBox {
|
||||
const inputContainer = DOM.append(container, DOM.$('.dialog-input-section'));
|
||||
DOM.append(inputContainer, DOM.$('.dialog-label')).innerText = label;
|
||||
const input = new InputBox(DOM.append(inputContainer, DOM.$('.dialog-input')), this._contextViewService, options);
|
||||
input.value = defaultValue;
|
||||
return input;
|
||||
}
|
||||
|
||||
public override render() {
|
||||
super.render();
|
||||
|
||||
this._submitButton = this.addFooterButton(localize('save', "Save"), () => this.onSubmitHandler());
|
||||
this._cancelButton = this.addFooterButton(localize('cancel', "Cancel"), () => this.onCancelHandler());
|
||||
|
||||
this._register(attachInputBoxStyler(this._viewNameInput!, this._themeService));
|
||||
this._register(attachButtonStyler(this._submitButton, this._themeService));
|
||||
this._register(attachButtonStyler(this._cancelButton, this._themeService));
|
||||
|
||||
this._register(this._viewNameInput.onDidChange(v => this.validate()));
|
||||
|
||||
attachModalDialogStyler(this, this._themeService);
|
||||
this.validate();
|
||||
}
|
||||
|
||||
private validate() {
|
||||
let valid = true;
|
||||
|
||||
if (!this._viewNameInput.validate()) {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
this._submitButton.enabled = valid;
|
||||
}
|
||||
|
||||
private onSubmitHandler() {
|
||||
this._view.name = this._viewNameInput.value;
|
||||
this._view.save();
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
private onCancelHandler() {
|
||||
this.close();
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
return this.hide();
|
||||
}
|
||||
|
||||
public open(): void {
|
||||
this.show();
|
||||
}
|
||||
|
||||
public override dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import { createandLoadNotebookModel } from 'sql/workbench/contrib/notebook/test/
|
||||
import { TestConfigurationService } from 'sql/platform/connection/test/common/testConfigurationService';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
export class TestSerializationProvider implements azdata.SerializationProvider {
|
||||
class TestSerializationProvider implements azdata.SerializationProvider {
|
||||
providerId: string;
|
||||
constructor(providerId: string = 'providerId') { }
|
||||
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { nb } from 'azdata';
|
||||
import { ICellModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||
import { INotebookView } from 'sql/workbench/services/notebook/browser/notebookViews/notebookViews';
|
||||
import { CellTypes } from 'sql/workbench/services/notebook/common/contracts';
|
||||
|
||||
class VisInfo<T> {
|
||||
public width: number;
|
||||
public height: number;
|
||||
public orderRank: number;
|
||||
public display: boolean;
|
||||
public cell: T;
|
||||
}
|
||||
|
||||
class DisplayCell<T> {
|
||||
constructor(private _item: T) { }
|
||||
|
||||
get item(): T {
|
||||
return this._item;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class DisplayGroup<T> {
|
||||
public width: number;
|
||||
public height: number;
|
||||
public orderRank: number;
|
||||
public display: boolean;
|
||||
private _displayCells: DisplayCell<T>[] = [];
|
||||
private _visInfos: VisInfo<T>[] = [];
|
||||
|
||||
constructor() { }
|
||||
|
||||
addCell(cell: T, initialView: INotebookView) {
|
||||
const dCell = new DisplayCell<T>(cell);
|
||||
this._displayCells.push(dCell);
|
||||
this._visInfos.push(this.evaluateCell(cell, initialView));
|
||||
}
|
||||
|
||||
get visInfos(): VisInfo<T>[] {
|
||||
return this._visInfos;
|
||||
}
|
||||
|
||||
get displayCells(): DisplayCell<T>[] {
|
||||
return this._displayCells;
|
||||
}
|
||||
|
||||
abstract evaluateCell(cell: T, view: INotebookView): VisInfo<T>;
|
||||
}
|
||||
|
||||
class CellDisplayGroup extends DisplayGroup<ICellModel> {
|
||||
evaluateCell(cell: ICellModel, view: INotebookView): VisInfo<ICellModel> {
|
||||
let meta = view.getCellMetadata(cell);
|
||||
let visInfo = new VisInfo<ICellModel>();
|
||||
visInfo.cell = cell;
|
||||
|
||||
if (cell.cellType !== CellTypes.Code && !this.isHeader(cell)) {
|
||||
visInfo.display = false;
|
||||
return visInfo;
|
||||
}
|
||||
|
||||
if (cell.cellType === CellTypes.Code && (!cell.outputs || !cell.outputs.length)) {
|
||||
visInfo.display = false;
|
||||
return visInfo;
|
||||
}
|
||||
|
||||
//For headers
|
||||
if (this.isHeader(cell)) {
|
||||
visInfo.height = 1;
|
||||
}
|
||||
//For graphs
|
||||
if (this.hasGraph(cell)) {
|
||||
visInfo.width = 6;
|
||||
visInfo.height = 12;
|
||||
}
|
||||
//For tables
|
||||
else if (this.hasTable(cell)) {
|
||||
visInfo.height = Math.min(meta?.height, 6);
|
||||
} else {
|
||||
visInfo.height = Math.min(meta?.height, 6);
|
||||
}
|
||||
|
||||
visInfo.display = true;
|
||||
return visInfo;
|
||||
}
|
||||
|
||||
isHeader(cell: ICellModel): boolean {
|
||||
return cell.cellType === 'markdown' && cell.source.length === 1 && cell.source[0].startsWith('#');
|
||||
}
|
||||
|
||||
hasGraph(cell: ICellModel): boolean {
|
||||
return !!cell.outputs.find((o: nb.ICellOutput) => o?.output_type === 'display_data' && (o as nb.IDisplayResult)?.data.hasOwnProperty('application/vnd.plotly.v1+json'));
|
||||
}
|
||||
|
||||
hasTable(cell: ICellModel): boolean {
|
||||
return !!cell.outputs.find((o: nb.ICellOutput) => o?.output_type === 'display_data' && (o as nb.IDisplayResult)?.data.hasOwnProperty('application/vnd.dataresource+json'));
|
||||
}
|
||||
}
|
||||
|
||||
export function generateLayout(initialView: INotebookView): void {
|
||||
let displayGroup: CellDisplayGroup = new CellDisplayGroup();
|
||||
|
||||
const cells = initialView.cells;
|
||||
|
||||
cells.forEach((cell, idx) => {
|
||||
displayGroup.addCell(cell, initialView);
|
||||
});
|
||||
|
||||
displayGroup.visInfos.forEach((v) => {
|
||||
if (!v.display) {
|
||||
initialView.hideCell(v.cell);
|
||||
}
|
||||
|
||||
if (v.width || v.height) {
|
||||
initialView.resizeCell(v.cell, v.width, v.height);
|
||||
}
|
||||
});
|
||||
|
||||
initialView.compactCells();
|
||||
}
|
||||
Reference in New Issue
Block a user