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

[VSX] Display plugins counts #11248

Merged
merged 1 commit into from
Jun 15, 2022
Merged

[VSX] Display plugins counts #11248

merged 1 commit into from
Jun 15, 2022

Conversation

alvsan09
Copy link
Contributor

@alvsan09 alvsan09 commented Jun 2, 2022

What it does

Adds a plugin count badge to the title 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.

How to test

  • Add an extensions.json file with the following content to your workspace .theia folder:
{
    "recommendations": [
        "ms-azuretools.vscode-docker",
        "exiasr.hadolint",
        "timonwong.shellcheck",
        "coenraads.bracket-pair-colorizer-2",
        "scalameta.metals"
    ]
}
  • Start theia and open the EXTENSIONS view
  • Install few extensions
  • Verify the counter values for each widget i.e. INSTALLED, BUILT-IN, RECOMMENDED
  • As per the listed extensions above the expected count for RECOMMENDED is 5
  • Make sure other view parts don't display a badge e.g. WATCH under the DEBUG view.

vsx_plugin_count gif

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added ui/ux issues related to user interface / user experience vsx-registry Issues related to Open VSX Registry Integration labels Jun 3, 2022
Copy link
Member

@vince-fugnitto vince-fugnitto left a 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:

Screen Shot 2022-06-02 at 8 21 49 PM

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:

Screen Shot 2022-06-02 at 8 22 36 PM

@msujew msujew self-requested a review June 8, 2022 13:39
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.

Looks good from a surface viewpoint. Haven't looked into the code yet. I noticed some minor layouting issues, where the badge clips into the focus outline. I believe we need a larger margin there:

grafik

VSCode:

grafik

@alvsan09
Copy link
Contributor Author

alvsan09 commented Jun 9, 2022

Looks good from a surface viewpoint. Haven't looked into the code yet. I noticed some minor layouting issues, where the badge clips into the focus outline. I believe we need a larger margin there:

I also received some comments off-line from @vince-fugnitto , I am in the process to change the code, i.e.

  • Give the responsibility to render the badge to the ViewContainerPart rather than from the VSXExtensionsWidget
  • Make the BadgeWidget interface more specific to contain a badge of type number | undefined rather that node | undefined
  • Make sure that if a part contains a toolbar the badge is not displayed.

I will add a right margin to it as you have pointed out as well,
Additional comments are very welcome !
Thanks @msujew !

@@ -34,6 +34,10 @@
text-align: center;
}

.notification-count-container-margin {
Copy link
Member

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 {
Copy link
Member

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.

Comment on lines 85 to 100
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();
}
Copy link
Member

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.

Comment on lines 110 to 107
protected async resolveCount(): Promise<number | undefined> {
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) {
const elements = await this.source?.getElements() || [];
return [...elements].length;
}
return undefined;
Copy link
Member

Choose a reason for hiding this comment

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

The changes do not properly handle a 0 count:

image

In this case I would still expect 0 to be displayed for recommended and installed.

Copy link
Contributor Author

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 !!

Copy link
Member

@vince-fugnitto vince-fugnitto left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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>
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.

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

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@alvsan09 alvsan09 merged commit f6c0689 into master Jun 15, 2022
@github-actions github-actions bot added this to the 1.27.0 milestone Jun 15, 2022
@alvsan09 alvsan09 deleted the asl/display_plugins_count branch June 15, 2022 17:05
@alvsan09
Copy link
Contributor Author

@msujew, @vince-fugnitto, Thanks !! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui/ux issues related to user interface / user experience vsx-registry Issues related to Open VSX Registry Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants