Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async $showSaveDialog(options: SaveDialogOptionsMain): Promise {
const rootStat = await this.getRootUri(options.defaultUri ? options.defaultUri : undefined);
// Fail if root not fount
if (!rootStat) {
throw new Error('Unable to find the rootStat');
}
// Take the info for root node
const rootNode = DirNode.createRoot(rootStat);
try {
// Create save file dialog props
const dialogProps = {
title: 'Save',
saveLabel: options.saveLabel,
filters: options.filters
} as SaveFileDialogProps;
// Show save file dialog
const dialog = this.saveFileDialogFactory(dialogProps);
dialog.model.navigateTo(rootNode);
const result = await dialog.open();
// Return the result
if (result) {
async $showOpenDialog(options: OpenDialogOptionsMain): Promise {
const rootStat = await this.getRootUri(options.defaultUri ? options.defaultUri : undefined);
// Fail if root not fount
if (!rootStat) {
throw new Error('Unable to find the rootStat');
}
// Take the info for root node
const rootNode = DirNode.createRoot(rootStat);
try {
// Determine proper title for the dialog
const canSelectFiles = typeof options.canSelectFiles === 'boolean' ? options.canSelectFiles : true;
const canSelectFolders = typeof options.canSelectFolders === 'boolean' ? options.canSelectFolders : true;
let title;
if (canSelectFiles && canSelectFolders) {
title = 'Open';
} else {
if (canSelectFiles) {
title = 'Open File';
} else {
title = 'Open Folder';
}
async selectPluginPath(): Promise {
const workspaceFolder = (await this.workspaceService.roots)[0] || await this.fileSystem.getCurrentUserHome();
if (!workspaceFolder) {
throw new Error('Unable to find the root');
}
const rootNode = DirNode.createRoot(workspaceFolder);
const dialog = this.openFileDialogFactory({
title: HostedPluginCommands.SELECT_PATH.label!,
openLabel: 'Select',
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false
});
dialog.model.navigateTo(rootNode);
const result = await dialog.open();
if (UriSelection.is(result)) {
if (await this.hostedPluginServer.isPluginValid(result.uri.toString())) {
this.pluginLocation = result.uri;
this.messageService.info('Plugin folder is set to: ' + this.labelProvider.getLongName(result.uri));
} else {