Correctly type ILM's optional dependencies as optional (#63255)
And guard against their absence.
This commit is contained in:
parent
d8a295dcbc
commit
8a283de3c5
|
@ -23,10 +23,12 @@ import {
|
|||
|
||||
import { defaultColdPhase, defaultWarmPhase, defaultHotPhase } from '../store/defaults';
|
||||
|
||||
export let trackUiMetric: (metricType: UiStatsMetricType, eventName: string) => void;
|
||||
export let trackUiMetric = (metricType: UiStatsMetricType, eventName: string) => {};
|
||||
|
||||
export function init(usageCollection: UsageCollectionSetup): void {
|
||||
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
|
||||
export function init(usageCollection?: UsageCollectionSetup): void {
|
||||
if (usageCollection) {
|
||||
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
export function getUiMetricsForPhases(phases: any): any {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { ManagementSetup } from '../../../../src/plugins/management/public';
|
|||
import { IndexManagementPluginSetup } from '../../index_management/public';
|
||||
|
||||
export interface PluginsDependencies {
|
||||
usageCollection: UsageCollectionSetup;
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
management: ManagementSetup;
|
||||
indexManagement?: IndexManagementPluginSetup;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ export class IndexLifecycleManagementServerPlugin implements Plugin<void, void,
|
|||
});
|
||||
|
||||
if (config.ui.enabled) {
|
||||
if (indexManagement.indexDataEnricher) {
|
||||
if (indexManagement && indexManagement.indexDataEnricher) {
|
||||
indexManagement.indexDataEnricher.add(indexLifecycleDataEnricher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import { isEsError } from './lib/is_es_error';
|
|||
|
||||
export interface Dependencies {
|
||||
licensing: LicensingPluginSetup;
|
||||
indexManagement: IndexManagementPluginSetup;
|
||||
indexManagement?: IndexManagementPluginSetup;
|
||||
}
|
||||
|
||||
export interface RouteDependencies {
|
||||
|
|
Loading…
Reference in a new issue