-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for "enablement" property in plugin command contributions #12483
Add support for "enablement" property in plugin command contributions #12483
Conversation
Fixes eclipse-theia#12426 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
6a52fb9
to
ab75432
Compare
Here's the test plugin: And here's the source: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Thomas! Works as advertised in browser, electron native and electron custom mode.
Code looks reasonable to me. I just added a minor nitpick inline.
@@ -162,10 +171,14 @@ export class TabBarToolbar extends ReactWidget { | |||
</div>; | |||
} | |||
|
|||
protected isEnabled(item: AnyToolbarItem): boolean { | |||
return (!!item.command && this.commandIsEnabled(item.command) && this.evaluateWhenClause(item.when)) || (!!item.menuPath && !item.command); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: maybe it helps readability if we extract two variables with helpful names for each of the two parts of the conditions.
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
@planger I changed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, much better imho!
@vince-fugnitto since action enablement works just fine for other context menus (file explorer or the general context menu on the editor), this might just be a bug in the action enablement that is revealed since we now actually honor the enabled state. |
…eclipse-theia#12483) Fixes eclipse-theia#12426 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
What it does
Reads the
enablement
property for commands contributed in a pluginpackage.json
and updates toolbar items when necessary.Fixes #12426
Contributed on behalf of STMicroelectronics
How to test
Review checklist
Reminder for reviewers