web - show a warning for unsupported browsers
This commit is contained in:
parent
bdee6209d7
commit
fd688fb33e
|
@ -40,7 +40,7 @@ export abstract class AbstractFileDialogService implements IFileDialogService {
|
|||
@IConfigurationService protected readonly configurationService: IConfigurationService,
|
||||
@IFileService protected readonly fileService: IFileService,
|
||||
@IOpenerService protected readonly openerService: IOpenerService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@IDialogService protected readonly dialogService: IDialogService,
|
||||
@IModeService private readonly modeService: IModeService,
|
||||
@IWorkspacesService private readonly workspacesService: IWorkspacesService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
|
|
|
@ -13,6 +13,8 @@ import { HTMLFileSystemProvider } from 'vs/platform/files/browser/htmlFileSystem
|
|||
import { localize } from 'vs/nls';
|
||||
import { getMediaOrTextMime } from 'vs/base/common/mime';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { WebFileSystemAccess } from 'vs/base/browser/dom';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
|
||||
export class FileDialogService extends AbstractFileDialogService implements IFileDialogService {
|
||||
|
||||
|
@ -46,6 +48,10 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
|
|||
return this.pickFileAndOpenSimplified(schema, options, false);
|
||||
}
|
||||
|
||||
if (!WebFileSystemAccess.supported(window)) {
|
||||
return this.showUnsupportedBrowserWarning();
|
||||
}
|
||||
|
||||
let fileHandle: FileSystemHandle | undefined = undefined;
|
||||
try {
|
||||
([fileHandle] = await window.showOpenFilePicker({ multiple: false }));
|
||||
|
@ -95,6 +101,10 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
|
|||
return this.pickFileToSaveSimplified(schema, options);
|
||||
}
|
||||
|
||||
if (!WebFileSystemAccess.supported(window)) {
|
||||
return this.showUnsupportedBrowserWarning();
|
||||
}
|
||||
|
||||
let fileHandle: FileSystemHandle | undefined = undefined;
|
||||
try {
|
||||
fileHandle = await window.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...{ suggestedName: basename(defaultUri) } });
|
||||
|
@ -126,6 +136,10 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
|
|||
return this.showSaveDialogSimplified(schema, options);
|
||||
}
|
||||
|
||||
if (!WebFileSystemAccess.supported(window)) {
|
||||
return this.showUnsupportedBrowserWarning();
|
||||
}
|
||||
|
||||
let fileHandle: FileSystemHandle | undefined = undefined;
|
||||
try {
|
||||
fileHandle = await window.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...options.defaultUri ? { suggestedName: basename(options.defaultUri) } : undefined });
|
||||
|
@ -143,6 +157,10 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
|
|||
return this.showOpenDialogSimplified(schema, options);
|
||||
}
|
||||
|
||||
if (!WebFileSystemAccess.supported(window)) {
|
||||
return this.showUnsupportedBrowserWarning();
|
||||
}
|
||||
|
||||
let uri: URI | undefined;
|
||||
try {
|
||||
if (options.canSelectFiles) {
|
||||
|
@ -161,6 +179,24 @@ export class FileDialogService extends AbstractFileDialogService implements IFil
|
|||
return uri ? [uri] : undefined;
|
||||
}
|
||||
|
||||
private async showUnsupportedBrowserWarning(): Promise<undefined> {
|
||||
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")],
|
||||
{
|
||||
detail: localize('unsupportedBrowserDetail', "Click 'Learn More' to see a list of supported browsers."),
|
||||
cancelId: 1
|
||||
}
|
||||
);
|
||||
|
||||
if (res.choice === 0) {
|
||||
this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2151362');
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private shouldUseSimplified(scheme: string): boolean {
|
||||
return ![Schemas.file, Schemas.userData, Schemas.tmp].includes(scheme);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue