Commit 9aee7186 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch 'milestone-fix-collapse-search' into 'milestone-logbook-search-settings'

fix search result in collapsed events

See merge request !523
parents 4aeedb65 da26127c
Pipeline #48272 passed with stage
in 5 minutes and 7 seconds
......@@ -16,14 +16,18 @@ function collapse(items) {
const collapsed = [];
for (let i = 0; i < items.length; i++) {
const event = items[i];
if (event.category) {
if (event.category && !isEventSearchedResult(event)) {
if (
event.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE &&
!event.previousVersionEvent
) {
const lastEvent = collapsed[collapsed.length - 1];
if (lastEvent && lastEvent.category) {
if (lastEvent.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE) {
if (
lastEvent.category.toLowerCase() === EVENT_CATEGORY_COMMANDLINE &&
!isEventSearchedResult(lastEvent)
) {
if (!lastEvent.events) {
lastEvent.events = [event];
} else {
......@@ -41,6 +45,12 @@ function collapse(items) {
return collapsed;
}
function isEventSearchedResult(event) {
const { hash } = window.location;
const id = hash ? hash.replace('#', '') : undefined;
return id && id === event._id;
}
/** Returns the list of items to be displayed in the table: events + days */
function getItems(events, automaticCollapsing) {
const eventsCopy = cloneDeep(events);
......@@ -86,11 +96,14 @@ function EventList(props) {
return <UserMessage type="info" message="No log found." />;
}
const collapseEvents =
search && search.length > 0 ? false : automaticCollapsing;
return (
<>
<Table responsive style={{ border: 0 }}>
<tbody>
{getItems(events, automaticCollapsing).map((event, index) => {
{getItems(events, collapseEvents).map((event, index) => {
if (event.type === 'date') {
return (
<tr
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment