mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Use remote file dialog for database and server properties dialogs (#24390)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
|
||||
"version": "4.10.0.1",
|
||||
"version": "4.10.0.2",
|
||||
"downloadFileNames": {
|
||||
"Windows_86": "win-x86-net7.0.zip",
|
||||
"Windows_64": "win-x64-net7.0.zip",
|
||||
|
||||
@@ -1572,7 +1572,7 @@
|
||||
"dependencies": {
|
||||
"@microsoft/ads-extension-telemetry": "^3.0.1",
|
||||
"@microsoft/ads-service-downloader": "^1.2.1",
|
||||
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#1.3.7",
|
||||
"dataprotocol-client": "github:Microsoft/sqlops-dataprotocolclient#1.3.8",
|
||||
"find-remove": "1.2.1",
|
||||
"vscode-languageclient": "5.2.1",
|
||||
"vscode-nls": "^4.0.0"
|
||||
|
||||
@@ -62,16 +62,20 @@ export class AttachDatabaseDialog extends ObjectManagementDialogBase<Database, D
|
||||
const buttonContainer = this.addButtonsForTable(this._databasesTable, addButton, removeButton);
|
||||
|
||||
this._nameField = this.createInputBox(async newValue => {
|
||||
let selectedRow = this._databasesTable.selectedRows[0];
|
||||
let dbFile = this._databasesToAttach[selectedRow];
|
||||
dbFile.databaseName = newValue;
|
||||
if (this._databasesTable.selectedRows?.length > 0) {
|
||||
let selectedRow = this._databasesTable.selectedRows[0];
|
||||
let dbFile = this._databasesToAttach[selectedRow];
|
||||
dbFile.databaseName = newValue;
|
||||
}
|
||||
}, {});
|
||||
this._nameContainer = this.createLabelInputContainer(loc.AttachAsText, this._nameField);
|
||||
|
||||
this._ownerDropdown = this.createDropdown(loc.OwnerText, async newValue => {
|
||||
let selectedRow = this._databasesTable.selectedRows[0];
|
||||
let dbFile = this._databasesToAttach[selectedRow];
|
||||
dbFile.owner = newValue;
|
||||
if (this._databasesTable.selectedRows?.length > 0) {
|
||||
let selectedRow = this._databasesTable.selectedRows[0];
|
||||
let dbFile = this._databasesToAttach[selectedRow];
|
||||
dbFile.owner = newValue;
|
||||
}
|
||||
}, this.viewInfo.loginNames.options, this.viewInfo.loginNames.options[this.viewInfo.loginNames.defaultValueIndex]);
|
||||
this._ownerContainer = this.createLabelInputContainer(loc.OwnerText, this._ownerDropdown);
|
||||
|
||||
|
||||
@@ -738,8 +738,9 @@ export class DatabaseDialog extends ObjectManagementDialogBase<Database, Databas
|
||||
defaultFileGrowthInMb: defaultFileGrowthInMb,
|
||||
defaultFileGrowthInPercent: defaultFileGrowthInPercent,
|
||||
defaultMaxFileSizeLimitedToInMb: defaultMaxFileSizeLimitedToInMb
|
||||
}
|
||||
});
|
||||
},
|
||||
connectionUri: this.options.connectionUri
|
||||
}, this.objectManagementService);
|
||||
await dialog.open();
|
||||
return await dialog.waitForClose();
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import { DefaultInputWidth, DialogBase } from '../../ui/dialogBase';
|
||||
import * as localizedConstants from '../localizedConstants';
|
||||
import { DatabaseFile, DatabaseViewInfo, FileGrowthType } from '../interfaces';
|
||||
import { isUndefinedOrNull } from '../../types';
|
||||
import { deepClone } from '../../util/objects';
|
||||
import { IObjectManagementService } from 'mssql';
|
||||
|
||||
export interface NewDatabaseFileDialogOptions {
|
||||
title: string;
|
||||
@@ -27,6 +27,7 @@ export interface NewDatabaseFileDialogOptions {
|
||||
defaultFileGrowthInMb: number,
|
||||
defaultMaxFileSizeLimitedToInMb: number
|
||||
};
|
||||
connectionUri: string;
|
||||
}
|
||||
|
||||
const fileSizeInputMaxValueInMbForDataType = 16776192; // Row type supports up to 16 TB (SSMS allows =~ 15.99TB)
|
||||
@@ -58,7 +59,7 @@ export class DatabaseFileDialog extends DialogBase<DatabaseFile> {
|
||||
private originalFileName: string;
|
||||
private isEditingFile: boolean;
|
||||
|
||||
constructor(private readonly options: NewDatabaseFileDialogOptions) {
|
||||
constructor(private readonly options: NewDatabaseFileDialogOptions, private readonly objectManagementService: IObjectManagementService) {
|
||||
super(options.title, 'DatabaseFileDialog');
|
||||
}
|
||||
|
||||
@@ -296,23 +297,12 @@ export class DatabaseFileDialog extends DialogBase<DatabaseFile> {
|
||||
* Creates a file browser and sets the path to the filePath
|
||||
*/
|
||||
private async createFileBrowser(): Promise<void> {
|
||||
let fileUris = await vscode.window.showOpenDialog(
|
||||
{
|
||||
canSelectFiles: false,
|
||||
canSelectFolders: true,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(this.options.databaseFile.path),
|
||||
openLabel: localizedConstants.SelectText
|
||||
}
|
||||
);
|
||||
|
||||
if (!fileUris || fileUris.length === 0) {
|
||||
return;
|
||||
let dataFolder = await this.objectManagementService.getDataFolder(this.options.connectionUri);
|
||||
let filePath = await azdata.window.openServerFileBrowserDialog(this.options.connectionUri, dataFolder, [{ label: localizedConstants.allFiles, filters: ['*'] }], true);
|
||||
if (filePath?.length > 0) {
|
||||
this.filePathTextBox.value = filePath;
|
||||
this.result.path = filePath;
|
||||
}
|
||||
|
||||
let fileUri = fileUris[0];
|
||||
this.filePathTextBox.value = fileUri.fsPath;
|
||||
this.result.path = fileUri.fsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +322,7 @@ export class DatabaseFileDialog extends DialogBase<DatabaseFile> {
|
||||
if (selectedOption === localizedConstants.LogFiletype) {
|
||||
fileGroupDdOptions = [localizedConstants.FileGroupForLogTypeText];
|
||||
fileGroupDdValue = localizedConstants.FileGroupForLogTypeText;
|
||||
fileSizeInputMaxValue = fileSizeInputMaxValueInMbForLogType
|
||||
fileSizeInputMaxValue = fileSizeInputMaxValueInMbForLogType;
|
||||
}
|
||||
// File Stream
|
||||
else if (selectedOption === localizedConstants.FilestreamFileType) {
|
||||
|
||||
@@ -661,21 +661,8 @@ export class ServerPropertiesDialog extends ObjectManagementDialogBase<Server, S
|
||||
}
|
||||
|
||||
public async selectFolder(location: string): Promise<string | undefined> {
|
||||
const allFilesFilter = localizedConstants.allFiles;
|
||||
let filter: any = {};
|
||||
filter[allFilesFilter] = '*';
|
||||
let uris = await vscode.window.showOpenDialog({
|
||||
filters: filter,
|
||||
canSelectFiles: false,
|
||||
canSelectMany: false,
|
||||
canSelectFolders: true,
|
||||
defaultUri: vscode.Uri.file(location),
|
||||
openLabel: localizedConstants.labelSelectFolder
|
||||
});
|
||||
if (uris && uris.length > 0) {
|
||||
return uris[0].fsPath;
|
||||
}
|
||||
return undefined;
|
||||
let dataFolder = await this.objectManagementService.getDataFolder(this.options.connectionUri);
|
||||
return await azdata.window.openServerFileBrowserDialog(this.options.connectionUri, dataFolder, [{ label: localizedConstants.allFiles, filters: ['*'] }], true);
|
||||
}
|
||||
|
||||
private initializeAdvancedSection(): void {
|
||||
|
||||
@@ -511,9 +511,9 @@ crypt@~0.0.1:
|
||||
resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b"
|
||||
integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=
|
||||
|
||||
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#1.3.7":
|
||||
version "1.3.7"
|
||||
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/0f07d03394eeebc2924971746470ac8224348fa4"
|
||||
"dataprotocol-client@github:Microsoft/sqlops-dataprotocolclient#1.3.8":
|
||||
version "1.3.8"
|
||||
resolved "https://codeload.github.com/Microsoft/sqlops-dataprotocolclient/tar.gz/828b7a5e5c1c077a0f6eb7f6acecd191fbaae13d"
|
||||
dependencies:
|
||||
vscode-languageclient "5.2.1"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user