Remove Test view from QuickView

Hello!

My question is related to this one.

Plugin-view-registry registers the test view here.

doRegisterViewContainer then proceeds to add the view to quickview here.

I’d like to completely remove all references to the test view in the UI. Removing the menu item and command label (so that it doesn’t show in the command palette) is easy.
However, quickview still shows an entry for this view and looking at the QuickViewService docs, I can’t find a way to remove the entry.

A bit of context:

My IDE will have a “Test” view which will allow the users to test their code. Obviously, since testing is the purpose of the view, it makes sense to call this view “Test” :slight_smile:.

The problem is that there already exists a view called Test so my UI shows two entries, one for my view, the other one for the view registered in the plugin-view-registry. As I said, I can remove the command label and the menu item, but removing the entry from quickview seems impossible. Or maybe I’m missing something obvious?

Alternatively (and maybe even preferably) I could add my widget to the existing test view. However, I can’t find a way to do that? I tried adding viewContainerId: ‘test’ to widget options in my contribution but that makes my IDE just show nothing and fail silently because it fails on this line.

Any ideas on how to solve this are very welcome.

Thank you!

You should implement AbstractViewContribution and provide plugin-view-container:test as view container id. See for instance how the navigator view is added to the explorer view container: https://github.com/eclipse-theia/theia/blob/9d2dcd0a0923d7f7d8def0b7377fc9667706c967/packages/navigator/src/browser/navigator-frontend-module.ts#L45-L73

Thank you @akosyakov!

I tried setting plugin-view-container:test but that didn’t work, unfortunately. What did work was setting just plugin-view-container (or rather PLUGIN_VIEW_CONTAINER_FACTORY_ID from @theia/plugin-ext/lib/main/browser/view/plugin-view-registry) as container id. But, of course, I still had the problem that the test view was already registered along with command and menu item so I had two entries in menu etc.

So then I took a look at the code you linked to and implemented the same logic in my frontend module. I then realized that with this code I don’t need a view contribution at all. Here’s what my frontend module code looks like now:

export default new ContainerModule(bind => {
bind(TestViewWidget).toSelf();

bind(WidgetFactory).toDynamicValue(ctx => ({
    id: TestViewWidget.ID,
    createWidget: () => ctx.container.get<TestViewWidget>(TestViewWidget)
})).inSingletonScope();

bind(WidgetFactory).toDynamicValue(ctx => ({
    id: PLUGIN_VIEW_CONTAINER_FACTORY_ID,        
    createWidget: async () => {
        const viewContainer = ctx.container.get<ViewContainer.Factory>(ViewContainer.Factory)({
            id: PLUGIN_VIEW_CONTAINER_FACTORY_ID
        });
        viewContainer.setTitleOptions(TEST_VIEW_CONTAINER_TITLE_OPTIONS);
        const widget = await ctx.container.get(WidgetManager).getOrCreateWidget(TestViewWidget.ID);            
        viewContainer.addWidget(widget, {canHide: false, initiallyCollapsed: false, initiallyHidden: false});
        return viewContainer;
    }
}));
});

However, now I have two problems:

  1. When the window is reloaded, the view gets closed and I’d like it to remain open. I’m not sure why this happens.
  2. I’d like the view to open to the right instead of left. I poked around a bit but couldn’t find any options that would specify view area.

Do you have any thoughts on what I could do to fix these issues?

Thanks

I don’t know. I was looking into the least impactful change by reusing test view container and embedding your view into it. I am sure it is possible, maybe id of a view container or timing is wrong.

Ok. Since I couldn’t find a way to deal with these two issues now, I think I’m going to go with my initial idea - hiding menu item and command label and I’ll also remove the “Open view…” menu item so that users can’t get to QuickView. At least until I find some time to dig deeper into this. Not a perfect solution, but it isn’t terrible either.

In any case, thank you for taking the time to try and help me with this problem!