From 514697c865001ebd90fe5a68901e88e7d2ae6bd8 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 26 Aug 2021 09:22:39 +0200 Subject: [PATCH] web - offer to "Open Remote..." when local file access is not possible --- .../dialogs/browser/abstractFileDialogService.ts | 4 +++- .../services/dialogs/browser/fileDialogService.ts | 11 ++++++++--- .../dialogs/electron-sandbox/fileDialogService.ts | 6 ++++-- .../services/dialogs/test/fileDialogService.test.ts | 6 ++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts index 50d2df67138..6112d2a5885 100644 --- a/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.ts @@ -26,6 +26,7 @@ import { ILabelService } from 'vs/platform/label/common/label'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; import { Schemas } from 'vs/base/common/network'; import { PLAINTEXT_EXTENSION } from 'vs/editor/common/modes/modesRegistry'; +import { ICommandService } from 'vs/platform/commands/common/commands'; export abstract class AbstractFileDialogService implements IFileDialogService { @@ -44,7 +45,8 @@ export abstract class AbstractFileDialogService implements IFileDialogService { @IModeService private readonly modeService: IModeService, @IWorkspacesService private readonly workspacesService: IWorkspacesService, @ILabelService private readonly labelService: ILabelService, - @IPathService private readonly pathService: IPathService + @IPathService private readonly pathService: IPathService, + @ICommandService protected readonly commandService: ICommandService ) { } async defaultFilePath(schemeFilter = this.getSchemeFilterForWindow()): Promise { diff --git a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts index 7d82b6d34fd..700542f2bd7 100644 --- a/src/vs/workbench/services/dialogs/browser/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/browser/fileDialogService.ts @@ -188,15 +188,20 @@ export class FileDialogService extends AbstractFileDialogService implements IFil const res = await this.dialogService.show( Severity.Warning, localize('unsupportedBrowserMessage', "Accessing local files is unsupported in your current browser."), - [localize('learnMore', "Learn More"), localize('cancel', "Cancel")], + [localize('openRemote', "Open Remote..."), localize('learnMore', "Learn More"), localize('cancel', "Cancel")], { detail: localize('unsupportedBrowserDetail', "Click 'Learn More' to see a list of supported browsers."), cancelId: 1 } ); - if (res.choice === 0) { - this.openerService.open('https://aka.ms/VSCodeWebLocalFileSystemAccess'); + switch (res.choice) { + case 0: + this.commandService.executeCommand('workbench.action.remote.showMenu'); + break; + case 1: + this.openerService.open('https://aka.ms/VSCodeWebLocalFileSystemAccess'); + break; } return undefined; diff --git a/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts b/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts index 94c437a817f..6a4d6e3a788 100644 --- a/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-sandbox/fileDialogService.ts @@ -22,6 +22,7 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { ILabelService } from 'vs/platform/label/common/label'; import { IPathService } from 'vs/workbench/services/path/common/pathService'; +import { ICommandService } from 'vs/platform/commands/common/commands'; export class FileDialogService extends AbstractFileDialogService implements IFileDialogService { @@ -39,10 +40,11 @@ export class FileDialogService extends AbstractFileDialogService implements IFil @IModeService modeService: IModeService, @IWorkspacesService workspacesService: IWorkspacesService, @ILabelService labelService: ILabelService, - @IPathService pathService: IPathService + @IPathService pathService: IPathService, + @ICommandService commandService: ICommandService ) { super(hostService, contextService, historyService, environmentService, instantiationService, - configurationService, fileService, openerService, dialogService, modeService, workspacesService, labelService, pathService); + configurationService, fileService, openerService, dialogService, modeService, workspacesService, labelService, pathService, commandService); } private toNativeOpenDialogOptions(options: IPickAndOpenOptions): INativeOpenDialogOptions { diff --git a/src/vs/workbench/services/dialogs/test/fileDialogService.test.ts b/src/vs/workbench/services/dialogs/test/fileDialogService.test.ts index c7e79e03afb..509a32b707a 100644 --- a/src/vs/workbench/services/dialogs/test/fileDialogService.test.ts +++ b/src/vs/workbench/services/dialogs/test/fileDialogService.test.ts @@ -29,6 +29,7 @@ import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IHostService } from 'vs/workbench/services/host/browser/host'; import { SimpleFileDialog } from 'vs/workbench/services/dialogs/browser/simpleFileDialog'; +import { ICommandService } from 'vs/platform/commands/common/commands'; class TestFileDialogService extends FileDialogService { constructor( @@ -46,10 +47,11 @@ class TestFileDialogService extends FileDialogService { @IModeService modeService: IModeService, @IWorkspacesService workspacesService: IWorkspacesService, @ILabelService labelService: ILabelService, - @IPathService pathService: IPathService + @IPathService pathService: IPathService, + @ICommandService commandService: ICommandService ) { super(hostService, contextService, historyService, environmentService, instantiationService, configurationService, fileService, - openerService, nativeHostService, dialogService, modeService, workspacesService, labelService, pathService); + openerService, nativeHostService, dialogService, modeService, workspacesService, labelService, pathService, commandService); } protected override getSimpleFileDialog() {