Remove/unregister entire menu items along with their corresponding submenus

Hi,
Upon including the common theia packages in a project, the menu items that come up are ‘FIle’, ‘Edit’, ‘Selection’, ‘View’, ‘Go’, ‘Terminal’, ‘Help’ and they have submenus under them. For eg: New File, New Folder actions come up under the ‘File’ menu. Now, I can unregister these submenu actions using the unregisterMenuAction method, and they are removed from their corresponding menu options in the UI. But even after unregistering all submenu items under them, the menu item still comes up on the UI. For example, say I do not want the ‘Selection’ menu on the top menubar i.e. I do not want it to be displayed at all in the UI, how do I do it? Also, how do I add a new menu with a title, say ‘Options’ which would be having its own set of submenus.

[original thread by rhendricks]

https://spectrum.chat/theia/general/how-to-disable-menu-sub-menu-items-via-my-custom-extensions~306b4799-fe97-4011-887f-f8dd07e4e51d?m=MTU2NDY2Mzg1OTM3Ng==https://spectrum.chat/theia/general/how-to-disable-menusub-menu-items-via-my-custom-extensions~306b4799-fe97-4011-887f-f8dd07e4e51d

registerSubmenu should allow to add new Options menu to MAIN_MENU_BAR

[rhendricks]

@anton-kosyakov I have another question. Say, I don’t want the Outline widget in the application at all. I want it removed from the right sidepanel in addition to the submenu option under View Menu. I do not want the user to enable that widget by any means. How do I do it ?

[Hanksha]

You could exclude the outline-view package from your application maybe?

At the moment it is very difficult to completely remove the outline-view since it is pulled by @theia/monaco. corresponding issue. The best approach or workaround would be to remove the menu item, and remove the outline-view from the list of default widgets (widgets that appear when first starting the application with a new workspace).

You can remove it with DI. something like:

rebind(OutlineViewContribution).toConstantValue({
        registerCommands: () => { },
        registerMenus: () => { },
        registerKeybindings: () => { },
        registerToolbarItems: () => { }
    } as any);

[rhendricks]

Thanks @anton-kosyakov . Works perfectly.