Commit e60e8058 authored by Robert Knight's avatar Robert Knight

Allow clearing filter query via `store.setFilterQuery(null)`

parent 5e632d59
......@@ -149,7 +149,7 @@ const reducers = {
return { filters: updatedFilters };
},
SET_FILTER_QUERY(state: State, action: { query: string }) {
SET_FILTER_QUERY(state: State, action: { query: string | null }) {
return { query: action.query };
},
......@@ -217,9 +217,10 @@ function setFilter(filterName: FilterKey, filterOption: FilterOption) {
}
/**
* Set the query used to filter displayed annotations.
* Set the query used to filter displayed annotations or `null` to clear the
* filter.
*/
function setFilterQuery(query: string) {
function setFilterQuery(query: string | null) {
return makeAction(reducers, 'SET_FILTER_QUERY', { query });
}
......
......@@ -138,10 +138,12 @@ describe('sidebar/store/modules/filters', () => {
});
describe('setFilterQuery', () => {
['a-query', '', null].forEach(query => {
it('sets the filter query', () => {
store.setFilterQuery('a-query');
assert.equal(getFiltersState().query, 'a-query');
assert.equal(store.filterQuery(), 'a-query');
store.setFilterQuery(query);
assert.equal(getFiltersState().query, query);
assert.equal(store.filterQuery(), query);
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment