Skip to content

Commit

Permalink
Move page template out of context hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Feb 15, 2023
1 parent 45328af commit 9b75916
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
11 changes: 7 additions & 4 deletions x-pack/plugins/infra/public/pages/logs/stream/page_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
} from '../../../observability_logs/log_stream_page/state';
import { InvalidStateCallout } from '../../../observability_logs/xstate_helpers';
import { ConnectedLogViewErrorPage } from '../shared/page_log_view_error';
import { StreamPageLogsForState } from './page_logs';
import { LogStreamPageTemplate } from './components/stream_page_template';
import { StreamPageLogsContentForState } from './page_logs_content';
import { StreamPageMissingIndicesContent } from './page_missing_indices_content';
import { LogStreamPageContentProviders } from './page_providers';

Expand All @@ -37,9 +38,11 @@ export const StreamPageContentForState: React.FC<{ logStreamPageState: LogStream
return <StreamPageMissingIndicesContent />;
} else if (logStreamPageState.matches({ hasLogViewIndices: 'initialized' })) {
return (
<LogStreamPageContentProviders logStreamPageState={logStreamPageState}>
<StreamPageLogsForState logStreamPageState={logStreamPageState} />
</LogStreamPageContentProviders>
<LogStreamPageTemplate hasData={true} isDataLoading={false}>
<LogStreamPageContentProviders logStreamPageState={logStreamPageState}>
<StreamPageLogsContentForState logStreamPageState={logStreamPageState} />
</LogStreamPageContentProviders>
</LogStreamPageTemplate>
);
} else {
return <InvalidStateCallout state={logStreamPageState} />;
Expand Down
39 changes: 0 additions & 39 deletions x-pack/plugins/infra/public/pages/logs/stream/page_logs.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import { useViewLogInProviderContext } from '../../../containers/logs/view_log_i
import { WithLogTextviewUrlState } from '../../../containers/logs/with_log_textview';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { useLogViewContext } from '../../../hooks/use_log_view';
import { LogStreamPageActorRef } from '../../../observability_logs/log_stream_page/state';
import { type ParsedQuery } from '../../../observability_logs/log_stream_query_state';
import { MatchedStateFromActor } from '../../../observability_logs/xstate_helpers';
import { datemathToEpochMillis, isValidDatemath } from '../../../utils/datemath';
import { LogsToolbar } from './page_toolbar';
import { PageViewLogInContext } from './page_view_log_in_context';
Expand Down Expand Up @@ -281,6 +283,21 @@ export const StreamPageLogsContent = React.memo<{
);
});

type InitializedLogStreamPageState = MatchedStateFromActor<
LogStreamPageActorRef,
{ hasLogViewIndices: 'initialized' }
>;

export const StreamPageLogsContentForState = React.memo<{
logStreamPageState: InitializedLogStreamPageState;
}>(({ logStreamPageState }) => {
const {
context: { parsedQuery },
} = logStreamPageState;

return <StreamPageLogsContent filterQuery={parsedQuery} />;
});

const LogPageMinimapColumn = euiStyled.div`
flex: 1 0 0%;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const LogEntriesStateProvider: React.FC<{
);
};

export const LogHighlightsState: React.FC<{
const LogHighlightsState: React.FC<{
logStreamPageState: InitializedLogStreamPageState;
}> = ({ children, logStreamPageState }) => {
const { logViewId, logView } = useLogViewContext();
Expand Down Expand Up @@ -97,7 +97,9 @@ export const LogStreamPageContentProviders: React.FC<{
<LogPositionStateProvider>
<ViewLogInContext>
<LogEntriesStateProvider logStreamPageState={logStreamPageState}>
{children}
<LogHighlightsState logStreamPageState={logStreamPageState}>
{children}
</LogHighlightsState>
</LogEntriesStateProvider>
</ViewLogInContext>
</LogPositionStateProvider>
Expand Down

0 comments on commit 9b75916

Please sign in to comment.