mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix more floating promises (#8460)
This commit is contained in:
@@ -64,9 +64,8 @@ export class InsightAction extends Action {
|
|||||||
super(id, label);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
run(actionContext: InsightActionContext): Promise<boolean> {
|
async run(actionContext: InsightActionContext): Promise<void> {
|
||||||
this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
await this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||||
return Promise.resolve(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,12 +72,12 @@ export default class FileBrowserTreeComponent extends ComponentBase implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleOnAddFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]) {
|
private async handleOnAddFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): Promise<void> {
|
||||||
this.updateFileTree(rootNode, selectedNode, expandedNodes);
|
await this.updateFileTree(rootNode, selectedNode, expandedNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): void {
|
private async updateFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): Promise<void> {
|
||||||
this._treeView.renderBody(this._treeContainer.nativeElement, rootNode, selectedNode, expandedNodes);
|
await this._treeView.renderBody(this._treeContainer.nativeElement, rootNode, selectedNode, expandedNodes);
|
||||||
this._treeView.setVisible(true);
|
this._treeView.setVisible(true);
|
||||||
this.layoutTree();
|
this.layoutTree();
|
||||||
this._changeRef.detectChanges();
|
this._changeRef.detectChanges();
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ import {
|
|||||||
RunQueryOnConnectionMode, IConnectionResult
|
RunQueryOnConnectionMode, IConnectionResult
|
||||||
} from 'sql/platform/connection/common/connectionManagement';
|
} from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { EditDataInput } from 'sql/workbench/contrib/editData/browser/editDataInput';
|
import { EditDataInput } from 'sql/workbench/contrib/editData/browser/editDataInput';
|
||||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/browser/insightsDialogService';
|
|
||||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||||
import { DashboardInput } from 'sql/workbench/contrib/dashboard/browser/dashboardInput';
|
import { DashboardInput } from 'sql/workbench/contrib/dashboard/browser/dashboardInput';
|
||||||
import { ProfilerInput } from 'sql/workbench/contrib/profiler/browser/profilerInput';
|
import { ProfilerInput } from 'sql/workbench/contrib/profiler/browser/profilerInput';
|
||||||
|
|
||||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||||
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
|
|
||||||
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
import { QueryEditorInput } from 'sql/workbench/contrib/query/common/queryEditorInput';
|
||||||
|
|
||||||
export function replaceConnection(oldUri: string, newUri: string, connectionService: IConnectionManagementService): Promise<IConnectionResult> {
|
export function replaceConnection(oldUri: string, newUri: string, connectionService: IConnectionManagementService): Promise<IConnectionResult> {
|
||||||
@@ -56,10 +54,6 @@ export function replaceConnection(oldUri: string, newUri: string, connectionServ
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openInsight(query: IInsightsConfig, profile: IConnectionProfile, insightDialogService: IInsightsDialogService) {
|
|
||||||
insightDialogService.show(query, profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current global connection, which is the connection from the active editor, unless OE
|
* Get the current global connection, which is the connection from the active editor, unless OE
|
||||||
* is focused or there is no such editor, in which case it comes from the OE selection. Returns
|
* is focused or there is no such editor, in which case it comes from the OE selection. Returns
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
|||||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
const maxActions = 1;
|
const maxActions = 1;
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ export class ErrorMessageDialog extends Modal {
|
|||||||
this.createCopyButton();
|
this.createCopyButton();
|
||||||
this._actionButtons = [];
|
this._actionButtons = [];
|
||||||
for (let i = 0; i < maxActions; i++) {
|
for (let i = 0; i < maxActions; i++) {
|
||||||
this._actionButtons.unshift(this.createStandardButton('Action', () => this.onActionSelected(i)));
|
this._actionButtons.unshift(this.createStandardButton(localize('errorMessageDialog.action', "Action"), () => this.onActionSelected(i)));
|
||||||
}
|
}
|
||||||
this._okButton = this.addFooterButton(this._okLabel, () => this.ok());
|
this._okButton = this.addFooterButton(this._okLabel, () => this.ok());
|
||||||
this._register(attachButtonStyler(this._okButton, this._themeService));
|
this._register(attachButtonStyler(this._okButton, this._themeService));
|
||||||
@@ -74,7 +75,7 @@ export class ErrorMessageDialog extends Modal {
|
|||||||
|
|
||||||
private createCopyButton() {
|
private createCopyButton() {
|
||||||
let copyButtonLabel = localize('copyDetails', "Copy details");
|
let copyButtonLabel = localize('copyDetails', "Copy details");
|
||||||
this._copyButton = this.addFooterButton(copyButtonLabel, () => this._clipboardService.writeText(this._messageDetails), 'left');
|
this._copyButton = this.addFooterButton(copyButtonLabel, () => this._clipboardService.writeText(this._messageDetails).catch(err => onUnexpectedError(err)), 'left');
|
||||||
this._copyButton.icon = 'codicon scriptToClipboard';
|
this._copyButton.icon = 'codicon scriptToClipboard';
|
||||||
this._copyButton.element.title = copyButtonLabel;
|
this._copyButton.element.title = copyButtonLabel;
|
||||||
this._register(attachButtonStyler(this._copyButton, this._themeService, { buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND, buttonForeground: SIDE_BAR_FOREGROUND }));
|
this._register(attachButtonStyler(this._copyButton, this._themeService, { buttonBackground: SIDE_BAR_BACKGROUND, buttonHoverBackground: SIDE_BAR_BACKGROUND, buttonForeground: SIDE_BAR_FOREGROUND }));
|
||||||
@@ -91,7 +92,7 @@ export class ErrorMessageDialog extends Modal {
|
|||||||
this.ok();
|
this.ok();
|
||||||
// Run the action if possible
|
// Run the action if possible
|
||||||
if (this._actions && index < this._actions.length) {
|
if (this._actions && index < this._actions.length) {
|
||||||
this._actions[index].run();
|
this._actions[index].run().catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import 'vs/css!sql/media/icons/common-icons';
|
import 'vs/css!sql/media/icons/common-icons';
|
||||||
import 'vs/css!./media/fileBrowserDialog';
|
import 'vs/css!./media/fileBrowserDialog';
|
||||||
import { Button } from 'sql/base/browser/ui/button/button';
|
import { Button } from 'sql/base/browser/ui/button/button';
|
||||||
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
import { InputBox, OnLoseFocusParams } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||||
import * as DialogHelper from 'sql/workbench/browser/modal/dialogHelper';
|
import * as DialogHelper from 'sql/workbench/browser/modal/dialogHelper';
|
||||||
import { Modal } from 'sql/workbench/browser/modal/modal';
|
import { Modal } from 'sql/workbench/browser/modal/modal';
|
||||||
@@ -32,6 +32,7 @@ import { ILogService } from 'vs/platform/log/common/log';
|
|||||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export class FileBrowserDialog extends Modal {
|
export class FileBrowserDialog extends Modal {
|
||||||
private _viewModel: FileBrowserViewModel;
|
private _viewModel: FileBrowserViewModel;
|
||||||
@@ -61,7 +62,7 @@ export class FileBrowserDialog extends Modal {
|
|||||||
) {
|
) {
|
||||||
super(title, TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { isFlyout: true, hasTitleIcon: false, hasBackButton: true, hasSpinner: true });
|
super(title, TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { isFlyout: true, hasTitleIcon: false, hasBackButton: true, hasSpinner: true });
|
||||||
this._viewModel = this._instantiationService.createInstance(FileBrowserViewModel);
|
this._viewModel = this._instantiationService.createInstance(FileBrowserViewModel);
|
||||||
this._viewModel.onAddFileTree(args => this.handleOnAddFileTree(args.rootNode, args.selectedNode, args.expandedNodes));
|
this._viewModel.onAddFileTree(args => this.handleOnAddFileTree(args.rootNode, args.selectedNode, args.expandedNodes).catch(err => onUnexpectedError(err)));
|
||||||
this._viewModel.onPathValidate(args => this.handleOnValidate(args.succeeded, args.message));
|
this._viewModel.onPathValidate(args => this.handleOnValidate(args.succeeded, args.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ export class FileBrowserDialog extends Modal {
|
|||||||
expandPath: string,
|
expandPath: string,
|
||||||
fileFilters: [{ label: string, filters: string[] }],
|
fileFilters: [{ label: string, filters: string[] }],
|
||||||
fileValidationServiceType: string,
|
fileValidationServiceType: string,
|
||||||
) {
|
): void {
|
||||||
this._viewModel.initialize(ownerUri, expandPath, fileFilters, fileValidationServiceType);
|
this._viewModel.initialize(ownerUri, expandPath, fileFilters, fileValidationServiceType);
|
||||||
this._fileFilterSelectBox.setOptions(this._viewModel.formattedFileFilters);
|
this._fileFilterSelectBox.setOptions(this._viewModel.formattedFileFilters);
|
||||||
this._fileFilterSelectBox.select(0);
|
this._fileFilterSelectBox.select(0);
|
||||||
@@ -127,7 +128,7 @@ export class FileBrowserDialog extends Modal {
|
|||||||
this._fileBrowserTreeView = this._instantiationService.createInstance(FileBrowserTreeView);
|
this._fileBrowserTreeView = this._instantiationService.createInstance(FileBrowserTreeView);
|
||||||
this._fileBrowserTreeView.setOnClickedCallback((arg) => this.onClicked(arg));
|
this._fileBrowserTreeView.setOnClickedCallback((arg) => this.onClicked(arg));
|
||||||
this._fileBrowserTreeView.setOnDoubleClickedCallback((arg) => this.onDoubleClicked(arg));
|
this._fileBrowserTreeView.setOnDoubleClickedCallback((arg) => this.onDoubleClicked(arg));
|
||||||
this._viewModel.openFileBrowser(0, false);
|
this._viewModel.openFileBrowser(0, false).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enter key */
|
/* enter key */
|
||||||
@@ -137,8 +138,8 @@ export class FileBrowserDialog extends Modal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleOnAddFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]) {
|
private async handleOnAddFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): Promise<void> {
|
||||||
this.updateFileTree(rootNode, selectedNode, expandedNodes);
|
await this.updateFileTree(rootNode, selectedNode, expandedNodes);
|
||||||
this.spinner = false;
|
this.spinner = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,10 +177,11 @@ export class FileBrowserDialog extends Modal {
|
|||||||
this.enableOkButton();
|
this.enableOkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFilePathBlur(param) {
|
private async onFilePathBlur(params: OnLoseFocusParams): Promise<boolean> {
|
||||||
if (!strings.isFalsyOrWhitespace(param.value)) {
|
if (!strings.isFalsyOrWhitespace(params.value)) {
|
||||||
this._viewModel.validateFilePaths([param.value]);
|
return this._viewModel.validateFilePaths([params.value]);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ok() {
|
private ok() {
|
||||||
@@ -196,35 +198,35 @@ export class FileBrowserDialog extends Modal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private close() {
|
private close(): void {
|
||||||
if (this._fileBrowserTreeView) {
|
if (this._fileBrowserTreeView) {
|
||||||
this._fileBrowserTreeView.dispose();
|
this._fileBrowserTreeView.dispose();
|
||||||
}
|
}
|
||||||
this._onOk.dispose();
|
this._onOk.dispose();
|
||||||
this.hide();
|
this.hide();
|
||||||
this._viewModel.closeFileBrowser();
|
this._viewModel.closeFileBrowser().catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): void {
|
private async updateFileTree(rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): Promise<void> {
|
||||||
this._fileBrowserTreeView.renderBody(this._treeContainer, rootNode, selectedNode, expandedNodes);
|
await this._fileBrowserTreeView.renderBody(this._treeContainer, rootNode, selectedNode, expandedNodes);
|
||||||
this._fileBrowserTreeView.setVisible(true);
|
this._fileBrowserTreeView.setVisible(true);
|
||||||
this._fileBrowserTreeView.layout(DOM.getTotalHeight(this._treeContainer));
|
this._fileBrowserTreeView.layout(DOM.getTotalHeight(this._treeContainer));
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFilterSelectChanged(filterIndex) {
|
private async onFilterSelectChanged(filterIndex): Promise<void> {
|
||||||
this.spinner = true;
|
this.spinner = true;
|
||||||
this._viewModel.openFileBrowser(filterIndex, true);
|
await this._viewModel.openFileBrowser(filterIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerListeners(): void {
|
private registerListeners(): void {
|
||||||
this._register(this._fileFilterSelectBox.onDidSelect(selection => {
|
this._register(this._fileFilterSelectBox.onDidSelect(selectData => {
|
||||||
this.onFilterSelectChanged(selection.index);
|
this.onFilterSelectChanged(selectData.index).catch(err => onUnexpectedError(err));
|
||||||
}));
|
}));
|
||||||
this._register(this._filePathInputBox.onDidChange(e => {
|
this._register(this._filePathInputBox.onDidChange(e => {
|
||||||
this.onFilePathChange(e);
|
this.onFilePathChange(e);
|
||||||
}));
|
}));
|
||||||
this._register(this._filePathInputBox.onLoseFocus(params => {
|
this._register(this._filePathInputBox.onLoseFocus((params: OnLoseFocusParams) => {
|
||||||
this.onFilePathBlur(params);
|
this.onFilePathBlur(params).catch(err => onUnexpectedError(err));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Theme styler
|
// Theme styler
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class FileBrowserDialogController implements IFileBrowserDialogController
|
|||||||
fileValidationServiceType: string,
|
fileValidationServiceType: string,
|
||||||
isWide: boolean,
|
isWide: boolean,
|
||||||
handleOnOk: (path: string) => void
|
handleOnOk: (path: string) => void
|
||||||
) {
|
): void {
|
||||||
if (!this._fileBrowserDialog) {
|
if (!this._fileBrowserDialog) {
|
||||||
this._fileBrowserDialog = this._instantiationService.createInstance(FileBrowserDialog, localize('filebrowser.selectFile', "Select a file"));
|
this._fileBrowserDialog = this._instantiationService.createInstance(FileBrowserDialog, localize('filebrowser.selectFile', "Select a file"));
|
||||||
this._fileBrowserDialog.render();
|
this._fileBrowserDialog.render();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { FileBrowserController } from 'sql/workbench/services/fileBrowser/browse
|
|||||||
import { FileBrowserRenderer } from 'sql/workbench/services/fileBrowser/browser/fileBrowserRenderer';
|
import { FileBrowserRenderer } from 'sql/workbench/services/fileBrowser/browser/fileBrowserRenderer';
|
||||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||||
import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
|
import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
|
||||||
import errors = require('vs/base/common/errors');
|
|
||||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import nls = require('vs/nls');
|
import nls = require('vs/nls');
|
||||||
@@ -37,7 +36,7 @@ export class FileBrowserTreeView extends Disposable implements IDisposable {
|
|||||||
/**
|
/**
|
||||||
* Render the view body
|
* Render the view body
|
||||||
*/
|
*/
|
||||||
public renderBody(container: HTMLElement, rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): void {
|
public async renderBody(container: HTMLElement, rootNode: FileNode, selectedNode: FileNode, expandedNodes: FileNode[]): Promise<void> {
|
||||||
if (!this._tree) {
|
if (!this._tree) {
|
||||||
DOM.addClass(container, 'show-file-icons');
|
DOM.addClass(container, 'show-file-icons');
|
||||||
this._tree = this._register(this.createFileBrowserTree(container, this._instantiationService));
|
this._tree = this._register(this.createFileBrowserTree(container, this._instantiationService));
|
||||||
@@ -48,16 +47,15 @@ export class FileBrowserTreeView extends Disposable implements IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rootNode) {
|
if (rootNode) {
|
||||||
this._tree.setInput(rootNode).then(() => {
|
await this._tree.setInput(rootNode);
|
||||||
if (expandedNodes) {
|
if (expandedNodes) {
|
||||||
this._tree.expandAll(expandedNodes);
|
await this._tree.expandAll(expandedNodes);
|
||||||
}
|
}
|
||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
this._tree.select(selectedNode);
|
this._tree.select(selectedNode);
|
||||||
this._tree.setFocus(selectedNode);
|
this._tree.setFocus(selectedNode);
|
||||||
}
|
}
|
||||||
this._tree.getFocus();
|
this._tree.getFocus();
|
||||||
}, errors.onUnexpectedError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +83,7 @@ export class FileBrowserTreeView extends Disposable implements IDisposable {
|
|||||||
/**
|
/**
|
||||||
* Refresh the tree
|
* Refresh the tree
|
||||||
*/
|
*/
|
||||||
public refreshTree(rootNode: FileNode): void {
|
public async refreshTree(rootNode: FileNode): Promise<void> {
|
||||||
let selectedElement: any;
|
let selectedElement: any;
|
||||||
let targetsToExpand: any[];
|
let targetsToExpand: any[];
|
||||||
|
|
||||||
@@ -103,17 +101,16 @@ export class FileBrowserTreeView extends Disposable implements IDisposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rootNode) {
|
if (rootNode) {
|
||||||
this._tree.setInput(rootNode).then(() => {
|
await this._tree.setInput(rootNode);
|
||||||
// Make sure to expand all folders that were expanded in the previous session
|
// Make sure to expand all folders that were expanded in the previous session
|
||||||
if (targetsToExpand) {
|
if (targetsToExpand) {
|
||||||
this._tree.expandAll(targetsToExpand);
|
await this._tree.expandAll(targetsToExpand);
|
||||||
}
|
}
|
||||||
if (selectedElement) {
|
if (selectedElement) {
|
||||||
this._tree.select(selectedElement);
|
this._tree.select(selectedElement);
|
||||||
this._tree.setFocus(selectedElement);
|
this._tree.setFocus(selectedElement);
|
||||||
}
|
}
|
||||||
this._tree.getFocus();
|
this._tree.getFocus();
|
||||||
}, errors.onUnexpectedError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View model for file browser dialog
|
* View model for file browser dialog
|
||||||
@@ -48,17 +49,17 @@ export class FileBrowserViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public validateFilePaths(selectedFiles: string[]) {
|
public async validateFilePaths(selectedFiles: string[]): Promise<boolean> {
|
||||||
this._fileBrowserService.validateFilePaths(this._ownerUri, this._fileValidationServiceType, selectedFiles);
|
return this._fileBrowserService.validateFilePaths(this._ownerUri, this._fileValidationServiceType, selectedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public openFileBrowser(filterIndex: number, changeFilter: boolean) {
|
public async openFileBrowser(filterIndex: number, changeFilter: boolean): Promise<void> {
|
||||||
if (this._fileFilters[filterIndex]) {
|
if (this._fileFilters[filterIndex]) {
|
||||||
this._fileBrowserService.openFileBrowser(this._ownerUri, this._expandPath, this._fileFilters[filterIndex].filters, changeFilter);
|
await this._fileBrowserService.openFileBrowser(this._ownerUri, this._expandPath, this._fileFilters[filterIndex].filters, changeFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeFileBrowser() {
|
public async closeFileBrowser(): Promise<void> {
|
||||||
this._fileBrowserService.closeFileBrowser(this._ownerUri);
|
await this._fileBrowserService.closeFileBrowser(this._ownerUri).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ export class CopyInsightDialogSelectionAction extends Action {
|
|||||||
super(id, label);
|
super(id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(event?: IInsightDialogActionContext): Promise<any> {
|
public async run(event?: IInsightDialogActionContext): Promise<void> {
|
||||||
this._clipboardService.writeText(event.cellData);
|
await this._clipboardService.writeText(event.cellData);
|
||||||
return Promise.resolve(void 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ export const IInsightsDialogService = createDecorator<IInsightsDialogService>('i
|
|||||||
|
|
||||||
export interface IInsightsDialogService {
|
export interface IInsightsDialogService {
|
||||||
_serviceBrand: undefined;
|
_serviceBrand: undefined;
|
||||||
show(input: IInsightsConfig, connectionProfile: IConnectionProfile): void;
|
show(input: IInsightsConfig, connectionProfile: IConnectionProfile): Promise<void>;
|
||||||
close();
|
close(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInsightDialogActionContext extends BaseActionContext {
|
export interface IInsightDialogActionContext extends BaseActionContext {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class InsightsDialogService implements IInsightsDialogService {
|
|||||||
constructor(@IInstantiationService private _instantiationService: IInstantiationService) { }
|
constructor(@IInstantiationService private _instantiationService: IInstantiationService) { }
|
||||||
|
|
||||||
// query string
|
// query string
|
||||||
public show(input: IInsightsConfig, connectionProfile: IConnectionProfile): void {
|
public async show(input: IInsightsConfig, connectionProfile: IConnectionProfile): Promise<void> {
|
||||||
if (!this._insightsDialogView) {
|
if (!this._insightsDialogView) {
|
||||||
this._insightsDialogModel = new InsightsDialogModel();
|
this._insightsDialogModel = new InsightsDialogModel();
|
||||||
this._insightsDialogController = this._instantiationService.createInstance(InsightsDialogController, this._insightsDialogModel);
|
this._insightsDialogController = this._instantiationService.createInstance(InsightsDialogController, this._insightsDialogModel);
|
||||||
@@ -32,7 +32,7 @@ export class InsightsDialogService implements IInsightsDialogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._insightsDialogModel.insight = input.details;
|
this._insightsDialogModel.insight = input.details;
|
||||||
this._insightsDialogController.update(input.details, connectionProfile);
|
await this._insightsDialogController.update(input.details, connectionProfile);
|
||||||
this._insightsDialogView.open(input.details, connectionProfile);
|
this._insightsDialogView.open(input.details, connectionProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import { IInsightsConfigDetails } from 'sql/platform/dashboard/browser/insightRe
|
|||||||
import { TaskRegistry } from 'sql/platform/tasks/browser/tasksRegistry';
|
import { TaskRegistry } from 'sql/platform/tasks/browser/tasksRegistry';
|
||||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
const labelDisplay = nls.localize("insights.item", "Item");
|
const labelDisplay = nls.localize("insights.item", "Item");
|
||||||
const valueDisplay = nls.localize("insights.value", "Value");
|
const valueDisplay = nls.localize("insights.value", "Value");
|
||||||
@@ -353,7 +354,7 @@ export class InsightsDialogView extends Modal {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let context = this.topInsightContext(resource);
|
let context = this.topInsightContext(resource);
|
||||||
this._commandService.executeCommand(action, context);
|
this._commandService.executeCommand(action, context).catch(err => onUnexpectedError(err));
|
||||||
}, 'left');
|
}, 'left');
|
||||||
button.enabled = false;
|
button.enabled = false;
|
||||||
this._taskButtonDisposables.push(button);
|
this._taskButtonDisposables.push(button);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const testColumns: string[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
suite('Insights Dialog Controller Tests', () => {
|
suite('Insights Dialog Controller Tests', () => {
|
||||||
test('updates correctly with good input', done => {
|
test('updates correctly with good input', async (done) => {
|
||||||
|
|
||||||
let model = new InsightsDialogModel();
|
let model = new InsightsDialogModel();
|
||||||
|
|
||||||
@@ -71,20 +71,19 @@ suite('Insights Dialog Controller Tests', () => {
|
|||||||
options: {}
|
options: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.update(<IInsightsConfigDetails>{ query: 'query' }, profile).then(() => {
|
await controller.update(<IInsightsConfigDetails>{ query: 'query' }, profile);
|
||||||
// Once we update the controller, listen on when it changes the model and verify the data it
|
// Once we update the controller, listen on when it changes the model and verify the data it
|
||||||
// puts in is correct
|
// puts in is correct
|
||||||
model.onDataChange(() => {
|
model.onDataChange(() => {
|
||||||
for (let i = 0; i < testData.length; i++) {
|
for (let i = 0; i < testData.length; i++) {
|
||||||
for (let j = 0; j < testData[i].length; j++) {
|
for (let j = 0; j < testData[i].length; j++) {
|
||||||
equal(testData[i][j], model.rows[i][j]);
|
equal(testData[i][j], model.rows[i][j]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
done();
|
}
|
||||||
});
|
done();
|
||||||
// Fake the query Runner telling the controller the query is complete
|
|
||||||
complete();
|
|
||||||
});
|
});
|
||||||
|
// Fake the query Runner telling the controller the query is complete
|
||||||
|
complete();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
|
|||||||
import { NotebookChangeType } from 'sql/workbench/contrib/notebook/common/models/contracts';
|
import { NotebookChangeType } from 'sql/workbench/contrib/notebook/common/models/contracts';
|
||||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||||
import { find, firstIndex } from 'vs/base/common/arrays';
|
import { find, firstIndex } from 'vs/base/common/arrays';
|
||||||
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
|
|
||||||
export interface NotebookProviderProperties {
|
export interface NotebookProviderProperties {
|
||||||
provider: string;
|
provider: string;
|
||||||
@@ -161,7 +162,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
this._register(this._queryManagementService.onHandlerAdded((queryType) => {
|
this._register(this._queryManagementService.onHandlerAdded((queryType) => {
|
||||||
this.updateSQLRegistrationWithConnectionProviders();
|
this.updateSQLRegistrationWithConnectionProviders();
|
||||||
}));
|
}));
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
if (extensionManagementService) {
|
if (extensionManagementService) {
|
||||||
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, this._extensionService)));
|
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => this.removeContributedProvidersFromCache(identifier, this._extensionService)));
|
||||||
@@ -530,7 +531,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeContributedProvidersFromCache(identifier: IExtensionIdentifier, extensionService: IExtensionService) {
|
private removeContributedProvidersFromCache(identifier: IExtensionIdentifier, extensionService: IExtensionService): void {
|
||||||
const notebookProvider = 'notebookProvider';
|
const notebookProvider = 'notebookProvider';
|
||||||
extensionService.getExtensions().then(i => {
|
extensionService.getExtensions().then(i => {
|
||||||
let extension = find(i, c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
let extension = find(i, c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||||
@@ -540,7 +541,7 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
let id = extension.contributes[notebookProvider].providerId;
|
let id = extension.contributes[notebookProvider].providerId;
|
||||||
delete this.providersMemento.notebookProviderCache[id];
|
delete this.providersMemento.notebookProviderCache[id];
|
||||||
}
|
}
|
||||||
});
|
}).catch(err => onUnexpectedError(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
async isNotebookTrustCached(notebookUri: URI, isDirty: boolean): Promise<boolean> {
|
async isNotebookTrustCached(notebookUri: URI, isDirty: boolean): Promise<boolean> {
|
||||||
|
|||||||
Reference in New Issue
Block a user