Bug 1440068 - Filtering messages in webconsole on groups. r=nchevobbe
MozReview-Commit-ID: JpLRD9gq1Bf
--- a/devtools/client/webconsole/reducers/messages.js
+++ b/devtools/client/webconsole/reducers/messages.js
@@ -341,19 +341,57 @@ function messages(state = MessageState()
if (visible) {
messagesToShow.push(msgId);
} else if (DEFAULT_FILTERS.includes(cause)) {
filtered.global = filtered.global + 1;
filtered[cause] = filtered[cause] + 1;
}
});
+ // if msg is part of group, then add all parents
+ let parentMsgIds = [];
+ messagesToShow.forEach(msgId => {
+ let groupIds = [];
+ let message = messagesById.get(msgId);
+ // push the immediate parent
+ groupIds.push(message.groupId);
+ // push all ancestors
+ if (state.groupsById.get(message.groupId)) {
+ groupIds.push(...state.groupsById.get(message.groupId));
+ }
+
+ groupIds.forEach(groupId => {
+ if (!parentMsgIds.includes(groupId)) {
+ parentMsgIds.push(groupId);
+ }
+ });
+ });
+
+ // if msg is a group then add all its children
+ let childIds = [];
+ messagesById.forEach((message, msgId) => {
+ if (messagesToShow.includes(message.groupId) || childIds.includes(message.groupId)) {
+ childIds.push(msgId);
+ }
+ });
+
+ let finalMsgsToShow = [];
+ messagesById.forEach((message, msgId) => {
+ if (childIds.includes(msgId) || // if message is a group, all children of that group should be shown
+ messagesToShow.includes(msgId) || // the individual filtered message
+ parentMsgIds.includes(msgId)) { // if message is being shown, then all ancestors should be shown
+ if (!finalMsgsToShow.includes(msgId)) {
+ finalMsgsToShow.push(msgId)
+ }
+ }
+ });
+
return {
...state,
- visibleMessages: messagesToShow,
+ visibleMessages: finalMsgsToShow,
filteredMessagesCount: filtered,
};
}
return state;
}
/**
@@ -586,24 +624,16 @@ function getMessageVisibility(message, m
&& !isInOpenedGroup(message, messagesState.groupsById, messagesState.messagesUiById)
) {
return {
visible: false,
cause: "closedGroup"
};
}
- // Some messages can't be filtered out (e.g. groups).
- // So, always return visible: true for those.
- if (isUnfilterable(message)) {
- return {
- visible: true
- };
- }
-
if (!passSearchFilters(message, filtersState)) {
return {
visible: false,
cause: FILTERS.TEXT
};
}
// Let's check all level filters (error, warn, log, …) and return visible: false