Skip to content

Commit

Permalink
Support component search by provider
Browse files Browse the repository at this point in the history
1. Added provider to the pattern string for coordinates suggestion
The search api call in service ignores provider type.
For example, the following call return results contains co-ordinates
with provider other than npmjs:
curl -X GET "https://dev-api.clearlydefined.io/definitions?pattern=jw&type=npm" -H "accept: */*"
This is probably by design: the suggestion api only takes the pattern
string into account.

When provider is included in the pattern string, the search result
reflects the provider specification. The solution is to pass the
provider information when searching in PageBrowse.

2. Also trigger search when provider is changed

Task: clearlydefined#990
  • Loading branch information
qtomlinson committed Jul 11, 2022
1 parent f829328 commit 7ca72e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/Navigation/Pages/PageBrowse/PageBrowse.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class PageBrowse extends SystemManagedList {
this.state = {
activeSort: 'releaseDate-desc',
searchFocused: false,
selectedProvider: providers[0]
selectedProvider: providers[0],
searchTerm: ''
}
this.onFilter = this.onFilter.bind(this)
this.onSort = this.onSort.bind(this)
Expand Down Expand Up @@ -63,13 +64,19 @@ class PageBrowse extends SystemManagedList {
}

onBrowse = value => {
this.setState({ activeName: value }, () => this.updateData())
this.setState({ activeName: value, searchTerm: '' }, () => this.updateData())
}

onFocusChange = value => {
this.setState({ searchFocused: value })
}

onSearch = value => {
this.setState({ searchTerm: value })
const provider = this.state.selectedProvider.value
super.onSearch(provider + '/' + value)
}

tableTitle() {
return 'Browse'
}
Expand Down Expand Up @@ -163,6 +170,7 @@ class PageBrowse extends SystemManagedList {

onProviderChange(item) {
this.setState({ selectedProvider: item })
this.state.searchTerm && super.onSearch(item.value + '/' + this.state.searchTerm)
}

// Overrides the default onFilter method
Expand Down

0 comments on commit 7ca72e8

Please sign in to comment.