Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs UI] Set streamLive false in URL state when arriving from link-to #56329

Merged
merged 12 commits into from
Feb 7, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ export const WithLogPositionUrlState = () => {
startLiveStreaming,
stopLiveStreaming,
} = useContext(LogPositionState.Context);
const urlState = useMemo(
() => ({
position: visibleMidpoint ? pickTimeKey(visibleMidpoint) : null,
streamLive: isAutoReloading,
}),
[visibleMidpoint, isAutoReloading]
);
const urlState = useMemo(() => {
const position = visibleMidpoint ? pickTimeKey(visibleMidpoint) : null;
if (isAutoReloading) return { position, streamLive: true };
return { position };
}, [visibleMidpoint, isAutoReloading]);
return (
<UrlStateContainer
urlState={urlState}
Expand Down Expand Up @@ -72,7 +70,7 @@ const mapToUrlState = (value: any): LogPositionUrlState | undefined =>
value
? {
position: mapToPositionUrlState(value.position),
streamLive: mapToStreamLiveUrlState(value.streamLive),
...(value.streamLive ? { streamLive: true } : {}),
}
: undefined;

Expand All @@ -81,8 +79,6 @@ const mapToPositionUrlState = (value: any) =>
? pickTimeKey(value)
: undefined;

const mapToStreamLiveUrlState = (value: any) => (typeof value === 'boolean' ? value : undefined);

export const replaceLogPositionInQueryString = (time: number) =>
Number.isNaN(time)
? (value: string) => value
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/infra/link_to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
state: undefined,
};
const expectedSearchString =
"logFilter=(expression:'trace.id:433b4651687e18be2c6c8e3b11f53d09',kind:kuery)&logPosition=(position:(tiebreaker:0,time:1565707203194),streamLive:!f)&sourceId=default";
"logFilter=(expression:'trace.id:433b4651687e18be2c6c8e3b11f53d09',kind:kuery)&logPosition=(position:(tiebreaker:0,time:1565707203194))&sourceId=default";
const expectedRedirectPath = '/logs/stream?';

await pageObjects.common.navigateToActualUrl(
Expand Down