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

View File

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

View File

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