Skip to content

Commit

Permalink
Include component type in search pattern for browse
Browse files Browse the repository at this point in the history
To refine the component search result in PageBrowse, pass component type information in search pattern.

Task: clearlydefined#957
  • Loading branch information
qtomlinson committed Oct 4, 2022
1 parent 6d64263 commit 2b2321a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 8 additions & 4 deletions src/components/Navigation/Pages/PageBrowse/PageBrowse.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ class PageBrowse extends SystemManagedList {

onSearch = value => {
this.setState({ searchTerm: value })
const valueToSearch = this.state.selectedProvider.value + '/' + value
this.props.dispatch(uiBrowseUpdateFilterList(this.props.token, valueToSearch))
const searchPattern = this._buildSearchPattern(this.state.selectedProvider, value)
this.props.dispatch(uiBrowseUpdateFilterList(this.props.token, searchPattern))
}

_buildSearchPattern = (provider, value) => {
return provider.type + '/' + provider.value + '/' + value
}

tableTitle() {
Expand Down Expand Up @@ -171,8 +175,8 @@ class PageBrowse extends SystemManagedList {
onProviderChange(item) {
this.setState({ selectedProvider: item })
if (this.state.searchTerm) {
const valueToSearch = item.value + '/' + this.state.searchTerm
this.props.dispatch(uiBrowseUpdateFilterList(this.props.token, valueToSearch))
const searchPattern = this._buildSearchPattern(item, this.state.searchTerm)
this.props.dispatch(uiBrowseUpdateFilterList(this.props.token, searchPattern))
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ const types = [
]

const providers = [
{ value: 'npmjs', label: 'NpmJS', image: npmImage },
{ value: 'github', label: 'GitHub', image: gitImage },
{ value: 'mavencentral', label: 'MavenCentral', image: mavenImage },
{ value: 'nuget', label: 'NuGet', image: nugetImage },
{ value: 'pypi', label: 'PyPi', image: pypiImage },
{ value: 'rubygems', label: 'RubyGems', image: gemImage },
{ value: 'cocoapods', label: 'CocoaPods', image: podImage },
{ value: 'cratesio', label: 'Crates.io', image: crateImage },
{ value: 'debian', label: 'Debian', image: debianImage },
{ value: 'packagist', label: 'Packagist', image: composerImage }
{ value: 'npmjs', label: 'NpmJS', image: npmImage, type: 'npm' },
{ value: 'github', label: 'GitHub', image: gitImage, type: 'git' },
{ value: 'mavencentral', label: 'MavenCentral', image: mavenImage, type: 'maven' },
{ value: 'nuget', label: 'NuGet', image: nugetImage, type: 'nuget' },
{ value: 'pypi', label: 'PyPi', image: pypiImage, type: 'pypi' },
{ value: 'rubygems', label: 'RubyGems', image: gemImage, type: 'gem' },
{ value: 'cocoapods', label: 'CocoaPods', image: podImage, type: 'pod' },
{ value: 'cratesio', label: 'Crates.io', image: crateImage, type: 'crate' },
{ value: 'debian', label: 'Debian', image: debianImage, type: 'deb' },
{ value: 'packagist', label: 'Packagist', image: composerImage, type: 'composer' }
]

const multiEditableFields = ['licensed.declared']
Expand Down

0 comments on commit 2b2321a

Please sign in to comment.