Skip to content

Improvement of empty lists and 404 pages#522

Merged
loic-sharma merged 5 commits intoloic-sharma:masterfrom
sipmann:master
Jun 12, 2020
Merged

Improvement of empty lists and 404 pages#522
loic-sharma merged 5 commits intoloic-sharma:masterfrom
sipmann:master

Conversation

@sipmann
Copy link
Contributor

@sipmann sipmann commented Jun 9, 2020

Summary of the changes (in less than 80 chars)

  • Added a message on the index/search page when there is no package on the list.
  • Added a message on the package page where the package can't be found.

Addresses #303

</div>
))}

{this._renderSearch()}
Copy link
Owner

@loic-sharma loic-sharma Jun 9, 2020

Choose a reason for hiding this comment

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

I'd rather avoid splitting up the HTML here if possible. What do you think of doing something like:

{(() => {
  if (this.state.items.length > 0) {
    // Show results
  } else {
    // Show empty message
  }
})()}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah for sure. You mean take the code from _renderSearch back to the render and do the if inside it. Right?

Suggested change
{this._renderSearch()}
render() {
...
<div className="form-group">
<Checkbox
defaultChecked={this.state.includePrerelease}
onChange={this.onChangePrerelease}
label="Include prerelease:"
boxSide="end"
/>
</div>
</form>
// {this._renderSearch()}
if (this.state.items.length > 0) {
this.state.items.map( i => ...
} else { ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be easier to understand. Something like this? https://gist.github.com/sipmann/9e266ca45333238ccfd9c14f033e2fa2

Copy link
Owner

Choose a reason for hiding this comment

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

Yup, that looks perfect

@loic-sharma
Copy link
Owner

Thanks for doing this, it looks great already! I left some minor comments, I'll merge this in once you address them :)

@sipmann
Copy link
Contributor Author

sipmann commented Jun 10, 2020

Awesome, I've just commited every suggestion :). ty for your patience

<div>
<h2>Oops, package not found...</h2>
<p>Could not find package '{this.id}'.</p>
<p>You can try searching on <a href={`https://www.nuget.org/packages?q=${this.id}`} target="_blank" rel="noopener noreferrer">nuget.org</a> package.</p>
Copy link
Owner

Choose a reason for hiding this comment

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

Nice job on these rel attributes, I didn't know these existed 👍

<span>by: {value.authors}</span>

{(() => {
if (this.state.items.length > 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Hm I noticed there's a small flaw with this logic. When we change the search input, we set items to an empty array, thereby causing that "Oops, nothing here..." message to flash while we load the new items. I think we should introduce a new loading property on the state object and change this line to:

Suggested change
if (this.state.items.length > 0) {
if (loading || this.state.items.length > 0) {

When we start loading new items using _loadItems, we should set loading to true. Once we complete loading items, we should set loading to false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap, totally agreed

@loic-sharma
Copy link
Owner

Ok I left one more comment to polish up the UI as we load search elements. I can't wait to get this merged in! :)

@sipmann
Copy link
Contributor Author

sipmann commented Jun 11, 2020

Almost done with the last suggestion. But I've found a bug at the way the search works. Fill a bug and solve in another pull request? Or solve on this one?
It should be just a one line change

@loic-sharma
Copy link
Owner

loic-sharma commented Jun 11, 2020

What's the bug? If it's a one liner then we can probably add it to this change as well

@sipmann
Copy link
Contributor Author

sipmann commented Jun 11, 2020

At line 71, we are sending the previous input value, instead of the new one. So when we type the next letter, the previous one is sent.

this._loadItems(
      prevProps.input,

search_bug

@loic-sharma
Copy link
Owner

loic-sharma commented Jun 11, 2020

Oh nice catch! Feel free to fix it in this PR or in another one, both approaches are fine by me

@loic-sharma loic-sharma merged commit 1954e94 into loic-sharma:master Jun 12, 2020
@loic-sharma
Copy link
Owner

Thanks for the awesome contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants