Skip to content

Commit

Permalink
Merge branch 'master' into kertal-pr-2020-06-30-migrate-search_saved_…
Browse files Browse the repository at this point in the history
…object-to-discover
  • Loading branch information
elasticmachine authored Jul 1, 2020
2 parents a6353da + 518e88c commit 14f59c7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type LogIndexField = rt.TypeOf<typeof logIndexFieldRT>;

const logSourceStatusRT = rt.strict({
logIndexFields: rt.array(logIndexFieldRT),
logIndexNames: rt.array(rt.string),
logIndicesExist: rt.boolean,
});

export type LogSourceStatus = rt.TypeOf<typeof logSourceStatusRT>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ export const useLogSource = ({
[sourceId, fetch]
);

/* eslint-disable-next-line react-hooks/exhaustive-deps */
const logIndicesExist = useMemo(() => (sourceStatus?.logIndexNames?.length ?? 0) > 0, [
sourceStatus,
]);

const derivedIndexPattern = useMemo(
() => ({
fields: sourceStatus?.logIndexFields ?? [],
Expand Down Expand Up @@ -160,7 +155,6 @@ export const useLogSource = ({
loadSourceFailureMessage,
loadSourceConfiguration,
loadSourceStatus,
logIndicesExist,
sourceConfiguration,
sourceId,
sourceStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const StreamPageContent: React.FunctionComponent = () => {
isUninitialized,
loadSource,
loadSourceFailureMessage,
logIndicesExist,
sourceStatus,
} = useLogSourceContext();

if (isLoading || isUninitialized) {
return <SourceLoadingPage />;
} else if (hasFailedLoadingSource) {
return <SourceErrorPage errorMessage={loadSourceFailureMessage ?? ''} retry={loadSource} />;
} else if (logIndicesExist) {
} else if (sourceStatus?.logIndicesExist) {
return <LogsPageLogsContent />;
} else {
return <LogsPageNoIndicesContent />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ const LogHighlightsStateProvider: React.FC = ({ children }) => {
};

export const LogsPageProviders: React.FunctionComponent = ({ children }) => {
const { logIndicesExist } = useLogSourceContext();
const { sourceStatus } = useLogSourceContext();

// The providers assume the source is loaded, so short-circuit them otherwise
if (!logIndicesExist) {
if (!sourceStatus?.logIndicesExist) {
return <>{children}</>;
}

Expand Down
11 changes: 5 additions & 6 deletions x-pack/plugins/infra/server/routes/log_sources/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,16 @@ export const initLogSourceStatusRoutes = ({
const { sourceId } = request.params;

try {
const logIndexNames = await sourceStatus.getLogIndexNames(requestContext, sourceId);
const logIndexFields =
logIndexNames.length > 0
? await fields.getFields(requestContext, sourceId, InfraIndexType.LOGS)
: [];
const logIndicesExist = await sourceStatus.hasLogIndices(requestContext, sourceId);
const logIndexFields = logIndicesExist
? await fields.getFields(requestContext, sourceId, InfraIndexType.LOGS)
: [];

return response.ok({
body: getLogSourceStatusSuccessResponsePayloadRT.encode({
data: {
logIndicesExist,
logIndexFields,
logIndexNames,
},
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { fetchPingHistogram, fetchSnapshotCount } from '../state/api';
import { UptimeFetchDataResponse } from '../../../observability/public/typings/fetch_data_response';
import { UptimeFetchDataResponse } from '../../../observability/public';

export async function fetchUptimeOverviewData({
startTime,
Expand Down

0 comments on commit 14f59c7

Please sign in to comment.