-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(filters): wrap badges + clear/disable filters on dashboard switch…
… and edit mode (#280) Remove filters when switching dashboard Filters are not removed when the same dashboard is (re)selected. Also disable filters when switching to edit mode and enable them again when returning to view mode. Wrap filter badges instead of text in them.
- Loading branch information
Showing
13 changed files
with
164 additions
and
187 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import reducer, { | ||
DEFAULT_STATE_EDIT_ITEM_FILTERS, | ||
SET_EDIT_ITEM_FILTERS, | ||
REMOVE_EDIT_ITEM_FILTER, | ||
CLEAR_EDIT_ITEM_FILTERS, | ||
} from '../editItemFilters'; | ||
|
||
const testKey = 'ou'; | ||
const testValue = [{ id: 'ou1', name: 'OU test' }]; | ||
|
||
const testState = { | ||
[testKey]: testValue, | ||
}; | ||
|
||
describe('item filter reducer', () => { | ||
describe('reducer', () => { | ||
it('should return the default state', () => { | ||
const actualState = reducer(DEFAULT_STATE_EDIT_ITEM_FILTERS, {}); | ||
|
||
expect(actualState).toEqual(DEFAULT_STATE_EDIT_ITEM_FILTERS); | ||
}); | ||
|
||
it('should set a filter', () => { | ||
const action = { | ||
type: SET_EDIT_ITEM_FILTERS, | ||
filters: testState, | ||
}; | ||
|
||
const expectedState = testState; | ||
|
||
const actualState = reducer(undefined, action); | ||
|
||
expect(actualState).toEqual(expectedState); | ||
}); | ||
|
||
it('should remove a filter', () => { | ||
const action = { | ||
type: REMOVE_EDIT_ITEM_FILTER, | ||
id: testKey, | ||
}; | ||
|
||
const expectedState = DEFAULT_STATE_EDIT_ITEM_FILTERS; | ||
|
||
const actualState = reducer(testState, action); | ||
|
||
expect(actualState).toEqual(expectedState); | ||
}); | ||
|
||
it('should clear all filters', () => { | ||
const action = { | ||
type: CLEAR_EDIT_ITEM_FILTERS, | ||
}; | ||
|
||
const expectedState = DEFAULT_STATE_EDIT_ITEM_FILTERS; | ||
|
||
const actualState = reducer(testState, action); | ||
|
||
expect(actualState).toEqual(expectedState); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.