Skip to content

Commit

Permalink
[Logs UI] Fix Check for New Data button on empty indices screen (#56239)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary authored Jan 29, 2020
1 parent 58722e5 commit 759663c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface ScrollableLogTextStreamViewProps {
fromScroll: boolean;
}) => any;
loadNewerItems: () => void;
reloadItems: () => void;
setFlyoutItem: (id: string) => void;
setFlyoutVisibility: (visible: boolean) => void;
highlightedItem: string | null;
Expand Down Expand Up @@ -269,10 +270,10 @@ export class ScrollableLogTextStreamView extends React.PureComponent<
};

private handleReload = () => {
const { jumpToTarget, target } = this.props;
const { reloadItems } = this.props;

if (target) {
jumpToTarget(target);
if (reloadItems) {
reloadItems();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type LogEntriesStateParams = {

export interface LogEntriesCallbacks {
fetchNewerEntries: () => Promise<TimeKey | null | undefined>;
checkForNewEntries: () => Promise<void>;
}
export const logEntriesInitialCallbacks = {
fetchNewerEntries: async () => {},
Expand Down Expand Up @@ -231,16 +232,16 @@ const useFetchEntriesEffect = (
useEffect(fetchMoreEntriesEffect, fetchMoreEntriesEffectDependencies);
useEffect(streamEntriesEffect, streamEntriesEffectDependencies);

return { fetchNewerEntries };
return { fetchNewerEntries, checkForNewEntries: runFetchNewEntriesRequest };
};

export const useLogEntriesState: (
props: LogEntriesProps
) => [LogEntriesStateParams, LogEntriesCallbacks] = props => {
const [state, dispatch] = useReducer(logEntriesStateReducer, logEntriesInitialState);

const { fetchNewerEntries } = useFetchEntriesEffect(state, dispatch, props);
const callbacks = { fetchNewerEntries };
const { fetchNewerEntries, checkForNewEntries } = useFetchEntriesEffect(state, dispatch, props);
const callbacks = { fetchNewerEntries, checkForNewEntries };

return [state, callbacks];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
items,
lastLoadedTime,
fetchNewerEntries,
checkForNewEntries,
}) => (
<ScrollableLogTextStreamView
columnConfigurations={(source && source.configuration.logColumns) || []}
Expand All @@ -94,6 +95,7 @@ export const LogsPageLogsContent: React.FunctionComponent = () => {
jumpToTarget={jumpToTargetPosition}
lastLoadedTime={lastLoadedTime}
loadNewerItems={fetchNewerEntries}
reloadItems={checkForNewEntries}
reportVisibleInterval={reportVisiblePositions}
scale={textScale}
target={targetPosition}
Expand Down

0 comments on commit 759663c

Please sign in to comment.