Skip to content
Snippets Groups Projects
Commit 66fcf185 authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Use case-insensitive search in dashboard list, extract search to lib/string

parent 5b31e698
No related branches found
No related tags found
No related merge requests found
......@@ -16,9 +16,12 @@ import Icon from "metabase/components/Icon.jsx";
import SearchHeader from "metabase/components/SearchHeader";
import EmptyState from "metabase/components/EmptyState";
import {caseInsensitiveSearch} from "metabase/lib/string"
import * as dashboardsActions from "../dashboards";
import {getDashboardListing} from "../selectors";
const mapStateToProps = (state, props) => ({
dashboards: getDashboardListing(state)
});
......@@ -77,7 +80,7 @@ export class Dashboards extends Component {
return dashboards;
} else {
return dashboards.filter(({name, description}) =>
name.includes(searchText) || (description && description.includes(searchText))
caseInsensitiveSearch(name,searchText) || (description && caseInsensitiveSearch(description, searchText))
);
}
}
......
......@@ -12,3 +12,7 @@ export function createMultiwordSearchRegex(input) {
}
export const countLines = (str) => str.split(/\n/g).length
export function caseInsensitiveSearch(haystack, needle) {
return !needle || (haystack != null && haystack.toLowerCase().indexOf(needle.toLowerCase()) >= 0);
}
......@@ -5,10 +5,7 @@ import { getIn } from "icepick";
import _ from "underscore";
import visualizations from "metabase/visualizations";
function caseInsensitiveSearch(haystack, needle) {
return !needle || (haystack != null && haystack.toLowerCase().indexOf(needle.toLowerCase()) >= 0);
}
import {caseInsensitiveSearch} from "metabase/lib/string"
export const getEntityType = (state, props) => props && props.entityType ? props.entityType : state.questions.lastEntityType;
export const getEntityQuery = (state, props) => props && props.entityQuery ? JSON.stringify(props.entityQuery) : state.questions.lastEntityQuery;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment