Skip to content

Commit

Permalink
plugin: fix hosted-plugin dialog
Browse files Browse the repository at this point in the history
The commit fixes the `hosted-plugin` dialog to make it operational in
both the `browser` and `electron` targets by not directly using the factory and
instead using the service.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Jul 29, 2021
1 parent 103e19b commit 1b16fe8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/plugin-dev/src/browser/hosted-plugin-manager-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MessageService, Command, Emitter, Event, UriSelection } from '@theia/co
import { LabelProvider, isNative, AbstractDialog } from '@theia/core/lib/browser';
import { WindowService } from '@theia/core/lib/browser/window/window-service';
import { WorkspaceService } from '@theia/workspace/lib/browser';
import { OpenFileDialogFactory, DirNode } from '@theia/filesystem/lib/browser';
import { FileDialogService } from '@theia/filesystem/lib/browser';
import { HostedPluginServer } from '../common/plugin-dev-protocol';
import { DebugPluginConfiguration, LaunchVSCodeArgument, LaunchVSCodeRequest, LaunchVSCodeResult } from '@theia/debug/lib/browser/debug-contribution';
import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
Expand Down Expand Up @@ -107,8 +107,6 @@ export class HostedPluginManagerClient {
protected readonly hostedPluginServer: HostedPluginServer;
@inject(MessageService)
protected readonly messageService: MessageService;
@inject(OpenFileDialogFactory)
protected readonly openFileDialogFactory: OpenFileDialogFactory;
@inject(LabelProvider)
protected readonly labelProvider: LabelProvider;
@inject(WindowService)
Expand All @@ -123,6 +121,8 @@ export class HostedPluginManagerClient {
protected readonly debugSessionManager: DebugSessionManager;
@inject(HostedPluginPreferences)
protected readonly hostedPluginPreferences: HostedPluginPreferences;
@inject(FileDialogService)
protected readonly fileDialogService: FileDialogService;

@postConstruct()
protected async init(): Promise<void> {
Expand Down Expand Up @@ -272,17 +272,13 @@ export class HostedPluginManagerClient {
throw new Error('Unable to find the root');
}

const rootNode = DirNode.createRoot(workspaceFolder);

const dialog = this.openFileDialogFactory({
const result = await this.fileDialogService.showOpenDialog({
title: HostedPluginCommands.SELECT_PATH.label!,
openLabel: 'Select',
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false
});
dialog.model.navigateTo(rootNode);
const result = await dialog.open();
}, workspaceFolder);

if (UriSelection.is(result)) {
if (await this.hostedPluginServer.isPluginValid(result.uri.toString())) {
Expand Down

0 comments on commit 1b16fe8

Please sign in to comment.