Skip to content

Commit

Permalink
Extract DEFAULT_SOURCE_ID constant to a shared location
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Fernández Gómez committed Jul 1, 2020
1 parent 2b10df8 commit 0dfddfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions x-pack/plugins/infra/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const DEFAULT_SOURCE_ID = 'default';
7 changes: 3 additions & 4 deletions x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { DEFAULT_SOURCE_ID } from '../../common/constants';
import { InfraClientCoreSetup, InfraClientStartDeps } from '../types';
import {
FetchData,
Expand Down Expand Up @@ -34,14 +35,12 @@ interface LogParams {

type StatsAndSeries = Pick<LogsFetchDataResponse, 'stats' | 'series'>;

const SOURCE_ID = 'default';

export function getLogsHasDataFetcher(
getStartServices: InfraClientCoreSetup['getStartServices']
): HasData {
return async () => {
const [core] = await getStartServices();
const sourceStatus = await callFetchLogSourceStatusAPI(SOURCE_ID, core.http.fetch);
const sourceStatus = await callFetchLogSourceStatusAPI(DEFAULT_SOURCE_ID, core.http.fetch);
return sourceStatus.data.logIndexNames.length > 0;
};
}
Expand All @@ -54,7 +53,7 @@ export function getLogsOverviewDataFetcher(
const { data } = startPlugins;

const sourceConfiguration = await callFetchLogSourceConfigurationAPI(
SOURCE_ID,
DEFAULT_SOURCE_ID,
core.http.fetch
);

Expand Down

0 comments on commit 0dfddfd

Please sign in to comment.