Fix regex special character filter match bug and revert Query Editor autocomplete filter
parent
32e481d7d4
commit
ccf23e4f48
|
@ -34,15 +34,16 @@ const AlertsTable = React.createClass({
|
||||||
|
|
||||||
filterAlerts(searchTerm, newAlerts) {
|
filterAlerts(searchTerm, newAlerts) {
|
||||||
const alerts = newAlerts || this.props.alerts
|
const alerts = newAlerts || this.props.alerts
|
||||||
|
const filterText = searchTerm.toLowerCase()
|
||||||
const filteredAlerts = alerts.filter(h => {
|
const filteredAlerts = alerts.filter(h => {
|
||||||
if (h.host === null || h.name === null || h.level === null) {
|
if (h.host === null || h.name === null || h.level === null) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h.name.toLowerCase().search(searchTerm.toLowerCase()) !== -1 ||
|
h.name.toLowerCase().includes(filterText) ||
|
||||||
h.host.toLowerCase().search(searchTerm.toLowerCase()) !== -1 ||
|
h.host.toLowerCase().includes(filterText) ||
|
||||||
h.level.toLowerCase().search(searchTerm.toLowerCase()) !== -1
|
h.level.toLowerCase().includes(filterText)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
this.setState({searchTerm, filteredAlerts})
|
this.setState({searchTerm, filteredAlerts})
|
||||||
|
|
|
@ -115,8 +115,9 @@ const MeasurementList = React.createClass({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filterText = this.state.filterText.toLowerCase()
|
||||||
const measurements = this.state.measurements.filter(m =>
|
const measurements = this.state.measurements.filter(m =>
|
||||||
m.match(this.state.filterText)
|
m.toLowerCase().includes(filterText)
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -162,9 +162,12 @@ class QueryEditor extends Component {
|
||||||
if (matched && !_.isEmpty(templates)) {
|
if (matched && !_.isEmpty(templates)) {
|
||||||
// maintain cursor poition
|
// maintain cursor poition
|
||||||
const start = this.editor.selectionStart
|
const start = this.editor.selectionStart
|
||||||
|
|
||||||
const end = this.editor.selectionEnd
|
const end = this.editor.selectionEnd
|
||||||
|
const filterText = matched[0].substr(1).toLowerCase()
|
||||||
|
|
||||||
const filteredTemplates = templates.filter(t =>
|
const filteredTemplates = templates.filter(t =>
|
||||||
t.tempVar.startsWith(matched[0])
|
t.tempVar.toLowerCase().includes(filterText)
|
||||||
)
|
)
|
||||||
|
|
||||||
const found = filteredTemplates.find(
|
const found = filteredTemplates.find(
|
||||||
|
|
|
@ -52,7 +52,8 @@ const TagListItem = React.createClass({
|
||||||
return <div>no tag values</div>
|
return <div>no tag values</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
const filtered = tagValues.filter(v => v.match(this.state.filterText))
|
const filterText = this.state.filterText.toLowerCase()
|
||||||
|
const filtered = tagValues.filter(v => v.toLowerCase().includes(filterText))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="query-builder--sub-list">
|
<div className="query-builder--sub-list">
|
||||||
|
|
|
@ -35,20 +35,21 @@ const HostsTable = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
filter(allHosts, searchTerm) {
|
filter(allHosts, searchTerm) {
|
||||||
|
const filterText = searchTerm.toLowerCase()
|
||||||
return allHosts.filter(h => {
|
return allHosts.filter(h => {
|
||||||
const apps = h.apps ? h.apps.join(', ') : ''
|
const apps = h.apps ? h.apps.join(', ') : ''
|
||||||
// search each tag for the presence of the search term
|
// search each tag for the presence of the search term
|
||||||
let tagResult = false
|
let tagResult = false
|
||||||
if (h.tags) {
|
if (h.tags) {
|
||||||
tagResult = Object.keys(h.tags).reduce((acc, key) => {
|
tagResult = Object.keys(h.tags).reduce((acc, key) => {
|
||||||
return acc || h.tags[key].search(searchTerm) !== -1
|
return acc || h.tags[key].toLowerCase().includes(filterText)
|
||||||
}, false)
|
}, false)
|
||||||
} else {
|
} else {
|
||||||
tagResult = false
|
tagResult = false
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
h.name.search(searchTerm) !== -1 ||
|
h.name.toLowerCase().includes(filterText) ||
|
||||||
apps.search(searchTerm) !== -1 ||
|
apps.toLowerCase().includes(filterText) ||
|
||||||
tagResult
|
tagResult
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -120,11 +120,11 @@ class Dropdown extends Component {
|
||||||
|
|
||||||
applyFilter(searchTerm) {
|
applyFilter(searchTerm) {
|
||||||
const {items} = this.props
|
const {items} = this.props
|
||||||
const matchingItems = items.filter(item => {
|
const filterText = searchTerm.toLowerCase()
|
||||||
if (item.text === null) {
|
const matchingItems = items.filter(item =>
|
||||||
return false
|
item.text.toLowerCase().includes(filterText)
|
||||||
}
|
)
|
||||||
return item.text.toLowerCase().search(searchTerm.toLowerCase()) !== -1
|
|
||||||
})
|
})
|
||||||
this.setState({filteredItems: matchingItems})
|
this.setState({filteredItems: matchingItems})
|
||||||
this.setState({highlightedItemIndex: 0})
|
this.setState({highlightedItemIndex: 0})
|
||||||
|
|
Loading…
Reference in New Issue