Skip to content

menus: make menus that reference unregistered commands more robust#9886

Merged
vince-fugnitto merged 1 commit intomasterfrom
vf/menu-robustness
Aug 16, 2021
Merged

menus: make menus that reference unregistered commands more robust#9886
vince-fugnitto merged 1 commit intomasterfrom
vf/menu-robustness

Conversation

@vince-fugnitto
Copy link
Member

What it does

Fixes: #9870

The pull-request updates the registration of menus that reference invalid or missing commands to be more robust.
Rather than fail the layout, or the start of the application, the menus items will be omitted with an error log for extenders to handle.

How to test

  1. start the application, and confirm it starts correctly
  2. the menus should be present - there should be error logs in the console regarding missing commands
  3. repeat the steps for the browser or electron target respectfully.
electron-menu-robust.mp4

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added menus issues related to the menu extensibility issues to simplify ability to extend Theia labels Aug 11, 2021
@vince-fugnitto vince-fugnitto self-assigned this Aug 11, 2021
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm the issue is present on master and is addressed by this change nicely:

  • On master unregistering those commands crashes the application on startup ❌
  • With this change in place, the application starts up nicely ✔️
  • The menu entries related to the commands are not visible ✔️
  • The missing commands are logged as errors in the console (perhaps a warning would suffice, but I don't really have a strong opinion on that) ✔️

@vince-fugnitto vince-fugnitto force-pushed the vf/menu-robustness branch 2 times, most recently from 9328bee to 2caaf89 Compare August 13, 2021 19:14
@vince-fugnitto
Copy link
Member Author

vince-fugnitto commented Aug 13, 2021

I updated the pull-request following @paul-marechal's offline comments about having a more permanent way to verify the feature in the framework (previously a dropped commit). I added an api-test, as well as a sample contribution in api-samples to both verify the behavior when a menu with an invalid command is registered.

The commit updates `menus` to not fail the layout when there are no
commands attached to them, and instead log the error. Previously, if a
command was unregistered and a command referenced it the layout would
fail, and possibly also fail to start the application.

The change also includes:
- a bogus menu registration in `api-samples` to verify the feature in the future.
- an api test to verify that registration does not fail for menus with invalid commands.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the application is not blocked because of unknown commands in menus anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensibility issues to simplify ability to extend Theia menus issues related to the menu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removing certain commands results in "Error: Failed to start the frontend application"

3 participants