/
search.hbs
60 lines (53 loc) · 2 KB
/
search.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{{page-title this.pageTitle}}
<PageHeader
@title="Search Results"
@suffix={{if this.q (concat "for '" this.q "'")}}
@showSpinner={{this.dataTask.isRunning}}
data-test-header
/>
{{#if this.hasMultiCategoryFilter}}
<div local-class="warning">
Support for using multiple <code>category:</code> filters is not yet implemented.
</div>
{{/if}}
{{#if this.firstResultPending}}
<h2>Loading search results...</h2>
{{else if this.dataTask.lastComplete.error}}
<p data-test-error-message>
Unfortunately something went wrong while loading the search results. Feel
free to try again, or let the <a href="mailto:help@crates.io">crates.io
team</a> know if the problem persists.
</p>
<button
type="button"
disabled={{this.dataTask.isRunning}}
local-class="try-again-button"
data-test-try-again-button
{{on "click" this.fetchData}}
>
Try Again
</button>
{{else if this.hasItems}}
<div local-class="results-meta">
<ResultsCount
@start={{this.pagination.currentPageStart}}
@end={{this.pagination.currentPageEnd}}
@total={{this.totalItems}}
data-test-search-nav
/>
<div data-test-search-sort local-class='sort-by'>
<span local-class="sort-by-label">Sort by </span>
<SortDropdown @current={{this.currentSortBy}} as |sd|>
<sd.Option @query={{hash page=1 sort="relevance"}}>Relevance</sd.Option>
<sd.Option @query={{hash page=1 sort="downloads"}}>All-Time Downloads</sd.Option>
<sd.Option @query={{hash page=1 sort="recent-downloads"}}>Recent Downloads</sd.Option>
<sd.Option @query={{hash page=1 sort="recent-updates"}}>Recent Updates</sd.Option>
<sd.Option @query={{hash page=1 sort="new"}}>Newly Added</sd.Option>
</SortDropdown>
</div>
</div>
<CrateList @crates={{this.model}} local-class="list" />
<Pagination @pagination={{this.pagination}} />
{{else}}
<h2>0 crates found. <a href='https://doc.rust-lang.org/cargo/getting-started/'>Get started</a> and create your own.</h2>
{{/if}}