-
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 global toolbar 🛠 #10731
Add global toolbar 🛠 #10731
Conversation
617f64e
to
292d5ed
Compare
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.
I'll test the changes more closely in the coming days, two things I noticed which I think would make the feature more consistent with the UX of the rest of the framework would be:
- a similar hover behavior as editor toolbar items and buttons (hover background) when
hovering over items in the main toolbar. Ex:
hover-item.mp4
- a secondary color (not the main foreground color) for separators
- the icon placement may need to be adjusted, it seems as though there is more space at the bottom:
- in the future we may want to make the toolbar items keyboard accessible, using tab to cycle through the toolbar
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.
I agree with Vince in regard to the UX changes. I also think that we should remove the dropshadow effect, it feels a bit out of place.
Extensive review following later today.
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.
This is looking really good in general already, good job! 👍
I have a few suggestion to improve on the i18n of this feature, most of it can be easily addressed by introducing new translation keys. I also have a more general discussion topic, where I would like to get some input from other contributors:
I don't think that overriding the ApplicationShell
to add toolbar support is an optimal solution to this problem. In my opinion, the toolbar UI is a "contributed" feature, rather than an "inherited" one, if that train of thought makes sense. Also, in my experience, downstream users of Theia often tend to override the ApplicationShell
themselves, making this change a bit more annoying to integrate into existing apps.
Going with the "contributed feature" thought leads me to believe that there should be a way to customize the ApplicationShell
(i.e. adding panels beside/above/below existing panels) using contributions. An example API I had in mind:
enum PanelLayoutDirection {
Left,
Right,
Above,
Below
}
interface ApplicationShellPanelRegistry {
// `relativeId` is the id of a panel the new panel should be placed in relation to
// e.g. for the toolbar it would be used like this:
// `registerPanel(toolbar, PanelLayoutDirection.Below, 'top-panel');`
registerPanel(panel: Panel, direction: PanelLayoutDirection, relativeId: string)
}
interface ApplicationShellContribution {
registerPanels(registry: ApplicationShellPanelRegistry)
}
By the way, I'd be alright with merging this PR in its current state first and refactoring it later, given that this would be quite a large change in the API.
packages/toolbar/src/browser/main-toolbar-command-quick-input-service.ts
Outdated
Show resolved
Hide resolved
packages/toolbar/src/browser/abstract-main-toolbar-contribution.tsx
Outdated
Show resolved
Hide resolved
packages/toolbar/src/browser/main-toolbar-icon-selector-dialog.tsx
Outdated
Show resolved
Hide resolved
packages/toolbar/src/browser/main-toolbar-icon-selector-dialog.tsx
Outdated
Show resolved
Hide resolved
@msujew I had added the shadow to distinguish the left/right panels from the toolbar. Removing it blends the two together in a somewhat awkward way since the icon sizing is different: Alternatively I can add a solid border below (ignore icon alignment for now, just a prototype 😉): Though this can cause some visual clutter around active editor tabs: |
@kenneth-marut-work I'm thinking defining a color that is a slightly darker version of the sidepanels would likely suffice, even just using |
292d5ed
to
ea0e4b3
Compare
@vince-fugnitto great suggestion. I think that worked out nicely |
40b72d3
to
2b7781a
Compare
2b7781a
to
69bae58
Compare
@vince-fugnitto @msujew @msujew I have also pushed a minor change that I believe makes the default layout much easier to customize for extenders. Previously I had expected |
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.
A couple of quick comments:
- please include a
readme
for the extension following the template we have for other extensions (it would be the first thing that consumers would see when looking at npm. - we should probably think about what toolbar items should be present by default, I think the custom
easy-search
should either be added to@theia/api-samples
or replaced by a genericmore (... icon)
toolbar item that downstream applications can contribute context-menus to - the new terminal can also likely be removed but I'm open to suggestions. - disabled toolbar items should not have the pointer cursor.
- we should try to aim to have consistent sizes for toolbar items (at the moment the easy-search seems bigger - I understand it is custom).
- I don't think that
search-in-workspace-root-quick-input-service.ts
should belong in a generic toolbar extension, perhaps it can be factored out - this might be related to removing the easy-search out to@theia/api-samples
. - we should prefix the files by
toolbar-
and notmain-toolbar-
since the extension and folder is namedtoolbar
(nitpick)
Regarding what should be included by default I'm open to suggestions :)
e2e6d2c
to
cfbcfeb
Compare
Thanks for the suggestions 👍 |
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.
I noticed that disabling/enabling toolbar elements lags behind, until the toolbar is forcefully updated by clicking on a command. It seems like the change of isEnabled
cannot be really propagated to the toolbar (there's no event for that).
For example, when closing all editors the "Split Editor" button is disabled. When opening a file, the button stays disabled. Clicking on it "enables" the button and executes the command.
I found that to be a bit confusing and leads me to believe that we maybe shouldn't render disabled buttons as being truly disabled. On the other hand, this could lead to confusion as well. What do the others think about that?
@msujew I agree, we should probably keep them disabled but be able to know when an underlying command is enabled/disabled so that the toolbar item updates accordingly. The toolbar items (for views and the editor) seems to be able to make this update, perhaps it is something we can follow. If it is something not feasible for the moment we can also consider it a future improvement and make the items always enabled. |
@msujew |
@kenneth-marut-work back and forward do seem to work well 👍 I confirmed it seems to be the split-editor which doesn't, although the command itself does seem to update from the command-palette (but of course the command-palette is not persistent). |
Ah, I can see that this may be an intermittent issue depending if/how a regular TabBarToolbarItem has registered an |
@vince-fugnitto @msujew |
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.
While your recent changes have improved the behavior of the disabled/enabled buttons @kenneth-marut-work, it still has some hiccups. Opening a file enables the Split Editor
button, but no actions afterwards seem to influence it (again, clicking on the toolbar updates the enabled state, but nothing else).
I'd be in favor of removing the ability to disable buttons on the toolbar. I think the feature looks and works well enough for a release today. We will have to polish it anyway in the upcoming weeks, e.g. I plan to add the proposed shell contribution API.
Also a minor, general comment: We should probably remove the localize
/localizeByDefault
calls from the toolbar api-samples
, this makes automatic translation (key extraction) a bit more difficult.
I agree there is still some funny business going on with the split editor command. It looks like that command has not registered an onDidChange so we are likely seeing different results (likely as a side effect of some other update). For example, I do see the enabled state update when opening and closing editors, but only when opening via Ctrl+P (apologies for the bad GIF compression). Still not enough to say that it works flawlessly. It's worth noting that commands that are registered in the tabbarToolbarRegistry with an
@vince-fugnitto any thoughts? I'm happy to always show items as "enabled" if you agree. Alternatively, maybe there is some compromise, for example that defaults toolbar items to always I'm realizing now that I've picked 3 very finicky commands to showcase as defaults :) |
I'm fine with showing them as enabled as a first contribution to the repo in today's release, we can think of a strategy to fix the problem in subsequent improvements.
It happens :) If you feel like it's problematic or not all that useful we can remove it as one of the defaults, keep the default toolbar simple. |
@msujew thanks for the additional suggestions. I've addressed your comments including renaming, removing internationalization in api-samples, and defaulting all commands to enabled. |
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.
The changes look good to me for today's release 👍
There are still things I'd like to clean up afterwards and some styling as well but we can tackle it in subsequent improvements.
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.
Thanks for the changes Ken! I agree with Vince, this is looking good enough for merging 👍
Thanks @kenneth-marut-work for contributing this and thanks @vince-fugnitto and @msujew for the quick review cycle! I am very happy to see this feature in the next release! |
Description
Fixes: #5037, Fixes: #7540
This PR adds an fully customizable and optional toolbar to the application shell as discussed here #10501.
Features include:
Main Functionality
Toolbar that can be hidden/shown via
alt+t
, by right clicking the toolbar, or through a new preference (hidden by default)A set of default command toolbar items including back and forth, split editor, new files/directories
A new
toolbar.json
file that lives in the user's.theia
directory to manage toolbar customizationsA contribution point for packages to contribute custom React toolbar items
Ability to drag and drop individual command and contributed icons to the LEFT, CENTER, or RIGHT areas of the toolbar, or anywhere in existing toolbar groups
Ability to
add a new group
(right click on item), which adds a vertical separator|
to the left or right of the toolbar itemAdd/remove toolbar items by right-clicking, or by editing the JSON file directly (probably not recommended, but possible)
Reset toolbar to defaults by right clicking an empty area of the toolbar
Add custom items to the toolbar, which opens a quickpick with all available commands, and new dialog to select a custom icon (codicon or font awesome). Will show a default icon option if one is available
1 contributed custom toolbar item (
easy-search-toolbar-item
) to demonstrate custom React toolbar widgetsEasy Search Toolbar Item
How to test
ctrl+t
toolbar.json
file which is accessible via right-clicking the toolbarBreaking Changes
Not yet included:
Review checklist
Reminder for reviewers