Skip to content

Commit 30f9765

Browse files
authored
Keep loading more events if no initial results doesnt for filter (#1101)
1 parent 0f2f788 commit 30f9765

File tree

2 files changed

+89
-60
lines changed

2 files changed

+89
-60
lines changed

src/views/workflow-history/__tests__/workflow-history.test.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,31 @@ describe('WorkflowHistory', () => {
190190
});
191191
});
192192

193-
it('should show no results when filtered events are empty', async () => {
194-
await setup({ emptyEvents: true });
193+
it('should show no results when filtered events are empty and no next page', async () => {
194+
await setup({ emptyEvents: true, hasNextPage: false });
195195
expect(await screen.findByText('No Results')).toBeInTheDocument();
196196
});
197197

198+
it('should not show no results when filtered events are empty but has next page', async () => {
199+
await setup({
200+
emptyEvents: true,
201+
hasNextPage: true,
202+
});
203+
204+
// Should not show "No Results" when there's a next page
205+
expect(screen.queryByText('No Results')).not.toBeInTheDocument();
206+
207+
// Should show the load more footer component instead
208+
expect(screen.getByText('Load more')).toBeInTheDocument();
209+
});
210+
211+
it('should not show no results when there are filtered events', async () => {
212+
await setup({});
213+
await waitFor(() => {
214+
expect(screen.queryByText('No Results')).not.toBeInTheDocument();
215+
});
216+
});
217+
198218
it('should show ungrouped table when ungrouped view is enabled', async () => {
199219
setup({ pageQueryParamsValues: { ungroupedHistoryViewEnabled: true } });
200220
expect(await screen.findByText('Ungrouped Table')).toBeInTheDocument();

src/views/workflow-history/workflow-history.tsx

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ export default function WorkflowHistory({ params }: Props) {
324324
return <SectionLoadingIndicator />;
325325
}
326326

327+
const showHasNoResults =
328+
filteredEventGroupsEntries.length === 0 && !hasNextPage;
329+
327330
return (
328331
<div className={cls.container}>
329332
<WorkflowHistoryHeader
@@ -387,7 +390,7 @@ export default function WorkflowHistory({ params }: Props) {
387390
}}
388391
/>
389392
<PageSection className={cls.contentSection}>
390-
{filteredEventGroupsEntries.length > 0 && (
393+
{!showHasNoResults && (
391394
<>
392395
{isUngroupedHistoryViewEnabled ? (
393396
<section className={cls.ungroupedEventsContainer}>
@@ -414,63 +417,69 @@ export default function WorkflowHistory({ params }: Props) {
414417
</section>
415418
) : (
416419
<div className={cls.eventsContainer}>
417-
<div role="list" className={cls.compactSection}>
418-
<Virtuoso
419-
data={filteredEventGroupsEntries}
420-
ref={compactSectionListRef}
421-
rangeChanged={({ startIndex, endIndex }) =>
422-
setTimelineListVisibleRange((currentRanges) => ({
423-
...currentRanges,
424-
compactStartIndex: startIndex,
425-
compactEndIndex: endIndex,
426-
}))
427-
}
428-
{...(initialEventGroupIndex === undefined
429-
? {}
430-
: {
431-
initialTopMostItemIndex: initialEventGroupIndex,
432-
})}
433-
itemContent={(index, [groupId, group]) => (
434-
<div role="listitem" className={cls.compactCardContainer}>
435-
<WorkflowHistoryCompactEventCard
436-
key={groupId}
437-
{...group}
438-
statusReady={
439-
!group.hasMissingEvents ||
440-
reachedEndOfAvailableHistory
441-
}
442-
workflowCloseStatus={
443-
workflowExecutionInfo?.closeStatus
444-
}
445-
workflowIsArchived={
446-
workflowExecutionInfo?.isArchived || false
447-
}
448-
workflowCloseTimeMs={workflowCloseTimeMs}
449-
showLabelPlaceholder={!group.label}
450-
selected={group.events.some(
451-
(e) =>
452-
e.eventId === queryParams.historySelectedEventId
453-
)}
454-
disabled={!Boolean(group.events[0].eventId)}
455-
onClick={() => {
456-
if (group.events[0].eventId)
457-
setQueryParams({
458-
historySelectedEventId: group.events[0].eventId,
420+
{filteredEventGroupsEntries.length > 0 && (
421+
<div role="list" className={cls.compactSection}>
422+
<Virtuoso
423+
data={filteredEventGroupsEntries}
424+
ref={compactSectionListRef}
425+
rangeChanged={({ startIndex, endIndex }) =>
426+
setTimelineListVisibleRange((currentRanges) => ({
427+
...currentRanges,
428+
compactStartIndex: startIndex,
429+
compactEndIndex: endIndex,
430+
}))
431+
}
432+
{...(initialEventGroupIndex === undefined
433+
? {}
434+
: {
435+
initialTopMostItemIndex: initialEventGroupIndex,
436+
})}
437+
itemContent={(index, [groupId, group]) => (
438+
<div
439+
role="listitem"
440+
className={cls.compactCardContainer}
441+
>
442+
<WorkflowHistoryCompactEventCard
443+
key={groupId}
444+
{...group}
445+
statusReady={
446+
!group.hasMissingEvents ||
447+
reachedEndOfAvailableHistory
448+
}
449+
workflowCloseStatus={
450+
workflowExecutionInfo?.closeStatus
451+
}
452+
workflowIsArchived={
453+
workflowExecutionInfo?.isArchived || false
454+
}
455+
workflowCloseTimeMs={workflowCloseTimeMs}
456+
showLabelPlaceholder={!group.label}
457+
selected={group.events.some(
458+
(e) =>
459+
e.eventId === queryParams.historySelectedEventId
460+
)}
461+
disabled={!Boolean(group.events[0].eventId)}
462+
onClick={() => {
463+
if (group.events[0].eventId)
464+
setQueryParams({
465+
historySelectedEventId:
466+
group.events[0].eventId,
467+
});
468+
timelineSectionListRef.current?.scrollToIndex({
469+
index,
470+
align: 'start',
471+
behavior: 'auto',
459472
});
460-
timelineSectionListRef.current?.scrollToIndex({
461-
index,
462-
align: 'start',
463-
behavior: 'auto',
464-
});
465-
}}
466-
/>
467-
</div>
468-
)}
469-
endReached={() => {
470-
manualFetchNextPage();
471-
}}
472-
/>
473-
</div>
473+
}}
474+
/>
475+
</div>
476+
)}
477+
endReached={() => {
478+
manualFetchNextPage();
479+
}}
480+
/>
481+
</div>
482+
)}
474483
<section className={cls.timelineSection}>
475484
<Virtuoso
476485
useWindowScroll
@@ -542,7 +551,7 @@ export default function WorkflowHistory({ params }: Props) {
542551
)}
543552
</>
544553
)}
545-
{filteredEventGroupsEntries.length === 0 && (
554+
{showHasNoResults && (
546555
<div className={cls.noResultsContainer}>No Results</div>
547556
)}
548557
{resetToDecisionEventId && (

0 commit comments

Comments
 (0)