Add basic output tailing

When follow mode is enabled, fix the scroll position to the highest row
so that the output panel is always displaying the latest events.
This commit is contained in:
Jake McDermott 2021-05-05 11:13:23 -04:00 committed by Alan Rominger
parent 4052603238
commit 768ac01f58
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559

View File

@ -183,6 +183,11 @@ const OutputWrapper = styled.div`
Object.keys(cssMap).map(className => `.${className}{${cssMap[className]}}`)}
`;
const ListWrapper = styled(List)`
${({ isFollowModeEnabled }) =>
isFollowModeEnabled ? `overflow: hidden !important;` : ''}
`;
const OutputFooter = styled.div`
background-color: #ebebeb;
border-right: 1px solid #d7d7d7;
@ -310,6 +315,7 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
const [showCancelModal, setShowCancelModal] = useState(false);
const [remoteRowCount, setRemoteRowCount] = useState(0);
const [results, setResults] = useState({});
const [isFollowModeEnabled, setIsFollowModeEnabled] = useState(false);
useEffect(() => {
loadJobEvents();
@ -657,6 +663,14 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
history.push(qs ? `${pathname}?${qs}` : pathname);
};
const handleFollowToggle = () => setIsFollowModeEnabled(!isFollowModeEnabled);
useEffect(() => {
if (isFollowModeEnabled) {
scrollToRow(remoteRowCount);
}
}, [remoteRowCount, isFollowModeEnabled]);
const renderSearchComponent = () => (
<Search
qsConfig={QS_CONFIG}
@ -763,6 +777,11 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
)}
</ToolbarItem>
</ToolbarToggleGroup>
{isJobRunning(job.status) ? (
<Button onClick={handleFollowToggle}>
{isFollowModeEnabled ? t`Unfollow` : t`Follow`}
</Button>
) : null}
</SearchToolbarContent>
</SearchToolbar>
<PageControls
@ -771,7 +790,10 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
onScrollNext={handleScrollNext}
onScrollPrevious={handleScrollPrevious}
/>
<OutputWrapper cssMap={cssMap}>
<OutputWrapper
cssMap={cssMap}
isFollowModeEnabled={isFollowModeEnabled}
>
<InfiniteLoader
isRowLoaded={isRowLoaded}
loadMoreRows={loadMoreRows}
@ -787,7 +809,8 @@ function JobOutput({ job, eventRelatedSearchableKeys, eventSearchableKeys }) {
<ContentLoading />
</div>
) : (
<List
<ListWrapper
isFollowModeEnabled={isFollowModeEnabled}
ref={ref => {
registerChild(ref);
listRef.current = ref;