From 85a1203df40c2bf674c77e1c8783961ccbeb9311 Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Mon, 11 Sep 2023 14:03:18 -0700 Subject: [PATCH] Pipe through argument --- src/sql/workbench/api/common/extHostWindow.ts | 4 ++-- src/sql/workbench/api/common/sqlExtHost.api.impl.ts | 4 ++-- src/sql/workbench/api/common/sqlExtHost.protocol.ts | 4 ++-- .../services/fileBrowser/browser/fileBrowserDialog.ts | 6 +++--- .../services/fileBrowser/common/fileBrowserViewModel.ts | 4 ++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/sql/workbench/api/common/extHostWindow.ts b/src/sql/workbench/api/common/extHostWindow.ts index 039639ccf1e2..dbffb9662434 100644 --- a/src/sql/workbench/api/common/extHostWindow.ts +++ b/src/sql/workbench/api/common/extHostWindow.ts @@ -17,7 +17,7 @@ export class ExtHostWindow implements ExtHostWindowShape { this._proxy = _mainContext.getProxy(SqlMainContext.MainThreadWindow); } - $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[]): Promise { - return this._proxy.$openServerFileBrowserDialog(connectionUri, targetPath, fileFilters); + $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[], showFoldersOnly?: boolean): Promise { + return this._proxy.$openServerFileBrowserDialog(connectionUri, targetPath, fileFilters, showFoldersOnly); } } diff --git a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts index e88ee30d44f9..3dacbb650d59 100644 --- a/src/sql/workbench/api/common/sqlExtHost.api.impl.ts +++ b/src/sql/workbench/api/common/sqlExtHost.api.impl.ts @@ -488,8 +488,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp openCustomErrorDialog(options: sqlExtHostTypes.IErrorDialogOptions): Thenable { return extHostModelViewDialog.openCustomErrorDialog(options); }, - openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[]): Thenable { - return extHostWindow.$openServerFileBrowserDialog(connectionUri, targetPath, fileFilters); + openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[], showFoldersOnly?: boolean): Thenable { + return extHostWindow.$openServerFileBrowserDialog(connectionUri, targetPath, fileFilters, showFoldersOnly); } }; diff --git a/src/sql/workbench/api/common/sqlExtHost.protocol.ts b/src/sql/workbench/api/common/sqlExtHost.protocol.ts index ef4610fbbf04..38cf4f15c5d4 100644 --- a/src/sql/workbench/api/common/sqlExtHost.protocol.ts +++ b/src/sql/workbench/api/common/sqlExtHost.protocol.ts @@ -833,7 +833,7 @@ export interface ExtHostWorkspaceShape { } export interface ExtHostWindowShape { - $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[]): Promise; + $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[], showFoldersOnly?: boolean): Promise; } export interface MainThreadWorkspaceShape { @@ -843,7 +843,7 @@ export interface MainThreadWorkspaceShape { } export interface MainThreadWindowShape { - $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[]): Promise; + $openServerFileBrowserDialog(connectionUri: string, targetPath: string, fileFilters: azdata.window.FileFilters[], showFoldersOnly?: boolean): Promise; } export interface MainThreadBackgroundTaskManagementShape extends IDisposable { diff --git a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts index 99302495af45..4b59c4e3fb9d 100644 --- a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts +++ b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts @@ -112,7 +112,7 @@ export class FileBrowserDialog extends Modal { expandPath: string, fileFilters: [{ label: string, filters: string[] }], fileValidationServiceType: string, - showFoldersOnly?: boolean + showFoldersOnly: boolean ): void { this._viewModel.initialize(ownerUri, expandPath, fileFilters, fileValidationServiceType, showFoldersOnly); this._viewModel.openFileBrowser(0, false).catch(err => onUnexpectedError(err)); @@ -130,7 +130,7 @@ export class FileBrowserDialog extends Modal { /* enter key */ protected override onAccept() { - if (this._okButton.enabled === true) { + if (this._okButton.enabled) { this.ok(); } } @@ -141,7 +141,7 @@ export class FileBrowserDialog extends Modal { } private enableOkButton() { - if (strings.isFalsyOrWhitespace(this._selectedFilePath) || this._isFolderSelected === true) { + if (strings.isFalsyOrWhitespace(this._selectedFilePath) || (this._isFolderSelected && !this._viewModel.showFoldersOnly)) { this._okButton.enabled = false; } else { this._okButton.enabled = true; diff --git a/src/sql/workbench/services/fileBrowser/common/fileBrowserViewModel.ts b/src/sql/workbench/services/fileBrowser/common/fileBrowserViewModel.ts index ce5fb4f791c5..d550bc08b200 100644 --- a/src/sql/workbench/services/fileBrowser/common/fileBrowserViewModel.ts +++ b/src/sql/workbench/services/fileBrowser/common/fileBrowserViewModel.ts @@ -29,6 +29,10 @@ export class FileBrowserViewModel { this._fileBrowserService.onPathValidate(args => onPathValidateCallback(args)); } + public get showFoldersOnly(): boolean { + return this._showFoldersOnly; + } + public initialize(ownerUri: string, expandPath: string, fileFilters: [{ label: string, filters: string[] }],