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

Omit rendering for rating/downloads of an extension if 0 #7380

Merged
merged 2 commits into from
Mar 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Omit rendering for rating/downloads of an extension if 0
Omit the rendering for rating/downloads of an extension in the extension tree if it is equal to 0
Omit the rendering for downloads in extension editor if it is equal to 0
Render the star icons of published extension in extension editor even if rating equals to 0

Signed-off-by: Kaiyue Pan <kaiyue.pan@ericsson.com>
  • Loading branch information
Kaiyue Pan committed Mar 26, 2020
commit 75ac21eb9ecad9bd8bdc5f32cfac07aaf6458578
14 changes: 6 additions & 8 deletions packages/vsx-registry/src/browser/vsx-extension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ export class VSXExtensionComponent extends AbstractVSXExtensionComponent {
<span className='name'>{displayName}</span> <span className='version'>{version}</span>
</div>
<div className='stat'>
{downloadCount && <span className='download-count'><i className='fa fa-download' />{downloadCompactFormatter.format(downloadCount)}</span>}
{averageRating && <span className='average-rating'><i className='fa fa-star' />{averageRating.toFixed(1)}</span>}
{!!downloadCount && <span className='download-count'><i className='fa fa-download' />{downloadCompactFormatter.format(downloadCount)}</span>}
{!!averageRating && <span className='average-rating'><i className='fa fa-star' />{averageRating.toFixed(1)}</span>}
</div>
</div>
<div className='noWrapInfo theia-vsx-extension-description'>{description}</div>
Expand Down Expand Up @@ -369,9 +369,9 @@ export class VSXExtensionEditorComponent extends AbstractVSXExtensionComponent {
{this.renderNamespaceAccess()}
{publisher}
</span>
{downloadCount && <span className='download-count' onClick={this.openExtension}>
{!!downloadCount && <span className='download-count' onClick={this.openExtension}>
<i className="fa fa-download" />{downloadFormatter.format(downloadCount)}</span>}
{averageRating && <span className='average-rating' onClick={this.openAverageRating}>{this.renderStars()}</span>}
{averageRating !== undefined && <span className='average-rating' onClick={this.openAverageRating}>{this.renderStars()}</span>}
kaiyue0329 marked this conversation as resolved.
Show resolved Hide resolved
{repository && <span className='repository' onClick={this.openRepository}>Repository</span>}
{license && <span className='license' onClick={this.openLicense}>{license}</span>}
</div>
Expand Down Expand Up @@ -404,10 +404,8 @@ export class VSXExtensionEditorComponent extends AbstractVSXExtensionComponent {
}

protected renderStars(): React.ReactNode {
const rating = this.props.extension.averageRating;
if (typeof rating !== 'number') {
return undefined;
}
const rating = this.props.extension.averageRating || 0;

const renderStarAt = (position: number) => position <= rating ?
<i className='fa fa-star' /> :
position > rating && position - rating < 1 ?
Expand Down