Skip to content

Commit

Permalink
Omit rendering for rating/downloads of an extension if 0
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Kaiyue Pan authored and vince-fugnitto committed Mar 27, 2020
1 parent 93ab22f commit 5e7dc96
Showing 1 changed file with 6 additions and 8 deletions.
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>}
{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

0 comments on commit 5e7dc96

Please sign in to comment.