web - offer to "Open Remote..." when local file access is not possible

This commit is contained in:
Benjamin Pasero
2021-08-26 09:22:39 +02:00
parent a577d545f1
commit 514697c865
4 changed files with 19 additions and 8 deletions
@@ -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<URI> {
@@ -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;
@@ -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 {
@@ -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() {