-
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
[VSX] Display plugins counts #11248
[VSX] Display plugins counts #11248
Conversation
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.
@alvsan09 if you're up for it I think we should try and aim to do something similar to vscode in this case, perhaps by updating ViewContainerPart
to accept a badge
property that can be applied if no toolbar items are registered. It can of course be styled similarly to vscode:
I'm also wondering if we should drop the count from the context-menu, it's not something I see done in other areas or in vscode:
9808f3b
to
be3202c
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 also received some comments off-line from @vince-fugnitto , I am in the process to change the code, i.e.
I will add a right margin to it as you have pointed out as well, |
be3202c
to
3b38e20
Compare
@@ -34,6 +34,10 @@ | |||
text-align: center; | |||
} | |||
|
|||
.notification-count-container-margin { |
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.
We should drop -margin
from the classname.
@@ -34,6 +34,10 @@ | |||
text-align: center; | |||
} | |||
|
|||
.notification-count-container-margin { |
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 believe this file is strictly for notifications styling, shouldn't we put our styling under view-container.css
?
The use of notifications
for badge styling in view-container
seems a little odd.
protected async computeTitle(): Promise<void> { | ||
let label: string; | ||
switch (this.options.id) { | ||
case VSXExtensionsSourceOptions.INSTALLED: | ||
return nls.localizeByDefault('Installed'); | ||
label = nls.localizeByDefault('Installed'); | ||
break; | ||
case VSXExtensionsSourceOptions.BUILT_IN: | ||
return nls.localizeByDefault('Built-in'); | ||
label = nls.localizeByDefault('Built-in'); | ||
break; | ||
case VSXExtensionsSourceOptions.RECOMMENDED: | ||
return nls.localizeByDefault('Recommended'); | ||
label = nls.localizeByDefault('Recommended'); | ||
break; | ||
case VSXExtensionsSourceOptions.SEARCH_RESULT: | ||
return nls.localize('theia/vsx-registry/openVSX', 'Open VSX Registry'); | ||
label = nls.localize('theia/vsx-registry/openVSX', 'Open VSX Registry'); | ||
break; | ||
default: | ||
return ''; | ||
label = ''; | ||
} | ||
const title = `${label}`; | ||
this.title.label = title; | ||
this.title.caption = title; | ||
|
||
this.badge = await this.resolveCount(); | ||
} |
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 believe this method is doing too much work and merges two concepts together (which is confusing), the title
of the view-part and handling the badge
.
protected async resolveCount(): Promise<number | undefined> { | ||
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) { | ||
const elements = await this.source?.getElements() || []; | ||
return [...elements].length; | ||
} | ||
return undefined; |
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.
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 have submitted a new commit to address these comments !!
Thanks @vince-fugnitto !!
3b38e20
to
4791a08
Compare
2c08a97
to
d538744
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 confirm that the changes work as expected:
- a badge of
0
is supported and displayed - the 'builtin', 'recommended' and 'installed' tree-view-parts have badges
- the badges correctly display the extension count for each part
- the badges are correctly updated when the count is updated
})); | ||
} | ||
|
||
private _badgeCount: number | undefined = undefined; |
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.
minor: we should rename to _badge
due to the getter and setter, or just use badgeCount
(dropping the unnecessary _
). I'm in favor of using _badge
however.
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 you, _badge
is more appropriate,
It has been updated in the latest commit,
I have also squashed the commits and re-based it to later master.
Thanks @vince-fugnitto !
Adds a plugin count to the title and captions of each instance of `VSXExtensionsWidget` except for `SEARCH_RESULT` as the count may be partial. The solution extends the functionality under view-container by adding a BadgeWidget interface that can be implemented by widgets wrapped in a ViewContainerPart, this is the reference implementation for it. This solution does not show the badge for view parts that contain a toolbar populated with more than one item. Signed-off-by: Alvaro Sanchez-Leon <alvaro.sanchez-leon@ericsson.com>
5670264
to
a535501
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.
Looks good to me 👍
- The extension count is displayed on the view parts as a badge (not the context menu)
- Not other view parts/widgets are affected by this change
- The badge updates when installing an extension
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.
LGTM 👍
@msujew, @vince-fugnitto, Thanks !! 👍 |
What it does
Adds a plugin count badge to the title of each instance of
VSXExtensionsWidget
except forSEARCH_RESULT
as the count may bepartial.
The solution extends the functionality under
view-container
by adding aBadgeWidget
interface that can beimplemented by widgets wrapped in a
ViewContainerPart
, this is the reference implementation for it.This solution does not show the badge for view parts that contain a toolbar populated with more than one item.
How to test
extensions.json
file with the following content to your workspace.theia
folder:theia
and open theEXTENSIONS
viewINSTALLED
,BUILT-IN
,RECOMMENDED
RECOMMENDED
is 5WATCH
under theDEBUG
view.Review checklist
Reminder for reviewers