Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbars: ToolbarItem.when field is evaluated and respected #12067

Merged

Conversation

jonah-iden
Copy link
Contributor

ToolbarItem.when field is evaluated and respected
by toolbar and tab-bar-toolbar +
when clause can be set in toolbar.json

Signed-off-by: Jonah Iden [email protected]

What it does

Implements/fixes #11705

This PR implements the funcitionality for toolbars to evaluate and respect the when field/clause of ConditionalToolbarItem.
Also allows setting the when field in toolbar.json.

How to test

easiest way to test is probably through the toolbar.json file:

  1. press Alt+T to open the toolbar
  2. right click it and click Customize Toolbar (open JSON)
  3. either add a new toolbar item or edit an existing one. Add "when": "inDebugMode" and save the file
  4. see the icon gets grayed out and does not react to clicks
  5. start a debug session
  6. see icon is white again and reacts to clicks
  7. stop debug session
  8. icon disabled again

Review checklist

Reminder for reviewers

by toolbar and tab-bar-toolbar +
when clause can be set in toolbar.json

Signed-off-by: Jonah Iden <[email protected]>
jonah-iden and others added 2 commits January 16, 2023 08:34
Co-authored-by: Mark Sujew <[email protected]>
Signed-off-by: Jonah Iden <[email protected]>
@vince-fugnitto vince-fugnitto added the toolbar issues related to the toolbar label Jan 16, 2023
Signed-off-by: Jonah Iden <[email protected]>
@msujew msujew self-requested a review February 17, 2023 15:21
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.

The changes look good to me 👍

  • Registering a when context correctly updates the toolbar item (disables/enables it)
  • When the context changes, the item is also updated as expected
  • A disabled toolbar item will not trigger its command when pressed (though it still allows to remove/move the item)
  • The string type for the when property is correctly reflected when editing the JSON file

@msujew msujew merged commit 81b98d6 into eclipse-theia:master Feb 21, 2023
@vince-fugnitto vince-fugnitto added this to the 1.35.0 milestone Feb 23, 2023
@vince-fugnitto
Copy link
Member

For transparency the pull-request has caused regressions with other toolbar items such as #12314.

@alvsan09
Copy link
Contributor

Another regression is described at:
#12314 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
toolbar issues related to the toolbar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toolbar items should be enabled/visible according to when-clause-contexts
4 participants