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,
|
startActionId,
|
||||||
onSelect,
|
onSelect,
|
||||||
onSearch,
|
onSearch,
|
||||||
searchValue,
|
searchInclude,
|
||||||
|
searchExclude,
|
||||||
currentActionId,
|
currentActionId,
|
||||||
hideMainButtons,
|
hideMainButtons,
|
||||||
hideActionButtons,
|
hideActionButtons,
|
||||||
|
@ -93,14 +94,14 @@ export default class ActionList extends Component {
|
||||||
onSweep,
|
onSweep,
|
||||||
onJumpToState
|
onJumpToState
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const lowerSearchValue = searchValue && searchValue.toLowerCase();
|
|
||||||
const filteredActionIds = searchValue
|
const filteredActionIds = actionIds.filter(id => {
|
||||||
? actionIds.filter(
|
const type = actions[id].action.type.toLowerCase();
|
||||||
id =>
|
return (
|
||||||
actions[id].action.type.toLowerCase().indexOf(lowerSearchValue) !==
|
searchExclude.every(searchData => !type.includes(searchData)) &&
|
||||||
-1
|
searchInclude.every(searchData => type.includes(searchData))
|
||||||
)
|
);
|
||||||
: actionIds;
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -219,7 +219,8 @@ export default class DevtoolsInspector extends Component {
|
||||||
const {
|
const {
|
||||||
selectedActionId,
|
selectedActionId,
|
||||||
startActionId,
|
startActionId,
|
||||||
searchValue,
|
searchInclude,
|
||||||
|
searchExclude,
|
||||||
tabName
|
tabName
|
||||||
} = monitorState;
|
} = monitorState;
|
||||||
const inspectedPathType =
|
const inspectedPathType =
|
||||||
|
@ -248,7 +249,8 @@ export default class DevtoolsInspector extends Component {
|
||||||
actions,
|
actions,
|
||||||
actionIds,
|
actionIds,
|
||||||
isWideLayout,
|
isWideLayout,
|
||||||
searchValue,
|
searchInclude,
|
||||||
|
searchExclude,
|
||||||
selectedActionId,
|
selectedActionId,
|
||||||
startActionId,
|
startActionId,
|
||||||
skippedActionIds,
|
skippedActionIds,
|
||||||
|
@ -322,8 +324,22 @@ export default class DevtoolsInspector extends Component {
|
||||||
this.props.dispatch(sweep());
|
this.props.dispatch(sweep());
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSearch = val => {
|
handleSearch = value => {
|
||||||
this.updateMonitorState({ searchValue: val });
|
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) => {
|
handleSelectAction = (e, actionId) => {
|
||||||
|
|
|
@ -5,7 +5,9 @@ export const DEFAULT_STATE = {
|
||||||
startActionId: null,
|
startActionId: null,
|
||||||
inspectedActionPath: [],
|
inspectedActionPath: [],
|
||||||
inspectedStatePath: [],
|
inspectedStatePath: [],
|
||||||
tabName: 'Diff'
|
tabName: 'Diff',
|
||||||
|
searchInclude: [],
|
||||||
|
searchExclude: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updateMonitorState(monitorState) {
|
export function updateMonitorState(monitorState) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user