From e286cabbe68b053e74b748a2a5c9be7decf9150d Mon Sep 17 00:00:00 2001 From: John Schulz Date: Tue, 3 Nov 2020 08:37:31 -0500 Subject: [PATCH] [Ingest Manager] Replace AgentAssetType enum with new approach (#82387) ## Summary Expands on pattern added in #82188 `AgentAssetType` `enum` is only used as part of a single type definition --- x-pack/plugins/ingest_manager/common/constants/epm.ts | 4 ++++ .../plugins/ingest_manager/common/types/models/epm.ts | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/constants/epm.ts b/x-pack/plugins/ingest_manager/common/constants/epm.ts index 9b7801cc07202..91b240f75cfbd 100644 --- a/x-pack/plugins/ingest_manager/common/constants/epm.ts +++ b/x-pack/plugins/ingest_manager/common/constants/epm.ts @@ -14,6 +14,10 @@ export const requiredPackages = { Endpoint: 'endpoint', } as const; +export const agentAssetTypes = { + Input: 'input', +} as const; + export const dataTypes = { Logs: 'logs', Metrics: 'metrics', diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index 3762fe382e61d..40ae47a2e3fbc 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -7,7 +7,8 @@ // Follow pattern from https://github.com/elastic/kibana/pull/52447 // TODO: Update when https://github.com/elastic/kibana/issues/53021 is closed import { SavedObject, SavedObjectAttributes, SavedObjectReference } from 'src/core/public'; -import { dataTypes, requiredPackages } from '../../constants'; +import { agentAssetTypes, dataTypes, requiredPackages } from '../../constants'; +import { ValueOf } from '../../types'; export enum InstallationStatus { installed = 'installed', @@ -27,7 +28,8 @@ export type EpmPackageInstallStatus = 'installed' | 'installing'; export type DetailViewPanelName = 'overview' | 'usages' | 'settings'; export type ServiceName = 'kibana' | 'elasticsearch'; -export type AssetType = KibanaAssetType | ElasticsearchAssetType | AgentAssetType; +export type AgentAssetType = typeof agentAssetTypes; +export type AssetType = KibanaAssetType | ElasticsearchAssetType | ValueOf; export enum KibanaAssetType { dashboard = 'dashboard', @@ -47,10 +49,6 @@ export enum ElasticsearchAssetType { export type DataType = typeof dataTypes; -export enum AgentAssetType { - input = 'input', -} - export type RegistryRelease = 'ga' | 'beta' | 'experimental'; // Fields common to packages that come from direct upload and the registry