Extends search filters

This add some new features to action filtering : cumulative filtering and term excluding using the '-' character
This commit is contained in:
vthibault 2020-02-08 19:58:13 +01:00
parent 03d1448dc3
commit 34c50b5f90
3 changed files with 33 additions and 14 deletions

View File

@ -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

View File

@ -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) => {

View File

@ -5,7 +5,9 @@ export const DEFAULT_STATE = {
startActionId: null,
inspectedActionPath: [],
inspectedStatePath: [],
tabName: 'Diff'
tabName: 'Diff',
searchInclude: [],
searchExclude: []
};
export function updateMonitorState(monitorState) {