mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-29 04:53:54 +03:00
Extends search filters
This add some new features to action filtering : cumulative filtering and term excluding using the '-' character
This commit is contained in:
parent
03d1448dc3
commit
34c50b5f90
|
@ -85,7 +85,8 @@ export default class ActionList extends Component {
|
|||
startActionId,
|
||||
onSelect,
|
||||
onSearch,
|
||||
searchValue,
|
||||
searchInclude,
|
||||
searchExclude,
|
||||
currentActionId,
|
||||
hideMainButtons,
|
||||
hideActionButtons,
|
||||
|
@ -93,14 +94,14 @@ export default class ActionList extends Component {
|
|||
onSweep,
|
||||
onJumpToState
|
||||
} = this.props;
|
||||
const lowerSearchValue = searchValue && searchValue.toLowerCase();
|
||||
const filteredActionIds = searchValue
|
||||
? actionIds.filter(
|
||||
id =>
|
||||
actions[id].action.type.toLowerCase().indexOf(lowerSearchValue) !==
|
||||
-1
|
||||
)
|
||||
: actionIds;
|
||||
|
||||
const filteredActionIds = actionIds.filter(id => {
|
||||
const type = actions[id].action.type.toLowerCase();
|
||||
return (
|
||||
searchExclude.every(searchData => !type.includes(searchData)) &&
|
||||
searchInclude.every(searchData => type.includes(searchData))
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
@ -219,7 +219,8 @@ export default class DevtoolsInspector extends Component {
|
|||
const {
|
||||
selectedActionId,
|
||||
startActionId,
|
||||
searchValue,
|
||||
searchInclude,
|
||||
searchExclude,
|
||||
tabName
|
||||
} = monitorState;
|
||||
const inspectedPathType =
|
||||
|
@ -248,7 +249,8 @@ export default class DevtoolsInspector extends Component {
|
|||
actions,
|
||||
actionIds,
|
||||
isWideLayout,
|
||||
searchValue,
|
||||
searchInclude,
|
||||
searchExclude,
|
||||
selectedActionId,
|
||||
startActionId,
|
||||
skippedActionIds,
|
||||
|
@ -322,8 +324,22 @@ export default class DevtoolsInspector extends Component {
|
|||
this.props.dispatch(sweep());
|
||||
};
|
||||
|
||||
handleSearch = val => {
|
||||
this.updateMonitorState({ searchValue: val });
|
||||
handleSearch = value => {
|
||||
const segments = value.toLowerCase().trim().split(/\s+/);
|
||||
const searchInclude = [];
|
||||
const searchExclude = [];
|
||||
|
||||
segments.forEach(segment => {
|
||||
if (segment.charAt(0) === '-') {
|
||||
if (segment.length > 1) {
|
||||
searchExclude.push(segment.substr(1));
|
||||
}
|
||||
} else {
|
||||
searchInclude.push(segment);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateMonitorState({ searchInclude, searchExclude });
|
||||
};
|
||||
|
||||
handleSelectAction = (e, actionId) => {
|
||||
|
|
|
@ -5,7 +5,9 @@ export const DEFAULT_STATE = {
|
|||
startActionId: null,
|
||||
inspectedActionPath: [],
|
||||
inspectedStatePath: [],
|
||||
tabName: 'Diff'
|
||||
tabName: 'Diff',
|
||||
searchInclude: [],
|
||||
searchExclude: []
|
||||
};
|
||||
|
||||
export function updateMonitorState(monitorState) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user