-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: allow for regular expressions to be used in search (PROJQUAY-6597) (
quay#2611) allow regex search and simplify search input --------- Signed-off-by: dmesser <dmesser@redhat.com>
- Loading branch information
Showing
22 changed files
with
387 additions
and
11,854 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,52 @@ | ||
import {atom} from 'recoil'; | ||
import {atom, selector} from 'recoil'; | ||
import {SearchState} from 'src/components/toolbar/SearchTypes'; | ||
import {IOrganization} from 'src/resources/OrganizationResource'; | ||
import {OrganizationDetail} from 'src/hooks/UseOrganizations'; | ||
import ColumnNames from 'src/routes/OrganizationsList/ColumnNames'; | ||
import {OrganizationsTableItem} from 'src/routes/OrganizationsList/OrganizationsList'; | ||
|
||
export const refreshPageState = atom({ | ||
key: 'refreshOrgPageState', | ||
default: 0, | ||
}); | ||
|
||
// Organization List page | ||
export const selectedOrgsState = atom<IOrganization[]>({ | ||
export const selectedOrgsState = atom<OrganizationsTableItem[]>({ | ||
key: 'selectedOrgsState', | ||
default: [], | ||
}); | ||
|
||
export const searchOrgsState = atom<SearchState>({ | ||
key: 'searchOrgsState', | ||
default: { | ||
query: '', | ||
field: ColumnNames.name, | ||
isRegEx: false, | ||
}, | ||
}); | ||
|
||
export const searchOrgsFilterState = selector({ | ||
key: 'searchOrgsFilter', | ||
get: ({get}) => { | ||
const search = get(searchOrgsState); | ||
if (search.query === '') { | ||
return null; | ||
} | ||
|
||
const filterByName = (org: OrganizationDetail) => | ||
org.name.includes(search.query); | ||
const filterByNameRegex = (org: OrganizationDetail) => { | ||
try { | ||
const regex = new RegExp(search.query, 'i'); | ||
return regex.test(org.name); | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
|
||
if (search.isRegEx) { | ||
return filterByNameRegex; | ||
} else { | ||
return filterByName; | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.