Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions packages/redux-devtools-inspector/src/ActionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,23 @@ export default class ActionList extends Component {
startActionId,
onSelect,
onSearch,
searchValue,
searchInclude,
searchExclude,
currentActionId,
hideMainButtons,
hideActionButtons,
onCommit,
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
Expand Down
24 changes: 20 additions & 4 deletions packages/redux-devtools-inspector/src/DevtoolsInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ export default class DevtoolsInspector extends Component {
const {
selectedActionId,
startActionId,
searchValue,
searchInclude,
searchExclude,
tabName
} = monitorState;
const inspectedPathType =
Expand Down Expand Up @@ -248,7 +249,8 @@ export default class DevtoolsInspector extends Component {
actions,
actionIds,
isWideLayout,
searchValue,
searchInclude,
searchExclude,
selectedActionId,
startActionId,
skippedActionIds,
Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/redux-devtools-inspector/src/redux.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export const DEFAULT_STATE = {
startActionId: null,
inspectedActionPath: [],
inspectedStatePath: [],
tabName: 'Diff'
tabName: 'Diff',
searchInclude: [],
searchExclude: []
};

export function updateMonitorState(monitorState) {
Expand Down