diff --git a/.eslintignore b/.eslintignore
index 2ed9ecf971ff3..4913192e81c1d 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -30,6 +30,7 @@ target
/x-pack/legacy/plugins/canvas/canvas_plugin_src/lib/flot-charts
/x-pack/legacy/plugins/canvas/shareable_runtime/build
/x-pack/legacy/plugins/canvas/storybook
+/x-pack/plugins/monitoring/public/lib/jquery_flot
/x-pack/legacy/plugins/infra/common/graphql/types.ts
/x-pack/legacy/plugins/infra/public/graphql/types.ts
/x-pack/legacy/plugins/infra/server/graphql/types.ts
diff --git a/.eslintrc.js b/.eslintrc.js
index c9b41ec711b7f..8b33ec83347a8 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -963,6 +963,12 @@ module.exports = {
jquery: true,
},
},
+ {
+ files: ['x-pack/plugins/monitoring/public/lib/jquery_flot/**/*.js'],
+ env: {
+ jquery: true,
+ },
+ },
/**
* TSVB overrides
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index a97400ee09c0e..3981a8e1e9afe 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -84,6 +84,7 @@
/x-pack/legacy/plugins/ingest_manager/ @elastic/ingest-management
/x-pack/plugins/observability/ @elastic/logs-metrics-ui @elastic/apm-ui @elastic/uptime @elastic/ingest-management
/x-pack/legacy/plugins/monitoring/ @elastic/stack-monitoring-ui
+/x-pack/plugins/monitoring/ @elastic/stack-monitoring-ui
/x-pack/plugins/uptime @elastic/uptime
# Machine Learning
@@ -203,6 +204,7 @@
/x-pack/plugins/snapshot_restore/ @elastic/es-ui
/x-pack/plugins/upgrade_assistant/ @elastic/es-ui
/x-pack/plugins/watcher/ @elastic/es-ui
+/x-pack/plugins/ingest_pipelines/ @elastic/es-ui
# Endpoint
/x-pack/plugins/endpoint/ @elastic/endpoint-app-team @elastic/siem
diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectmigrationfn.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectmigrationfn.md
index a502c40db0cd8..a3294fb0a087a 100644
--- a/docs/development/core/server/kibana-plugin-core-server.savedobjectmigrationfn.md
+++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectmigrationfn.md
@@ -9,22 +9,36 @@ A migration function for a [saved object type](./kibana-plugin-core-server.saved
Signature:
```typescript
-export declare type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;
+export declare type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;
```
## Example
```typescript
-const migrateProperty: SavedObjectMigrationFn = (doc, { log }) => {
- if(doc.attributes.someProp === null) {
- log.warn('Skipping migration');
- } else {
- doc.attributes.someProp = migrateProperty(doc.attributes.someProp);
- }
-
- return doc;
+interface TypeV1Attributes {
+ someKey: string;
+ obsoleteProperty: number;
}
+interface TypeV2Attributes {
+ someKey: string;
+ newProperty: string;
+}
+
+const migrateToV2: SavedObjectMigrationFn = (doc, { log }) => {
+ const { obsoleteProperty, ...otherAttributes } = doc.attributes;
+ // instead of mutating `doc` we make a shallow copy so that we can use separate types for the input
+ // and output attributes. We don't need to make a deep copy, we just need to ensure that obsolete
+ // attributes are not present on the returned doc.
+ return {
+ ...doc,
+ attributes: {
+ ...otherAttributes,
+ newProperty: migrate(obsoleteProperty),
+ },
+ };
+};
+
```
diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectsanitizeddoc.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectsanitizeddoc.md
index 6d4e252fe7532..3f4090619edbf 100644
--- a/docs/development/core/server/kibana-plugin-core-server.savedobjectsanitizeddoc.md
+++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectsanitizeddoc.md
@@ -9,5 +9,5 @@ Describes Saved Object documents that have passed through the migration framewor
Signature:
```typescript
-export declare type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
+export declare type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
```
diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectunsanitizeddoc.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectunsanitizeddoc.md
index be51400addbbc..8e2395ee6310d 100644
--- a/docs/development/core/server/kibana-plugin-core-server.savedobjectunsanitizeddoc.md
+++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectunsanitizeddoc.md
@@ -9,5 +9,5 @@ Describes Saved Object documents from Kibana < 7.0.0 which don't have a `refe
Signature:
```typescript
-export declare type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
+export declare type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggrouplabels.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggrouplabels.md
new file mode 100644
index 0000000000000..6684ba8546f85
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggrouplabels.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggGroupLabels](./kibana-plugin-plugins-data-public.agggrouplabels.md)
+
+## AggGroupLabels variable
+
+Signature:
+
+```typescript
+AggGroupLabels: {
+ [AggGroupNames.Buckets]: string;
+ [AggGroupNames.Metrics]: string;
+ [AggGroupNames.None]: string;
+}
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggroupname.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggroupname.md
new file mode 100644
index 0000000000000..d4476398680a8
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.agggroupname.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggGroupName](./kibana-plugin-plugins-data-public.agggroupname.md)
+
+## AggGroupName type
+
+Signature:
+
+```typescript
+export declare type AggGroupName = $Values;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.addfilter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.addfilter.md
deleted file mode 100644
index c9d6772a13b8d..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.addfilter.md
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) > [addFilter](./kibana-plugin-plugins-data-public.aggtypefieldfilters.addfilter.md)
-
-## AggTypeFieldFilters.addFilter() method
-
-Register a new with this registry. This will be used by the .
-
-Signature:
-
-```typescript
-addFilter(filter: AggTypeFieldFilter): void;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| filter | AggTypeFieldFilter | |
-
-Returns:
-
-`void`
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.filter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.filter.md
deleted file mode 100644
index 038c339bf6774..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.filter.md
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) > [filter](./kibana-plugin-plugins-data-public.aggtypefieldfilters.filter.md)
-
-## AggTypeFieldFilters.filter() method
-
-Returns the filtered by all registered filters.
-
-Signature:
-
-```typescript
-filter(fields: IndexPatternField[], aggConfig: IAggConfig): IndexPatternField[];
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| fields | IndexPatternField[] | |
-| aggConfig | IAggConfig | |
-
-Returns:
-
-`IndexPatternField[]`
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.md
deleted file mode 100644
index c0b386efbf9c7..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefieldfilters.md
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md)
-
-## AggTypeFieldFilters class
-
-A registry to store which are used to filter down available fields for a specific visualization and .
-
-Signature:
-
-```typescript
-declare class AggTypeFieldFilters
-```
-
-## Methods
-
-| Method | Modifiers | Description |
-| --- | --- | --- |
-| [addFilter(filter)](./kibana-plugin-plugins-data-public.aggtypefieldfilters.addfilter.md) | | Register a new with this registry. This will be used by the . |
-| [filter(fields, aggConfig)](./kibana-plugin-plugins-data-public.aggtypefieldfilters.filter.md) | | Returns the filtered by all registered filters. |
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.addfilter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.addfilter.md
deleted file mode 100644
index 9df003377c4a1..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.addfilter.md
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) > [addFilter](./kibana-plugin-plugins-data-public.aggtypefilters.addfilter.md)
-
-## AggTypeFilters.addFilter() method
-
-Register a new with this registry.
-
-Signature:
-
-```typescript
-addFilter(filter: AggTypeFilter): void;
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| filter | AggTypeFilter | |
-
-Returns:
-
-`void`
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.filter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.filter.md
deleted file mode 100644
index 81e6e9b95d655..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.filter.md
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) > [filter](./kibana-plugin-plugins-data-public.aggtypefilters.filter.md)
-
-## AggTypeFilters.filter() method
-
-Returns the filtered by all registered filters.
-
-Signature:
-
-```typescript
-filter(aggTypes: IAggType[], indexPattern: IndexPattern, aggConfig: IAggConfig, aggFilter: string[]): IAggType[];
-```
-
-## Parameters
-
-| Parameter | Type | Description |
-| --- | --- | --- |
-| aggTypes | IAggType[] | |
-| indexPattern | IndexPattern | |
-| aggConfig | IAggConfig | |
-| aggFilter | string[] | |
-
-Returns:
-
-`IAggType[]`
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.md
deleted file mode 100644
index c5e24bc0a78a0..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.aggtypefilters.md
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md)
-
-## AggTypeFilters class
-
-A registry to store which are used to filter down available aggregations for a specific visualization and .
-
-Signature:
-
-```typescript
-declare class AggTypeFilters
-```
-
-## Methods
-
-| Method | Modifiers | Description |
-| --- | --- | --- |
-| [addFilter(filter)](./kibana-plugin-plugins-data-public.aggtypefilters.addfilter.md) | | Register a new with this registry. |
-| [filter(aggTypes, indexPattern, aggConfig, aggFilter)](./kibana-plugin-plugins-data-public.aggtypefilters.filter.md) | | Returns the filtered by all registered filters. |
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.from.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.from.md
deleted file mode 100644
index 245269af366bc..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.from.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DateRangeKey](./kibana-plugin-plugins-data-public.daterangekey.md) > [from](./kibana-plugin-plugins-data-public.daterangekey.from.md)
-
-## DateRangeKey.from property
-
-Signature:
-
-```typescript
-from: number;
-```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.md
deleted file mode 100644
index 540d429dced48..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.md
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DateRangeKey](./kibana-plugin-plugins-data-public.daterangekey.md)
-
-## DateRangeKey interface
-
-Signature:
-
-```typescript
-export interface DateRangeKey
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [from](./kibana-plugin-plugins-data-public.daterangekey.from.md) | number | |
-| [to](./kibana-plugin-plugins-data-public.daterangekey.to.md) | number | |
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.to.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.to.md
deleted file mode 100644
index 024a6c2105427..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.daterangekey.to.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DateRangeKey](./kibana-plugin-plugins-data-public.daterangekey.md) > [to](./kibana-plugin-plugins-data-public.daterangekey.to.md)
-
-## DateRangeKey.to property
-
-Signature:
-
-```typescript
-to: number;
-```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iagggroupnames.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iagggroupnames.md
deleted file mode 100644
index 07310a4219359..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iagggroupnames.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IAggGroupNames](./kibana-plugin-plugins-data-public.iagggroupnames.md)
-
-## IAggGroupNames type
-
-Signature:
-
-```typescript
-export declare type IAggGroupNames = $Values;
-```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iprangekey.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iprangekey.md
deleted file mode 100644
index 96903a5df9844..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.iprangekey.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IpRangeKey](./kibana-plugin-plugins-data-public.iprangekey.md)
-
-## IpRangeKey type
-
-Signature:
-
-```typescript
-export declare type IpRangeKey = {
- type: 'mask';
- mask: string;
-} | {
- type: 'range';
- from: string;
- to: string;
-};
-```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
index e1df493143b73..13e38ba5e6e5d 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
@@ -9,8 +9,6 @@
| Class | Description |
| --- | --- |
| [AggParamType](./kibana-plugin-plugins-data-public.aggparamtype.md) | |
-| [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) | A registry to store which are used to filter down available fields for a specific visualization and . |
-| [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) | A registry to store which are used to filter down available aggregations for a specific visualization and . |
| [Field](./kibana-plugin-plugins-data-public.field.md) | |
| [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) | |
| [FilterManager](./kibana-plugin-plugins-data-public.filtermanager.md) | |
@@ -53,7 +51,6 @@
| [AggParamOption](./kibana-plugin-plugins-data-public.aggparamoption.md) | |
| [DataPublicPluginSetup](./kibana-plugin-plugins-data-public.datapublicpluginsetup.md) | |
| [DataPublicPluginStart](./kibana-plugin-plugins-data-public.datapublicpluginstart.md) | |
-| [DateRangeKey](./kibana-plugin-plugins-data-public.daterangekey.md) | |
| [EsQueryConfig](./kibana-plugin-plugins-data-public.esqueryconfig.md) | |
| [FetchOptions](./kibana-plugin-plugins-data-public.fetchoptions.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-public.fieldformatconfig.md) | |
@@ -75,7 +72,6 @@
| [ISearchStrategy](./kibana-plugin-plugins-data-public.isearchstrategy.md) | Search strategy interface contains a search method that takes in a request and returns a promise that resolves to a response. |
| [ISyncSearchRequest](./kibana-plugin-plugins-data-public.isyncsearchrequest.md) | |
| [KueryNode](./kibana-plugin-plugins-data-public.kuerynode.md) | |
-| [OptionedParamEditorProps](./kibana-plugin-plugins-data-public.optionedparameditorprops.md) | |
| [OptionedValueProp](./kibana-plugin-plugins-data-public.optionedvalueprop.md) | |
| [Query](./kibana-plugin-plugins-data-public.query.md) | |
| [QueryState](./kibana-plugin-plugins-data-public.querystate.md) | All query state service state |
@@ -95,6 +91,7 @@
| Variable | Description |
| --- | --- |
+| [AggGroupLabels](./kibana-plugin-plugins-data-public.agggrouplabels.md) | |
| [AggGroupNames](./kibana-plugin-plugins-data-public.agggroupnames.md) | |
| [baseFormattersPublic](./kibana-plugin-plugins-data-public.baseformatterspublic.md) | |
| [castEsToKbnFieldTypeName](./kibana-plugin-plugins-data-public.castestokbnfieldtypename.md) | Get the KbnFieldType name for an esType string |
@@ -119,6 +116,7 @@
| Type Alias | Description |
| --- | --- |
| [AggConfigOptions](./kibana-plugin-plugins-data-public.aggconfigoptions.md) | |
+| [AggGroupName](./kibana-plugin-plugins-data-public.agggroupname.md) | |
| [AggParam](./kibana-plugin-plugins-data-public.aggparam.md) | |
| [CustomFilter](./kibana-plugin-plugins-data-public.customfilter.md) | |
| [EsQuerySortValue](./kibana-plugin-plugins-data-public.esquerysortvalue.md) | |
@@ -127,7 +125,6 @@
| [FieldFormatsContentType](./kibana-plugin-plugins-data-public.fieldformatscontenttype.md) | \* |
| [FieldFormatsGetConfigFn](./kibana-plugin-plugins-data-public.fieldformatsgetconfigfn.md) | |
| [IAggConfig](./kibana-plugin-plugins-data-public.iaggconfig.md) | AggConfig This class represents an aggregation, which is displayed in the left-hand nav of the Visualize app. |
-| [IAggGroupNames](./kibana-plugin-plugins-data-public.iagggroupnames.md) | |
| [IAggType](./kibana-plugin-plugins-data-public.iaggtype.md) | |
| [IFieldFormat](./kibana-plugin-plugins-data-public.ifieldformat.md) | |
| [IFieldFormatsRegistry](./kibana-plugin-plugins-data-public.ifieldformatsregistry.md) | |
@@ -136,7 +133,6 @@
| [IndexPatternAggRestrictions](./kibana-plugin-plugins-data-public.indexpatternaggrestrictions.md) | |
| [IndexPatternsContract](./kibana-plugin-plugins-data-public.indexpatternscontract.md) | |
| [InputTimeRange](./kibana-plugin-plugins-data-public.inputtimerange.md) | |
-| [IpRangeKey](./kibana-plugin-plugins-data-public.iprangekey.md) | |
| [ISearch](./kibana-plugin-plugins-data-public.isearch.md) | |
| [ISearchGeneric](./kibana-plugin-plugins-data-public.isearchgeneric.md) | |
| [ISearchSource](./kibana-plugin-plugins-data-public.isearchsource.md) | \* |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.aggparam.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.aggparam.md
deleted file mode 100644
index 68e4371acc2f3..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.aggparam.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [OptionedParamEditorProps](./kibana-plugin-plugins-data-public.optionedparameditorprops.md) > [aggParam](./kibana-plugin-plugins-data-public.optionedparameditorprops.aggparam.md)
-
-## OptionedParamEditorProps.aggParam property
-
-Signature:
-
-```typescript
-aggParam: {
- options: T[];
- };
-```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.md
deleted file mode 100644
index 00a440a0a775a..0000000000000
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.optionedparameditorprops.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [OptionedParamEditorProps](./kibana-plugin-plugins-data-public.optionedparameditorprops.md)
-
-## OptionedParamEditorProps interface
-
-Signature:
-
-```typescript
-export interface OptionedParamEditorProps
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [aggParam](./kibana-plugin-plugins-data-public.optionedparameditorprops.aggparam.md) | { options: T[]; } | |
-
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md
index 9a22339fd0530..67c4eac67a9e6 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md
@@ -9,12 +9,7 @@
```typescript
search: {
aggs: {
- AggConfigs: typeof AggConfigs;
- aggGroupNamesMap: () => Record<"metrics" | "buckets", string>;
- aggTypeFilters: import("./search/aggs/filter/agg_type_filters").AggTypeFilters;
CidrMask: typeof CidrMask;
- convertDateRangeToString: typeof convertDateRangeToString;
- convertIPRangeToString: (range: import("./search").IpRangeKey, format: (val: any) => string) => string;
dateHistogramInterval: typeof dateHistogramInterval;
intervalOptions: ({
display: string;
diff --git a/src/cli/cluster/cluster_manager.ts b/src/cli/cluster/cluster_manager.ts
index 32a23d74dbda4..97dec3eead303 100644
--- a/src/cli/cluster/cluster_manager.ts
+++ b/src/cli/cluster/cluster_manager.ts
@@ -259,13 +259,15 @@ export class ClusterManager {
const ignorePaths = [
/[\\\/](\..*|node_modules|bower_components|target|public|__[a-z0-9_]+__|coverage)([\\\/]|$)/,
- /\.test\.(js|ts)$/,
+ /\.test\.(js|tsx?)$/,
+ /\.md$/,
+ /debug\.log$/,
...pluginInternalDirsIgnore,
fromRoot('src/legacy/server/sass/__tmp__'),
fromRoot('x-pack/legacy/plugins/reporting/.chromium'),
fromRoot('x-pack/plugins/siem/cypress'),
- fromRoot('x-pack/legacy/plugins/apm/e2e'),
- fromRoot('x-pack/legacy/plugins/apm/scripts'),
+ fromRoot('x-pack/plugins/apm/e2e'),
+ fromRoot('x-pack/plugins/apm/scripts'),
fromRoot('x-pack/legacy/plugins/canvas/canvas_plugin_src'), // prevents server from restarting twice for Canvas plugin changes,
'plugins/java_languageserver',
];
diff --git a/src/core/MIGRATION_EXAMPLES.md b/src/core/MIGRATION_EXAMPLES.md
index 8c5fe4875aaea..c91c00bc1aa02 100644
--- a/src/core/MIGRATION_EXAMPLES.md
+++ b/src/core/MIGRATION_EXAMPLES.md
@@ -957,7 +957,7 @@ const migration = (doc, log) => {...}
Would be converted to:
```typescript
-const migration: SavedObjectMigrationFn = (doc, { log }) => {...}
+const migration: SavedObjectMigrationFn = (doc, { log }) => {...}
```
### Remarks
diff --git a/src/core/server/http/http_server.test.ts b/src/core/server/http/http_server.test.ts
index 27db79bb94d25..4fb433b5c77ba 100644
--- a/src/core/server/http/http_server.test.ts
+++ b/src/core/server/http/http_server.test.ts
@@ -1068,6 +1068,14 @@ describe('setup contract', () => {
await create();
expect(create()).rejects.toThrowError('A cookieSessionStorageFactory was already created');
});
+
+ it('does not throw if called after stop', async () => {
+ const { createCookieSessionStorageFactory } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ createCookieSessionStorageFactory(cookieOptions);
+ }).not.toThrow();
+ });
});
describe('#isTlsEnabled', () => {
@@ -1113,4 +1121,54 @@ describe('setup contract', () => {
expect(getServerInfo().protocol).toEqual('https');
});
});
+
+ describe('#registerStaticDir', () => {
+ it('does not throw if called after stop', async () => {
+ const { registerStaticDir } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ registerStaticDir('/path1/{path*}', '/path/to/resource');
+ }).not.toThrow();
+ });
+ });
+
+ describe('#registerOnPreAuth', () => {
+ test('does not throw if called after stop', async () => {
+ const { registerOnPreAuth } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ registerOnPreAuth((req, res) => res.unauthorized());
+ }).not.toThrow();
+ });
+ });
+
+ describe('#registerOnPostAuth', () => {
+ test('does not throw if called after stop', async () => {
+ const { registerOnPostAuth } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ registerOnPostAuth((req, res) => res.unauthorized());
+ }).not.toThrow();
+ });
+ });
+
+ describe('#registerOnPreResponse', () => {
+ test('does not throw if called after stop', async () => {
+ const { registerOnPreResponse } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ registerOnPreResponse((req, res, t) => t.next());
+ }).not.toThrow();
+ });
+ });
+
+ describe('#registerAuth', () => {
+ test('does not throw if called after stop', async () => {
+ const { registerAuth } = await server.setup(config);
+ await server.stop();
+ expect(() => {
+ registerAuth((req, res) => res.unauthorized());
+ }).not.toThrow();
+ });
+ });
});
diff --git a/src/core/server/http/http_server.ts b/src/core/server/http/http_server.ts
index 77d3d99fb48cb..92ac5220735a1 100644
--- a/src/core/server/http/http_server.ts
+++ b/src/core/server/http/http_server.ts
@@ -74,6 +74,7 @@ export class HttpServer {
private registeredRouters = new Set();
private authRegistered = false;
private cookieSessionStorageCreated = false;
+ private stopped = false;
private readonly log: Logger;
private readonly authState: AuthStateStorage;
@@ -144,6 +145,10 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Http server is not setup up yet');
}
+ if (this.stopped) {
+ this.log.warn(`start called after stop`);
+ return;
+ }
this.log.debug('starting http server');
for (const router of this.registeredRouters) {
@@ -189,13 +194,13 @@ export class HttpServer {
}
public async stop() {
+ this.stopped = true;
if (this.server === undefined) {
return;
}
this.log.debug('stopping http server');
await this.server.stop();
- this.server = undefined;
}
private getAuthOption(
@@ -234,6 +239,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`setupConditionalCompression called after stop`);
+ }
const { enabled, referrerWhitelist: list } = config.compression;
if (!enabled) {
@@ -261,6 +269,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`registerOnPostAuth called after stop`);
+ }
this.server.ext('onPostAuth', adoptToHapiOnPostAuthFormat(fn, this.log));
}
@@ -269,6 +280,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`registerOnPreAuth called after stop`);
+ }
this.server.ext('onRequest', adoptToHapiOnPreAuthFormat(fn, this.log));
}
@@ -277,6 +291,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`registerOnPreResponse called after stop`);
+ }
this.server.ext('onPreResponse', adoptToHapiOnPreResponseFormat(fn, this.log));
}
@@ -288,6 +305,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`createCookieSessionStorageFactory called after stop`);
+ }
if (this.cookieSessionStorageCreated) {
throw new Error('A cookieSessionStorageFactory was already created');
}
@@ -305,6 +325,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Server is not created yet');
}
+ if (this.stopped) {
+ this.log.warn(`registerAuth called after stop`);
+ }
if (this.authRegistered) {
throw new Error('Auth interceptor was already registered');
}
@@ -348,6 +371,9 @@ export class HttpServer {
if (this.server === undefined) {
throw new Error('Http server is not setup up yet');
}
+ if (this.stopped) {
+ this.log.warn(`registerStaticDir called after stop`);
+ }
this.server.route({
path,
diff --git a/src/core/server/saved_objects/migrations/core/index.ts b/src/core/server/saved_objects/migrations/core/index.ts
index 466d399f653cd..f7274740ea5fe 100644
--- a/src/core/server/saved_objects/migrations/core/index.ts
+++ b/src/core/server/saved_objects/migrations/core/index.ts
@@ -21,5 +21,5 @@ export { DocumentMigrator } from './document_migrator';
export { IndexMigrator } from './index_migrator';
export { buildActiveMappings } from './build_active_mappings';
export { CallCluster } from './call_cluster';
-export { LogFn } from './migration_logger';
+export { LogFn, SavedObjectsMigrationLogger } from './migration_logger';
export { MigrationResult, MigrationStatus } from './migration_coordinator';
diff --git a/src/legacy/server/config/explode_by.js b/src/core/server/saved_objects/migrations/mocks.ts
similarity index 60%
rename from src/legacy/server/config/explode_by.js
rename to src/core/server/saved_objects/migrations/mocks.ts
index 46347feca550d..76a890d26bfa0 100644
--- a/src/legacy/server/config/explode_by.js
+++ b/src/core/server/saved_objects/migrations/mocks.ts
@@ -17,21 +17,27 @@
* under the License.
*/
-import _ from 'lodash';
+import { SavedObjectMigrationContext } from './types';
+import { SavedObjectsMigrationLogger } from './core';
-export default function(dot, flatObject) {
- const fullObject = {};
- _.each(flatObject, function(value, key) {
- const keys = key.split(dot);
- (function walk(memo, keys, value) {
- const _key = keys.shift();
- if (keys.length === 0) {
- memo[_key] = value;
- } else {
- if (!memo[_key]) memo[_key] = {};
- walk(memo[_key], keys, value);
- }
- })(fullObject, keys, value);
- });
- return fullObject;
-}
+const createLoggerMock = (): jest.Mocked => {
+ const mock = {
+ debug: jest.fn(),
+ info: jest.fn(),
+ warning: jest.fn(),
+ warn: jest.fn(),
+ };
+
+ return mock;
+};
+
+const createContextMock = (): jest.Mocked => {
+ const mock = {
+ log: createLoggerMock(),
+ };
+ return mock;
+};
+
+export const migrationMocks = {
+ createContext: createContextMock,
+};
diff --git a/src/core/server/saved_objects/migrations/types.ts b/src/core/server/saved_objects/migrations/types.ts
index 6bc085dde872e..85f15b4c18b66 100644
--- a/src/core/server/saved_objects/migrations/types.ts
+++ b/src/core/server/saved_objects/migrations/types.ts
@@ -26,23 +26,37 @@ import { SavedObjectsMigrationLogger } from './core/migration_logger';
*
* @example
* ```typescript
- * const migrateProperty: SavedObjectMigrationFn = (doc, { log }) => {
- * if(doc.attributes.someProp === null) {
- * log.warn('Skipping migration');
- * } else {
- * doc.attributes.someProp = migrateProperty(doc.attributes.someProp);
- * }
+ * interface TypeV1Attributes {
+ * someKey: string;
+ * obsoleteProperty: number;
+ * }
*
- * return doc;
+ * interface TypeV2Attributes {
+ * someKey: string;
+ * newProperty: string;
* }
+ *
+ * const migrateToV2: SavedObjectMigrationFn = (doc, { log }) => {
+ * const { obsoleteProperty, ...otherAttributes } = doc.attributes;
+ * // instead of mutating `doc` we make a shallow copy so that we can use separate types for the input
+ * // and output attributes. We don't need to make a deep copy, we just need to ensure that obsolete
+ * // attributes are not present on the returned doc.
+ * return {
+ * ...doc,
+ * attributes: {
+ * ...otherAttributes,
+ * newProperty: migrate(obsoleteProperty),
+ * },
+ * };
+ * };
* ```
*
* @public
*/
-export type SavedObjectMigrationFn = (
- doc: SavedObjectUnsanitizedDoc,
+export type SavedObjectMigrationFn = (
+ doc: SavedObjectUnsanitizedDoc,
context: SavedObjectMigrationContext
-) => SavedObjectUnsanitizedDoc;
+) => SavedObjectUnsanitizedDoc;
/**
* Migration context provided when invoking a {@link SavedObjectMigrationFn | migration handler}
diff --git a/src/core/server/saved_objects/saved_objects_service.mock.ts b/src/core/server/saved_objects/saved_objects_service.mock.ts
index 7ba4613c857d7..4e1f5981d6a41 100644
--- a/src/core/server/saved_objects/saved_objects_service.mock.ts
+++ b/src/core/server/saved_objects/saved_objects_service.mock.ts
@@ -31,6 +31,7 @@ import { savedObjectsClientProviderMock } from './service/lib/scoped_client_prov
import { savedObjectsRepositoryMock } from './service/lib/repository.mock';
import { savedObjectsClientMock } from './service/saved_objects_client.mock';
import { typeRegistryMock } from './saved_objects_type_registry.mock';
+import { migrationMocks } from './migrations/mocks';
import { ServiceStatusLevels } from '../status';
type SavedObjectsServiceContract = PublicMethodsOf;
@@ -105,4 +106,5 @@ export const savedObjectsServiceMock = {
createSetupContract: createSetupContractMock,
createInternalStartContract: createInternalStartContractMock,
createStartContract: createStartContractMock,
+ createMigrationContext: migrationMocks.createContext,
};
diff --git a/src/core/server/saved_objects/serialization/types.ts b/src/core/server/saved_objects/serialization/types.ts
index a33e16895078e..acd2c7b5284aa 100644
--- a/src/core/server/saved_objects/serialization/types.ts
+++ b/src/core/server/saved_objects/serialization/types.ts
@@ -47,8 +47,8 @@ export interface SavedObjectsRawDocSource {
/**
* Saved Object base document
*/
-interface SavedObjectDoc {
- attributes: any;
+interface SavedObjectDoc {
+ attributes: T;
id?: string; // NOTE: SavedObjectDoc is used for uncreated objects where `id` is optional
type: string;
namespace?: string;
@@ -69,7 +69,7 @@ interface Referencable {
*
* @public
*/
-export type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
+export type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
/**
* Describes Saved Object documents that have passed through the migration
@@ -77,4 +77,4 @@ export type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
*
* @public
*/
-export type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
+export type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index dc1c9d379d508..e8b77a8570291 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -1680,7 +1680,7 @@ export interface SavedObjectMigrationContext {
}
// @public
-export type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;
+export type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc;
// @public
export interface SavedObjectMigrationMap {
@@ -1708,7 +1708,7 @@ export interface SavedObjectsAddToNamespacesOptions extends SavedObjectsBaseOpti
// Warning: (ae-forgotten-export) The symbol "Referencable" needs to be exported by the entry point index.d.ts
//
// @public
-export type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
+export type SavedObjectSanitizedDoc = SavedObjectDoc & Referencable;
// @public (undocumented)
export interface SavedObjectsBaseOptions {
@@ -2311,7 +2311,7 @@ export class SavedObjectTypeRegistry {
}
// @public
-export type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
+export type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial;
// @public
export type ScopeableRequest = KibanaRequest | LegacyRequest | FakeRequest;
diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js
index 66296736b3ad0..8630221b3e94f 100644
--- a/src/dev/precommit_hook/casing_check_config.js
+++ b/src/dev/precommit_hook/casing_check_config.js
@@ -35,9 +35,9 @@ export const IGNORE_FILE_GLOBS = [
'**/Gruntfile.js',
'tasks/config/**/*',
'**/{Dockerfile,docker-compose.yml}',
- 'x-pack/legacy/plugins/apm/**/*',
'x-pack/legacy/plugins/canvas/tasks/**/*',
'x-pack/legacy/plugins/canvas/canvas_plugin_src/**/*',
+ 'x-pack/plugins/monitoring/public/lib/jquery_flot/**/*',
'**/.*',
'**/{webpackShims,__mocks__}/**/*',
'x-pack/docs/**/*',
@@ -58,6 +58,11 @@ export const IGNORE_FILE_GLOBS = [
// filename required by api-extractor
'api-documenter.json',
+
+ // TODO fix file names in APM to remove these
+ 'x-pack/plugins/apm/public/**/*',
+ 'x-pack/plugins/apm/scripts/**/*',
+ 'x-pack/plugins/apm/e2e/**/*',
];
/**
@@ -160,12 +165,11 @@ export const TEMPORARILY_IGNORED_PATHS = [
'webpackShims/ui-bootstrap.js',
'x-pack/legacy/plugins/index_management/public/lib/editSettings.js',
'x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js',
- 'x-pack/legacy/plugins/monitoring/public/components/sparkline/__mocks__/plugins/xpack_main/jquery_flot.js',
- 'x-pack/legacy/plugins/monitoring/public/icons/alert-blue.svg',
- 'x-pack/legacy/plugins/monitoring/public/icons/health-gray.svg',
- 'x-pack/legacy/plugins/monitoring/public/icons/health-green.svg',
- 'x-pack/legacy/plugins/monitoring/public/icons/health-red.svg',
- 'x-pack/legacy/plugins/monitoring/public/icons/health-yellow.svg',
+ 'x-pack/plugins/monitoring/public/components/sparkline/__mocks__/plugins/xpack_main/jquery_flot.js',
+ 'x-pack/plugins/monitoring/public/icons/health-gray.svg',
+ 'x-pack/plugins/monitoring/public/icons/health-green.svg',
+ 'x-pack/plugins/monitoring/public/icons/health-red.svg',
+ 'x-pack/plugins/monitoring/public/icons/health-yellow.svg',
'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Medium.ttf',
'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/noto/NotoSansCJKtc-Regular.ttf',
'x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/lib/pdf/assets/fonts/roboto/Roboto-Italic.ttf',
diff --git a/src/dev/run_check_lockfile_symlinks.js b/src/dev/run_check_lockfile_symlinks.js
index 6c6fc54638ee8..b912ea9ddb87e 100644
--- a/src/dev/run_check_lockfile_symlinks.js
+++ b/src/dev/run_check_lockfile_symlinks.js
@@ -35,9 +35,9 @@ const IGNORE_FILE_GLOBS = [
// fixtures aren't used in production, ignore them
'**/*fixtures*/**/*',
// cypress isn't used in production, ignore it
- 'x-pack/legacy/plugins/apm/e2e/*',
+ 'x-pack/plugins/apm/e2e/*',
// apm scripts aren't used in production, ignore them
- 'x-pack/legacy/plugins/apm/scripts/*',
+ 'x-pack/plugins/apm/scripts/*',
];
run(async ({ log }) => {
diff --git a/src/dev/storybook/aliases.ts b/src/dev/storybook/aliases.ts
index 43114b2edccfc..4dc930dae3e25 100644
--- a/src/dev/storybook/aliases.ts
+++ b/src/dev/storybook/aliases.ts
@@ -18,7 +18,7 @@
*/
export const storybookAliases = {
- apm: 'x-pack/legacy/plugins/apm/scripts/storybook.js',
+ apm: 'x-pack/plugins/apm/scripts/storybook.js',
canvas: 'x-pack/legacy/plugins/canvas/scripts/storybook_new.js',
codeeditor: 'src/plugins/kibana_react/public/code_editor/scripts/storybook.ts',
drilldowns: 'x-pack/plugins/drilldowns/scripts/storybook.js',
diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts
index 01d8a30b598c1..a13f61af60173 100644
--- a/src/dev/typescript/projects.ts
+++ b/src/dev/typescript/projects.ts
@@ -30,7 +30,7 @@ export const PROJECTS = [
new Project(resolve(REPO_ROOT, 'x-pack/plugins/siem/cypress/tsconfig.json'), {
name: 'siem/cypress',
}),
- new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/apm/e2e/tsconfig.json'), {
+ new Project(resolve(REPO_ROOT, 'x-pack/plugins/apm/e2e/tsconfig.json'), {
name: 'apm/cypress',
disableTypeCheck: true,
}),
diff --git a/src/legacy/server/config/config.js b/src/legacy/server/config/config.js
index c31ded608dd31..b186071edeaf7 100644
--- a/src/legacy/server/config/config.js
+++ b/src/legacy/server/config/config.js
@@ -19,7 +19,7 @@
import Joi from 'joi';
import _ from 'lodash';
-import override from './override';
+import { override } from './override';
import createDefaultSchema from './schema';
import { unset, deepCloneWithBuffers as clone, IS_KIBANA_DISTRIBUTABLE } from '../../utils';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
diff --git a/src/legacy/server/config/explode_by.test.js b/src/legacy/server/config/explode_by.test.js
deleted file mode 100644
index 741edba27d325..0000000000000
--- a/src/legacy/server/config/explode_by.test.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import explodeBy from './explode_by';
-
-describe('explode_by(dot, flatObject)', function() {
- it('should explode a flatten object with dots', function() {
- const flatObject = {
- 'test.enable': true,
- 'test.hosts': ['host-01', 'host-02'],
- };
- expect(explodeBy('.', flatObject)).toEqual({
- test: {
- enable: true,
- hosts: ['host-01', 'host-02'],
- },
- });
- });
-
- it('should explode a flatten object with slashes', function() {
- const flatObject = {
- 'test/enable': true,
- 'test/hosts': ['host-01', 'host-02'],
- };
- expect(explodeBy('/', flatObject)).toEqual({
- test: {
- enable: true,
- hosts: ['host-01', 'host-02'],
- },
- });
- });
-});
diff --git a/src/legacy/server/config/override.test.js b/src/legacy/server/config/override.test.js
deleted file mode 100644
index 331c586e28a87..0000000000000
--- a/src/legacy/server/config/override.test.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import override from './override';
-
-describe('override(target, source)', function() {
- it('should override the values form source to target', function() {
- const target = {
- test: {
- enable: true,
- host: ['host-01', 'host-02'],
- client: {
- type: 'sql',
- },
- },
- };
- const source = { test: { client: { type: 'nosql' } } };
- expect(override(target, source)).toEqual({
- test: {
- enable: true,
- host: ['host-01', 'host-02'],
- client: {
- type: 'nosql',
- },
- },
- });
- });
-});
diff --git a/src/legacy/server/config/override.test.ts b/src/legacy/server/config/override.test.ts
new file mode 100644
index 0000000000000..4e21a88e79e61
--- /dev/null
+++ b/src/legacy/server/config/override.test.ts
@@ -0,0 +1,130 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { override } from './override';
+
+describe('override(target, source)', function() {
+ it('should override the values form source to target', function() {
+ const target = {
+ test: {
+ enable: true,
+ host: ['something else'],
+ client: {
+ type: 'sql',
+ },
+ },
+ };
+
+ const source = {
+ test: {
+ host: ['host-01', 'host-02'],
+ client: {
+ type: 'nosql',
+ },
+ foo: {
+ bar: {
+ baz: 1,
+ },
+ },
+ },
+ };
+
+ expect(override(target, source)).toMatchInlineSnapshot(`
+ Object {
+ "test": Object {
+ "client": Object {
+ "type": "nosql",
+ },
+ "enable": true,
+ "foo": Object {
+ "bar": Object {
+ "baz": 1,
+ },
+ },
+ "host": Array [
+ "host-01",
+ "host-02",
+ ],
+ },
+ }
+ `);
+ });
+
+ it('does not mutate arguments', () => {
+ const target = {
+ foo: {
+ bar: 1,
+ baz: 1,
+ },
+ };
+
+ const source = {
+ foo: {
+ bar: 2,
+ },
+ box: 2,
+ };
+
+ expect(override(target, source)).toMatchInlineSnapshot(`
+ Object {
+ "box": 2,
+ "foo": Object {
+ "bar": 2,
+ "baz": 1,
+ },
+ }
+ `);
+ expect(target).not.toHaveProperty('box');
+ expect(source.foo).not.toHaveProperty('baz');
+ });
+
+ it('explodes keys with dots in them', () => {
+ const target = {
+ foo: {
+ bar: 1,
+ },
+ 'baz.box.boot.bar.bar': 20,
+ };
+
+ const source = {
+ 'foo.bar': 2,
+ 'baz.box.boot': {
+ 'bar.foo': 10,
+ },
+ };
+
+ expect(override(target, source)).toMatchInlineSnapshot(`
+ Object {
+ "baz": Object {
+ "box": Object {
+ "boot": Object {
+ "bar": Object {
+ "bar": 20,
+ "foo": 10,
+ },
+ },
+ },
+ },
+ "foo": Object {
+ "bar": 2,
+ },
+ }
+ `);
+ });
+});
diff --git a/src/legacy/server/config/override.ts b/src/legacy/server/config/override.ts
new file mode 100644
index 0000000000000..3dd7d62016004
--- /dev/null
+++ b/src/legacy/server/config/override.ts
@@ -0,0 +1,52 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const isObject = (v: any): v is Record =>
+ typeof v === 'object' && v !== null && !Array.isArray(v);
+
+const assignDeep = (target: Record, source: Record) => {
+ for (let [key, value] of Object.entries(source)) {
+ // unwrap dot-separated keys
+ if (key.includes('.')) {
+ const [first, ...others] = key.split('.');
+ key = first;
+ value = { [others.join('.')]: value };
+ }
+
+ if (isObject(value)) {
+ if (!target.hasOwnProperty(key)) {
+ target[key] = {};
+ }
+
+ assignDeep(target[key], value);
+ } else {
+ target[key] = value;
+ }
+ }
+};
+
+export const override = (...sources: Array>): Record => {
+ const result = {};
+
+ for (const object of sources) {
+ assignDeep(result, object);
+ }
+
+ return result;
+};
diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
index 271586bb8c582..3caba24748bfa 100644
--- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
+++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
@@ -462,16 +462,6 @@ export const npStart = {
types: aggTypesRegistry.start(),
},
__LEGACY: {
- AggConfig: sinon.fake(),
- AggType: sinon.fake(),
- aggTypeFieldFilters: {
- addFilter: sinon.fake(),
- filter: sinon.fake(),
- },
- FieldParamType: sinon.fake(),
- MetricAggType: sinon.fake(),
- parentPipelineAggHelper: sinon.fake(),
- siblingPipelineAggHelper: sinon.fake(),
esClient: {
search: sinon.fake(),
msearch: sinon.fake(),
diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx
index 5f6b67ee6ad20..7de054f2eaa9c 100644
--- a/src/plugins/dashboard/public/plugin.tsx
+++ b/src/plugins/dashboard/public/plugin.tsx
@@ -141,10 +141,14 @@ export class DashboardPlugin
if (share) {
share.urlGenerators.registerUrlGenerator(
- createDirectAccessDashboardLinkGenerator(async () => ({
- appBasePath: (await startServices)[0].application.getUrlForApp('dashboard'),
- useHashedUrl: (await startServices)[0].uiSettings.get('state:storeInSessionStorage'),
- }))
+ createDirectAccessDashboardLinkGenerator(async () => {
+ const [coreStart, , selfStart] = await startServices;
+ return {
+ appBasePath: coreStart.application.getUrlForApp('dashboard'),
+ useHashedUrl: coreStart.uiSettings.get('state:storeInSessionStorage'),
+ savedDashboardLoader: selfStart.getSavedDashboardLoader(),
+ };
+ })
);
}
diff --git a/src/plugins/dashboard/public/url_generator.test.ts b/src/plugins/dashboard/public/url_generator.test.ts
index d48aacc1d8c1e..248a3f991d6cb 100644
--- a/src/plugins/dashboard/public/url_generator.test.ts
+++ b/src/plugins/dashboard/public/url_generator.test.ts
@@ -21,10 +21,33 @@ import { createDirectAccessDashboardLinkGenerator } from './url_generator';
import { hashedItemStore } from '../../kibana_utils/public';
// eslint-disable-next-line
import { mockStorage } from '../../kibana_utils/public/storage/hashed_item_store/mock';
-import { esFilters } from '../../data/public';
+import { esFilters, Filter } from '../../data/public';
+import { SavedObjectLoader } from '../../saved_objects/public';
const APP_BASE_PATH: string = 'xyz/app/kibana';
+const createMockDashboardLoader = (
+ dashboardToFilters: {
+ [dashboardId: string]: () => Filter[];
+ } = {}
+) => {
+ return {
+ get: async (dashboardId: string) => {
+ return {
+ searchSource: {
+ getField: (field: string) => {
+ if (field === 'filter')
+ return dashboardToFilters[dashboardId] ? dashboardToFilters[dashboardId]() : [];
+ throw new Error(
+ `createMockDashboardLoader > searchSource > getField > ${field} is not mocked`
+ );
+ },
+ },
+ };
+ },
+ } as SavedObjectLoader;
+};
+
describe('dashboard url generator', () => {
beforeEach(() => {
// @ts-ignore
@@ -33,7 +56,11 @@ describe('dashboard url generator', () => {
test('creates a link to a saved dashboard', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: false })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({});
expect(url).toMatchInlineSnapshot(`"xyz/app/kibana#/dashboard?_a=()&_g=()"`);
@@ -41,7 +68,11 @@ describe('dashboard url generator', () => {
test('creates a link with global time range set up', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: false })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' },
@@ -53,7 +84,11 @@ describe('dashboard url generator', () => {
test('creates a link with filters, time range, refresh interval and query to a saved object', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: false })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' },
@@ -89,7 +124,11 @@ describe('dashboard url generator', () => {
test('if no useHash setting is given, uses the one was start services', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: true })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: true,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' },
@@ -99,7 +138,11 @@ describe('dashboard url generator', () => {
test('can override a false useHash ui setting', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: false })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' },
@@ -110,7 +153,11 @@ describe('dashboard url generator', () => {
test('can override a true useHash ui setting', async () => {
const generator = createDirectAccessDashboardLinkGenerator(() =>
- Promise.resolve({ appBasePath: APP_BASE_PATH, useHashedUrl: true })
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: true,
+ savedDashboardLoader: createMockDashboardLoader(),
+ })
);
const url = await generator.createUrl!({
timeRange: { to: 'now', from: 'now-15m', mode: 'relative' },
@@ -118,4 +165,150 @@ describe('dashboard url generator', () => {
});
expect(url.indexOf('relative')).toBeGreaterThan(1);
});
+
+ describe('preserving saved filters', () => {
+ const savedFilter1 = {
+ meta: {
+ alias: null,
+ disabled: false,
+ negate: false,
+ },
+ query: { query: 'savedfilter1' },
+ };
+
+ const savedFilter2 = {
+ meta: {
+ alias: null,
+ disabled: false,
+ negate: false,
+ },
+ query: { query: 'savedfilter2' },
+ };
+
+ const appliedFilter = {
+ meta: {
+ alias: null,
+ disabled: false,
+ negate: false,
+ },
+ query: { query: 'appliedfilter' },
+ };
+
+ test('attaches filters from destination dashboard', async () => {
+ const generator = createDirectAccessDashboardLinkGenerator(() =>
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader({
+ ['dashboard1']: () => [savedFilter1],
+ ['dashboard2']: () => [savedFilter2],
+ }),
+ })
+ );
+
+ const urlToDashboard1 = await generator.createUrl!({
+ dashboardId: 'dashboard1',
+ filters: [appliedFilter],
+ });
+
+ expect(urlToDashboard1).toEqual(expect.stringContaining('query:savedfilter1'));
+ expect(urlToDashboard1).toEqual(expect.stringContaining('query:appliedfilter'));
+
+ const urlToDashboard2 = await generator.createUrl!({
+ dashboardId: 'dashboard2',
+ filters: [appliedFilter],
+ });
+
+ expect(urlToDashboard2).toEqual(expect.stringContaining('query:savedfilter2'));
+ expect(urlToDashboard2).toEqual(expect.stringContaining('query:appliedfilter'));
+ });
+
+ test("doesn't fail if can't retrieve filters from destination dashboard", async () => {
+ const generator = createDirectAccessDashboardLinkGenerator(() =>
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader({
+ ['dashboard1']: () => {
+ throw new Error('Not found');
+ },
+ }),
+ })
+ );
+
+ const url = await generator.createUrl!({
+ dashboardId: 'dashboard1',
+ filters: [appliedFilter],
+ });
+
+ expect(url).not.toEqual(expect.stringContaining('query:savedfilter1'));
+ expect(url).toEqual(expect.stringContaining('query:appliedfilter'));
+ });
+
+ test('can enforce empty filters', async () => {
+ const generator = createDirectAccessDashboardLinkGenerator(() =>
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader({
+ ['dashboard1']: () => [savedFilter1],
+ }),
+ })
+ );
+
+ const url = await generator.createUrl!({
+ dashboardId: 'dashboard1',
+ filters: [],
+ preserveSavedFilters: false,
+ });
+
+ expect(url).not.toEqual(expect.stringContaining('query:savedfilter1'));
+ expect(url).not.toEqual(expect.stringContaining('query:appliedfilter'));
+ expect(url).toMatchInlineSnapshot(
+ `"xyz/app/kibana#/dashboard/dashboard1?_a=(filters:!())&_g=(filters:!())"`
+ );
+ });
+
+ test('no filters in result url if no filters applied', async () => {
+ const generator = createDirectAccessDashboardLinkGenerator(() =>
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader({
+ ['dashboard1']: () => [savedFilter1],
+ }),
+ })
+ );
+
+ const url = await generator.createUrl!({
+ dashboardId: 'dashboard1',
+ });
+ expect(url).not.toEqual(expect.stringContaining('filters'));
+ expect(url).toMatchInlineSnapshot(`"xyz/app/kibana#/dashboard/dashboard1?_a=()&_g=()"`);
+ });
+
+ test('can turn off preserving filters', async () => {
+ const generator = createDirectAccessDashboardLinkGenerator(() =>
+ Promise.resolve({
+ appBasePath: APP_BASE_PATH,
+ useHashedUrl: false,
+ savedDashboardLoader: createMockDashboardLoader({
+ ['dashboard1']: () => [savedFilter1],
+ }),
+ })
+ );
+ const urlWithPreservedFiltersTurnedOff = await generator.createUrl!({
+ dashboardId: 'dashboard1',
+ filters: [appliedFilter],
+ preserveSavedFilters: false,
+ });
+
+ expect(urlWithPreservedFiltersTurnedOff).not.toEqual(
+ expect.stringContaining('query:savedfilter1')
+ );
+ expect(urlWithPreservedFiltersTurnedOff).toEqual(
+ expect.stringContaining('query:appliedfilter')
+ );
+ });
+ });
});
diff --git a/src/plugins/dashboard/public/url_generator.ts b/src/plugins/dashboard/public/url_generator.ts
index 0fdf395e75bca..6f121ceb2d373 100644
--- a/src/plugins/dashboard/public/url_generator.ts
+++ b/src/plugins/dashboard/public/url_generator.ts
@@ -27,6 +27,7 @@ import {
} from '../../data/public';
import { setStateToKbnUrl } from '../../kibana_utils/public';
import { UrlGeneratorsDefinition, UrlGeneratorState } from '../../share/public';
+import { SavedObjectLoader } from '../../saved_objects/public';
export const STATE_STORAGE_KEY = '_a';
export const GLOBAL_STATE_STORAGE_KEY = '_g';
@@ -64,10 +65,22 @@ export type DashboardAppLinkGeneratorState = UrlGeneratorState<{
* whether to hash the data in the url to avoid url length issues.
*/
useHash?: boolean;
+
+ /**
+ * When `true` filters from saved filters from destination dashboard as merged with applied filters
+ * When `false` applied filters take precedence and override saved filters
+ *
+ * true is default
+ */
+ preserveSavedFilters?: boolean;
}>;
export const createDirectAccessDashboardLinkGenerator = (
- getStartServices: () => Promise<{ appBasePath: string; useHashedUrl: boolean }>
+ getStartServices: () => Promise<{
+ appBasePath: string;
+ useHashedUrl: boolean;
+ savedDashboardLoader: SavedObjectLoader;
+ }>
): UrlGeneratorsDefinition => ({
id: DASHBOARD_APP_URL_GENERATOR,
createUrl: async state => {
@@ -76,6 +89,19 @@ export const createDirectAccessDashboardLinkGenerator = (
const appBasePath = startServices.appBasePath;
const hash = state.dashboardId ? `dashboard/${state.dashboardId}` : `dashboard`;
+ const getSavedFiltersFromDestinationDashboardIfNeeded = async (): Promise => {
+ if (state.preserveSavedFilters === false) return [];
+ if (!state.dashboardId) return [];
+ try {
+ const dashboard = await startServices.savedDashboardLoader.get(state.dashboardId);
+ return dashboard?.searchSource?.getField('filter') ?? [];
+ } catch (e) {
+ // in case dashboard is missing, built the url without those filters
+ // dashboard app will handle redirect to landing page with toast message
+ return [];
+ }
+ };
+
const cleanEmptyKeys = (stateObj: Record) => {
Object.keys(stateObj).forEach(key => {
if (stateObj[key] === undefined) {
@@ -85,11 +111,18 @@ export const createDirectAccessDashboardLinkGenerator = (
return stateObj;
};
+ // leave filters `undefined` if no filters was applied
+ // in this case dashboard will restore saved filters on its own
+ const filters = state.filters && [
+ ...(await getSavedFiltersFromDestinationDashboardIfNeeded()),
+ ...state.filters,
+ ];
+
const appStateUrl = setStateToKbnUrl(
STATE_STORAGE_KEY,
cleanEmptyKeys({
query: state.query,
- filters: state.filters?.filter(f => !esFilters.isFilterPinned(f)),
+ filters: filters?.filter(f => !esFilters.isFilterPinned(f)),
}),
{ useHash },
`${appBasePath}#/${hash}`
@@ -99,7 +132,7 @@ export const createDirectAccessDashboardLinkGenerator = (
GLOBAL_STATE_STORAGE_KEY,
cleanEmptyKeys({
time: state.timeRange,
- filters: state.filters?.filter(f => esFilters.isFilterPinned(f)),
+ filters: filters?.filter(f => esFilters.isFilterPinned(f)),
refreshInterval: state.refreshInterval,
}),
{ useHash },
diff --git a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts
index 9829498118cc0..22ed18f75c652 100644
--- a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts
+++ b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts
@@ -18,14 +18,17 @@
*/
import { SavedObjectUnsanitizedDoc } from 'kibana/server';
+import { savedObjectsServiceMock } from '../../../../core/server/mocks';
import { dashboardSavedObjectTypeMigrations as migrations } from './dashboard_migrations';
+const contextMock = savedObjectsServiceMock.createMigrationContext();
+
describe('dashboard', () => {
describe('7.0.0', () => {
const migration = migrations['7.0.0'];
test('skips error on empty object', () => {
- expect(migration({} as SavedObjectUnsanitizedDoc)).toMatchInlineSnapshot(`
+ expect(migration({} as SavedObjectUnsanitizedDoc, contextMock)).toMatchInlineSnapshot(`
Object {
"references": Array [],
}
@@ -44,7 +47,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
@@ -83,7 +86,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
@@ -122,7 +125,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"kibanaSavedObjectMeta": Object {
@@ -160,7 +163,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"kibanaSavedObjectMeta": Object {
@@ -198,7 +201,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
@@ -237,7 +240,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
@@ -291,7 +294,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
};
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
@@ -331,7 +334,7 @@ Object {
panelsJSON: 123,
},
} as SavedObjectUnsanitizedDoc;
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"panelsJSON": 123,
@@ -349,7 +352,7 @@ Object {
panelsJSON: '{123abc}',
},
} as SavedObjectUnsanitizedDoc;
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"panelsJSON": "{123abc}",
@@ -367,7 +370,7 @@ Object {
panelsJSON: '{}',
},
} as SavedObjectUnsanitizedDoc;
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"panelsJSON": "{}",
@@ -385,7 +388,7 @@ Object {
panelsJSON: '[{"id":"123"}]',
},
} as SavedObjectUnsanitizedDoc;
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"panelsJSON": "[{\\"id\\":\\"123\\"}]",
@@ -403,7 +406,7 @@ Object {
panelsJSON: '[{"type":"visualization"}]',
},
} as SavedObjectUnsanitizedDoc;
- expect(migration(doc)).toMatchInlineSnapshot(`
+ expect(migration(doc, contextMock)).toMatchInlineSnapshot(`
Object {
"attributes": Object {
"panelsJSON": "[{\\"type\\":\\"visualization\\"}]",
@@ -422,7 +425,7 @@ Object {
'[{"id":"1","type":"visualization","foo":true},{"id":"2","type":"visualization","bar":true}]',
},
} as SavedObjectUnsanitizedDoc;
- const migratedDoc = migration(doc);
+ const migratedDoc = migration(doc, contextMock);
expect(migratedDoc).toMatchInlineSnapshot(`
Object {
"attributes": Object {
diff --git a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts
index 7c1d0568cd3d7..4f7945d6dd601 100644
--- a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts
+++ b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts
@@ -19,7 +19,7 @@
import { get, flow } from 'lodash';
-import { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server';
+import { SavedObjectMigrationFn } from 'kibana/server';
import { migrations730 } from './migrations_730';
import { migrateMatchAllQuery } from './migrate_match_all_query';
import { DashboardDoc700To720 } from '../../common';
@@ -62,7 +62,7 @@ function migrateIndexPattern(doc: DashboardDoc700To720) {
doc.attributes.kibanaSavedObjectMeta.searchSourceJSON = JSON.stringify(searchSource);
}
-const migrations700: SavedObjectMigrationFn = (doc): DashboardDoc700To720 => {
+const migrations700: SavedObjectMigrationFn = (doc): DashboardDoc700To720 => {
// Set new "references" attribute
doc.references = doc.references || [];
@@ -111,7 +111,7 @@ export const dashboardSavedObjectTypeMigrations = {
* in that version. So we apply this twice, once with 6.7.2 and once with 7.0.1 while the backport to 6.7
* only contained the 6.7.2 migration and not the 7.0.1 migration.
*/
- '6.7.2': flow(migrateMatchAllQuery),
- '7.0.0': flow<(doc: SavedObjectUnsanitizedDoc) => DashboardDoc700To720>(migrations700),
- '7.3.0': flow(migrations730),
+ '6.7.2': flow>(migrateMatchAllQuery),
+ '7.0.0': flow>(migrations700),
+ '7.3.0': flow>(migrations730),
};
diff --git a/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts b/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts
index 5b8582bf821ef..db2fbeb278802 100644
--- a/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts
+++ b/src/plugins/dashboard/server/saved_objects/migrate_match_all_query.ts
@@ -21,7 +21,7 @@ import { SavedObjectMigrationFn } from 'kibana/server';
import { get } from 'lodash';
import { DEFAULT_QUERY_LANGUAGE } from '../../../data/common';
-export const migrateMatchAllQuery: SavedObjectMigrationFn = doc => {
+export const migrateMatchAllQuery: SavedObjectMigrationFn = doc => {
const searchSourceJSON = get(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON');
if (searchSourceJSON) {
diff --git a/src/plugins/dashboard/server/saved_objects/migrations_730.test.ts b/src/plugins/dashboard/server/saved_objects/migrations_730.test.ts
index aa744324428a4..a58df547fa522 100644
--- a/src/plugins/dashboard/server/saved_objects/migrations_730.test.ts
+++ b/src/plugins/dashboard/server/saved_objects/migrations_730.test.ts
@@ -17,19 +17,13 @@
* under the License.
*/
+import { savedObjectsServiceMock } from '../../../../core/server/mocks';
import { dashboardSavedObjectTypeMigrations as migrations } from './dashboard_migrations';
import { migrations730 } from './migrations_730';
import { DashboardDoc700To720, DashboardDoc730ToLatest, DashboardDocPre700 } from '../../common';
import { RawSavedDashboardPanel730ToLatest } from '../../common';
-const mockContext = {
- log: {
- warning: () => {},
- warn: () => {},
- debug: () => {},
- info: () => {},
- },
-};
+const mockContext = savedObjectsServiceMock.createMigrationContext();
test('dashboard migration 7.3.0 migrates filters to query on search source', () => {
const doc: DashboardDoc700To720 = {
@@ -95,7 +89,7 @@ test('dashboard migration 7.3.0 migrates filters to query on search source when
},
};
- const doc700: DashboardDoc700To720 = migrations['7.0.0'](doc);
+ const doc700 = migrations['7.0.0'](doc, mockContext);
const newDoc = migrations['7.3.0'](doc700, mockContext);
const parsedSearchSource = JSON.parse(newDoc.attributes.kibanaSavedObjectMeta.searchSourceJSON);
@@ -127,7 +121,7 @@ test('dashboard migration works when panelsJSON is missing panelIndex', () => {
},
};
- const doc700: DashboardDoc700To720 = migrations['7.0.0'](doc);
+ const doc700 = migrations['7.0.0'](doc, mockContext);
const newDoc = migrations['7.3.0'](doc700, mockContext);
const parsedSearchSource = JSON.parse(newDoc.attributes.kibanaSavedObjectMeta.searchSourceJSON);
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index 60d8079b22347..75deff23ce20d 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -288,13 +288,8 @@ export {
import {
// aggs
- AggConfigs,
- aggTypeFilters,
- aggGroupNamesMap,
CidrMask,
- convertDateRangeToString,
- convertIPRangeToString,
- intervalOptions, // only used in Discover
+ intervalOptions,
isDateHistogramBucketAggConfig,
isNumberType,
isStringType,
@@ -326,26 +321,22 @@ export { ParsedInterval } from '../common';
export {
// aggs
+ AggGroupLabels,
+ AggGroupName,
AggGroupNames,
- AggParam, // only the type is used externally, only in vis editor
- AggParamOption, // only the type is used externally
+ AggParam,
+ AggParamOption,
AggParamType,
- AggTypeFieldFilters, // TODO convert to interface
- AggTypeFilters, // TODO convert to interface
AggConfigOptions,
BUCKET_TYPES,
- DateRangeKey, // only used in field formatter deserialization, which will live in data
IAggConfig,
IAggConfigs,
- IAggGroupNames,
IAggType,
IFieldParamType,
IMetricAggType,
- IpRangeKey, // only used in field formatter deserialization, which will live in data
METRIC_TYPES,
- OptionedParamEditorProps, // only type is used externally
OptionedParamType,
- OptionedValueProp, // only type is used externally
+ OptionedValueProp,
// search
ES_SEARCH_STRATEGY,
SYNC_SEARCH_STRATEGY,
@@ -383,17 +374,12 @@ export {
// Search namespace
export const search = {
aggs: {
- AggConfigs,
- aggGroupNamesMap,
- aggTypeFilters,
CidrMask,
- convertDateRangeToString,
- convertIPRangeToString,
dateHistogramInterval,
- intervalOptions, // only used in Discover
+ intervalOptions,
InvalidEsCalendarIntervalError,
InvalidEsIntervalFormatError,
- isDateHistogramBucketAggConfig,
+ isDateHistogramBucketAggConfig, // TODO: remove in build_pipeline refactor
isNumberType,
isStringType,
isType,
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index 91dea66f06a94..b0bb911dca9e5 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -26,7 +26,6 @@ import { History } from 'history';
import { HttpSetup } from 'src/core/public';
import { HttpStart } from 'src/core/public';
import { IconType } from '@elastic/eui';
-import { IndexPatternField as IndexPatternField_2 } from 'src/plugins/data/public';
import { InjectedIntl } from '@kbn/i18n/react';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { IUiSettingsClient } from 'src/core/public';
@@ -68,6 +67,20 @@ export type AggConfigOptions = Assign;
+// Warning: (ae-missing-release-tag) "AggGroupLabels" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const AggGroupLabels: {
+ [AggGroupNames.Buckets]: string;
+ [AggGroupNames.Metrics]: string;
+ [AggGroupNames.None]: string;
+};
+
+// Warning: (ae-missing-release-tag) "AggGroupName" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export type AggGroupName = $Values;
+
// Warning: (ae-missing-release-tag) "AggGroupNames" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -108,32 +121,6 @@ export class AggParamType extends Ba
makeAgg: (agg: TAggConfig, state?: AggConfigSerialized) => TAggConfig;
}
-// Warning: (ae-missing-release-tag) "AggTypeFieldFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggTypeFieldFilter"
-// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggType"
-//
-// @public
-export class AggTypeFieldFilters {
- // Warning: (ae-forgotten-export) The symbol "AggTypeFieldFilter" needs to be exported by the entry point index.d.ts
- // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggTypeFieldFilter"
- addFilter(filter: AggTypeFieldFilter): void;
- // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "any"
- filter(fields: IndexPatternField_2[], aggConfig: IAggConfig): IndexPatternField_2[];
- }
-
-// Warning: (ae-missing-release-tag) "AggTypeFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggTypeFilter"
-// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggConfig"
-//
-// @public
-export class AggTypeFilters {
- // Warning: (ae-forgotten-export) The symbol "AggTypeFilter" needs to be exported by the entry point index.d.ts
- // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggTypeFilter"
- addFilter(filter: AggTypeFilter): void;
- // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AggType"
- filter(aggTypes: IAggType[], indexPattern: IndexPattern, aggConfig: IAggConfig, aggFilter: string[]): IAggType[];
- }
-
// Warning: (ae-forgotten-export) The symbol "DateFormat" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "baseFormattersPublic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -266,16 +253,6 @@ export interface DataPublicPluginStart {
};
}
-// Warning: (ae-missing-release-tag) "DateRangeKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export interface DateRangeKey {
- // (undocumented)
- from: number;
- // (undocumented)
- to: number;
-}
-
// @public (undocumented)
export enum ES_FIELD_TYPES {
// (undocumented)
@@ -714,11 +691,6 @@ export type IAggConfig = AggConfig;
// @internal
export type IAggConfigs = AggConfigs;
-// Warning: (ae-missing-release-tag) "IAggGroupNames" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IAggGroupNames = $Values;
-
// Warning: (ae-forgotten-export) The symbol "AggType" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "IAggType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
@@ -1101,18 +1073,6 @@ export type InputTimeRange = TimeRange | {
to: Moment;
};
-// Warning: (ae-missing-release-tag) "IpRangeKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export type IpRangeKey = {
- type: 'mask';
- mask: string;
-} | {
- type: 'range';
- from: string;
- to: string;
-};
-
// Warning: (ae-missing-release-tag) "IRequestTypesMap" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -1290,16 +1250,6 @@ export enum METRIC_TYPES {
TOP_HITS = "top_hits"
}
-// Warning: (ae-missing-release-tag) "OptionedParamEditorProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
-//
-// @public (undocumented)
-export interface OptionedParamEditorProps {
- // (undocumented)
- aggParam: {
- options: T[];
- };
-}
-
// Warning: (ae-missing-release-tag) "OptionedParamType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
@@ -1578,12 +1528,7 @@ export type SavedQueryTimeFilter = TimeRange & {
// @public (undocumented)
export const search: {
aggs: {
- AggConfigs: typeof AggConfigs;
- aggGroupNamesMap: () => Record<"metrics" | "buckets", string>;
- aggTypeFilters: import("./search/aggs/filter/agg_type_filters").AggTypeFilters;
CidrMask: typeof CidrMask;
- convertDateRangeToString: typeof convertDateRangeToString;
- convertIPRangeToString: (range: import("./search").IpRangeKey, format: (val: any) => string) => string;
dateHistogramInterval: typeof dateHistogramInterval;
intervalOptions: ({
display: string;
@@ -1870,21 +1815,20 @@ export type TSearchStrategyProvider = (context: ISearc
// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:407:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
-// src/plugins/data/public/index.ts:415:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:375:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:377:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:378:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:397:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:398:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
+// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts
diff --git a/src/plugins/data/public/search/aggs/agg_groups.ts b/src/plugins/data/public/search/aggs/agg_groups.ts
index 9cebff76c9684..dec3397126e67 100644
--- a/src/plugins/data/public/search/aggs/agg_groups.ts
+++ b/src/plugins/data/public/search/aggs/agg_groups.ts
@@ -25,15 +25,17 @@ export const AggGroupNames = Object.freeze({
Metrics: 'metrics' as 'metrics',
None: 'none' as 'none',
});
-export type IAggGroupNames = $Values;
-type IAggGroupNamesMap = () => Record<'buckets' | 'metrics', string>;
+export type AggGroupName = $Values;
-export const aggGroupNamesMap: IAggGroupNamesMap = () => ({
+export const AggGroupLabels = {
+ [AggGroupNames.Buckets]: i18n.translate('data.search.aggs.aggGroups.bucketsText', {
+ defaultMessage: 'Buckets',
+ }),
[AggGroupNames.Metrics]: i18n.translate('data.search.aggs.aggGroups.metricsText', {
defaultMessage: 'Metrics',
}),
- [AggGroupNames.Buckets]: i18n.translate('data.search.aggs.aggGroups.bucketsText', {
- defaultMessage: 'Buckets',
+ [AggGroupNames.None]: i18n.translate('data.search.aggs.aggGroups.noneText', {
+ defaultMessage: 'None',
}),
-});
+};
diff --git a/src/plugins/data/public/search/aggs/filter/agg_type_filters.test.ts b/src/plugins/data/public/search/aggs/filter/agg_type_filters.test.ts
deleted file mode 100644
index 58f5aef0b9dfd..0000000000000
--- a/src/plugins/data/public/search/aggs/filter/agg_type_filters.test.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexPattern } from '../../../index_patterns';
-import { AggTypeFilters } from './agg_type_filters';
-import { IAggConfig, IAggType } from '../types';
-
-describe('AggTypeFilters', () => {
- let registry: AggTypeFilters;
- const indexPattern = ({ id: '1234', fields: [], title: 'foo' } as unknown) as IndexPattern;
- const aggConfig = {} as IAggConfig;
-
- beforeEach(() => {
- registry = new AggTypeFilters();
- });
-
- it('should filter nothing without registered filters', async () => {
- const aggTypes = [{ name: 'count' }, { name: 'sum' }] as IAggType[];
- const filtered = registry.filter(aggTypes, indexPattern, aggConfig, []);
- expect(filtered).toEqual(aggTypes);
- });
-
- it('should pass all aggTypes to the registered filter', async () => {
- const aggTypes = [{ name: 'count' }, { name: 'sum' }] as IAggType[];
- const filter = jest.fn();
- registry.addFilter(filter);
- registry.filter(aggTypes, indexPattern, aggConfig, []);
- expect(filter).toHaveBeenCalledWith(aggTypes[0], indexPattern, aggConfig, []);
- expect(filter).toHaveBeenCalledWith(aggTypes[1], indexPattern, aggConfig, []);
- });
-
- it('should allow registered filters to filter out aggTypes', async () => {
- const aggTypes = [{ name: 'count' }, { name: 'sum' }, { name: 'avg' }] as IAggType[];
- let filtered = registry.filter(aggTypes, indexPattern, aggConfig, []);
- expect(filtered).toEqual(aggTypes);
-
- registry.addFilter(() => true);
- registry.addFilter(aggType => aggType.name !== 'count');
- filtered = registry.filter(aggTypes, indexPattern, aggConfig, []);
- expect(filtered).toEqual([aggTypes[1], aggTypes[2]]);
-
- registry.addFilter(aggType => aggType.name !== 'avg');
- filtered = registry.filter(aggTypes, indexPattern, aggConfig, []);
- expect(filtered).toEqual([aggTypes[1]]);
- });
-});
diff --git a/src/plugins/data/public/search/aggs/filter/agg_type_filters.ts b/src/plugins/data/public/search/aggs/filter/agg_type_filters.ts
deleted file mode 100644
index b8d192cd66b5a..0000000000000
--- a/src/plugins/data/public/search/aggs/filter/agg_type_filters.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { IndexPattern } from '../../../index_patterns';
-import { IAggConfig, IAggType } from '../types';
-
-type AggTypeFilter = (
- aggType: IAggType,
- indexPattern: IndexPattern,
- aggConfig: IAggConfig,
- aggFilter: string[]
-) => boolean;
-
-/**
- * A registry to store {@link AggTypeFilter} which are used to filter down
- * available aggregations for a specific visualization and {@link AggConfig}.
- */
-class AggTypeFilters {
- private filters = new Set();
-
- /**
- * Register a new {@link AggTypeFilter} with this registry.
- *
- * @param filter The filter to register.
- */
- public addFilter(filter: AggTypeFilter): void {
- this.filters.add(filter);
- }
-
- /**
- * Returns the {@link AggType|aggTypes} filtered by all registered filters.
- *
- * @param aggTypes A list of aggTypes that will be filtered down by this registry.
- * @param indexPattern The indexPattern for which this list should be filtered down.
- * @param aggConfig The aggConfig for which the returning list will be used.
- * @param schema
- * @return A filtered list of the passed aggTypes.
- */
- public filter(
- aggTypes: IAggType[],
- indexPattern: IndexPattern,
- aggConfig: IAggConfig,
- aggFilter: string[]
- ) {
- const allFilters = Array.from(this.filters);
- const allowedAggTypes = aggTypes.filter(aggType => {
- const isAggTypeAllowed = allFilters.every(filter =>
- filter(aggType, indexPattern, aggConfig, aggFilter)
- );
- return isAggTypeAllowed;
- });
- return allowedAggTypes;
- }
-}
-
-const aggTypeFilters = new AggTypeFilters();
-
-export { aggTypeFilters, AggTypeFilters };
diff --git a/src/plugins/data/public/search/aggs/filter/index.ts b/src/plugins/data/public/search/aggs/filter/index.ts
deleted file mode 100644
index 35d06807d0ec2..0000000000000
--- a/src/plugins/data/public/search/aggs/filter/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-export { aggTypeFilters, AggTypeFilters } from './agg_type_filters';
-export { propFilter } from './prop_filter';
diff --git a/src/plugins/data/public/search/aggs/index.ts b/src/plugins/data/public/search/aggs/index.ts
index 5dfb6aeff8d14..1139d9c7ff722 100644
--- a/src/plugins/data/public/search/aggs/index.ts
+++ b/src/plugins/data/public/search/aggs/index.ts
@@ -24,7 +24,6 @@ export * from './agg_type';
export * from './agg_types';
export * from './agg_types_registry';
export * from './buckets';
-export * from './filter';
export * from './metrics';
export * from './param_types';
export * from './types';
diff --git a/src/plugins/data/public/search/aggs/param_types/field.ts b/src/plugins/data/public/search/aggs/param_types/field.ts
index 4d67f41905c5a..63dbed9cec612 100644
--- a/src/plugins/data/public/search/aggs/param_types/field.ts
+++ b/src/plugins/data/public/search/aggs/param_types/field.ts
@@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n';
import { IAggConfig } from '../agg_config';
import { SavedObjectNotFound } from '../../../../../../plugins/kibana_utils/public';
import { BaseParamType } from './base';
-import { propFilter } from '../filter';
+import { propFilter } from '../utils';
import { isNestedField, KBN_FIELD_TYPES } from '../../../../common';
import { Field as IndexPatternField } from '../../../index_patterns';
import { GetInternalStartServicesFn } from '../../../types';
diff --git a/src/plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts b/src/plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts
deleted file mode 100644
index f776a3deb23a1..0000000000000
--- a/src/plugins/data/public/search/aggs/param_types/filter/field_filters.test.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { AggTypeFieldFilters } from './field_filters';
-import { IAggConfig } from '../../agg_config';
-import { Field as IndexPatternField } from '../../../../index_patterns';
-
-describe('AggTypeFieldFilters', () => {
- let registry: AggTypeFieldFilters;
- const aggConfig = {} as IAggConfig;
-
- beforeEach(() => {
- registry = new AggTypeFieldFilters();
- });
-
- it('should filter nothing without registered filters', async () => {
- const fields = [{ name: 'foo' }, { name: 'bar' }] as IndexPatternField[];
- const filtered = registry.filter(fields, aggConfig);
- expect(filtered).toEqual(fields);
- });
-
- it('should pass all fields to the registered filter', async () => {
- const fields = [{ name: 'foo' }, { name: 'bar' }] as IndexPatternField[];
- const filter = jest.fn();
- registry.addFilter(filter);
- registry.filter(fields, aggConfig);
- expect(filter).toHaveBeenCalledWith(fields[0], aggConfig);
- expect(filter).toHaveBeenCalledWith(fields[1], aggConfig);
- });
-
- it('should allow registered filters to filter out fields', async () => {
- const fields = [{ name: 'foo' }, { name: 'bar' }] as IndexPatternField[];
- let filtered = registry.filter(fields, aggConfig);
- expect(filtered).toEqual(fields);
-
- registry.addFilter(() => true);
- registry.addFilter(field => field.name !== 'foo');
- filtered = registry.filter(fields, aggConfig);
- expect(filtered).toEqual([fields[1]]);
-
- registry.addFilter(field => field.name !== 'bar');
- filtered = registry.filter(fields, aggConfig);
- expect(filtered).toEqual([]);
- });
-});
diff --git a/src/plugins/data/public/search/aggs/param_types/filter/field_filters.ts b/src/plugins/data/public/search/aggs/param_types/filter/field_filters.ts
deleted file mode 100644
index 1cbf0c9ae3624..0000000000000
--- a/src/plugins/data/public/search/aggs/param_types/filter/field_filters.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { IndexPatternField } from 'src/plugins/data/public';
-import { IAggConfig } from '../../agg_config';
-
-type AggTypeFieldFilter = (field: IndexPatternField, aggConfig: IAggConfig) => boolean;
-
-/**
- * A registry to store {@link AggTypeFieldFilter} which are used to filter down
- * available fields for a specific visualization and {@link AggType}.
- */
-class AggTypeFieldFilters {
- private filters = new Set();
-
- /**
- * Register a new {@link AggTypeFieldFilter} with this registry.
- * This will be used by the {@link #filter|filter method}.
- *
- * @param filter The filter to register.
- */
- public addFilter(filter: AggTypeFieldFilter): void {
- this.filters.add(filter);
- }
-
- /**
- * Returns the {@link any|fields} filtered by all registered filters.
- *
- * @param fields An array of fields that will be filtered down by this registry.
- * @param aggConfig The aggConfig for which the returning list will be used.
- * @return A filtered list of the passed fields.
- */
- public filter(fields: IndexPatternField[], aggConfig: IAggConfig) {
- const allFilters = Array.from(this.filters);
- const allowedAggTypeFields = fields.filter(field => {
- const isAggTypeFieldAllowed = allFilters.every(filter => filter(field, aggConfig));
- return isAggTypeFieldAllowed;
- });
- return allowedAggTypeFields;
- }
-}
-
-const aggTypeFieldFilters = new AggTypeFieldFilters();
-
-export { aggTypeFieldFilters, AggTypeFieldFilters };
diff --git a/src/plugins/data/public/search/aggs/param_types/index.ts b/src/plugins/data/public/search/aggs/param_types/index.ts
index c9e8a9879f427..e25dd55dbd3f2 100644
--- a/src/plugins/data/public/search/aggs/param_types/index.ts
+++ b/src/plugins/data/public/search/aggs/param_types/index.ts
@@ -20,7 +20,6 @@
export * from './agg';
export * from './base';
export * from './field';
-export * from './filter';
export * from './json';
export * from './optioned';
export * from './string';
diff --git a/src/plugins/data/public/search/aggs/param_types/optioned.ts b/src/plugins/data/public/search/aggs/param_types/optioned.ts
index 9eb7ceda60711..45d0a65f69170 100644
--- a/src/plugins/data/public/search/aggs/param_types/optioned.ts
+++ b/src/plugins/data/public/search/aggs/param_types/optioned.ts
@@ -27,12 +27,6 @@ export interface OptionedValueProp {
isCompatible: (agg: IAggConfig) => boolean;
}
-export interface OptionedParamEditorProps {
- aggParam: {
- options: T[];
- };
-}
-
export class OptionedParamType extends BaseParamType {
options: OptionedValueProp[];
diff --git a/src/plugins/data/public/search/aggs/types.ts b/src/plugins/data/public/search/aggs/types.ts
index 95a7a45013567..1c5b5b458ce90 100644
--- a/src/plugins/data/public/search/aggs/types.ts
+++ b/src/plugins/data/public/search/aggs/types.ts
@@ -19,20 +19,13 @@
import { IndexPattern } from '../../index_patterns';
import {
- AggConfig,
AggConfigSerialized,
AggConfigs,
AggParamsTerms,
- AggType,
- aggTypeFieldFilters,
AggTypesRegistrySetup,
AggTypesRegistryStart,
CreateAggConfigParams,
- FieldParamType,
getCalculateAutoTimeExpression,
- MetricAggType,
- parentPipelineAggHelper,
- siblingPipelineAggHelper,
} from './';
export { IAggConfig, AggConfigSerialized } from './agg_config';
@@ -43,7 +36,7 @@ export { IFieldParamType } from './param_types';
export { IMetricAggType } from './metrics/metric_agg_type';
export { DateRangeKey } from './buckets/lib/date_range';
export { IpRangeKey } from './buckets/lib/ip_range';
-export { OptionedValueProp, OptionedParamEditorProps } from './param_types/optioned';
+export { OptionedValueProp } from './param_types/optioned';
/** @internal */
export interface SearchAggsSetup {
@@ -51,17 +44,6 @@ export interface SearchAggsSetup {
types: AggTypesRegistrySetup;
}
-/** @internal */
-export interface SearchAggsStartLegacy {
- AggConfig: typeof AggConfig;
- AggType: typeof AggType;
- aggTypeFieldFilters: typeof aggTypeFieldFilters;
- FieldParamType: typeof FieldParamType;
- MetricAggType: typeof MetricAggType;
- parentPipelineAggHelper: typeof parentPipelineAggHelper;
- siblingPipelineAggHelper: typeof siblingPipelineAggHelper;
-}
-
/** @internal */
export interface SearchAggsStart {
calculateAutoTimeExpression: ReturnType;
diff --git a/src/plugins/data/public/search/aggs/utils/index.ts b/src/plugins/data/public/search/aggs/utils/index.ts
index 23606bd109342..169d872b17d3a 100644
--- a/src/plugins/data/public/search/aggs/utils/index.ts
+++ b/src/plugins/data/public/search/aggs/utils/index.ts
@@ -18,4 +18,5 @@
*/
export * from './calculate_auto_time_expression';
+export * from './prop_filter';
export * from './to_angular_json';
diff --git a/src/plugins/data/public/search/aggs/filter/prop_filter.test.ts b/src/plugins/data/public/search/aggs/utils/prop_filter.test.ts
similarity index 100%
rename from src/plugins/data/public/search/aggs/filter/prop_filter.test.ts
rename to src/plugins/data/public/search/aggs/utils/prop_filter.test.ts
diff --git a/src/plugins/data/public/search/aggs/filter/prop_filter.ts b/src/plugins/data/public/search/aggs/utils/prop_filter.ts
similarity index 97%
rename from src/plugins/data/public/search/aggs/filter/prop_filter.ts
rename to src/plugins/data/public/search/aggs/utils/prop_filter.ts
index e6b5f3831e65d..01e98a68d3949 100644
--- a/src/plugins/data/public/search/aggs/filter/prop_filter.ts
+++ b/src/plugins/data/public/search/aggs/utils/prop_filter.ts
@@ -28,7 +28,7 @@ type FilterFunc
= (item: T[P]) => boolean;
*
* @returns the filter function which can be registered with angular
*/
-function propFilter
(prop: P) {
+export function propFilter
(prop: P) {
/**
* List filtering function which accepts an array or list of values that a property
* must contain
@@ -92,5 +92,3 @@ function propFilter
- For more license options please visit
- License Management.
-
-
-
-
- );
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/filters/index.js b/x-pack/legacy/plugins/monitoring/public/filters/index.js
deleted file mode 100644
index a67770ff50dc8..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/filters/index.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-import { capitalize } from 'lodash';
-import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
-import { formatNumber, formatMetric } from 'plugins/monitoring/lib/format_number';
-import { extractIp } from 'plugins/monitoring/lib/extract_ip';
-
-const uiModule = uiModules.get('monitoring/filters', []);
-
-uiModule.filter('capitalize', function() {
- return function(input) {
- return capitalize(input.toLowerCase());
- };
-});
-
-uiModule.filter('formatNumber', function() {
- return formatNumber;
-});
-
-uiModule.filter('formatMetric', function() {
- return formatMetric;
-});
-
-uiModule.filter('extractIp', function() {
- return extractIp;
-});
diff --git a/x-pack/legacy/plugins/monitoring/public/hacks/toggle_app_link_in_nav.js b/x-pack/legacy/plugins/monitoring/public/hacks/toggle_app_link_in_nav.js
deleted file mode 100644
index 9448e826f3723..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/hacks/toggle_app_link_in_nav.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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.
- */
-
-import { uiModules } from 'ui/modules';
-import { npStart } from 'ui/new_platform';
-
-uiModules.get('monitoring/hacks').run(monitoringUiEnabled => {
- if (monitoringUiEnabled) {
- return;
- }
-
- npStart.core.chrome.navLinks.update('monitoring', { hidden: true });
-});
diff --git a/x-pack/legacy/plugins/monitoring/public/icons/monitoring.svg b/x-pack/legacy/plugins/monitoring/public/icons/monitoring.svg
deleted file mode 100644
index e00faca26a251..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/icons/monitoring.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
diff --git a/x-pack/legacy/plugins/monitoring/public/legacy.ts b/x-pack/legacy/plugins/monitoring/public/legacy.ts
deleted file mode 100644
index 293b6ac7bd821..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/legacy.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-import 'plugins/monitoring/filters';
-import 'plugins/monitoring/services/clusters';
-import 'plugins/monitoring/services/features';
-import 'plugins/monitoring/services/executor';
-import 'plugins/monitoring/services/license';
-import 'plugins/monitoring/services/title';
-import 'plugins/monitoring/services/breadcrumbs';
-import 'plugins/monitoring/directives/all';
-import 'plugins/monitoring/views/all';
-import { npSetup, npStart } from '../public/np_imports/legacy_imports';
-import { plugin } from './np_ready';
-import { localApplicationService } from '../../../../../src/legacy/core_plugins/kibana/public/local_application_service';
-
-const pluginInstance = plugin({} as any);
-pluginInstance.setup(npSetup.core, npSetup.plugins);
-pluginInstance.start(npStart.core, {
- ...npStart.plugins,
- __LEGACY: {
- localApplicationService,
- },
-});
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/angular_config.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/angular/angular_config.ts
deleted file mode 100644
index d1849d9247985..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/angular_config.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * 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.
- */
-
-import {
- ICompileProvider,
- IHttpProvider,
- IHttpService,
- ILocationProvider,
- IModule,
- IRootScopeService,
-} from 'angular';
-import $ from 'jquery';
-import _, { cloneDeep, forOwn, get, set } from 'lodash';
-import * as Rx from 'rxjs';
-import { CoreStart, LegacyCoreStart } from 'kibana/public';
-
-const isSystemApiRequest = (request: any) =>
- Boolean(request && request.headers && !!request.headers['kbn-system-api']);
-
-export const configureAppAngularModule = (angularModule: IModule, newPlatform: LegacyCoreStart) => {
- const legacyMetadata = newPlatform.injectedMetadata.getLegacyMetadata();
-
- forOwn(newPlatform.injectedMetadata.getInjectedVars(), (val, name) => {
- if (name !== undefined) {
- // The legacy platform modifies some of these values, clone to an unfrozen object.
- angularModule.value(name, cloneDeep(val));
- }
- });
-
- angularModule
- .value('kbnVersion', newPlatform.injectedMetadata.getKibanaVersion())
- .value('buildNum', legacyMetadata.buildNum)
- .value('buildSha', legacyMetadata.buildSha)
- .value('serverName', legacyMetadata.serverName)
- .value('esUrl', getEsUrl(newPlatform))
- .value('uiCapabilities', newPlatform.application.capabilities)
- .config(setupCompileProvider(newPlatform))
- .config(setupLocationProvider())
- .config($setupXsrfRequestInterceptor(newPlatform))
- .run(capture$httpLoadingCount(newPlatform))
- .run($setupUICapabilityRedirect(newPlatform));
-};
-
-const getEsUrl = (newPlatform: CoreStart) => {
- const a = document.createElement('a');
- a.href = newPlatform.http.basePath.prepend('/elasticsearch');
- const protocolPort = /https/.test(a.protocol) ? 443 : 80;
- const port = a.port || protocolPort;
- return {
- host: a.hostname,
- port,
- protocol: a.protocol,
- pathname: a.pathname,
- };
-};
-
-const setupCompileProvider = (newPlatform: LegacyCoreStart) => (
- $compileProvider: ICompileProvider
-) => {
- if (!newPlatform.injectedMetadata.getLegacyMetadata().devMode) {
- $compileProvider.debugInfoEnabled(false);
- }
-};
-
-const setupLocationProvider = () => ($locationProvider: ILocationProvider) => {
- $locationProvider.html5Mode({
- enabled: false,
- requireBase: false,
- rewriteLinks: false,
- });
-
- $locationProvider.hashPrefix('');
-};
-
-const $setupXsrfRequestInterceptor = (newPlatform: LegacyCoreStart) => {
- const version = newPlatform.injectedMetadata.getLegacyMetadata().version;
-
- // Configure jQuery prefilter
- $.ajaxPrefilter(({ kbnXsrfToken = true }: any, originalOptions, jqXHR) => {
- if (kbnXsrfToken) {
- jqXHR.setRequestHeader('kbn-version', version);
- }
- });
-
- return ($httpProvider: IHttpProvider) => {
- // Configure $httpProvider interceptor
- $httpProvider.interceptors.push(() => {
- return {
- request(opts) {
- const { kbnXsrfToken = true } = opts as any;
- if (kbnXsrfToken) {
- set(opts, ['headers', 'kbn-version'], version);
- }
- return opts;
- },
- };
- });
- };
-};
-
-/**
- * Injected into angular module by ui/chrome angular integration
- * and adds a root-level watcher that will capture the count of
- * active $http requests on each digest loop and expose the count to
- * the core.loadingCount api
- * @param {Angular.Scope} $rootScope
- * @param {HttpService} $http
- * @return {undefined}
- */
-const capture$httpLoadingCount = (newPlatform: CoreStart) => (
- $rootScope: IRootScopeService,
- $http: IHttpService
-) => {
- newPlatform.http.addLoadingCountSource(
- new Rx.Observable(observer => {
- const unwatch = $rootScope.$watch(() => {
- const reqs = $http.pendingRequests || [];
- observer.next(reqs.filter(req => !isSystemApiRequest(req)).length);
- });
-
- return unwatch;
- })
- );
-};
-
-/**
- * integrates with angular to automatically redirect to home if required
- * capability is not met
- */
-const $setupUICapabilityRedirect = (newPlatform: CoreStart) => (
- $rootScope: IRootScopeService,
- $injector: any
-) => {
- const isKibanaAppRoute = window.location.pathname.endsWith('/app/kibana');
- // this feature only works within kibana app for now after everything is
- // switched to the application service, this can be changed to handle all
- // apps.
- if (!isKibanaAppRoute) {
- return;
- }
- $rootScope.$on(
- '$routeChangeStart',
- (event, { $$route: route }: { $$route?: { requireUICapability: boolean } } = {}) => {
- if (!route || !route.requireUICapability) {
- return;
- }
-
- if (!get(newPlatform.application.capabilities, route.requireUICapability)) {
- $injector.get('kbnUrl').change('/home');
- event.preventDefault();
- }
- }
- );
-};
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/index.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/angular/index.ts
deleted file mode 100644
index 8fd8d170bbb40..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/index.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-import angular, { IModule } from 'angular';
-
-import { AppMountContext, LegacyCoreStart } from 'kibana/public';
-
-// @ts-ignore TODO: change to absolute path
-import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
-// @ts-ignore TODO: change to absolute path
-import chrome from 'plugins/monitoring/np_imports/ui/chrome';
-// @ts-ignore TODO: change to absolute path
-import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
-// @ts-ignore TODO: change to absolute path
-import { registerTimefilterWithGlobalState } from 'plugins/monitoring/np_imports/ui/timefilter';
-import { configureAppAngularModule } from './angular_config';
-
-import { localAppModule, appModuleName } from './modules';
-
-export class AngularApp {
- private injector?: angular.auto.IInjectorService;
-
- constructor({ core }: AppMountContext, { element }: { element: HTMLElement }) {
- uiModules.addToModule();
- const app: IModule = localAppModule(core);
- app.config(($routeProvider: any) => {
- $routeProvider.eagerInstantiationEnabled(false);
- uiRoutes.addToProvider($routeProvider);
- });
- configureAppAngularModule(app, core as LegacyCoreStart);
- registerTimefilterWithGlobalState(app);
- const appElement = document.createElement('div');
- appElement.setAttribute('style', 'height: 100%');
- appElement.innerHTML = '';
- this.injector = angular.bootstrap(appElement, [appModuleName]);
- chrome.setInjector(this.injector);
- angular.element(element).append(appElement);
- }
-
- public destroy = () => {
- if (this.injector) {
- this.injector.get('$rootScope').$destroy();
- }
- };
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/modules.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/angular/modules.ts
deleted file mode 100644
index c6031cb220334..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/modules.ts
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.
- */
-
-import angular, { IWindowService } from 'angular';
-// required for `ngSanitize` angular module
-import 'angular-sanitize';
-import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular';
-
-import { AppMountContext } from 'kibana/public';
-import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
-import {
- createTopNavDirective,
- createTopNavHelper,
-} from '../../../../../../../src/plugins/kibana_legacy/public';
-
-import {
- GlobalStateProvider,
- StateManagementConfigProvider,
- AppStateProvider,
- KbnUrlProvider,
- npStart,
-} from '../legacy_imports';
-
-// @ts-ignore
-import { PromiseServiceCreator } from './providers/promises';
-// @ts-ignore
-import { PrivateProvider } from './providers/private';
-import { getSafeForExternalLink } from '../../lib/get_safe_for_external_link';
-
-type IPrivate = (provider: (...injectable: any[]) => T) => T;
-
-export const appModuleName = 'monitoring';
-const thirdPartyAngularDependencies = ['ngSanitize', 'ngRoute', 'react'];
-
-export const localAppModule = (core: AppMountContext['core']) => {
- createLocalI18nModule();
- createLocalPrivateModule();
- createLocalPromiseModule();
- createLocalStorage();
- createLocalConfigModule(core);
- createLocalKbnUrlModule();
- createLocalStateModule();
- createLocalTopNavModule(npStart.plugins.navigation);
- createHrefModule(core);
-
- const appModule = angular.module(appModuleName, [
- ...thirdPartyAngularDependencies,
- 'monitoring/Config',
- 'monitoring/I18n',
- 'monitoring/Private',
- 'monitoring/TopNav',
- 'monitoring/State',
- 'monitoring/Storage',
- 'monitoring/href',
- 'monitoring/services',
- 'monitoring/filters',
- 'monitoring/directives',
- ]);
- return appModule;
-};
-
-function createLocalStateModule() {
- angular
- .module('monitoring/State', [
- 'monitoring/Private',
- 'monitoring/Config',
- 'monitoring/KbnUrl',
- 'monitoring/Promise',
- ])
- .factory('AppState', function(Private: IPrivate) {
- return Private(AppStateProvider);
- })
- .service('globalState', function(Private: IPrivate) {
- return Private(GlobalStateProvider);
- });
-}
-
-function createLocalKbnUrlModule() {
- angular
- .module('monitoring/KbnUrl', ['monitoring/Private', 'ngRoute'])
- .service('kbnUrl', (Private: IPrivate) => Private(KbnUrlProvider));
-}
-
-function createLocalConfigModule(core: AppMountContext['core']) {
- angular
- .module('monitoring/Config', ['monitoring/Private'])
- .provider('stateManagementConfig', StateManagementConfigProvider)
- .provider('config', () => {
- return {
- $get: () => ({
- get: core.uiSettings.get.bind(core.uiSettings),
- }),
- };
- });
-}
-
-function createLocalPromiseModule() {
- angular.module('monitoring/Promise', []).service('Promise', PromiseServiceCreator);
-}
-
-function createLocalStorage() {
- angular
- .module('monitoring/Storage', [])
- .service('localStorage', ($window: IWindowService) => new Storage($window.localStorage))
- .service('sessionStorage', ($window: IWindowService) => new Storage($window.sessionStorage))
- .service('sessionTimeout', () => {});
-}
-
-function createLocalPrivateModule() {
- angular.module('monitoring/Private', []).provider('Private', PrivateProvider);
-}
-
-function createLocalTopNavModule({ ui }: any) {
- angular
- .module('monitoring/TopNav', ['react'])
- .directive('kbnTopNav', createTopNavDirective)
- .directive('kbnTopNavHelper', createTopNavHelper(ui));
-}
-
-function createLocalI18nModule() {
- angular
- .module('monitoring/I18n', [])
- .provider('i18n', I18nProvider)
- .filter('i18n', i18nFilter)
- .directive('i18nId', i18nDirective);
-}
-
-function createHrefModule(core: AppMountContext['core']) {
- const name: string = 'kbnHref';
- angular.module('monitoring/href', []).directive(name, () => {
- return {
- restrict: 'A',
- link: {
- pre: (_$scope, _$el, $attr) => {
- $attr.$observe(name, val => {
- if (val) {
- const url = getSafeForExternalLink(val as string);
- $attr.$set('href', core.http.basePath.prepend(url));
- }
- });
- },
- },
- };
- });
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/promises.js b/x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/promises.js
deleted file mode 100644
index 22adccaf3db7f..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/angular/providers/promises.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.
- */
-
-import _ from 'lodash';
-
-export function PromiseServiceCreator($q, $timeout) {
- function Promise(fn) {
- if (typeof this === 'undefined')
- throw new Error('Promise constructor must be called with "new"');
-
- const defer = $q.defer();
- try {
- fn(defer.resolve, defer.reject);
- } catch (e) {
- defer.reject(e);
- }
- return defer.promise;
- }
-
- Promise.all = Promise.props = $q.all;
- Promise.resolve = function(val) {
- const defer = $q.defer();
- defer.resolve(val);
- return defer.promise;
- };
- Promise.reject = function(reason) {
- const defer = $q.defer();
- defer.reject(reason);
- return defer.promise;
- };
- Promise.cast = $q.when;
- Promise.delay = function(ms) {
- return $timeout(_.noop, ms);
- };
- Promise.method = function(fn) {
- return function() {
- const args = Array.prototype.slice.call(arguments);
- return Promise.try(fn, args, this);
- };
- };
- Promise.nodeify = function(promise, cb) {
- promise.then(function(val) {
- cb(void 0, val);
- }, cb);
- };
- Promise.map = function(arr, fn) {
- return Promise.all(
- arr.map(function(i, el, list) {
- return Promise.try(fn, [i, el, list]);
- })
- );
- };
- Promise.each = function(arr, fn) {
- const queue = arr.slice(0);
- let i = 0;
- return (function next() {
- if (!queue.length) return arr;
- return Promise.try(fn, [arr.shift(), i++]).then(next);
- })();
- };
- Promise.is = function(obj) {
- // $q doesn't create instances of any constructor, promises are just objects with a then function
- // https://github.com/angular/angular.js/blob/58f5da86645990ef984353418cd1ed83213b111e/src/ng/q.js#L335
- return obj && typeof obj.then === 'function';
- };
- Promise.halt = _.once(function() {
- const promise = new Promise(() => {});
- promise.then = _.constant(promise);
- promise.catch = _.constant(promise);
- return promise;
- });
- Promise.try = function(fn, args, ctx) {
- if (typeof fn !== 'function') {
- return Promise.reject(new TypeError('fn must be a function'));
- }
-
- let value;
-
- if (Array.isArray(args)) {
- try {
- value = fn.apply(ctx, args);
- } catch (e) {
- return Promise.reject(e);
- }
- } else {
- try {
- value = fn.call(ctx, args);
- } catch (e) {
- return Promise.reject(e);
- }
- }
-
- return Promise.resolve(value);
- };
- Promise.fromNode = function(takesCbFn) {
- return new Promise(function(resolve, reject) {
- takesCbFn(function(err, ...results) {
- if (err) reject(err);
- else if (results.length > 1) resolve(results);
- else resolve(results[0]);
- });
- });
- };
- Promise.race = function(iterable) {
- return new Promise((resolve, reject) => {
- for (const i of iterable) {
- Promise.resolve(i).then(resolve, reject);
- }
- });
- };
-
- return Promise;
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/legacy_imports.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/legacy_imports.ts
deleted file mode 100644
index 208b7e2acdb0f..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/legacy_imports.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Last remaining 'ui/*' imports that will eventually be shimmed with their np alternatives
- */
-
-export { npSetup, npStart } from 'ui/new_platform';
-// @ts-ignore
-export { GlobalStateProvider } from 'ui/state_management/global_state';
-// @ts-ignore
-export { StateManagementConfigProvider } from 'ui/state_management/config_provider';
-// @ts-ignore
-export { AppStateProvider } from 'ui/state_management/app_state';
-// @ts-ignore
-export { EventsProvider } from 'ui/events';
-// @ts-ignore
-export { KbnUrlProvider } from 'ui/url';
-export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/chrome.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/ui/chrome.ts
deleted file mode 100644
index f0c5bacabecbf..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/chrome.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-import angular from 'angular';
-import { npStart, npSetup } from '../legacy_imports';
-
-type OptionalInjector = void | angular.auto.IInjectorService;
-
-class Chrome {
- private injector?: OptionalInjector;
-
- public setInjector = (injector: OptionalInjector): void => void (this.injector = injector);
- public dangerouslyGetActiveInjector = (): OptionalInjector => this.injector;
-
- public getBasePath = (): string => npStart.core.http.basePath.get();
-
- public getInjected = (name?: string, defaultValue?: any): string | unknown => {
- const { getInjectedVar, getInjectedVars } = npSetup.core.injectedMetadata;
- return name ? getInjectedVar(name, defaultValue) : getInjectedVars();
- };
-
- public get breadcrumbs() {
- const set = (...args: any[]) => npStart.core.chrome.setBreadcrumbs.apply(this, args as any);
- return { set };
- }
-}
-
-const chrome = new Chrome();
-
-export default chrome; // eslint-disable-line import/no-default-export
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/modules.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/ui/modules.ts
deleted file mode 100644
index 70201a7906110..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/modules.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.
- */
-
-import angular from 'angular';
-
-type PrivateProvider = (...args: any) => any;
-interface Provider {
- name: string;
- provider: PrivateProvider;
-}
-
-class Modules {
- private _services: Provider[] = [];
- private _filters: Provider[] = [];
- private _directives: Provider[] = [];
-
- public get = (_name: string, _dep?: string[]) => {
- return this;
- };
-
- public service = (...args: any) => {
- this._services.push(args);
- };
-
- public filter = (...args: any) => {
- this._filters.push(args);
- };
-
- public directive = (...args: any) => {
- this._directives.push(args);
- };
-
- public addToModule = () => {
- angular.module('monitoring/services', []);
- angular.module('monitoring/filters', []);
- angular.module('monitoring/directives', []);
-
- this._services.forEach(args => {
- angular.module('monitoring/services').service.apply(null, args as any);
- });
-
- this._filters.forEach(args => {
- angular.module('monitoring/filters').filter.apply(null, args as any);
- });
-
- this._directives.forEach(args => {
- angular.module('monitoring/directives').directive.apply(null, args as any);
- });
- };
-}
-
-export const uiModules = new Modules();
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/timefilter.ts b/x-pack/legacy/plugins/monitoring/public/np_imports/ui/timefilter.ts
deleted file mode 100644
index e28699bd126b9..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/timefilter.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-
-import { IModule, IRootScopeService } from 'angular';
-import { npStart, registerTimefilterWithGlobalStateFactory } from '../legacy_imports';
-
-const {
- core: { uiSettings },
-} = npStart;
-export const { timefilter } = npStart.plugins.data.query.timefilter;
-
-uiSettings.overrideLocalDefault(
- 'timepicker:refreshIntervalDefaults',
- JSON.stringify({ value: 10000, pause: false })
-);
-uiSettings.overrideLocalDefault(
- 'timepicker:timeDefaults',
- JSON.stringify({ from: 'now-1h', to: 'now' })
-);
-
-export const registerTimefilterWithGlobalState = (app: IModule) => {
- app.run((globalState: any, $rootScope: IRootScopeService) => {
- globalState.fetch();
- globalState.$inheritedGlobalState = true;
- globalState.save();
- registerTimefilterWithGlobalStateFactory(timefilter, globalState, $rootScope);
- });
-};
diff --git a/x-pack/legacy/plugins/monitoring/public/np_ready/plugin.ts b/x-pack/legacy/plugins/monitoring/public/np_ready/plugin.ts
deleted file mode 100644
index 5598a7a51cf42..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/np_ready/plugin.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-import { App, CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
-
-export class MonitoringPlugin implements Plugin {
- constructor(ctx: PluginInitializerContext) {}
-
- public setup(core: CoreSetup, plugins: any) {
- const app: App = {
- id: 'monitoring',
- title: 'Monitoring',
- mount: async (context, params) => {
- const { AngularApp } = await import('../np_imports/angular');
- const monitoringApp = new AngularApp(context, params);
- return monitoringApp.destroy;
- },
- };
-
- core.application.register(app);
- }
-
- public start(core: CoreStart, plugins: any) {}
- public stop() {}
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/register_feature.ts b/x-pack/legacy/plugins/monitoring/public/register_feature.ts
deleted file mode 100644
index 9b72e01a19394..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/register_feature.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-
-import { i18n } from '@kbn/i18n';
-import chrome from 'ui/chrome';
-import { npSetup } from 'ui/new_platform';
-import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public';
-
-const {
- plugins: { home },
-} = npSetup;
-
-if (chrome.getInjected('monitoringUiEnabled')) {
- home.featureCatalogue.register({
- id: 'monitoring',
- title: i18n.translate('xpack.monitoring.monitoringTitle', {
- defaultMessage: 'Monitoring',
- }),
- description: i18n.translate('xpack.monitoring.monitoringDescription', {
- defaultMessage: 'Track the real-time health and performance of your Elastic Stack.',
- }),
- icon: 'monitoringApp',
- path: '/app/monitoring',
- showOnHomePage: true,
- category: FeatureCatalogueCategory.ADMIN,
- });
-}
diff --git a/x-pack/legacy/plugins/monitoring/public/services/breadcrumbs.js b/x-pack/legacy/plugins/monitoring/public/services/breadcrumbs.js
deleted file mode 100644
index d0fe600386307..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/services/breadcrumbs.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * 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.
- */
-
-import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
-import { breadcrumbsProvider } from './breadcrumbs_provider';
-const uiModule = uiModules.get('monitoring/breadcrumbs', []);
-uiModule.service('breadcrumbs', breadcrumbsProvider);
diff --git a/x-pack/legacy/plugins/monitoring/public/services/executor.js b/x-pack/legacy/plugins/monitoring/public/services/executor.js
deleted file mode 100644
index 5004cd0238012..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/services/executor.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * 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.
- */
-
-import { uiModules } from 'plugins/monitoring/np_imports/ui/modules';
-import { executorProvider } from './executor_provider';
-const uiModule = uiModules.get('monitoring/executor', []);
-uiModule.service('$executor', executorProvider);
diff --git a/x-pack/legacy/plugins/monitoring/public/views/kibana/instance/index.js b/x-pack/legacy/plugins/monitoring/public/views/kibana/instance/index.js
deleted file mode 100644
index 6535bd7410445..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/views/kibana/instance/index.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Kibana Instance
- */
-import React from 'react';
-import { get } from 'lodash';
-import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
-import { ajaxErrorHandlersProvider } from 'plugins/monitoring/lib/ajax_error_handler';
-import { routeInitProvider } from 'plugins/monitoring/lib/route_init';
-import template from './index.html';
-import { timefilter } from 'plugins/monitoring/np_imports/ui/timefilter';
-import {
- EuiPage,
- EuiPageBody,
- EuiPageContent,
- EuiSpacer,
- EuiFlexGrid,
- EuiFlexItem,
- EuiPanel,
-} from '@elastic/eui';
-import { MonitoringTimeseriesContainer } from '../../../components/chart';
-import { DetailStatus } from 'plugins/monitoring/components/kibana/detail_status';
-import { I18nContext } from 'ui/i18n';
-import { MonitoringViewBaseController } from '../../base_controller';
-import { CODE_PATH_KIBANA } from '../../../../common/constants';
-
-function getPageData($injector) {
- const $http = $injector.get('$http');
- const globalState = $injector.get('globalState');
- const $route = $injector.get('$route');
- const url = `../api/monitoring/v1/clusters/${globalState.cluster_uuid}/kibana/${$route.current.params.uuid}`;
- const timeBounds = timefilter.getBounds();
-
- return $http
- .post(url, {
- ccs: globalState.ccs,
- timeRange: {
- min: timeBounds.min.toISOString(),
- max: timeBounds.max.toISOString(),
- },
- })
- .then(response => response.data)
- .catch(err => {
- const Private = $injector.get('Private');
- const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider);
- return ajaxErrorHandlers(err);
- });
-}
-
-uiRoutes.when('/kibana/instances/:uuid', {
- template,
- resolve: {
- clusters(Private) {
- const routeInit = Private(routeInitProvider);
- return routeInit({ codePaths: [CODE_PATH_KIBANA] });
- },
- pageData: getPageData,
- },
- controllerAs: 'monitoringKibanaInstanceApp',
- controller: class extends MonitoringViewBaseController {
- constructor($injector, $scope) {
- super({
- title: `Kibana - ${get($scope.pageData, 'kibanaSummary.name')}`,
- defaultData: {},
- getPageData,
- reactNodeId: 'monitoringKibanaInstanceApp',
- $scope,
- $injector,
- });
-
- $scope.$watch(
- () => this.data,
- data => {
- if (!data || !data.metrics) {
- return;
- }
-
- this.setTitle(`Kibana - ${get(data, 'kibanaSummary.name')}`);
-
- this.renderReact(
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
- );
- }
- },
-});
diff --git a/x-pack/legacy/plugins/monitoring/public/views/loading/index.html b/x-pack/legacy/plugins/monitoring/public/views/loading/index.html
deleted file mode 100644
index 11da26a0ceed2..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/views/loading/index.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/x-pack/legacy/plugins/monitoring/public/views/loading/index.js b/x-pack/legacy/plugins/monitoring/public/views/loading/index.js
deleted file mode 100644
index 0488683845a7d..0000000000000
--- a/x-pack/legacy/plugins/monitoring/public/views/loading/index.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.
- */
-
-import React from 'react';
-import { render, unmountComponentAtNode } from 'react-dom';
-import { PageLoading } from 'plugins/monitoring/components';
-import uiRoutes from 'plugins/monitoring/np_imports/ui/routes';
-import { I18nContext } from 'ui/i18n';
-import template from './index.html';
-import { CODE_PATH_LICENSE } from '../../../common/constants';
-
-const REACT_DOM_ID = 'monitoringLoadingReactApp';
-
-uiRoutes.when('/loading', {
- template,
- controller: class {
- constructor($injector, $scope) {
- const monitoringClusters = $injector.get('monitoringClusters');
- const kbnUrl = $injector.get('kbnUrl');
-
- $scope.$on('$destroy', () => {
- unmountComponentAtNode(document.getElementById(REACT_DOM_ID));
- });
-
- $scope.$$postDigest(() => {
- this.renderReact();
- });
-
- monitoringClusters(undefined, undefined, [CODE_PATH_LICENSE]).then(clusters => {
- if (clusters && clusters.length) {
- kbnUrl.changePath('/home');
- return;
- }
- kbnUrl.changePath('/no-data');
- return;
- });
- }
-
- renderReact() {
- render(
-
-
- ,
- document.getElementById(REACT_DOM_ID)
- );
- }
- },
-});
diff --git a/x-pack/legacy/plugins/monitoring/ui_exports.js b/x-pack/legacy/plugins/monitoring/ui_exports.js
deleted file mode 100644
index e0c04411ef46b..0000000000000
--- a/x-pack/legacy/plugins/monitoring/ui_exports.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-import { i18n } from '@kbn/i18n';
-import { resolve } from 'path';
-import {
- MONITORING_CONFIG_ALERTING_EMAIL_ADDRESS,
- KIBANA_ALERTING_ENABLED,
-} from './common/constants';
-import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils';
-
-/**
- * Configuration of dependency objects for the UI, which are needed for the
- * Monitoring UI app and views and data for outside the monitoring
- * app (injectDefaultVars and hacks)
- * @return {Object} data per Kibana plugin uiExport schema
- */
-export const getUiExports = () => {
- const uiSettingDefaults = {};
- if (KIBANA_ALERTING_ENABLED) {
- uiSettingDefaults[MONITORING_CONFIG_ALERTING_EMAIL_ADDRESS] = {
- name: i18n.translate('xpack.monitoring.alertingEmailAddress.name', {
- defaultMessage: 'Alerting email address',
- }),
- value: '',
- description: i18n.translate('xpack.monitoring.alertingEmailAddress.description', {
- defaultMessage: `The default email address to receive alerts from Stack Monitoring`,
- }),
- category: ['monitoring'],
- };
- }
-
- return {
- app: {
- title: i18n.translate('xpack.monitoring.stackMonitoringTitle', {
- defaultMessage: 'Stack Monitoring',
- }),
- order: 9002,
- description: i18n.translate('xpack.monitoring.uiExportsDescription', {
- defaultMessage: 'Monitoring for Elastic Stack',
- }),
- icon: 'plugins/monitoring/icons/monitoring.svg',
- euiIconType: 'monitoringApp',
- linkToLastSubUrl: false,
- main: 'plugins/monitoring/legacy',
- category: DEFAULT_APP_CATEGORIES.management,
- },
- injectDefaultVars(server) {
- const config = server.config();
- return {
- monitoringUiEnabled: config.get('monitoring.ui.enabled'),
- monitoringLegacyEmailAddress: config.get(
- 'monitoring.cluster_alerts.email_notifications.email_address'
- ),
- };
- },
- uiSettingDefaults,
- hacks: ['plugins/monitoring/hacks/toggle_app_link_in_nav'],
- home: ['plugins/monitoring/register_feature'],
- styleSheetPaths: resolve(__dirname, 'public/index.scss'),
- };
-};
diff --git a/x-pack/legacy/plugins/xpack_main/server/routes/api/v1/settings.js b/x-pack/legacy/plugins/xpack_main/server/routes/api/v1/settings.js
index c830fc9fcd483..99071a2f85e13 100644
--- a/x-pack/legacy/plugins/xpack_main/server/routes/api/v1/settings.js
+++ b/x-pack/legacy/plugins/xpack_main/server/routes/api/v1/settings.js
@@ -6,7 +6,7 @@
import { boomify } from 'boom';
import { get } from 'lodash';
-import { KIBANA_SETTINGS_TYPE } from '../../../../../monitoring/common/constants';
+import { KIBANA_SETTINGS_TYPE } from '../../../../../../../plugins/monitoring/common/constants';
const getClusterUuid = async callCluster => {
const { cluster_uuid: uuid } = await callCluster('info', { filterPath: 'cluster_uuid' });
diff --git a/x-pack/plugins/actions/README.md b/x-pack/plugins/actions/README.md
index decd170ca5dd6..4c8cc3aa503e6 100644
--- a/x-pack/plugins/actions/README.md
+++ b/x-pack/plugins/actions/README.md
@@ -28,7 +28,7 @@ Table of Contents
- [RESTful API](#restful-api)
- [`POST /api/action`: Create action](#post-apiaction-create-action)
- [`DELETE /api/action/{id}`: Delete action](#delete-apiactionid-delete-action)
- - [`GET /api/action/_getAll`: Get all actions](#get-apiaction-get-all-actions)
+ - [`GET /api/action/_getAll`: Get all actions](#get-apiactiongetall-get-all-actions)
- [`GET /api/action/{id}`: Get action](#get-apiactionid-get-action)
- [`GET /api/action/types`: List action types](#get-apiactiontypes-list-action-types)
- [`PUT /api/action/{id}`: Update action](#put-apiactionid-update-action)
@@ -64,6 +64,12 @@ Table of Contents
- [`config`](#config-6)
- [`secrets`](#secrets-6)
- [`params`](#params-6)
+ - [`subActionParams (pushToService)`](#subactionparams-pushtoservice)
+ - [Jira](#jira)
+ - [`config`](#config-7)
+ - [`secrets`](#secrets-7)
+ - [`params`](#params-7)
+ - [`subActionParams (pushToService)`](#subactionparams-pushtoservice-1)
- [Command Line Utility](#command-line-utility)
## Terminology
@@ -143,8 +149,8 @@ This is the primary function for an action type. Whenever the action needs to ex
| actionId | The action saved object id that the action type is executing for. |
| config | The decrypted configuration given to an action. This comes from the action saved object that is partially or fully encrypted within the data store. If you would like to validate the config before being passed to the executor, define `validate.config` within the action type. |
| params | Parameters for the execution. These will be given at execution time by either an alert or manually provided when calling the plugin provided execute function. |
-| services.callCluster(path, opts) | Use this to do Elasticsearch queries on the cluster Kibana connects to. This function is the same as any other `callCluster` in Kibana but runs in the context of the user who is calling the action when security is enabled.|
-| services.getScopedCallCluster | This function scopes an instance of CallCluster by returning a `callCluster(path, opts)` function that runs in the context of the user who is calling the action when security is enabled. This must only be called with instances of CallCluster provided by core.|
+| services.callCluster(path, opts) | Use this to do Elasticsearch queries on the cluster Kibana connects to. This function is the same as any other `callCluster` in Kibana but runs in the context of the user who is calling the action when security is enabled. |
+| services.getScopedCallCluster | This function scopes an instance of CallCluster by returning a `callCluster(path, opts)` function that runs in the context of the user who is calling the action when security is enabled. This must only be called with instances of CallCluster provided by core. |
| services.savedObjectsClient | This is an instance of the saved objects client. This provides the ability to do CRUD on any saved objects within the same space the alert lives in.
The scope of the saved objects client is tied to the user in context calling the execute API or the API key provided to the execute plugin function (only when security isenabled). |
| services.log(tags, [data], [timestamp]) | Use this to create server logs. (This is the same function as server.log) |
@@ -483,13 +489,59 @@ The ServiceNow action uses the [V2 Table API](https://developer.servicenow.com/a
### `params`
+| Property | Description | Type |
+| --------------- | ------------------------------------------------------------------------------------ | ------ |
+| subAction | The sub action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string |
+| subActionParams | The parameters of the sub action | object |
+
+#### `subActionParams (pushToService)`
+
| Property | Description | Type |
| ----------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| caseId | The case id | string |
| title | The title of the case | string _(optional)_ |
| description | The description of the case | string _(optional)_ |
| comments | The comments of the case. A comment is of the form `{ commentId: string, version: string, comment: string }` | object[] _(optional)_ |
-| incidentID | The id of the incident in ServiceNow . If presented the incident will be update. Otherwise a new incident will be created. | string _(optional)_ |
+| externalId | The id of the incident in ServiceNow . If presented the incident will be update. Otherwise a new incident will be created. | string _(optional)_ |
+
+---
+
+## Jira
+
+ID: `.jira`
+
+The Jira action uses the [V2 API](https://developer.atlassian.com/cloud/jira/platform/rest/v2/) to create and update Jira incidents.
+
+### `config`
+
+| Property | Description | Type |
+| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
+| apiUrl | ServiceNow instance URL. | string |
+| casesConfiguration | Case configuration object. The object should contain an attribute called `mapping`. A `mapping` is an array of objects. Each mapping object should be of the form `{ source: string, target: string, actionType: string }`. `source` is the Case field. `target` is the Jira field where `source` will be mapped to. `actionType` can be one of `nothing`, `overwrite` or `append`. For example the `{ source: 'title', target: 'summary', actionType: 'overwrite' }` record, inside mapping array, means that the title of a case will be mapped to the short description of an incident in ServiceNow and will be overwrite on each update. | object |
+
+### `secrets`
+
+| Property | Description | Type |
+| -------- | --------------------------------------- | ------ |
+| email | email for HTTP Basic authentication | string |
+| apiToken | API token for HTTP Basic authentication | string |
+
+### `params`
+
+| Property | Description | Type |
+| --------------- | ------------------------------------------------------------------------------------ | ------ |
+| subAction | The sub action to perform. It can be `pushToService`, `handshake`, and `getIncident` | string |
+| subActionParams | The parameters of the sub action | object |
+
+#### `subActionParams (pushToService)`
+
+| Property | Description | Type |
+| ----------- | ------------------------------------------------------------------------------------------------------------------- | --------------------- |
+| caseId | The case id | string |
+| title | The title of the case | string _(optional)_ |
+| description | The description of the case | string _(optional)_ |
+| comments | The comments of the case. A comment is of the form `{ commentId: string, version: string, comment: string }` | object[] _(optional)_ |
+| externalId | The id of the incident in Jira. If presented the incident will be update. Otherwise a new incident will be created. | string _(optional)_ |
# Command Line Utility
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/api.ts b/x-pack/plugins/actions/server/builtin_action_types/case/api.ts
new file mode 100644
index 0000000000000..6dc8a9cc9af6a
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/api.ts
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+import {
+ ExternalServiceApi,
+ ExternalServiceParams,
+ PushToServiceResponse,
+ GetIncidentApiHandlerArgs,
+ HandshakeApiHandlerArgs,
+ PushToServiceApiHandlerArgs,
+} from './types';
+import { prepareFieldsForTransformation, transformFields, transformComments } from './utils';
+
+const handshakeHandler = async ({
+ externalService,
+ mapping,
+ params,
+}: HandshakeApiHandlerArgs) => {};
+const getIncidentHandler = async ({
+ externalService,
+ mapping,
+ params,
+}: GetIncidentApiHandlerArgs) => {};
+
+const pushToServiceHandler = async ({
+ externalService,
+ mapping,
+ params,
+}: PushToServiceApiHandlerArgs): Promise => {
+ const { externalId, comments } = params;
+ const updateIncident = externalId ? true : false;
+ const defaultPipes = updateIncident ? ['informationUpdated'] : ['informationCreated'];
+ let currentIncident: ExternalServiceParams | undefined;
+ let res: PushToServiceResponse;
+
+ if (externalId) {
+ currentIncident = await externalService.getIncident(externalId);
+ }
+
+ const fields = prepareFieldsForTransformation({
+ params,
+ mapping,
+ defaultPipes,
+ });
+
+ const incident = transformFields({
+ params,
+ fields,
+ currentIncident,
+ });
+
+ if (updateIncident) {
+ res = await externalService.updateIncident({ incidentId: externalId, incident });
+ } else {
+ res = await externalService.createIncident({ incident });
+ }
+
+ if (
+ comments &&
+ Array.isArray(comments) &&
+ comments.length > 0 &&
+ mapping.get('comments')?.actionType !== 'nothing'
+ ) {
+ const commentsTransformed = transformComments(comments, ['informationAdded']);
+
+ res.comments = [];
+ for (const currentComment of commentsTransformed) {
+ const comment = await externalService.createComment({
+ incidentId: res.id,
+ comment: currentComment,
+ field: mapping.get('comments')?.target ?? 'comments',
+ });
+ res.comments = [
+ ...(res.comments ?? []),
+ {
+ commentId: comment.commentId,
+ pushedDate: comment.pushedDate,
+ },
+ ];
+ }
+ }
+
+ return res;
+};
+
+export const api: ExternalServiceApi = {
+ handshake: handshakeHandler,
+ pushToService: pushToServiceHandler,
+ getIncident: getIncidentHandler,
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/constants.ts b/x-pack/plugins/actions/server/builtin_action_types/case/constants.ts
similarity index 87%
rename from x-pack/plugins/actions/server/builtin_action_types/servicenow/constants.ts
rename to x-pack/plugins/actions/server/builtin_action_types/case/constants.ts
index a0ffd859e14ca..1f2bc7f5e8e53 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/constants.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/constants.ts
@@ -4,5 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export const ACTION_TYPE_ID = '.servicenow';
export const SUPPORTED_SOURCE_FIELDS = ['title', 'comments', 'description'];
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts
new file mode 100644
index 0000000000000..33b2ad6d18684
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/schema.ts
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+import { schema } from '@kbn/config-schema';
+
+export const MappingActionType = schema.oneOf([
+ schema.literal('nothing'),
+ schema.literal('overwrite'),
+ schema.literal('append'),
+]);
+
+export const MapRecordSchema = schema.object({
+ source: schema.string(),
+ target: schema.string(),
+ actionType: MappingActionType,
+});
+
+export const CaseConfigurationSchema = schema.object({
+ mapping: schema.arrayOf(MapRecordSchema),
+});
+
+export const ExternalIncidentServiceConfiguration = {
+ apiUrl: schema.string(),
+ casesConfiguration: CaseConfigurationSchema,
+};
+
+export const ExternalIncidentServiceConfigurationSchema = schema.object(
+ ExternalIncidentServiceConfiguration
+);
+
+export const ExternalIncidentServiceSecretConfiguration = {
+ password: schema.string(),
+ username: schema.string(),
+};
+
+export const ExternalIncidentServiceSecretConfigurationSchema = schema.object(
+ ExternalIncidentServiceSecretConfiguration
+);
+
+export const UserSchema = schema.object({
+ fullName: schema.nullable(schema.string()),
+ username: schema.nullable(schema.string()),
+});
+
+const EntityInformation = {
+ createdAt: schema.string(),
+ createdBy: UserSchema,
+ updatedAt: schema.nullable(schema.string()),
+ updatedBy: schema.nullable(UserSchema),
+};
+
+export const EntityInformationSchema = schema.object(EntityInformation);
+
+export const CommentSchema = schema.object({
+ commentId: schema.string(),
+ comment: schema.string(),
+ ...EntityInformation,
+});
+
+export const ExecutorSubActionSchema = schema.oneOf([
+ schema.literal('getIncident'),
+ schema.literal('pushToService'),
+ schema.literal('handshake'),
+]);
+
+export const ExecutorSubActionPushParamsSchema = schema.object({
+ caseId: schema.string(),
+ title: schema.string(),
+ description: schema.nullable(schema.string()),
+ comments: schema.nullable(schema.arrayOf(CommentSchema)),
+ externalId: schema.nullable(schema.string()),
+ ...EntityInformation,
+});
+
+export const ExecutorSubActionGetIncidentParamsSchema = schema.object({
+ externalId: schema.string(),
+});
+
+// Reserved for future implementation
+export const ExecutorSubActionHandshakeParamsSchema = schema.object({});
+
+export const ExecutorParamsSchema = schema.oneOf([
+ schema.object({
+ subAction: schema.literal('getIncident'),
+ subActionParams: ExecutorSubActionGetIncidentParamsSchema,
+ }),
+ schema.object({
+ subAction: schema.literal('handshake'),
+ subActionParams: ExecutorSubActionHandshakeParamsSchema,
+ }),
+ schema.object({
+ subAction: schema.literal('pushToService'),
+ subActionParams: ExecutorSubActionPushParamsSchema,
+ }),
+]);
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/transformers.test.ts b/x-pack/plugins/actions/server/builtin_action_types/case/transformers.test.ts
new file mode 100644
index 0000000000000..75dcab65ee9f2
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/transformers.test.ts
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+import { transformers } from './transformers';
+
+const { informationCreated, informationUpdated, informationAdded, append } = transformers;
+
+describe('informationCreated', () => {
+ test('transforms correctly', () => {
+ const res = informationCreated({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ });
+ expect(res).toEqual({ value: 'a value (created at 2020-04-15T08:19:27.400Z by elastic)' });
+ });
+
+ test('transforms correctly without optional fields', () => {
+ const res = informationCreated({
+ value: 'a value',
+ });
+ expect(res).toEqual({ value: 'a value (created at by )' });
+ });
+
+ test('returns correctly rest fields', () => {
+ const res = informationCreated({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ previousValue: 'previous value',
+ });
+ expect(res).toEqual({
+ value: 'a value (created at 2020-04-15T08:19:27.400Z by elastic)',
+ previousValue: 'previous value',
+ });
+ });
+});
+
+describe('informationUpdated', () => {
+ test('transforms correctly', () => {
+ const res = informationUpdated({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ });
+ expect(res).toEqual({ value: 'a value (updated at 2020-04-15T08:19:27.400Z by elastic)' });
+ });
+
+ test('transforms correctly without optional fields', () => {
+ const res = informationUpdated({
+ value: 'a value',
+ });
+ expect(res).toEqual({ value: 'a value (updated at by )' });
+ });
+
+ test('returns correctly rest fields', () => {
+ const res = informationUpdated({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ previousValue: 'previous value',
+ });
+ expect(res).toEqual({
+ value: 'a value (updated at 2020-04-15T08:19:27.400Z by elastic)',
+ previousValue: 'previous value',
+ });
+ });
+});
+
+describe('informationAdded', () => {
+ test('transforms correctly', () => {
+ const res = informationAdded({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ });
+ expect(res).toEqual({ value: 'a value (added at 2020-04-15T08:19:27.400Z by elastic)' });
+ });
+
+ test('transforms correctly without optional fields', () => {
+ const res = informationAdded({
+ value: 'a value',
+ });
+ expect(res).toEqual({ value: 'a value (added at by )' });
+ });
+
+ test('returns correctly rest fields', () => {
+ const res = informationAdded({
+ value: 'a value',
+ date: '2020-04-15T08:19:27.400Z',
+ user: 'elastic',
+ previousValue: 'previous value',
+ });
+ expect(res).toEqual({
+ value: 'a value (added at 2020-04-15T08:19:27.400Z by elastic)',
+ previousValue: 'previous value',
+ });
+ });
+});
+
+describe('append', () => {
+ test('transforms correctly', () => {
+ const res = append({
+ value: 'a value',
+ previousValue: 'previous value',
+ });
+ expect(res).toEqual({ value: 'previous value \r\na value' });
+ });
+
+ test('transforms correctly without optional fields', () => {
+ const res = append({
+ value: 'a value',
+ });
+ expect(res).toEqual({ value: 'a value' });
+ });
+
+ test('returns correctly rest fields', () => {
+ const res = append({
+ value: 'a value',
+ user: 'elastic',
+ previousValue: 'previous value',
+ });
+ expect(res).toEqual({
+ value: 'previous value \r\na value',
+ user: 'elastic',
+ });
+ });
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/transformers.ts b/x-pack/plugins/actions/server/builtin_action_types/case/transformers.ts
new file mode 100644
index 0000000000000..3dca1fd703430
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/transformers.ts
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+import { TransformerArgs } from './types';
+import * as i18n from './translations';
+
+export type Transformer = (args: TransformerArgs) => TransformerArgs;
+
+export const transformers: Record = {
+ informationCreated: ({ value, date, user, ...rest }: TransformerArgs): TransformerArgs => ({
+ value: `${value} ${i18n.FIELD_INFORMATION('create', date, user)}`,
+ ...rest,
+ }),
+ informationUpdated: ({ value, date, user, ...rest }: TransformerArgs): TransformerArgs => ({
+ value: `${value} ${i18n.FIELD_INFORMATION('update', date, user)}`,
+ ...rest,
+ }),
+ informationAdded: ({ value, date, user, ...rest }: TransformerArgs): TransformerArgs => ({
+ value: `${value} ${i18n.FIELD_INFORMATION('add', date, user)}`,
+ ...rest,
+ }),
+ append: ({ value, previousValue, ...rest }: TransformerArgs): TransformerArgs => ({
+ value: previousValue ? `${previousValue} \r\n${value}` : `${value}`,
+ ...rest,
+ }),
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/translations.ts b/x-pack/plugins/actions/server/builtin_action_types/case/translations.ts
new file mode 100644
index 0000000000000..4842728b0e4e7
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/translations.ts
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+import { i18n } from '@kbn/i18n';
+
+export const API_URL_REQUIRED = i18n.translate('xpack.actions.builtin.case.connectorApiNullError', {
+ defaultMessage: 'connector [apiUrl] is required',
+});
+
+export const FIELD_INFORMATION = (
+ mode: string,
+ date: string | undefined,
+ user: string | undefined
+) => {
+ switch (mode) {
+ case 'create':
+ return i18n.translate('xpack.actions.builtin.case.common.externalIncidentCreated', {
+ values: { date, user },
+ defaultMessage: '(created at {date} by {user})',
+ });
+ case 'update':
+ return i18n.translate('xpack.actions.builtin.case.common.externalIncidentUpdated', {
+ values: { date, user },
+ defaultMessage: '(updated at {date} by {user})',
+ });
+ case 'add':
+ return i18n.translate('xpack.actions.builtin.case.common.externalIncidentAdded', {
+ values: { date, user },
+ defaultMessage: '(added at {date} by {user})',
+ });
+ default:
+ return i18n.translate('xpack.actions.builtin.case.common.externalIncidentDefault', {
+ values: { date, user },
+ defaultMessage: '(created at {date} by {user})',
+ });
+ }
+};
+
+export const MAPPING_EMPTY = i18n.translate(
+ 'xpack.actions.builtin.case.configuration.emptyMapping',
+ {
+ defaultMessage: '[casesConfiguration.mapping]: expected non-empty but got empty',
+ }
+);
+
+export const WHITE_LISTED_ERROR = (message: string) =>
+ i18n.translate('xpack.actions.builtin.case.configuration.apiWhitelistError', {
+ defaultMessage: 'error configuring connector action: {message}',
+ values: {
+ message,
+ },
+ });
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/types.ts b/x-pack/plugins/actions/server/builtin_action_types/case/types.ts
new file mode 100644
index 0000000000000..459e9d2b03f92
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/types.ts
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+
+// This will have to remain `any` until we can extend connectors with generics
+// and circular dependencies eliminated.
+/* eslint-disable @typescript-eslint/no-explicit-any */
+
+import { TypeOf } from '@kbn/config-schema';
+
+import {
+ ExternalIncidentServiceConfigurationSchema,
+ ExternalIncidentServiceSecretConfigurationSchema,
+ ExecutorParamsSchema,
+ CaseConfigurationSchema,
+ MapRecordSchema,
+ CommentSchema,
+ ExecutorSubActionPushParamsSchema,
+ ExecutorSubActionGetIncidentParamsSchema,
+ ExecutorSubActionHandshakeParamsSchema,
+} from './schema';
+
+export interface AnyParams {
+ [index: string]: string | number | object | undefined | null;
+}
+
+export type ExternalIncidentServiceConfiguration = TypeOf<
+ typeof ExternalIncidentServiceConfigurationSchema
+>;
+export type ExternalIncidentServiceSecretConfiguration = TypeOf<
+ typeof ExternalIncidentServiceSecretConfigurationSchema
+>;
+
+export type ExecutorParams = TypeOf;
+export type ExecutorSubActionPushParams = TypeOf;
+
+export type ExecutorSubActionGetIncidentParams = TypeOf<
+ typeof ExecutorSubActionGetIncidentParamsSchema
+>;
+
+export type ExecutorSubActionHandshakeParams = TypeOf<
+ typeof ExecutorSubActionHandshakeParamsSchema
+>;
+
+export type CaseConfiguration = TypeOf;
+export type MapRecord = TypeOf;
+export type Comment = TypeOf;
+
+export interface ExternalServiceConfiguration {
+ id: string;
+ name: string;
+}
+
+export interface ExternalServiceCredentials {
+ config: Record;
+ secrets: Record;
+}
+
+export interface ExternalServiceValidation {
+ config: (configurationUtilities: any, configObject: any) => void;
+ secrets: (configurationUtilities: any, secrets: any) => void;
+}
+
+export interface ExternalServiceIncidentResponse {
+ id: string;
+ title: string;
+ url: string;
+ pushedDate: string;
+}
+
+export interface ExternalServiceCommentResponse {
+ commentId: string;
+ pushedDate: string;
+ externalCommentId?: string;
+}
+
+export interface ExternalServiceParams {
+ [index: string]: any;
+}
+
+export interface ExternalService {
+ getIncident: (id: string) => Promise;
+ createIncident: (params: ExternalServiceParams) => Promise;
+ updateIncident: (params: ExternalServiceParams) => Promise;
+ createComment: (params: ExternalServiceParams) => Promise;
+}
+
+export interface PushToServiceApiParams extends ExecutorSubActionPushParams {
+ externalCase: Record;
+}
+
+export interface ExternalServiceApiHandlerArgs {
+ externalService: ExternalService;
+ mapping: Map;
+}
+
+export interface PushToServiceApiHandlerArgs extends ExternalServiceApiHandlerArgs {
+ params: PushToServiceApiParams;
+}
+
+export interface GetIncidentApiHandlerArgs extends ExternalServiceApiHandlerArgs {
+ params: ExecutorSubActionGetIncidentParams;
+}
+
+export interface HandshakeApiHandlerArgs extends ExternalServiceApiHandlerArgs {
+ params: ExecutorSubActionHandshakeParams;
+}
+
+export interface PushToServiceResponse extends ExternalServiceIncidentResponse {
+ comments?: ExternalServiceCommentResponse[];
+}
+
+export interface ExternalServiceApi {
+ handshake: (args: HandshakeApiHandlerArgs) => Promise;
+ pushToService: (args: PushToServiceApiHandlerArgs) => Promise;
+ getIncident: (args: GetIncidentApiHandlerArgs) => Promise;
+}
+
+export interface CreateExternalServiceBasicArgs {
+ api: ExternalServiceApi;
+ createExternalService: (credentials: ExternalServiceCredentials) => ExternalService;
+}
+
+export interface CreateExternalServiceArgs extends CreateExternalServiceBasicArgs {
+ config: ExternalServiceConfiguration;
+ validate: ExternalServiceValidation;
+ validationSchema: { config: any; secrets: any };
+}
+
+export interface CreateActionTypeArgs {
+ configurationUtilities: any;
+ executor?: any;
+}
+
+export interface PipedField {
+ key: string;
+ value: string;
+ actionType: string;
+ pipes: string[];
+}
+
+export interface PrepareFieldsForTransformArgs {
+ params: PushToServiceApiParams;
+ mapping: Map;
+ defaultPipes?: string[];
+}
+
+export interface TransformFieldsArgs {
+ params: PushToServiceApiParams;
+ fields: PipedField[];
+ currentIncident?: ExternalServiceParams;
+}
+
+export interface TransformerArgs {
+ value: string;
+ date?: string;
+ user?: string;
+ previousValue?: string;
+}
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.test.ts b/x-pack/plugins/actions/server/builtin_action_types/case/utils.test.ts
similarity index 56%
rename from x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.test.ts
rename to x-pack/plugins/actions/server/builtin_action_types/case/utils.test.ts
index cbcefe6364e8f..1e8cc3eda20e5 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.test.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/utils.test.ts
@@ -4,28 +4,65 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import axios from 'axios';
+
import {
normalizeMapping,
buildMap,
mapParams,
- appendField,
- appendInformationToField,
prepareFieldsForTransformation,
transformFields,
transformComments,
-} from './helpers';
-import { mapping, finalMapping } from './mock';
+ addTimeZoneToDate,
+ throwIfNotAlive,
+ request,
+ patch,
+ getErrorMessage,
+} from './utils';
+
import { SUPPORTED_SOURCE_FIELDS } from './constants';
-import { MapEntry, Params, Comment } from './types';
+import { Comment, MapRecord, PushToServiceApiParams } from './types';
+
+jest.mock('axios');
+const axiosMock = (axios as unknown) as jest.Mock;
+
+const mapping: MapRecord[] = [
+ { source: 'title', target: 'short_description', actionType: 'overwrite' },
+ { source: 'description', target: 'description', actionType: 'append' },
+ { source: 'comments', target: 'comments', actionType: 'append' },
+];
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+const finalMapping: Map = new Map();
+
+finalMapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+});
-const maliciousMapping: MapEntry[] = [
+finalMapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+});
+
+finalMapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+});
+
+finalMapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+});
+
+const maliciousMapping: MapRecord[] = [
{ source: '__proto__', target: 'short_description', actionType: 'nothing' },
{ source: 'description', target: '__proto__', actionType: 'nothing' },
{ source: 'comments', target: 'comments', actionType: 'nothing' },
{ source: 'unsupportedSource', target: 'comments', actionType: 'nothing' },
];
-const fullParams: Params = {
+const fullParams: PushToServiceApiParams = {
caseId: 'd4387ac5-0899-4dc2-bbfa-0dd605c934aa',
title: 'a title',
description: 'a description',
@@ -33,15 +70,14 @@ const fullParams: Params = {
createdBy: { fullName: 'Elastic User', username: 'elastic' },
updatedAt: null,
updatedBy: null,
- incidentId: null,
- incident: {
+ externalId: null,
+ externalCase: {
short_description: 'a title',
description: 'a description',
},
comments: [
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -50,7 +86,6 @@ const fullParams: Params = {
},
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'second comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -60,7 +95,7 @@ const fullParams: Params = {
],
};
-describe('sanitizeMapping', () => {
+describe('normalizeMapping', () => {
test('remove malicious fields', () => {
const sanitizedMapping = normalizeMapping(SUPPORTED_SOURCE_FIELDS, maliciousMapping);
expect(sanitizedMapping.every(m => m.source !== '__proto__' && m.target !== '__proto__')).toBe(
@@ -194,7 +229,10 @@ describe('transformFields', () => {
params: {
...fullParams,
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { username: 'anotherUser', fullName: 'Another User' },
+ updatedBy: {
+ username: 'anotherUser',
+ fullName: 'Another User',
+ },
},
mapping: finalMapping,
defaultPipes: ['informationUpdated'],
@@ -204,7 +242,10 @@ describe('transformFields', () => {
params: {
...fullParams,
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { username: 'anotherUser', fullName: 'Another User' },
+ updatedBy: {
+ username: 'anotherUser',
+ fullName: 'Another User',
+ },
},
fields,
currentIncident: {
@@ -244,7 +285,10 @@ describe('transformFields', () => {
});
const res = transformFields({
- params: { ...fullParams, createdBy: { fullName: null, username: 'elastic' } },
+ params: {
+ ...fullParams,
+ createdBy: { fullName: '', username: 'elastic' },
+ },
fields,
});
@@ -259,7 +303,10 @@ describe('transformFields', () => {
params: {
...fullParams,
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { username: 'anotherUser', fullName: 'Another User' },
+ updatedBy: {
+ username: 'anotherUser',
+ fullName: 'Another User',
+ },
},
mapping: finalMapping,
defaultPipes: ['informationUpdated'],
@@ -269,7 +316,7 @@ describe('transformFields', () => {
params: {
...fullParams,
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { username: 'anotherUser', fullName: null },
+ updatedBy: { username: 'anotherUser', fullName: '' },
},
fields,
});
@@ -281,60 +328,11 @@ describe('transformFields', () => {
});
});
-describe('appendField', () => {
- test('prefix correctly', () => {
- expect('my_prefixmy_value ').toEqual(appendField({ value: 'my_value', prefix: 'my_prefix' }));
- });
-
- test('suffix correctly', () => {
- expect('my_value my_suffix').toEqual(appendField({ value: 'my_value', suffix: 'my_suffix' }));
- });
-
- test('prefix and suffix correctly', () => {
- expect('my_prefixmy_value my_suffix').toEqual(
- appendField({ value: 'my_value', prefix: 'my_prefix', suffix: 'my_suffix' })
- );
- });
-});
-
-describe('appendInformationToField', () => {
- test('creation mode', () => {
- const res = appendInformationToField({
- value: 'my value',
- user: 'Elastic Test User',
- date: '2020-03-13T08:34:53.450Z',
- mode: 'create',
- });
- expect(res).toEqual('my value (created at 2020-03-13T08:34:53.450Z by Elastic Test User)');
- });
-
- test('update mode', () => {
- const res = appendInformationToField({
- value: 'my value',
- user: 'Elastic Test User',
- date: '2020-03-13T08:34:53.450Z',
- mode: 'update',
- });
- expect(res).toEqual('my value (updated at 2020-03-13T08:34:53.450Z by Elastic Test User)');
- });
-
- test('add mode', () => {
- const res = appendInformationToField({
- value: 'my value',
- user: 'Elastic Test User',
- date: '2020-03-13T08:34:53.450Z',
- mode: 'add',
- });
- expect(res).toEqual('my value (added at 2020-03-13T08:34:53.450Z by Elastic Test User)');
- });
-});
-
describe('transformComments', () => {
test('transform creation comments', () => {
const comments: Comment[] = [
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -342,11 +340,10 @@ describe('transformComments', () => {
updatedBy: null,
},
];
- const res = transformComments(comments, fullParams, ['informationCreated']);
+ const res = transformComments(comments, ['informationCreated']);
expect(res).toEqual([
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment (created at 2020-03-13T08:34:53.450Z by Elastic User)',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -360,32 +357,36 @@ describe('transformComments', () => {
const comments: Comment[] = [
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
+ updatedBy: {
+ fullName: 'Another User',
+ username: 'anotherUser',
+ },
},
];
- const res = transformComments(comments, fullParams, ['informationUpdated']);
+ const res = transformComments(comments, ['informationUpdated']);
expect(res).toEqual([
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment (updated at 2020-03-15T08:34:53.450Z by Another User)',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
+ updatedBy: {
+ fullName: 'Another User',
+ username: 'anotherUser',
+ },
},
]);
});
+
test('transform added comments', () => {
const comments: Comment[] = [
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -393,11 +394,10 @@ describe('transformComments', () => {
updatedBy: null,
},
];
- const res = transformComments(comments, fullParams, ['informationAdded']);
+ const res = transformComments(comments, ['informationAdded']);
expect(res).toEqual([
{
commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
comment: 'first comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: 'elastic' },
@@ -406,4 +406,171 @@ describe('transformComments', () => {
},
]);
});
+
+ test('transform comments without fullname', () => {
+ const comments: Comment[] = [
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: '', username: 'elastic' },
+ updatedAt: null,
+ updatedBy: null,
+ },
+ ];
+ const res = transformComments(comments, ['informationAdded']);
+ expect(res).toEqual([
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment (added at 2020-03-13T08:34:53.450Z by elastic)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: '', username: 'elastic' },
+ updatedAt: null,
+ updatedBy: null,
+ },
+ ]);
+ });
+
+ test('adds update user correctly', () => {
+ const comments: Comment[] = [
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic', username: 'elastic' },
+ updatedAt: '2020-04-13T08:34:53.450Z',
+ updatedBy: { fullName: 'Elastic2', username: 'elastic' },
+ },
+ ];
+ const res = transformComments(comments, ['informationAdded']);
+ expect(res).toEqual([
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment (added at 2020-04-13T08:34:53.450Z by Elastic2)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic', username: 'elastic' },
+ updatedAt: '2020-04-13T08:34:53.450Z',
+ updatedBy: { fullName: 'Elastic2', username: 'elastic' },
+ },
+ ]);
+ });
+
+ test('adds update user with empty fullname correctly', () => {
+ const comments: Comment[] = [
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic', username: 'elastic' },
+ updatedAt: '2020-04-13T08:34:53.450Z',
+ updatedBy: { fullName: '', username: 'elastic2' },
+ },
+ ];
+ const res = transformComments(comments, ['informationAdded']);
+ expect(res).toEqual([
+ {
+ commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
+ comment: 'first comment (added at 2020-04-13T08:34:53.450Z by elastic2)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic', username: 'elastic' },
+ updatedAt: '2020-04-13T08:34:53.450Z',
+ updatedBy: { fullName: '', username: 'elastic2' },
+ },
+ ]);
+ });
+});
+
+describe('addTimeZoneToDate', () => {
+ test('adds timezone with default', () => {
+ const date = addTimeZoneToDate('2020-04-14T15:01:55.456Z');
+ expect(date).toBe('2020-04-14T15:01:55.456Z GMT');
+ });
+
+ test('adds timezone correctly', () => {
+ const date = addTimeZoneToDate('2020-04-14T15:01:55.456Z', 'PST');
+ expect(date).toBe('2020-04-14T15:01:55.456Z PST');
+ });
+});
+
+describe('throwIfNotAlive ', () => {
+ test('throws correctly when status is invalid', async () => {
+ expect(() => {
+ throwIfNotAlive(404, 'application/json');
+ }).toThrow('Instance is not alive.');
+ });
+
+ test('throws correctly when content is invalid', () => {
+ expect(() => {
+ throwIfNotAlive(200, 'application/html');
+ }).toThrow('Instance is not alive.');
+ });
+
+ test('do NOT throws with custom validStatusCodes', async () => {
+ expect(() => {
+ throwIfNotAlive(404, 'application/json', [404]);
+ }).not.toThrow('Instance is not alive.');
+ });
+});
+
+describe('request', () => {
+ beforeEach(() => {
+ axiosMock.mockImplementation(() => ({
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ data: { incidentId: '123' },
+ }));
+ });
+
+ test('it fetch correctly with defaults', async () => {
+ const res = await request({ axios, url: '/test' });
+
+ expect(axiosMock).toHaveBeenCalledWith('/test', { method: 'get', data: {} });
+ expect(res).toEqual({
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ data: { incidentId: '123' },
+ });
+ });
+
+ test('it fetch correctly', async () => {
+ const res = await request({ axios, url: '/test', method: 'post', data: { id: '123' } });
+
+ expect(axiosMock).toHaveBeenCalledWith('/test', { method: 'post', data: { id: '123' } });
+ expect(res).toEqual({
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ data: { incidentId: '123' },
+ });
+ });
+
+ test('it throws correctly', async () => {
+ axiosMock.mockImplementation(() => ({
+ status: 404,
+ headers: { 'content-type': 'application/json' },
+ data: { incidentId: '123' },
+ }));
+
+ await expect(request({ axios, url: '/test' })).rejects.toThrow();
+ });
+});
+
+describe('patch', () => {
+ beforeEach(() => {
+ axiosMock.mockImplementation(() => ({
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ }));
+ });
+
+ test('it fetch correctly', async () => {
+ await patch({ axios, url: '/test', data: { id: '123' } });
+ expect(axiosMock).toHaveBeenCalledWith('/test', { method: 'patch', data: { id: '123' } });
+ });
+});
+
+describe('getErrorMessage', () => {
+ test('it returns the correct error message', () => {
+ const msg = getErrorMessage('My connector name', 'An error has occurred');
+ expect(msg).toBe('[Action][My connector name]: An error has occurred');
+ });
});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts b/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts
new file mode 100644
index 0000000000000..7d69b2791f624
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/utils.ts
@@ -0,0 +1,249 @@
+/*
+ * 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.
+ */
+
+import { curry, flow, get } from 'lodash';
+import { schema } from '@kbn/config-schema';
+import { AxiosInstance, Method, AxiosResponse } from 'axios';
+
+import { ActionTypeExecutorOptions, ActionTypeExecutorResult, ActionType } from '../../types';
+
+import { ExecutorParamsSchema } from './schema';
+
+import {
+ CreateExternalServiceArgs,
+ CreateActionTypeArgs,
+ ExecutorParams,
+ MapRecord,
+ AnyParams,
+ CreateExternalServiceBasicArgs,
+ PrepareFieldsForTransformArgs,
+ PipedField,
+ TransformFieldsArgs,
+ Comment,
+ ExecutorSubActionPushParams,
+} from './types';
+
+import { transformers, Transformer } from './transformers';
+
+import { SUPPORTED_SOURCE_FIELDS } from './constants';
+
+export const normalizeMapping = (supportedFields: string[], mapping: MapRecord[]): MapRecord[] => {
+ // Prevent prototype pollution and remove unsupported fields
+ return mapping.filter(
+ m => m.source !== '__proto__' && m.target !== '__proto__' && supportedFields.includes(m.source)
+ );
+};
+
+export const buildMap = (mapping: MapRecord[]): Map => {
+ return normalizeMapping(SUPPORTED_SOURCE_FIELDS, mapping).reduce((fieldsMap, field) => {
+ const { source, target, actionType } = field;
+ fieldsMap.set(source, { target, actionType });
+ fieldsMap.set(target, { target: source, actionType });
+ return fieldsMap;
+ }, new Map());
+};
+
+export const mapParams = (
+ params: Partial,
+ mapping: Map
+): AnyParams => {
+ return Object.keys(params).reduce((prev: AnyParams, curr: string): AnyParams => {
+ const field = mapping.get(curr);
+ if (field) {
+ prev[field.target] = get(params, curr);
+ }
+ return prev;
+ }, {});
+};
+
+export const createConnectorExecutor = ({
+ api,
+ createExternalService,
+}: CreateExternalServiceBasicArgs) => async (
+ execOptions: ActionTypeExecutorOptions
+): Promise => {
+ const { actionId, config, params, secrets } = execOptions;
+ const { subAction, subActionParams } = params as ExecutorParams;
+ let data = {};
+
+ const res: Pick &
+ Pick = {
+ status: 'ok',
+ actionId,
+ };
+
+ const externalService = createExternalService({
+ config,
+ secrets,
+ });
+
+ if (!api[subAction]) {
+ throw new Error('[Action][ExternalService] Unsupported subAction type.');
+ }
+
+ if (subAction !== 'pushToService') {
+ throw new Error('[Action][ExternalService] subAction not implemented.');
+ }
+
+ if (subAction === 'pushToService') {
+ const pushToServiceParams = subActionParams as ExecutorSubActionPushParams;
+ const { comments, externalId, ...restParams } = pushToServiceParams;
+
+ const mapping = buildMap(config.casesConfiguration.mapping);
+ const externalCase = mapParams(restParams, mapping);
+
+ data = await api.pushToService({
+ externalService,
+ mapping,
+ params: { ...pushToServiceParams, externalCase },
+ });
+ }
+
+ return {
+ ...res,
+ data,
+ };
+};
+
+export const createConnector = ({
+ api,
+ config,
+ validate,
+ createExternalService,
+ validationSchema,
+}: CreateExternalServiceArgs) => {
+ return ({
+ configurationUtilities,
+ executor = createConnectorExecutor({ api, createExternalService }),
+ }: CreateActionTypeArgs): ActionType => ({
+ id: config.id,
+ name: config.name,
+ minimumLicenseRequired: 'platinum',
+ validate: {
+ config: schema.object(validationSchema.config, {
+ validate: curry(validate.config)(configurationUtilities),
+ }),
+ secrets: schema.object(validationSchema.secrets, {
+ validate: curry(validate.secrets)(configurationUtilities),
+ }),
+ params: ExecutorParamsSchema,
+ },
+ executor,
+ });
+};
+
+export const throwIfNotAlive = (
+ status: number,
+ contentType: string,
+ validStatusCodes: number[] = [200, 201, 204]
+) => {
+ if (!validStatusCodes.includes(status) || !contentType.includes('application/json')) {
+ throw new Error('Instance is not alive.');
+ }
+};
+
+export const request = async ({
+ axios,
+ url,
+ method = 'get',
+ data,
+}: {
+ axios: AxiosInstance;
+ url: string;
+ method?: Method;
+ data?: T;
+}): Promise => {
+ const res = await axios(url, { method, data: data ?? {} });
+ throwIfNotAlive(res.status, res.headers['content-type']);
+ return res;
+};
+
+export const patch = async ({
+ axios,
+ url,
+ data,
+}: {
+ axios: AxiosInstance;
+ url: string;
+ data: T;
+}): Promise => {
+ return request({
+ axios,
+ url,
+ method: 'patch',
+ data,
+ });
+};
+
+export const addTimeZoneToDate = (date: string, timezone = 'GMT'): string => {
+ return `${date} ${timezone}`;
+};
+
+export const prepareFieldsForTransformation = ({
+ params,
+ mapping,
+ defaultPipes = ['informationCreated'],
+}: PrepareFieldsForTransformArgs): PipedField[] => {
+ return Object.keys(params.externalCase)
+ .filter(p => mapping.get(p)?.actionType != null && mapping.get(p)?.actionType !== 'nothing')
+ .map(p => {
+ const actionType = mapping.get(p)?.actionType ?? 'nothing';
+ return {
+ key: p,
+ value: params.externalCase[p],
+ actionType,
+ pipes: actionType === 'append' ? [...defaultPipes, 'append'] : defaultPipes,
+ };
+ });
+};
+
+export const transformFields = ({
+ params,
+ fields,
+ currentIncident,
+}: TransformFieldsArgs): Record => {
+ return fields.reduce((prev, cur) => {
+ const transform = flow(...cur.pipes.map(p => transformers[p]));
+ return {
+ ...prev,
+ [cur.key]: transform({
+ value: cur.value,
+ date: params.updatedAt ?? params.createdAt,
+ user:
+ (params.updatedBy != null
+ ? params.updatedBy.fullName
+ ? params.updatedBy.fullName
+ : params.updatedBy.username
+ : params.createdBy.fullName
+ ? params.createdBy.fullName
+ : params.createdBy.username) ?? '',
+ previousValue: currentIncident ? currentIncident[cur.key] : '',
+ }).value,
+ };
+ }, {});
+};
+
+export const transformComments = (comments: Comment[], pipes: string[]): Comment[] => {
+ return comments.map(c => ({
+ ...c,
+ comment: flow(...pipes.map(p => transformers[p]))({
+ value: c.comment,
+ date: c.updatedAt ?? c.createdAt,
+ user:
+ (c.updatedBy != null
+ ? c.updatedBy.fullName
+ ? c.updatedBy.fullName
+ : c.updatedBy.username
+ : c.createdBy.fullName
+ ? c.createdBy.fullName
+ : c.createdBy.username) ?? '',
+ }).value,
+ }));
+};
+
+export const getErrorMessage = (connector: string, msg: string) => {
+ return `[Action][${connector}]: ${msg}`;
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/case/validators.ts b/x-pack/plugins/actions/server/builtin_action_types/case/validators.ts
new file mode 100644
index 0000000000000..80e301e5be082
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/case/validators.ts
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+import { isEmpty } from 'lodash';
+
+import { ActionsConfigurationUtilities } from '../../actions_config';
+import {
+ ExternalIncidentServiceConfiguration,
+ ExternalIncidentServiceSecretConfiguration,
+} from './types';
+
+import * as i18n from './translations';
+
+export const validateCommonConfig = (
+ configurationUtilities: ActionsConfigurationUtilities,
+ configObject: ExternalIncidentServiceConfiguration
+) => {
+ try {
+ if (isEmpty(configObject.casesConfiguration.mapping)) {
+ return i18n.MAPPING_EMPTY;
+ }
+
+ configurationUtilities.ensureWhitelistedUri(configObject.apiUrl);
+ } catch (whitelistError) {
+ return i18n.WHITE_LISTED_ERROR(whitelistError.message);
+ }
+};
+
+export const validateCommonSecrets = (
+ configurationUtilities: ActionsConfigurationUtilities,
+ secrets: ExternalIncidentServiceSecretConfiguration
+) => {};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/index.ts b/x-pack/plugins/actions/server/builtin_action_types/index.ts
index a92a279d08439..6ba4d7cfc7de0 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/index.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/index.ts
@@ -12,9 +12,10 @@ import { getActionType as getEmailActionType } from './email';
import { getActionType as getIndexActionType } from './es_index';
import { getActionType as getPagerDutyActionType } from './pagerduty';
import { getActionType as getServerLogActionType } from './server_log';
-import { getActionType as getServiceNowActionType } from './servicenow';
import { getActionType as getSlackActionType } from './slack';
import { getActionType as getWebhookActionType } from './webhook';
+import { getActionType as getServiceNowActionType } from './servicenow';
+import { getActionType as getJiraActionType } from './jira';
export function registerBuiltInActionTypes({
actionsConfigUtils: configurationUtilities,
@@ -29,7 +30,8 @@ export function registerBuiltInActionTypes({
actionTypeRegistry.register(getIndexActionType({ logger }));
actionTypeRegistry.register(getPagerDutyActionType({ logger, configurationUtilities }));
actionTypeRegistry.register(getServerLogActionType({ logger }));
- actionTypeRegistry.register(getServiceNowActionType({ configurationUtilities }));
actionTypeRegistry.register(getSlackActionType({ configurationUtilities }));
actionTypeRegistry.register(getWebhookActionType({ logger, configurationUtilities }));
+ actionTypeRegistry.register(getServiceNowActionType({ configurationUtilities }));
+ actionTypeRegistry.register(getJiraActionType({ configurationUtilities }));
}
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts
new file mode 100644
index 0000000000000..bcfb82077d286
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/api.test.ts
@@ -0,0 +1,517 @@
+/*
+ * 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.
+ */
+
+import { api } from '../case/api';
+import { externalServiceMock, mapping, apiParams } from './mocks';
+import { ExternalService } from '../case/types';
+
+describe('api', () => {
+ let externalService: jest.Mocked;
+
+ beforeEach(() => {
+ externalService = externalServiceMock.create();
+ });
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ describe('pushToService', () => {
+ describe('create incident', () => {
+ test('it creates an incident', async () => {
+ const params = { ...apiParams, externalId: null };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ },
+ {
+ commentId: 'case-comment-2',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ },
+ ],
+ });
+ });
+
+ test('it creates an incident without comments', async () => {
+ const params = { ...apiParams, externalId: null, comments: [] };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ });
+ });
+
+ test('it calls createIncident correctly', async () => {
+ const params = { ...apiParams, externalId: null };
+ await api.pushToService({ externalService, mapping, params });
+
+ expect(externalService.createIncident).toHaveBeenCalledWith({
+ incident: {
+ description:
+ 'Incident description (created at 2020-04-27T10:59:46.202Z by Elastic User)',
+ summary: 'Incident title (created at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ expect(externalService.updateIncident).not.toHaveBeenCalled();
+ });
+
+ test('it calls createComment correctly', async () => {
+ const params = { ...apiParams, externalId: null };
+ await api.pushToService({ externalService, mapping, params });
+ expect(externalService.createComment).toHaveBeenCalledTimes(2);
+ expect(externalService.createComment).toHaveBeenNthCalledWith(1, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-1',
+ comment: 'A comment (added at 2020-04-27T10:59:46.202Z by Elastic User)',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+
+ expect(externalService.createComment).toHaveBeenNthCalledWith(2, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-2',
+ comment: 'Another comment (added at 2020-04-27T10:59:46.202Z by Elastic User)',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+ });
+ });
+
+ describe('update incident', () => {
+ test('it updates an incident', async () => {
+ const res = await api.pushToService({ externalService, mapping, params: apiParams });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ },
+ {
+ commentId: 'case-comment-2',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ },
+ ],
+ });
+ });
+
+ test('it updates an incident without comments', async () => {
+ const params = { ...apiParams, comments: [] };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ });
+ });
+
+ test('it calls updateIncident correctly', async () => {
+ const params = { ...apiParams };
+ await api.pushToService({ externalService, mapping, params });
+
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ expect(externalService.createIncident).not.toHaveBeenCalled();
+ });
+
+ test('it calls createComment correctly', async () => {
+ const params = { ...apiParams };
+ await api.pushToService({ externalService, mapping, params });
+ expect(externalService.createComment).toHaveBeenCalledTimes(2);
+ expect(externalService.createComment).toHaveBeenNthCalledWith(1, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-1',
+ comment: 'A comment (added at 2020-04-27T10:59:46.202Z by Elastic User)',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+
+ expect(externalService.createComment).toHaveBeenNthCalledWith(2, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-2',
+ comment: 'Another comment (added at 2020-04-27T10:59:46.202Z by Elastic User)',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+ });
+ });
+
+ describe('mapping variations', () => {
+ test('overwrite & append', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ description:
+ 'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & append', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & append', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary:
+ 'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ description:
+ 'description from jira \r\nIncident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & nothing', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {},
+ });
+ });
+
+ test('overwrite & nothing', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('overwrite & overwrite', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary: 'Incident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ description:
+ 'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & overwrite', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & overwrite', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary:
+ 'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ description:
+ 'Incident description (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & nothing', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ summary:
+ 'title from jira \r\nIncident title (updated at 2020-04-27T10:59:46.202Z by Elastic User)',
+ },
+ });
+ });
+
+ test('comment nothing', async () => {
+ mapping.set('title', {
+ target: 'summary',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'nothing',
+ });
+
+ mapping.set('summary', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.createComment).not.toHaveBeenCalled();
+ });
+ });
+ });
+});
diff --git a/x-pack/legacy/plugins/monitoring/public/directives/all.js b/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts
similarity index 69%
rename from x-pack/legacy/plugins/monitoring/public/directives/all.js
rename to x-pack/plugins/actions/server/builtin_action_types/jira/api.ts
index 43ad80a7a7e94..3db66e5884af4 100644
--- a/x-pack/legacy/plugins/monitoring/public/directives/all.js
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/api.ts
@@ -4,7 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import './main';
-import './elasticsearch/ml_job_listing';
-import './beats/overview';
-import './beats/beat';
+export { api } from '../case/api';
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/config.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/config.ts
new file mode 100644
index 0000000000000..7e415109f1bd9
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/config.ts
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ */
+
+import { ExternalServiceConfiguration } from '../case/types';
+import * as i18n from './translations';
+
+export const config: ExternalServiceConfiguration = {
+ id: '.jira',
+ name: i18n.NAME,
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts
new file mode 100644
index 0000000000000..a2d7bb5930a75
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/index.ts
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+import { createConnector } from '../case/utils';
+
+import { api } from './api';
+import { config } from './config';
+import { validate } from './validators';
+import { createExternalService } from './service';
+import { JiraSecretConfiguration, JiraPublicConfiguration } from './schema';
+
+export const getActionType = createConnector({
+ api,
+ config,
+ validate,
+ createExternalService,
+ validationSchema: {
+ config: JiraPublicConfiguration,
+ secrets: JiraSecretConfiguration,
+ },
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts
new file mode 100644
index 0000000000000..3ae0e9db36de0
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/mocks.ts
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+import {
+ ExternalService,
+ PushToServiceApiParams,
+ ExecutorSubActionPushParams,
+ MapRecord,
+} from '../case/types';
+
+const createMock = (): jest.Mocked => {
+ const service = {
+ getIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ id: 'incident-1',
+ key: 'CK-1',
+ summary: 'title from jira',
+ description: 'description from jira',
+ created: '2020-04-27T10:59:46.202Z',
+ updated: '2020-04-27T10:59:46.202Z',
+ })
+ ),
+ createIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ })
+ ),
+ updateIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ id: 'incident-1',
+ title: 'CK-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ })
+ ),
+ createComment: jest.fn(),
+ };
+
+ service.createComment.mockImplementationOnce(() =>
+ Promise.resolve({
+ commentId: 'case-comment-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ externalCommentId: '1',
+ })
+ );
+
+ service.createComment.mockImplementationOnce(() =>
+ Promise.resolve({
+ commentId: 'case-comment-2',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ externalCommentId: '2',
+ })
+ );
+
+ return service;
+};
+
+const externalServiceMock = {
+ create: createMock,
+};
+
+const mapping: Map> = new Map();
+
+mapping.set('title', {
+ target: 'summary',
+ actionType: 'overwrite',
+});
+
+mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+});
+
+mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+});
+
+mapping.set('summary', {
+ target: 'title',
+ actionType: 'overwrite',
+});
+
+const executorParams: ExecutorSubActionPushParams = {
+ caseId: 'd4387ac5-0899-4dc2-bbfa-0dd605c934aa',
+ externalId: 'incident-3',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ title: 'Incident title',
+ description: 'Incident description',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ comment: 'A comment',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ },
+ {
+ commentId: 'case-comment-2',
+ comment: 'Another comment',
+ createdAt: '2020-04-27T10:59:46.202Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-04-27T10:59:46.202Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ },
+ ],
+};
+
+const apiParams: PushToServiceApiParams = {
+ ...executorParams,
+ externalCase: { summary: 'Incident title', description: 'Incident description' },
+};
+
+export { externalServiceMock, mapping, executorParams, apiParams };
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts
new file mode 100644
index 0000000000000..9c831e75d91c1
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/schema.ts
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+import { schema } from '@kbn/config-schema';
+import { ExternalIncidentServiceConfiguration } from '../case/schema';
+
+export const JiraPublicConfiguration = {
+ projectKey: schema.string(),
+ ...ExternalIncidentServiceConfiguration,
+};
+
+export const JiraPublicConfigurationSchema = schema.object(JiraPublicConfiguration);
+
+export const JiraSecretConfiguration = {
+ email: schema.string(),
+ apiToken: schema.string(),
+};
+
+export const JiraSecretConfigurationSchema = schema.object(JiraSecretConfiguration);
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts
new file mode 100644
index 0000000000000..b9225b043d526
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/service.test.ts
@@ -0,0 +1,297 @@
+/*
+ * 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.
+ */
+
+import axios from 'axios';
+
+import { createExternalService } from './service';
+import * as utils from '../case/utils';
+import { ExternalService } from '../case/types';
+
+jest.mock('axios');
+jest.mock('../case/utils', () => {
+ const originalUtils = jest.requireActual('../case/utils');
+ return {
+ ...originalUtils,
+ request: jest.fn(),
+ };
+});
+
+axios.create = jest.fn(() => axios);
+const requestMock = utils.request as jest.Mock;
+
+describe('Jira service', () => {
+ let service: ExternalService;
+
+ beforeAll(() => {
+ service = createExternalService({
+ config: { apiUrl: 'https://siem-kibana.atlassian.net', projectKey: 'CK' },
+ secrets: { apiToken: 'token', email: 'elastic@elastic.com' },
+ });
+ });
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ describe('createExternalService', () => {
+ test('throws without url', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: null, projectKey: 'CK' },
+ secrets: { apiToken: 'token', email: 'elastic@elastic.com' },
+ })
+ ).toThrow();
+ });
+
+ test('throws without projectKey', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: 'test.com', projectKey: null },
+ secrets: { apiToken: 'token', email: 'elastic@elastic.com' },
+ })
+ ).toThrow();
+ });
+
+ test('throws without username', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: 'test.com' },
+ secrets: { apiToken: '', email: 'elastic@elastic.com' },
+ })
+ ).toThrow();
+ });
+
+ test('throws without password', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: 'test.com' },
+ secrets: { apiToken: '', email: undefined },
+ })
+ ).toThrow();
+ });
+ });
+
+ describe('getIncident', () => {
+ test('it returns the incident correctly', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { id: '1', key: 'CK-1', fields: { summary: 'title', description: 'description' } },
+ }));
+ const res = await service.getIncident('1');
+ expect(res).toEqual({ id: '1', key: 'CK-1', summary: 'title', description: 'description' });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { id: '1', key: 'CK-1' },
+ }));
+
+ await service.getIncident('1');
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://siem-kibana.atlassian.net/rest/api/2/issue/1',
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+ expect(service.getIncident('1')).rejects.toThrow(
+ 'Unable to get incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+
+ describe('createIncident', () => {
+ test('it creates the incident correctly', async () => {
+ // The response from Jira when creating an issue contains only the key and the id.
+ // The service makes two calls when creating an issue. One to create and one to get
+ // the created incident with all the necessary fields.
+ requestMock.mockImplementationOnce(() => ({
+ data: { id: '1', key: 'CK-1', fields: { summary: 'title', description: 'description' } },
+ }));
+
+ requestMock.mockImplementationOnce(() => ({
+ data: { id: '1', key: 'CK-1', fields: { created: '2020-04-27T10:59:46.202Z' } },
+ }));
+
+ const res = await service.createIncident({
+ incident: { summary: 'title', description: 'desc' },
+ });
+
+ expect(res).toEqual({
+ title: 'CK-1',
+ id: '1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: {
+ id: '1',
+ key: 'CK-1',
+ fields: { created: '2020-04-27T10:59:46.202Z' },
+ },
+ }));
+
+ await service.createIncident({
+ incident: { summary: 'title', description: 'desc' },
+ });
+
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://siem-kibana.atlassian.net/rest/api/2/issue',
+ method: 'post',
+ data: {
+ fields: {
+ summary: 'title',
+ description: 'desc',
+ project: { key: 'CK' },
+ issuetype: { name: 'Task' },
+ },
+ },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.createIncident({
+ incident: { summary: 'title', description: 'desc' },
+ })
+ ).rejects.toThrow('[Action][Jira]: Unable to create incident. Error: An error has occurred');
+ });
+ });
+
+ describe('updateIncident', () => {
+ test('it updates the incident correctly', async () => {
+ requestMock.mockImplementation(() => ({
+ data: {
+ id: '1',
+ key: 'CK-1',
+ fields: { updated: '2020-04-27T10:59:46.202Z' },
+ },
+ }));
+
+ const res = await service.updateIncident({
+ incidentId: '1',
+ incident: { summary: 'title', description: 'desc' },
+ });
+
+ expect(res).toEqual({
+ title: 'CK-1',
+ id: '1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ url: 'https://siem-kibana.atlassian.net/browse/CK-1',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: {
+ id: '1',
+ key: 'CK-1',
+ fields: { updated: '2020-04-27T10:59:46.202Z' },
+ },
+ }));
+
+ await service.updateIncident({
+ incidentId: '1',
+ incident: { summary: 'title', description: 'desc' },
+ });
+
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ method: 'put',
+ url: 'https://siem-kibana.atlassian.net/rest/api/2/issue/1',
+ data: { fields: { summary: 'title', description: 'desc' } },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.updateIncident({
+ incidentId: '1',
+ incident: { summary: 'title', description: 'desc' },
+ })
+ ).rejects.toThrow(
+ '[Action][Jira]: Unable to update incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+
+ describe('createComment', () => {
+ test('it creates the comment correctly', async () => {
+ requestMock.mockImplementation(() => ({
+ data: {
+ id: '1',
+ key: 'CK-1',
+ created: '2020-04-27T10:59:46.202Z',
+ },
+ }));
+
+ const res = await service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'comments',
+ });
+
+ expect(res).toEqual({
+ commentId: 'comment-1',
+ pushedDate: '2020-04-27T10:59:46.202Z',
+ externalCommentId: '1',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: {
+ id: '1',
+ key: 'CK-1',
+ created: '2020-04-27T10:59:46.202Z',
+ },
+ }));
+
+ await service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'my_field',
+ });
+
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ method: 'post',
+ url: 'https://siem-kibana.atlassian.net/rest/api/2/issue/1/comment',
+ data: { body: 'comment' },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'comments',
+ })
+ ).rejects.toThrow(
+ '[Action][Jira]: Unable to create comment at incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts
new file mode 100644
index 0000000000000..ff22b8368e7dd
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/service.ts
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+import axios from 'axios';
+
+import { ExternalServiceCredentials, ExternalService, ExternalServiceParams } from '../case/types';
+import {
+ JiraPublicConfigurationType,
+ JiraSecretConfigurationType,
+ CreateIncidentRequest,
+ UpdateIncidentRequest,
+ CreateCommentRequest,
+} from './types';
+
+import * as i18n from './translations';
+import { getErrorMessage, request } from '../case/utils';
+
+const VERSION = '2';
+const BASE_URL = `rest/api/${VERSION}`;
+const INCIDENT_URL = `issue`;
+const COMMENT_URL = `comment`;
+
+const VIEW_INCIDENT_URL = `browse`;
+
+export const createExternalService = ({
+ config,
+ secrets,
+}: ExternalServiceCredentials): ExternalService => {
+ const { apiUrl: url, projectKey } = config as JiraPublicConfigurationType;
+ const { apiToken, email } = secrets as JiraSecretConfigurationType;
+
+ if (!url || !projectKey || !apiToken || !email) {
+ throw Error(`[Action]${i18n.NAME}: Wrong configuration.`);
+ }
+
+ const incidentUrl = `${url}/${BASE_URL}/${INCIDENT_URL}`;
+ const commentUrl = `${incidentUrl}/{issueId}/${COMMENT_URL}`;
+ const axiosInstance = axios.create({
+ auth: { username: email, password: apiToken },
+ });
+
+ const getIncidentViewURL = (key: string) => {
+ return `${url}/${VIEW_INCIDENT_URL}/${key}`;
+ };
+
+ const getCommentsURL = (issueId: string) => {
+ return commentUrl.replace('{issueId}', issueId);
+ };
+
+ const getIncident = async (id: string) => {
+ try {
+ const res = await request({
+ axios: axiosInstance,
+ url: `${incidentUrl}/${id}`,
+ });
+
+ const { fields, ...rest } = res.data;
+
+ return { ...rest, ...fields };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(i18n.NAME, `Unable to get incident with id ${id}. Error: ${error.message}`)
+ );
+ }
+ };
+
+ const createIncident = async ({ incident }: ExternalServiceParams) => {
+ // The response from Jira when creating an issue contains only the key and the id.
+ // The function makes two calls when creating an issue. One to create the issue and one to get
+ // the created issue with all the necessary fields.
+ try {
+ const res = await request({
+ axios: axiosInstance,
+ url: `${incidentUrl}`,
+ method: 'post',
+ data: {
+ fields: { ...incident, project: { key: projectKey }, issuetype: { name: 'Task' } },
+ },
+ });
+
+ const updatedIncident = await getIncident(res.data.id);
+
+ return {
+ title: updatedIncident.key,
+ id: updatedIncident.id,
+ pushedDate: new Date(updatedIncident.created).toISOString(),
+ url: getIncidentViewURL(updatedIncident.key),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(i18n.NAME, `Unable to create incident. Error: ${error.message}`)
+ );
+ }
+ };
+
+ const updateIncident = async ({ incidentId, incident }: ExternalServiceParams) => {
+ try {
+ await request({
+ axios: axiosInstance,
+ method: 'put',
+ url: `${incidentUrl}/${incidentId}`,
+ data: { fields: { ...incident } },
+ });
+
+ const updatedIncident = await getIncident(incidentId);
+
+ return {
+ title: updatedIncident.key,
+ id: updatedIncident.id,
+ pushedDate: new Date(updatedIncident.updated).toISOString(),
+ url: getIncidentViewURL(updatedIncident.key),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(
+ i18n.NAME,
+ `Unable to update incident with id ${incidentId}. Error: ${error.message}`
+ )
+ );
+ }
+ };
+
+ const createComment = async ({ incidentId, comment, field }: ExternalServiceParams) => {
+ try {
+ const res = await request({
+ axios: axiosInstance,
+ method: 'post',
+ url: getCommentsURL(incidentId),
+ data: { body: comment.comment },
+ });
+
+ return {
+ commentId: comment.commentId,
+ externalCommentId: res.data.id,
+ pushedDate: new Date(res.data.created).toISOString(),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(
+ i18n.NAME,
+ `Unable to create comment at incident with id ${incidentId}. Error: ${error.message}`
+ )
+ );
+ }
+ };
+
+ return {
+ getIncident,
+ createIncident,
+ updateIncident,
+ createComment,
+ };
+};
diff --git a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/capabilities.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/translations.ts
similarity index 63%
rename from x-pack/legacy/plugins/monitoring/public/np_imports/ui/capabilities.ts
rename to x-pack/plugins/actions/server/builtin_action_types/jira/translations.ts
index 5aff302501401..dae0d75952e11 100644
--- a/x-pack/legacy/plugins/monitoring/public/np_imports/ui/capabilities.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/translations.ts
@@ -4,5 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { npStart } from '../legacy_imports';
-export const capabilities = { get: () => npStart.core.application.capabilities };
+import { i18n } from '@kbn/i18n';
+
+export const NAME = i18n.translate('xpack.actions.builtin.case.jiraTitle', {
+ defaultMessage: 'Jira',
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts
new file mode 100644
index 0000000000000..8d9c6b92abb3b
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/types.ts
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+import { TypeOf } from '@kbn/config-schema';
+import { JiraPublicConfigurationSchema, JiraSecretConfigurationSchema } from './schema';
+
+export type JiraPublicConfigurationType = TypeOf;
+export type JiraSecretConfigurationType = TypeOf;
+
+interface CreateIncidentBasicRequestArgs {
+ summary: string;
+ description: string;
+}
+interface CreateIncidentRequestArgs extends CreateIncidentBasicRequestArgs {
+ project: { key: string };
+ issuetype: { name: string };
+}
+
+export interface CreateIncidentRequest {
+ fields: CreateIncidentRequestArgs;
+}
+
+export interface UpdateIncidentRequest {
+ fields: Partial;
+}
+
+export interface CreateCommentRequest {
+ body: string;
+}
diff --git a/x-pack/plugins/actions/server/builtin_action_types/jira/validators.ts b/x-pack/plugins/actions/server/builtin_action_types/jira/validators.ts
new file mode 100644
index 0000000000000..7226071392bc6
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/jira/validators.ts
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ */
+
+import { validateCommonConfig, validateCommonSecrets } from '../case/validators';
+import { ExternalServiceValidation } from '../case/types';
+
+export const validate: ExternalServiceValidation = {
+ config: validateCommonConfig,
+ secrets: validateCommonSecrets,
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.test.ts
deleted file mode 100644
index aa9b1dcfcf239..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.test.ts
+++ /dev/null
@@ -1,850 +0,0 @@
-/*
- * 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.
- */
-
-import {
- handleCreateIncident,
- handleUpdateIncident,
- handleIncident,
- createComments,
-} from './action_handlers';
-import { ServiceNow } from './lib';
-import { Mapping } from './types';
-
-jest.mock('./lib');
-
-const ServiceNowMock = ServiceNow as jest.Mock;
-
-const finalMapping: Mapping = new Map();
-
-finalMapping.set('title', {
- target: 'short_description',
- actionType: 'overwrite',
-});
-
-finalMapping.set('description', {
- target: 'description',
- actionType: 'overwrite',
-});
-
-finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
-});
-
-finalMapping.set('short_description', {
- target: 'title',
- actionType: 'overwrite',
-});
-
-const params = {
- caseId: '123',
- title: 'a title',
- description: 'a description',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- incidentId: null,
- incident: {
- short_description: 'a title',
- description: 'a description',
- },
- comments: [
- {
- commentId: '456',
- version: 'WzU3LDFd',
- comment: 'first comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- },
- ],
-};
-
-beforeAll(() => {
- ServiceNowMock.mockImplementation(() => {
- return {
- serviceNow: {
- getUserID: jest.fn().mockResolvedValue('1234'),
- getIncident: jest.fn().mockResolvedValue({
- short_description: 'servicenow title',
- description: 'servicenow desc',
- }),
- createIncident: jest.fn().mockResolvedValue({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- }),
- updateIncident: jest.fn().mockResolvedValue({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- }),
- batchCreateComments: jest
- .fn()
- .mockResolvedValue([{ commentId: '456', pushedDate: '2020-03-10T12:24:20.000Z' }]),
- },
- };
- });
-});
-
-describe('handleIncident', () => {
- test('create an incident', async () => {
- const { serviceNow } = new ServiceNowMock();
-
- const res = await handleIncident({
- incidentId: null,
- serviceNow,
- params,
- comments: params.comments,
- mapping: finalMapping,
- });
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- comments: [
- {
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- ],
- });
- });
- test('update an incident', async () => {
- const { serviceNow } = new ServiceNowMock();
-
- const res = await handleIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: params.comments,
- mapping: finalMapping,
- });
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- comments: [
- {
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- ],
- });
- });
-});
-
-describe('handleCreateIncident', () => {
- test('create an incident without comments', async () => {
- const { serviceNow } = new ServiceNowMock();
-
- const res = await handleCreateIncident({
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.createIncident).toHaveBeenCalled();
- expect(serviceNow.createIncident).toHaveBeenCalledWith({
- short_description: 'a title (created at 2020-03-13T08:34:53.450Z by Elastic User)',
- description: 'a description (created at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.createIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('create an incident with comments', async () => {
- const { serviceNow } = new ServiceNowMock();
-
- const res = await handleCreateIncident({
- serviceNow,
- params,
- comments: params.comments,
- mapping: finalMapping,
- });
-
- expect(serviceNow.createIncident).toHaveBeenCalled();
- expect(serviceNow.createIncident).toHaveBeenCalledWith({
- description: 'a description (created at 2020-03-13T08:34:53.450Z by Elastic User)',
- short_description: 'a title (created at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.createIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).toHaveBeenCalled();
- expect(serviceNow.batchCreateComments).toHaveBeenCalledWith(
- '123',
- [
- {
- comment: 'first comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
- commentId: '456',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: null,
- updatedBy: null,
- version: 'WzU3LDFd',
- },
- ],
- 'comments'
- );
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- comments: [
- {
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- ],
- });
- });
-});
-
-describe('handleUpdateIncident', () => {
- test('update an incident without comments', async () => {
- const { serviceNow } = new ServiceNowMock();
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params: {
- ...params,
- updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
- },
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description: 'a title (updated at 2020-03-15T08:34:53.450Z by Another User)',
- description: 'a description (updated at 2020-03-15T08:34:53.450Z by Another User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('update an incident with comments', async () => {
- const { serviceNow } = new ServiceNowMock();
- serviceNow.batchCreateComments.mockResolvedValue([
- { commentId: '456', pushedDate: '2020-03-10T12:24:20.000Z' },
- { commentId: '789', pushedDate: '2020-03-10T12:24:20.000Z' },
- ]);
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params: {
- ...params,
- updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
- },
- comments: [
- {
- comment: 'first comment',
- commentId: '456',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: null,
- updatedBy: null,
- version: 'WzU3LDFd',
- },
- {
- comment: 'second comment',
- commentId: '789',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: '2020-03-16T08:34:53.450Z',
- updatedBy: {
- fullName: 'Another User',
- username: 'anotherUser',
- },
- version: 'WzU3LDFd',
- },
- ],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- description: 'a description (updated at 2020-03-15T08:34:53.450Z by Another User)',
- short_description: 'a title (updated at 2020-03-15T08:34:53.450Z by Another User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).toHaveBeenCalled();
- expect(serviceNow.batchCreateComments).toHaveBeenCalledWith(
- '123',
- [
- {
- comment: 'first comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
- commentId: '456',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: null,
- updatedBy: null,
- version: 'WzU3LDFd',
- },
- {
- comment: 'second comment (added at 2020-03-16T08:34:53.450Z by Another User)',
- commentId: '789',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: '2020-03-16T08:34:53.450Z',
- updatedBy: {
- fullName: 'Another User',
- username: 'anotherUser',
- },
- version: 'WzU3LDFd',
- },
- ],
- 'comments'
- );
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- comments: [
- {
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- {
- commentId: '789',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- ],
- });
- });
-});
-
-describe('handleUpdateIncident: different action types', () => {
- test('overwrite & append', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'append',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'overwrite',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description: 'a title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- description:
- 'servicenow desc \r\na description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('nothing & append', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'nothing',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'append',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'nothing',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- description:
- 'servicenow desc \r\na description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('append & append', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'append',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'append',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'append',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description:
- 'servicenow title \r\na title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- description:
- 'servicenow desc \r\na description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('nothing & nothing', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'nothing',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'nothing',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'nothing',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {});
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('overwrite & nothing', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'nothing',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'overwrite',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description: 'a title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('overwrite & overwrite', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'overwrite',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description: 'a title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- description: 'a description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('nothing & overwrite', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'nothing',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'nothing',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- description: 'a description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('append & overwrite', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'append',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'overwrite',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'append',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description:
- 'servicenow title \r\na title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- description: 'a description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('append & nothing', async () => {
- const { serviceNow } = new ServiceNowMock();
- finalMapping.set('title', {
- target: 'short_description',
- actionType: 'append',
- });
-
- finalMapping.set('description', {
- target: 'description',
- actionType: 'nothing',
- });
-
- finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
- });
-
- finalMapping.set('short_description', {
- target: 'title',
- actionType: 'append',
- });
-
- const res = await handleUpdateIncident({
- incidentId: '123',
- serviceNow,
- params,
- comments: [],
- mapping: finalMapping,
- });
-
- expect(serviceNow.updateIncident).toHaveBeenCalled();
- expect(serviceNow.updateIncident).toHaveBeenCalledWith('123', {
- short_description:
- 'servicenow title \r\na title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
- });
- expect(serviceNow.updateIncident).toHaveReturned();
- expect(serviceNow.batchCreateComments).not.toHaveBeenCalled();
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-});
-
-describe('createComments', () => {
- test('create comments correctly', async () => {
- const { serviceNow } = new ServiceNowMock();
- serviceNow.batchCreateComments.mockResolvedValue([
- { commentId: '456', pushedDate: '2020-03-10T12:24:20.000Z' },
- { commentId: '789', pushedDate: '2020-03-10T12:24:20.000Z' },
- ]);
-
- const comments = [
- {
- comment: 'first comment',
- commentId: '456',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: null,
- updatedBy: null,
- version: 'WzU3LDFd',
- },
- {
- comment: 'second comment',
- commentId: '789',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: '2020-03-13T08:34:53.450Z',
- updatedBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- version: 'WzU3LDFd',
- },
- ];
-
- const res = await createComments(serviceNow, '123', 'comments', comments);
-
- expect(serviceNow.batchCreateComments).toHaveBeenCalled();
- expect(serviceNow.batchCreateComments).toHaveBeenCalledWith(
- '123',
- [
- {
- comment: 'first comment',
- commentId: '456',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: null,
- updatedBy: null,
- version: 'WzU3LDFd',
- },
- {
- comment: 'second comment',
- commentId: '789',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- updatedAt: '2020-03-13T08:34:53.450Z',
- updatedBy: {
- fullName: 'Elastic User',
- username: 'elastic',
- },
- version: 'WzU3LDFd',
- },
- ],
- 'comments'
- );
- expect(res).toEqual([
- {
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- {
- commentId: '789',
- pushedDate: '2020-03-10T12:24:20.000Z',
- },
- ]);
- });
-});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.ts
deleted file mode 100644
index 9166f53cf757e..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/action_handlers.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.
- */
-
-import { zipWith } from 'lodash';
-import { CommentResponse } from './lib/types';
-import {
- HandlerResponse,
- Comment,
- SimpleComment,
- CreateHandlerArguments,
- UpdateHandlerArguments,
- IncidentHandlerArguments,
-} from './types';
-import { ServiceNow } from './lib';
-import { transformFields, prepareFieldsForTransformation, transformComments } from './helpers';
-
-export const createComments = async (
- serviceNow: ServiceNow,
- incidentId: string,
- key: string,
- comments: Comment[]
-): Promise => {
- const createdComments = await serviceNow.batchCreateComments(incidentId, comments, key);
-
- return zipWith(comments, createdComments, (a: Comment, b: CommentResponse) => ({
- commentId: a.commentId,
- pushedDate: b.pushedDate,
- }));
-};
-
-export const handleCreateIncident = async ({
- serviceNow,
- params,
- comments,
- mapping,
-}: CreateHandlerArguments): Promise => {
- const fields = prepareFieldsForTransformation({
- params,
- mapping,
- });
-
- const incident = transformFields({
- params,
- fields,
- });
-
- const createdIncident = await serviceNow.createIncident({
- ...incident,
- });
-
- const res: HandlerResponse = { ...createdIncident };
-
- if (
- comments &&
- Array.isArray(comments) &&
- comments.length > 0 &&
- mapping.get('comments')?.actionType !== 'nothing'
- ) {
- comments = transformComments(comments, params, ['informationAdded']);
- res.comments = [
- ...(await createComments(
- serviceNow,
- res.incidentId,
- mapping.get('comments')!.target,
- comments
- )),
- ];
- }
-
- return { ...res };
-};
-
-export const handleUpdateIncident = async ({
- incidentId,
- serviceNow,
- params,
- comments,
- mapping,
-}: UpdateHandlerArguments): Promise => {
- const currentIncident = await serviceNow.getIncident(incidentId);
- const fields = prepareFieldsForTransformation({
- params,
- mapping,
- defaultPipes: ['informationUpdated'],
- });
-
- const incident = transformFields({
- params,
- fields,
- currentIncident,
- });
-
- const updatedIncident = await serviceNow.updateIncident(incidentId, {
- ...incident,
- });
-
- const res: HandlerResponse = { ...updatedIncident };
-
- if (
- comments &&
- Array.isArray(comments) &&
- comments.length > 0 &&
- mapping.get('comments')?.actionType !== 'nothing'
- ) {
- comments = transformComments(comments, params, ['informationAdded']);
- res.comments = [
- ...(await createComments(serviceNow, incidentId, mapping.get('comments')!.target, comments)),
- ];
- }
-
- return { ...res };
-};
-
-export const handleIncident = async ({
- incidentId,
- serviceNow,
- params,
- comments,
- mapping,
-}: IncidentHandlerArguments): Promise => {
- if (!incidentId) {
- return await handleCreateIncident({ serviceNow, params, comments, mapping });
- } else {
- return await handleUpdateIncident({ incidentId, serviceNow, params, comments, mapping });
- }
-};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts
new file mode 100644
index 0000000000000..86a8318841271
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.test.ts
@@ -0,0 +1,523 @@
+/*
+ * 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.
+ */
+
+import { api } from '../case/api';
+import { externalServiceMock, mapping, apiParams } from './mocks';
+import { ExternalService } from '../case/types';
+
+describe('api', () => {
+ let externalService: jest.Mocked;
+
+ beforeEach(() => {
+ externalService = externalServiceMock.create();
+ jest.clearAllMocks();
+ });
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ describe('pushToService', () => {
+ describe('create incident', () => {
+ test('it creates an incident', async () => {
+ const params = { ...apiParams, externalId: null };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'INC01',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ },
+ {
+ commentId: 'case-comment-2',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ },
+ ],
+ });
+ });
+
+ test('it creates an incident without comments', async () => {
+ const params = { ...apiParams, externalId: null, comments: [] };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-1',
+ title: 'INC01',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ });
+ });
+
+ test('it calls createIncident correctly', async () => {
+ const params = { ...apiParams, externalId: null };
+ await api.pushToService({ externalService, mapping, params });
+
+ expect(externalService.createIncident).toHaveBeenCalledWith({
+ incident: {
+ description:
+ 'Incident description (created at 2020-03-13T08:34:53.450Z by Elastic User)',
+ short_description:
+ 'Incident title (created at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ expect(externalService.updateIncident).not.toHaveBeenCalled();
+ });
+
+ test('it calls createComment correctly', async () => {
+ const params = { ...apiParams, externalId: null };
+ await api.pushToService({ externalService, mapping, params });
+ expect(externalService.createComment).toHaveBeenCalledTimes(2);
+ expect(externalService.createComment).toHaveBeenNthCalledWith(1, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-1',
+ comment: 'A comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+
+ expect(externalService.createComment).toHaveBeenNthCalledWith(2, {
+ incidentId: 'incident-1',
+ comment: {
+ commentId: 'case-comment-2',
+ comment: 'Another comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+ });
+ });
+
+ describe('update incident', () => {
+ test('it updates an incident', async () => {
+ const res = await api.pushToService({ externalService, mapping, params: apiParams });
+
+ expect(res).toEqual({
+ id: 'incident-2',
+ title: 'INC02',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ },
+ {
+ commentId: 'case-comment-2',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ },
+ ],
+ });
+ });
+
+ test('it updates an incident without comments', async () => {
+ const params = { ...apiParams, comments: [] };
+ const res = await api.pushToService({ externalService, mapping, params });
+
+ expect(res).toEqual({
+ id: 'incident-2',
+ title: 'INC02',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ });
+ });
+
+ test('it calls updateIncident correctly', async () => {
+ const params = { ...apiParams };
+ await api.pushToService({ externalService, mapping, params });
+
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'Incident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ short_description:
+ 'Incident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ expect(externalService.createIncident).not.toHaveBeenCalled();
+ });
+
+ test('it calls createComment correctly', async () => {
+ const params = { ...apiParams };
+ await api.pushToService({ externalService, mapping, params });
+ expect(externalService.createComment).toHaveBeenCalledTimes(2);
+ expect(externalService.createComment).toHaveBeenNthCalledWith(1, {
+ incidentId: 'incident-2',
+ comment: {
+ commentId: 'case-comment-1',
+ comment: 'A comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+
+ expect(externalService.createComment).toHaveBeenNthCalledWith(2, {
+ incidentId: 'incident-2',
+ comment: {
+ commentId: 'case-comment-2',
+ comment: 'Another comment (added at 2020-03-13T08:34:53.450Z by Elastic User)',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: {
+ fullName: 'Elastic User',
+ username: 'elastic',
+ },
+ },
+ field: 'comments',
+ });
+ });
+ });
+
+ describe('mapping variations', () => {
+ test('overwrite & append', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'Incident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ description:
+ 'description from servicenow \r\nIncident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & append', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'description from servicenow \r\nIncident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & append', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'append',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'title from servicenow \r\nIncident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ description:
+ 'description from servicenow \r\nIncident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & nothing', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {},
+ });
+ });
+
+ test('overwrite & nothing', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'Incident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('overwrite & overwrite', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'Incident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ description:
+ 'Incident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('nothing & overwrite', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'nothing',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ description:
+ 'Incident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & overwrite', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'title from servicenow \r\nIncident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ description:
+ 'Incident description (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('append & nothing', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'append',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'append',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.updateIncident).toHaveBeenCalledWith({
+ incidentId: 'incident-3',
+ incident: {
+ short_description:
+ 'title from servicenow \r\nIncident title (updated at 2020-03-13T08:34:53.450Z by Elastic User)',
+ },
+ });
+ });
+
+ test('comment nothing', async () => {
+ mapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+ });
+
+ mapping.set('description', {
+ target: 'description',
+ actionType: 'nothing',
+ });
+
+ mapping.set('comments', {
+ target: 'comments',
+ actionType: 'nothing',
+ });
+
+ mapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+ });
+
+ await api.pushToService({ externalService, mapping, params: apiParams });
+ expect(externalService.createComment).not.toHaveBeenCalled();
+ });
+ });
+ });
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts
new file mode 100644
index 0000000000000..3db66e5884af4
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/api.ts
@@ -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 { api } from '../case/api';
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/config.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/config.ts
new file mode 100644
index 0000000000000..4ad8108c3b137
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/config.ts
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ */
+
+import { ExternalServiceConfiguration } from '../case/types';
+import * as i18n from './translations';
+
+export const config: ExternalServiceConfiguration = {
+ id: '.servicenow',
+ name: i18n.NAME,
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.ts
deleted file mode 100644
index 0a26996ea8d69..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/helpers.ts
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-import { flow } from 'lodash';
-
-import { SUPPORTED_SOURCE_FIELDS } from './constants';
-import {
- MapEntry,
- Mapping,
- AppendFieldArgs,
- AppendInformationFieldArgs,
- Params,
- Comment,
- TransformFieldsArgs,
- PipedField,
- PrepareFieldsForTransformArgs,
- KeyAny,
-} from './types';
-import { Incident } from './lib/types';
-
-import * as transformers from './transformers';
-import * as i18n from './translations';
-
-export const normalizeMapping = (supportedFields: string[], mapping: MapEntry[]): MapEntry[] => {
- // Prevent prototype pollution and remove unsupported fields
- return mapping.filter(
- m => m.source !== '__proto__' && m.target !== '__proto__' && supportedFields.includes(m.source)
- );
-};
-
-export const buildMap = (mapping: MapEntry[]): Mapping => {
- return normalizeMapping(SUPPORTED_SOURCE_FIELDS, mapping).reduce((fieldsMap, field) => {
- const { source, target, actionType } = field;
- fieldsMap.set(source, { target, actionType });
- fieldsMap.set(target, { target: source, actionType });
- return fieldsMap;
- }, new Map());
-};
-
-export const mapParams = (params: Record, mapping: Mapping) => {
- return Object.keys(params).reduce((prev: KeyAny, curr: string): KeyAny => {
- const field = mapping.get(curr);
- if (field) {
- prev[field.target] = params[curr];
- }
- return prev;
- }, {});
-};
-
-export const appendField = ({ value, prefix = '', suffix = '' }: AppendFieldArgs): string => {
- return `${prefix}${value} ${suffix}`;
-};
-
-const t = { ...transformers } as { [index: string]: Function }; // TODO: Find a better solution exists.
-
-export const prepareFieldsForTransformation = ({
- params,
- mapping,
- defaultPipes = ['informationCreated'],
-}: PrepareFieldsForTransformArgs): PipedField[] => {
- return Object.keys(params.incident)
- .filter(p => mapping.get(p)!.actionType !== 'nothing')
- .map(p => ({
- key: p,
- value: params.incident[p] as string,
- actionType: mapping.get(p)!.actionType,
- pipes: [...defaultPipes],
- }))
- .map(p => ({
- ...p,
- pipes: p.actionType === 'append' ? [...p.pipes, 'append'] : p.pipes,
- }));
-};
-
-export const transformFields = ({
- params,
- fields,
- currentIncident,
-}: TransformFieldsArgs): Incident => {
- return fields.reduce((prev: Incident, cur) => {
- const transform = flow(...cur.pipes.map(p => t[p]));
- prev[cur.key] = transform({
- value: cur.value,
- date: params.updatedAt ?? params.createdAt,
- user:
- params.updatedBy != null
- ? params.updatedBy.fullName ?? params.updatedBy.username
- : params.createdBy.fullName ?? params.createdBy.username,
- previousValue: currentIncident ? currentIncident[cur.key] : '',
- }).value;
- return prev;
- }, {} as Incident);
-};
-
-export const appendInformationToField = ({
- value,
- user,
- date,
- mode = 'create',
-}: AppendInformationFieldArgs): string => {
- return appendField({
- value,
- suffix: i18n.FIELD_INFORMATION(mode, date, user),
- });
-};
-
-export const transformComments = (
- comments: Comment[],
- params: Params,
- pipes: string[]
-): Comment[] => {
- return comments.map(c => ({
- ...c,
- comment: flow(...pipes.map(p => t[p]))({
- value: c.comment,
- date: c.updatedAt ?? c.createdAt,
- user:
- c.updatedBy != null
- ? c.updatedBy.fullName ?? c.updatedBy.username
- : c.createdBy.fullName ?? c.createdBy.username,
- }).value,
- }));
-};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.test.ts
deleted file mode 100644
index a6c3ae88765ac..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.test.ts
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * 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.
- */
-
-import { getActionType } from '.';
-import { ActionType, Services, ActionTypeExecutorOptions } from '../../types';
-import { validateConfig, validateSecrets, validateParams } from '../../lib';
-import { createActionTypeRegistry } from '../index.test';
-import { actionsConfigMock } from '../../actions_config.mock';
-import { actionsMock } from '../../mocks';
-
-import { ACTION_TYPE_ID } from './constants';
-import * as i18n from './translations';
-
-import { handleIncident } from './action_handlers';
-import { incidentResponse } from './mock';
-
-jest.mock('./action_handlers');
-
-const handleIncidentMock = handleIncident as jest.Mock;
-
-const services: Services = actionsMock.createServices();
-
-let actionType: ActionType;
-
-const mockOptions = {
- name: 'servicenow-connector',
- actionTypeId: '.servicenow',
- secrets: {
- username: 'secret-username',
- password: 'secret-password',
- },
- config: {
- apiUrl: 'https://service-now.com',
- casesConfiguration: {
- mapping: [
- {
- source: 'title',
- target: 'short_description',
- actionType: 'overwrite',
- },
- {
- source: 'description',
- target: 'description',
- actionType: 'overwrite',
- },
- {
- source: 'comments',
- target: 'work_notes',
- actionType: 'append',
- },
- ],
- },
- },
- params: {
- caseId: 'd4387ac5-0899-4dc2-bbfa-0dd605c934aa',
- incidentId: 'ceb5986e079f00100e48fbbf7c1ed06d',
- title: 'Incident title',
- description: 'Incident description',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- comments: [
- {
- commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
- comment: 'A comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- },
- ],
- },
-};
-
-beforeAll(() => {
- const { actionTypeRegistry } = createActionTypeRegistry();
- actionType = actionTypeRegistry.get(ACTION_TYPE_ID);
-});
-
-describe('get()', () => {
- test('should return correct action type', () => {
- expect(actionType.id).toEqual(ACTION_TYPE_ID);
- expect(actionType.name).toEqual(i18n.NAME);
- });
-});
-
-describe('validateConfig()', () => {
- test('should validate and pass when config is valid', () => {
- const { config } = mockOptions;
- expect(validateConfig(actionType, config)).toEqual(config);
- });
-
- test('should validate and throw error when config is invalid', () => {
- expect(() => {
- validateConfig(actionType, { shouldNotBeHere: true });
- }).toThrowErrorMatchingInlineSnapshot(
- `"error validating action type config: [apiUrl]: expected value of type [string] but got [undefined]"`
- );
- });
-
- test('should validate and pass when the servicenow url is whitelisted', () => {
- actionType = getActionType({
- configurationUtilities: {
- ...actionsConfigMock.create(),
- ensureWhitelistedUri: url => {
- expect(url).toEqual(mockOptions.config.apiUrl);
- },
- },
- });
-
- expect(validateConfig(actionType, mockOptions.config)).toEqual(mockOptions.config);
- });
-
- test('config validation returns an error if the specified URL isnt whitelisted', () => {
- actionType = getActionType({
- configurationUtilities: {
- ...actionsConfigMock.create(),
- ensureWhitelistedUri: _ => {
- throw new Error(`target url is not whitelisted`);
- },
- },
- });
-
- expect(() => {
- validateConfig(actionType, mockOptions.config);
- }).toThrowErrorMatchingInlineSnapshot(
- `"error validating action type config: error configuring servicenow action: target url is not whitelisted"`
- );
- });
-});
-
-describe('validateSecrets()', () => {
- test('should validate and pass when secrets is valid', () => {
- const { secrets } = mockOptions;
- expect(validateSecrets(actionType, secrets)).toEqual(secrets);
- });
-
- test('should validate and throw error when secrets is invalid', () => {
- expect(() => {
- validateSecrets(actionType, { username: false });
- }).toThrowErrorMatchingInlineSnapshot(
- `"error validating action type secrets: [password]: expected value of type [string] but got [undefined]"`
- );
-
- expect(() => {
- validateSecrets(actionType, { username: false, password: 'hello' });
- }).toThrowErrorMatchingInlineSnapshot(
- `"error validating action type secrets: [username]: expected value of type [string] but got [boolean]"`
- );
- });
-});
-
-describe('validateParams()', () => {
- test('should validate and pass when params is valid', () => {
- const { params } = mockOptions;
- expect(validateParams(actionType, params)).toEqual(params);
- });
-
- test('should validate and throw error when params is invalid', () => {
- expect(() => {
- validateParams(actionType, {});
- }).toThrowErrorMatchingInlineSnapshot(
- `"error validating action params: [caseId]: expected value of type [string] but got [undefined]"`
- );
- });
-});
-
-describe('execute()', () => {
- beforeEach(() => {
- handleIncidentMock.mockReset();
- });
-
- test('should create an incident', async () => {
- const actionId = 'some-id';
- const { incidentId, ...rest } = mockOptions.params;
-
- const executorOptions: ActionTypeExecutorOptions = {
- actionId,
- config: mockOptions.config,
- params: { ...rest },
- secrets: mockOptions.secrets,
- services,
- };
-
- handleIncidentMock.mockImplementation(() => incidentResponse);
-
- const actionResponse = await actionType.executor(executorOptions);
- expect(actionResponse).toEqual({ actionId, status: 'ok', data: incidentResponse });
- });
-
- test('should throw an error when failed to create incident', async () => {
- expect.assertions(1);
- const { incidentId, ...rest } = mockOptions.params;
-
- const actionId = 'some-id';
- const executorOptions: ActionTypeExecutorOptions = {
- actionId,
- config: mockOptions.config,
- params: { ...rest },
- secrets: mockOptions.secrets,
- services,
- };
- const errorMessage = 'Failed to create incident';
-
- handleIncidentMock.mockImplementation(() => {
- throw new Error(errorMessage);
- });
-
- try {
- await actionType.executor(executorOptions);
- } catch (error) {
- expect(error.message).toEqual(errorMessage);
- }
- });
-
- test('should update an incident', async () => {
- const actionId = 'some-id';
- const executorOptions: ActionTypeExecutorOptions = {
- actionId,
- config: mockOptions.config,
- params: {
- ...mockOptions.params,
- updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
- },
- secrets: mockOptions.secrets,
- services,
- };
-
- handleIncidentMock.mockImplementation(() => incidentResponse);
-
- const actionResponse = await actionType.executor(executorOptions);
- expect(actionResponse).toEqual({ actionId, status: 'ok', data: incidentResponse });
- });
-
- test('should throw an error when failed to update an incident', async () => {
- expect.assertions(1);
-
- const actionId = 'some-id';
- const executorOptions: ActionTypeExecutorOptions = {
- actionId,
- config: mockOptions.config,
- params: {
- ...mockOptions.params,
- updatedAt: '2020-03-15T08:34:53.450Z',
- updatedBy: { fullName: 'Another User', username: 'anotherUser' },
- },
- secrets: mockOptions.secrets,
- services,
- };
- const errorMessage = 'Failed to update incident';
-
- handleIncidentMock.mockImplementation(() => {
- throw new Error(errorMessage);
- });
-
- try {
- await actionType.executor(executorOptions);
- } catch (error) {
- expect(error.message).toEqual(errorMessage);
- }
- });
-});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts
index 5066190d4fe56..dbb536d2fa53d 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/index.ts
@@ -4,108 +4,24 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { curry, isEmpty } from 'lodash';
-import { schema } from '@kbn/config-schema';
-import {
- ActionType,
- ActionTypeExecutorOptions,
- ActionTypeExecutorResult,
- ExecutorType,
-} from '../../types';
-import { ActionsConfigurationUtilities } from '../../actions_config';
-import { ServiceNow } from './lib';
-
-import * as i18n from './translations';
-
-import { ACTION_TYPE_ID } from './constants';
-import { ConfigType, SecretsType, Comment, ExecutorParams } from './types';
-
-import { ConfigSchemaProps, SecretsSchemaProps, ParamsSchema } from './schema';
-
-import { buildMap, mapParams } from './helpers';
-import { handleIncident } from './action_handlers';
-
-function validateConfig(
- configurationUtilities: ActionsConfigurationUtilities,
- configObject: ConfigType
-) {
- try {
- if (isEmpty(configObject.casesConfiguration.mapping)) {
- return i18n.MAPPING_EMPTY;
- }
-
- configurationUtilities.ensureWhitelistedUri(configObject.apiUrl);
- } catch (whitelistError) {
- return i18n.WHITE_LISTED_ERROR(whitelistError.message);
- }
-}
-
-function validateSecrets(
- configurationUtilities: ActionsConfigurationUtilities,
- secrets: SecretsType
-) {}
+import { createConnector } from '../case/utils';
-// action type definition
-export function getActionType({
- configurationUtilities,
- executor = serviceNowExecutor,
-}: {
- configurationUtilities: ActionsConfigurationUtilities;
- executor?: ExecutorType;
-}): ActionType {
- return {
- id: ACTION_TYPE_ID,
- name: i18n.NAME,
- minimumLicenseRequired: 'platinum',
- validate: {
- config: schema.object(ConfigSchemaProps, {
- validate: curry(validateConfig)(configurationUtilities),
- }),
- secrets: schema.object(SecretsSchemaProps, {
- validate: curry(validateSecrets)(configurationUtilities),
- }),
- params: ParamsSchema,
- },
- executor,
- };
-}
-
-// action executor
-
-async function serviceNowExecutor(
- execOptions: ActionTypeExecutorOptions
-): Promise {
- const actionId = execOptions.actionId;
- const {
- apiUrl,
- casesConfiguration: { mapping: configurationMapping },
- } = execOptions.config as ConfigType;
- const { username, password } = execOptions.secrets as SecretsType;
- const params = execOptions.params as ExecutorParams;
- const { comments, incidentId, ...restParams } = params;
-
- const mapping = buildMap(configurationMapping);
- const incident = mapParams((restParams as unknown) as Record, mapping);
- const serviceNow = new ServiceNow({ url: apiUrl, username, password });
-
- const handlerInput = {
- incidentId,
- serviceNow,
- params: { ...params, incident },
- comments: comments as Comment[],
- mapping,
- };
-
- const res: Pick &
- Pick = {
- status: 'ok',
- actionId,
- };
-
- const data = await handleIncident(handlerInput);
-
- return {
- ...res,
- data,
- };
-}
+import { api } from './api';
+import { config } from './config';
+import { validate } from './validators';
+import { createExternalService } from './service';
+import {
+ ExternalIncidentServiceConfiguration,
+ ExternalIncidentServiceSecretConfiguration,
+} from '../case/schema';
+
+export const getActionType = createConnector({
+ api,
+ config,
+ validate,
+ createExternalService,
+ validationSchema: {
+ config: ExternalIncidentServiceConfiguration,
+ secrets: ExternalIncidentServiceSecretConfiguration,
+ },
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/constants.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/constants.ts
deleted file mode 100644
index 3f102ae19f437..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/constants.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * 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 API_VERSION = 'v2';
-export const INCIDENT_URL = `api/now/${API_VERSION}/table/incident`;
-export const USER_URL = `api/now/${API_VERSION}/table/sys_user?user_name=`;
-export const COMMENT_URL = `api/now/${API_VERSION}/table/incident`;
-
-// Based on: https://docs.servicenow.com/bundle/orlando-platform-user-interface/page/use/navigation/reference/r_NavigatingByURLExamples.html
-export const VIEW_INCIDENT_URL = `nav_to.do?uri=incident.do?sys_id=`;
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.test.ts
deleted file mode 100644
index 40eeb0f920f82..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.test.ts
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * 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.
- */
-
-import axios from 'axios';
-import { ServiceNow } from '.';
-import { instance, params } from '../mock';
-
-jest.mock('axios');
-
-axios.create = jest.fn(() => axios);
-const axiosMock = (axios as unknown) as jest.Mock;
-
-let serviceNow: ServiceNow;
-
-const testMissingConfiguration = (field: string) => {
- expect.assertions(1);
- try {
- new ServiceNow({ ...instance, [field]: '' });
- } catch (error) {
- expect(error.message).toEqual('[Action][ServiceNow]: Wrong configuration.');
- }
-};
-
-const prependInstanceUrl = (url: string): string => `${instance.url}/${url}`;
-
-describe('ServiceNow lib', () => {
- beforeEach(() => {
- serviceNow = new ServiceNow(instance);
- });
-
- afterEach(() => {
- jest.clearAllMocks();
- });
-
- test('should thrown an error if url is missing', () => {
- testMissingConfiguration('url');
- });
-
- test('should thrown an error if username is missing', () => {
- testMissingConfiguration('username');
- });
-
- test('should thrown an error if password is missing', () => {
- testMissingConfiguration('password');
- });
-
- test('get user id', async () => {
- axiosMock.mockResolvedValue({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: [{ sys_id: '123' }] },
- });
-
- const res = await serviceNow.getUserID();
- const [url, { method }] = axiosMock.mock.calls[0];
-
- expect(url).toEqual(prependInstanceUrl('api/now/v2/table/sys_user?user_name=username'));
- expect(method).toEqual('get');
- expect(res).toEqual('123');
- });
-
- test('create incident', async () => {
- axiosMock.mockResolvedValue({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: { sys_id: '123', number: 'INC01', sys_created_on: '2020-03-10 12:24:20' } },
- });
-
- const res = await serviceNow.createIncident({
- short_description: 'A title',
- description: 'A description',
- caller_id: '123',
- });
- const [url, { method, data }] = axiosMock.mock.calls[0];
-
- expect(url).toEqual(prependInstanceUrl('api/now/v2/table/incident'));
- expect(method).toEqual('post');
- expect(data).toEqual({
- short_description: 'A title',
- description: 'A description',
- caller_id: '123',
- });
-
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('update incident', async () => {
- axiosMock.mockResolvedValue({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: { sys_id: '123', number: 'INC01', sys_updated_on: '2020-03-10 12:24:20' } },
- });
-
- const res = await serviceNow.updateIncident('123', {
- short_description: params.title,
- });
- const [url, { method, data }] = axiosMock.mock.calls[0];
-
- expect(url).toEqual(prependInstanceUrl(`api/now/v2/table/incident/123`));
- expect(method).toEqual('patch');
- expect(data).toEqual({ short_description: params.title });
- expect(res).toEqual({
- incidentId: '123',
- number: 'INC01',
- pushedDate: '2020-03-10T12:24:20.000Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
- });
- });
-
- test('create comment', async () => {
- axiosMock.mockResolvedValue({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: { sys_updated_on: '2020-03-10 12:24:20' } },
- });
-
- const comment = {
- commentId: '456',
- version: 'WzU3LDFd',
- comment: 'A comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- };
-
- const res = await serviceNow.createComment('123', comment, 'comments');
-
- const [url, { method, data }] = axiosMock.mock.calls[0];
-
- expect(url).toEqual(prependInstanceUrl(`api/now/v2/table/incident/123`));
- expect(method).toEqual('patch');
- expect(data).toEqual({
- comments: 'A comment',
- });
-
- expect(res).toEqual({
- commentId: '456',
- pushedDate: '2020-03-10T12:24:20.000Z',
- });
- });
-
- test('create batch comment', async () => {
- axiosMock.mockReturnValueOnce({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: { sys_updated_on: '2020-03-10 12:24:20' } },
- });
-
- axiosMock.mockReturnValueOnce({
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
- data: { result: { sys_updated_on: '2020-03-10 12:25:20' } },
- });
-
- const comments = [
- {
- commentId: '123',
- version: 'WzU3LDFd',
- comment: 'A comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- },
- {
- commentId: '456',
- version: 'WzU3LDFd',
- comment: 'A second comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- },
- ];
- const res = await serviceNow.batchCreateComments('000', comments, 'comments');
-
- comments.forEach((comment, index) => {
- const [url, { method, data }] = axiosMock.mock.calls[index];
- expect(url).toEqual(prependInstanceUrl('api/now/v2/table/incident/000'));
- expect(method).toEqual('patch');
- expect(data).toEqual({
- comments: comment.comment,
- });
- expect(res).toEqual([
- { commentId: '123', pushedDate: '2020-03-10T12:24:20.000Z' },
- { commentId: '456', pushedDate: '2020-03-10T12:25:20.000Z' },
- ]);
- });
- });
-
- test('throw if not status is not ok', async () => {
- expect.assertions(1);
-
- axiosMock.mockResolvedValue({
- status: 401,
- headers: {
- 'content-type': 'application/json',
- },
- });
- try {
- await serviceNow.getUserID();
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to get user id. Error: [ServiceNow]: Instance is not alive.'
- );
- }
- });
-
- test('throw if not content-type is not application/json', async () => {
- expect.assertions(1);
-
- axiosMock.mockResolvedValue({
- status: 200,
- headers: {
- 'content-type': 'application/html',
- },
- });
- try {
- await serviceNow.getUserID();
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to get user id. Error: [ServiceNow]: Instance is not alive.'
- );
- }
- });
-
- test('check error when getting user', async () => {
- expect.assertions(1);
-
- axiosMock.mockImplementationOnce(() => {
- throw new Error('Bad request.');
- });
- try {
- await serviceNow.getUserID();
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to get user id. Error: Bad request.'
- );
- }
- });
-
- test('check error when getting incident', async () => {
- expect.assertions(1);
-
- axiosMock.mockImplementationOnce(() => {
- throw new Error('Bad request.');
- });
- try {
- await serviceNow.getIncident('123');
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to get incident with id 123. Error: Bad request.'
- );
- }
- });
-
- test('check error when creating incident', async () => {
- expect.assertions(1);
-
- axiosMock.mockImplementationOnce(() => {
- throw new Error('Bad request.');
- });
- try {
- await serviceNow.createIncident({ short_description: 'title' });
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to create incident. Error: Bad request.'
- );
- }
- });
-
- test('check error when updating incident', async () => {
- expect.assertions(1);
-
- axiosMock.mockImplementationOnce(() => {
- throw new Error('Bad request.');
- });
- try {
- await serviceNow.updateIncident('123', { short_description: 'title' });
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to update incident with id 123. Error: Bad request.'
- );
- }
- });
-
- test('check error when creating comment', async () => {
- expect.assertions(1);
-
- axiosMock.mockImplementationOnce(() => {
- throw new Error('Bad request.');
- });
- try {
- await serviceNow.createComment(
- '123',
- {
- commentId: '456',
- version: 'WzU3LDFd',
- comment: 'A second comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: null,
- updatedBy: null,
- },
- 'comment'
- );
- } catch (error) {
- expect(error.message).toEqual(
- '[Action][ServiceNow]: Unable to create comment at incident with id 123. Error: Bad request.'
- );
- }
- });
-});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts
deleted file mode 100644
index ed9cfe67a19a1..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * 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.
- */
-
-import axios, { AxiosInstance, Method, AxiosResponse } from 'axios';
-
-import { INCIDENT_URL, USER_URL, COMMENT_URL, VIEW_INCIDENT_URL } from './constants';
-import { Instance, Incident, IncidentResponse, UpdateIncident, CommentResponse } from './types';
-import { Comment } from '../types';
-
-const validStatusCodes = [200, 201];
-
-class ServiceNow {
- private readonly incidentUrl: string;
- private readonly commentUrl: string;
- private readonly userUrl: string;
- private readonly axios: AxiosInstance;
-
- constructor(private readonly instance: Instance) {
- if (
- !this.instance ||
- !this.instance.url ||
- !this.instance.username ||
- !this.instance.password
- ) {
- throw Error('[Action][ServiceNow]: Wrong configuration.');
- }
-
- this.incidentUrl = `${this.instance.url}/${INCIDENT_URL}`;
- this.commentUrl = `${this.instance.url}/${COMMENT_URL}`;
- this.userUrl = `${this.instance.url}/${USER_URL}`;
- this.axios = axios.create({
- auth: { username: this.instance.username, password: this.instance.password },
- });
- }
-
- private _throwIfNotAlive(status: number, contentType: string) {
- if (!validStatusCodes.includes(status) || !contentType.includes('application/json')) {
- throw new Error('[ServiceNow]: Instance is not alive.');
- }
- }
-
- private async _request({
- url,
- method = 'get',
- data = {},
- }: {
- url: string;
- method?: Method;
- data?: unknown;
- }): Promise {
- const res = await this.axios(url, { method, data });
- this._throwIfNotAlive(res.status, res.headers['content-type']);
- return res;
- }
-
- private _patch({ url, data }: { url: string; data: unknown }): Promise {
- return this._request({
- url,
- method: 'patch',
- data,
- });
- }
-
- private _addTimeZoneToDate(date: string, timezone = 'GMT'): string {
- return `${date} GMT`;
- }
-
- private _getErrorMessage(msg: string) {
- return `[Action][ServiceNow]: ${msg}`;
- }
-
- private _getIncidentViewURL(id: string) {
- return `${this.instance.url}/${VIEW_INCIDENT_URL}${id}`;
- }
-
- async getUserID(): Promise {
- try {
- const res = await this._request({ url: `${this.userUrl}${this.instance.username}` });
- return res.data.result[0].sys_id;
- } catch (error) {
- throw new Error(this._getErrorMessage(`Unable to get user id. Error: ${error.message}`));
- }
- }
-
- async getIncident(incidentId: string) {
- try {
- const res = await this._request({
- url: `${this.incidentUrl}/${incidentId}`,
- });
-
- return { ...res.data.result };
- } catch (error) {
- throw new Error(
- this._getErrorMessage(
- `Unable to get incident with id ${incidentId}. Error: ${error.message}`
- )
- );
- }
- }
-
- async createIncident(incident: Incident): Promise {
- try {
- const res = await this._request({
- url: `${this.incidentUrl}`,
- method: 'post',
- data: { ...incident },
- });
-
- return {
- number: res.data.result.number,
- incidentId: res.data.result.sys_id,
- pushedDate: new Date(this._addTimeZoneToDate(res.data.result.sys_created_on)).toISOString(),
- url: this._getIncidentViewURL(res.data.result.sys_id),
- };
- } catch (error) {
- throw new Error(this._getErrorMessage(`Unable to create incident. Error: ${error.message}`));
- }
- }
-
- async updateIncident(incidentId: string, incident: UpdateIncident): Promise {
- try {
- const res = await this._patch({
- url: `${this.incidentUrl}/${incidentId}`,
- data: { ...incident },
- });
-
- return {
- number: res.data.result.number,
- incidentId: res.data.result.sys_id,
- pushedDate: new Date(this._addTimeZoneToDate(res.data.result.sys_updated_on)).toISOString(),
- url: this._getIncidentViewURL(res.data.result.sys_id),
- };
- } catch (error) {
- throw new Error(
- this._getErrorMessage(
- `Unable to update incident with id ${incidentId}. Error: ${error.message}`
- )
- );
- }
- }
-
- async batchCreateComments(
- incidentId: string,
- comments: Comment[],
- field: string
- ): Promise {
- // Create comments sequentially.
- const promises = comments.reduce(async (prevPromise, currentComment) => {
- const totalComments = await prevPromise;
- const res = await this.createComment(incidentId, currentComment, field);
- return [...totalComments, res];
- }, Promise.resolve([] as CommentResponse[]));
-
- const res = await promises;
- return res;
- }
-
- async createComment(
- incidentId: string,
- comment: Comment,
- field: string
- ): Promise {
- try {
- const res = await this._patch({
- url: `${this.commentUrl}/${incidentId}`,
- data: { [field]: comment.comment },
- });
-
- return {
- commentId: comment.commentId,
- pushedDate: new Date(this._addTimeZoneToDate(res.data.result.sys_updated_on)).toISOString(),
- };
- } catch (error) {
- throw new Error(
- this._getErrorMessage(
- `Unable to create comment at incident with id ${incidentId}. Error: ${error.message}`
- )
- );
- }
- }
-}
-
-export { ServiceNow };
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/types.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/types.ts
deleted file mode 100644
index a65e417dbc486..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/types.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 interface Instance {
- url: string;
- username: string;
- password: string;
-}
-
-export interface Incident {
- short_description: string;
- description?: string;
- caller_id?: string;
- [index: string]: string | undefined;
-}
-
-export interface IncidentResponse {
- number: string;
- incidentId: string;
- pushedDate: string;
- url: string;
-}
-
-export interface CommentResponse {
- commentId: string;
- pushedDate: string;
-}
-
-export type UpdateIncident = Partial;
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/mock.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/mock.ts
deleted file mode 100644
index 06c006fb37825..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/mock.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.
- */
-
-import { MapEntry, Mapping, ExecutorParams } from './types';
-import { Incident } from './lib/types';
-
-const mapping: MapEntry[] = [
- { source: 'title', target: 'short_description', actionType: 'overwrite' },
- { source: 'description', target: 'description', actionType: 'append' },
- { source: 'comments', target: 'comments', actionType: 'append' },
-];
-
-const finalMapping: Mapping = new Map();
-
-finalMapping.set('title', {
- target: 'short_description',
- actionType: 'overwrite',
-});
-
-finalMapping.set('description', {
- target: 'description',
- actionType: 'append',
-});
-
-finalMapping.set('comments', {
- target: 'comments',
- actionType: 'append',
-});
-
-finalMapping.set('short_description', {
- target: 'title',
- actionType: 'overwrite',
-});
-
-const params: ExecutorParams = {
- caseId: 'd4387ac5-0899-4dc2-bbfa-0dd605c934aa',
- incidentId: 'ceb5986e079f00100e48fbbf7c1ed06d',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: '2020-03-13T08:34:53.450Z',
- updatedBy: { fullName: 'Elastic User', username: 'elastic' },
- title: 'Incident title',
- description: 'Incident description',
- comments: [
- {
- commentId: 'b5b4c4d0-574e-11ea-9e2e-21b90f8a9631',
- version: 'WzU3LDFd',
- comment: 'A comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: '2020-03-13T08:34:53.450Z',
- updatedBy: { fullName: 'Elastic User', username: 'elastic' },
- },
- {
- commentId: 'e3db587f-ca27-4ae9-ad2e-31f2dcc9bd0d',
- version: 'WlK3LDFd',
- comment: 'Another comment',
- createdAt: '2020-03-13T08:34:53.450Z',
- createdBy: { fullName: 'Elastic User', username: 'elastic' },
- updatedAt: '2020-03-13T08:34:53.450Z',
- updatedBy: { fullName: 'Elastic User', username: 'elastic' },
- },
- ],
-};
-
-const incidentResponse = {
- incidentId: 'c816f79cc0a8016401c5a33be04be441',
- number: 'INC0010001',
- pushedDate: '2020-03-13T08:34:53.450Z',
- url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
-};
-
-const userId = '2e9a0a5e2f79001016ab51172799b670';
-
-const axiosResponse = {
- status: 200,
- headers: {
- 'content-type': 'application/json',
- },
-};
-const userIdResponse = {
- result: [{ sys_id: userId }],
-};
-
-const incidentAxiosResponse = {
- result: { sys_id: incidentResponse.incidentId, number: incidentResponse.number },
-};
-
-const instance = {
- url: 'https://instance.service-now.com',
- username: 'username',
- password: 'password',
-};
-
-const incident: Incident = {
- short_description: params.title,
- description: params.description,
- caller_id: userId,
-};
-
-export {
- mapping,
- finalMapping,
- params,
- incidentResponse,
- incidentAxiosResponse,
- userId,
- userIdResponse,
- axiosResponse,
- instance,
- incident,
-};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts
new file mode 100644
index 0000000000000..37228380910b3
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/mocks.ts
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+import {
+ ExternalService,
+ PushToServiceApiParams,
+ ExecutorSubActionPushParams,
+ MapRecord,
+} from '../case/types';
+
+const createMock = (): jest.Mocked => {
+ const service = {
+ getIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ short_description: 'title from servicenow',
+ description: 'description from servicenow',
+ })
+ ),
+ createIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ id: 'incident-1',
+ title: 'INC01',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ })
+ ),
+ updateIncident: jest.fn().mockImplementation(() =>
+ Promise.resolve({
+ id: 'incident-2',
+ title: 'INC02',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://instance.service-now.com/nav_to.do?uri=incident.do?sys_id=123',
+ })
+ ),
+ createComment: jest.fn(),
+ };
+
+ service.createComment.mockImplementationOnce(() =>
+ Promise.resolve({
+ commentId: 'case-comment-1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ })
+ );
+
+ service.createComment.mockImplementationOnce(() =>
+ Promise.resolve({
+ commentId: 'case-comment-2',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ })
+ );
+ return service;
+};
+
+const externalServiceMock = {
+ create: createMock,
+};
+
+const mapping: Map> = new Map();
+
+mapping.set('title', {
+ target: 'short_description',
+ actionType: 'overwrite',
+});
+
+mapping.set('description', {
+ target: 'description',
+ actionType: 'overwrite',
+});
+
+mapping.set('comments', {
+ target: 'comments',
+ actionType: 'append',
+});
+
+mapping.set('short_description', {
+ target: 'title',
+ actionType: 'overwrite',
+});
+
+const executorParams: ExecutorSubActionPushParams = {
+ caseId: 'd4387ac5-0899-4dc2-bbfa-0dd605c934aa',
+ externalId: 'incident-3',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ title: 'Incident title',
+ description: 'Incident description',
+ comments: [
+ {
+ commentId: 'case-comment-1',
+ comment: 'A comment',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ },
+ {
+ commentId: 'case-comment-2',
+ comment: 'Another comment',
+ createdAt: '2020-03-13T08:34:53.450Z',
+ createdBy: { fullName: 'Elastic User', username: 'elastic' },
+ updatedAt: '2020-03-13T08:34:53.450Z',
+ updatedBy: { fullName: 'Elastic User', username: 'elastic' },
+ },
+ ],
+};
+
+const apiParams: PushToServiceApiParams = {
+ ...executorParams,
+ externalCase: { short_description: 'Incident title', description: 'Incident description' },
+};
+
+export { externalServiceMock, mapping, executorParams, apiParams };
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts
deleted file mode 100644
index 889b57c8e92e2..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/schema.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-
-import { schema } from '@kbn/config-schema';
-
-export const MapEntrySchema = schema.object({
- source: schema.string(),
- target: schema.string(),
- actionType: schema.oneOf([
- schema.literal('nothing'),
- schema.literal('overwrite'),
- schema.literal('append'),
- ]),
-});
-
-export const CasesConfigurationSchema = schema.object({
- mapping: schema.arrayOf(MapEntrySchema),
-});
-
-export const ConfigSchemaProps = {
- apiUrl: schema.string(),
- casesConfiguration: CasesConfigurationSchema,
-};
-
-export const ConfigSchema = schema.object(ConfigSchemaProps);
-
-export const SecretsSchemaProps = {
- password: schema.string(),
- username: schema.string(),
-};
-
-export const SecretsSchema = schema.object(SecretsSchemaProps);
-
-export const UserSchema = schema.object({
- fullName: schema.nullable(schema.string()),
- username: schema.string(),
-});
-
-const EntityInformationSchemaProps = {
- createdAt: schema.string(),
- createdBy: UserSchema,
- updatedAt: schema.nullable(schema.string()),
- updatedBy: schema.nullable(UserSchema),
-};
-
-export const EntityInformationSchema = schema.object(EntityInformationSchemaProps);
-
-export const CommentSchema = schema.object({
- commentId: schema.string(),
- comment: schema.string(),
- version: schema.maybe(schema.string()),
- ...EntityInformationSchemaProps,
-});
-
-export const ExecutorAction = schema.oneOf([
- schema.literal('newIncident'),
- schema.literal('updateIncident'),
-]);
-
-export const ParamsSchema = schema.object({
- caseId: schema.string(),
- title: schema.string(),
- comments: schema.maybe(schema.arrayOf(CommentSchema)),
- description: schema.maybe(schema.string()),
- incidentId: schema.nullable(schema.string()),
- ...EntityInformationSchemaProps,
-});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts
new file mode 100644
index 0000000000000..f65cd5430560e
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.test.ts
@@ -0,0 +1,255 @@
+/*
+ * 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.
+ */
+
+import axios from 'axios';
+
+import { createExternalService } from './service';
+import * as utils from '../case/utils';
+import { ExternalService } from '../case/types';
+
+jest.mock('axios');
+jest.mock('../case/utils', () => {
+ const originalUtils = jest.requireActual('../case/utils');
+ return {
+ ...originalUtils,
+ request: jest.fn(),
+ patch: jest.fn(),
+ };
+});
+
+axios.create = jest.fn(() => axios);
+const requestMock = utils.request as jest.Mock;
+const patchMock = utils.patch as jest.Mock;
+
+describe('ServiceNow service', () => {
+ let service: ExternalService;
+
+ beforeAll(() => {
+ service = createExternalService({
+ config: { apiUrl: 'https://dev102283.service-now.com' },
+ secrets: { username: 'admin', password: 'admin' },
+ });
+ });
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ describe('createExternalService', () => {
+ test('throws without url', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: null },
+ secrets: { username: 'admin', password: 'admin' },
+ })
+ ).toThrow();
+ });
+
+ test('throws without username', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: 'test.com' },
+ secrets: { username: '', password: 'admin' },
+ })
+ ).toThrow();
+ });
+
+ test('throws without password', () => {
+ expect(() =>
+ createExternalService({
+ config: { apiUrl: 'test.com' },
+ secrets: { username: '', password: undefined },
+ })
+ ).toThrow();
+ });
+ });
+
+ describe('getIncident', () => {
+ test('it returns the incident correctly', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01' } },
+ }));
+ const res = await service.getIncident('1');
+ expect(res).toEqual({ sys_id: '1', number: 'INC01' });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01' } },
+ }));
+
+ await service.getIncident('1');
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://dev102283.service-now.com/api/now/v2/table/incident/1',
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+ expect(service.getIncident('1')).rejects.toThrow(
+ 'Unable to get incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+
+ describe('createIncident', () => {
+ test('it creates the incident correctly', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_created_on: '2020-03-10 12:24:20' } },
+ }));
+
+ const res = await service.createIncident({
+ incident: { short_description: 'title', description: 'desc' },
+ });
+
+ expect(res).toEqual({
+ title: 'INC01',
+ id: '1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://dev102283.service-now.com/nav_to.do?uri=incident.do?sys_id=1',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ requestMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_created_on: '2020-03-10 12:24:20' } },
+ }));
+
+ await service.createIncident({
+ incident: { short_description: 'title', description: 'desc' },
+ });
+
+ expect(requestMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://dev102283.service-now.com/api/now/v2/table/incident',
+ method: 'post',
+ data: { short_description: 'title', description: 'desc' },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ requestMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.createIncident({
+ incident: { short_description: 'title', description: 'desc' },
+ })
+ ).rejects.toThrow(
+ '[Action][ServiceNow]: Unable to create incident. Error: An error has occurred'
+ );
+ });
+ });
+
+ describe('updateIncident', () => {
+ test('it updates the incident correctly', async () => {
+ patchMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_updated_on: '2020-03-10 12:24:20' } },
+ }));
+
+ const res = await service.updateIncident({
+ incidentId: '1',
+ incident: { short_description: 'title', description: 'desc' },
+ });
+
+ expect(res).toEqual({
+ title: 'INC01',
+ id: '1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ url: 'https://dev102283.service-now.com/nav_to.do?uri=incident.do?sys_id=1',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ patchMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_updated_on: '2020-03-10 12:24:20' } },
+ }));
+
+ await service.updateIncident({
+ incidentId: '1',
+ incident: { short_description: 'title', description: 'desc' },
+ });
+
+ expect(patchMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://dev102283.service-now.com/api/now/v2/table/incident/1',
+ data: { short_description: 'title', description: 'desc' },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ patchMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.updateIncident({
+ incidentId: '1',
+ incident: { short_description: 'title', description: 'desc' },
+ })
+ ).rejects.toThrow(
+ '[Action][ServiceNow]: Unable to update incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+
+ describe('createComment', () => {
+ test('it creates the comment correctly', async () => {
+ patchMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_updated_on: '2020-03-10 12:24:20' } },
+ }));
+
+ const res = await service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'comments',
+ });
+
+ expect(res).toEqual({
+ commentId: 'comment-1',
+ pushedDate: '2020-03-10T12:24:20.000Z',
+ });
+ });
+
+ test('it should call request with correct arguments', async () => {
+ patchMock.mockImplementation(() => ({
+ data: { result: { sys_id: '1', number: 'INC01', sys_updated_on: '2020-03-10 12:24:20' } },
+ }));
+
+ await service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'my_field',
+ });
+
+ expect(patchMock).toHaveBeenCalledWith({
+ axios,
+ url: 'https://dev102283.service-now.com/api/now/v2/table/incident/1',
+ data: { my_field: 'comment' },
+ });
+ });
+
+ test('it should throw an error', async () => {
+ patchMock.mockImplementation(() => {
+ throw new Error('An error has occurred');
+ });
+
+ expect(
+ service.createComment({
+ incidentId: '1',
+ comment: { comment: 'comment', commentId: 'comment-1' },
+ field: 'comments',
+ })
+ ).rejects.toThrow(
+ '[Action][ServiceNow]: Unable to create comment at incident with id 1. Error: An error has occurred'
+ );
+ });
+ });
+});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts
new file mode 100644
index 0000000000000..541fefce2f2ff
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/service.ts
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+import axios from 'axios';
+
+import { ExternalServiceCredentials, ExternalService, ExternalServiceParams } from '../case/types';
+import { addTimeZoneToDate, patch, request, getErrorMessage } from '../case/utils';
+
+import * as i18n from './translations';
+import {
+ ServiceNowPublicConfigurationType,
+ ServiceNowSecretConfigurationType,
+ CreateIncidentRequest,
+ UpdateIncidentRequest,
+ CreateCommentRequest,
+} from './types';
+
+const API_VERSION = 'v2';
+const INCIDENT_URL = `api/now/${API_VERSION}/table/incident`;
+const COMMENT_URL = `api/now/${API_VERSION}/table/incident`;
+
+// Based on: https://docs.servicenow.com/bundle/orlando-platform-user-interface/page/use/navigation/reference/r_NavigatingByURLExamples.html
+const VIEW_INCIDENT_URL = `nav_to.do?uri=incident.do?sys_id=`;
+
+export const createExternalService = ({
+ config,
+ secrets,
+}: ExternalServiceCredentials): ExternalService => {
+ const { apiUrl: url } = config as ServiceNowPublicConfigurationType;
+ const { username, password } = secrets as ServiceNowSecretConfigurationType;
+
+ if (!url || !username || !password) {
+ throw Error(`[Action]${i18n.NAME}: Wrong configuration.`);
+ }
+
+ const incidentUrl = `${url}/${INCIDENT_URL}`;
+ const commentUrl = `${url}/${COMMENT_URL}`;
+ const axiosInstance = axios.create({
+ auth: { username, password },
+ });
+
+ const getIncidentViewURL = (id: string) => {
+ return `${url}/${VIEW_INCIDENT_URL}${id}`;
+ };
+
+ const getIncident = async (id: string) => {
+ try {
+ const res = await request({
+ axios: axiosInstance,
+ url: `${incidentUrl}/${id}`,
+ });
+
+ return { ...res.data.result };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(i18n.NAME, `Unable to get incident with id ${id}. Error: ${error.message}`)
+ );
+ }
+ };
+
+ const createIncident = async ({ incident }: ExternalServiceParams) => {
+ try {
+ const res = await request({
+ axios: axiosInstance,
+ url: `${incidentUrl}`,
+ method: 'post',
+ data: { ...incident },
+ });
+
+ return {
+ title: res.data.result.number,
+ id: res.data.result.sys_id,
+ pushedDate: new Date(addTimeZoneToDate(res.data.result.sys_created_on)).toISOString(),
+ url: getIncidentViewURL(res.data.result.sys_id),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(i18n.NAME, `Unable to create incident. Error: ${error.message}`)
+ );
+ }
+ };
+
+ const updateIncident = async ({ incidentId, incident }: ExternalServiceParams) => {
+ try {
+ const res = await patch({
+ axios: axiosInstance,
+ url: `${incidentUrl}/${incidentId}`,
+ data: { ...incident },
+ });
+
+ return {
+ title: res.data.result.number,
+ id: res.data.result.sys_id,
+ pushedDate: new Date(addTimeZoneToDate(res.data.result.sys_updated_on)).toISOString(),
+ url: getIncidentViewURL(res.data.result.sys_id),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(
+ i18n.NAME,
+ `Unable to update incident with id ${incidentId}. Error: ${error.message}`
+ )
+ );
+ }
+ };
+
+ const createComment = async ({ incidentId, comment, field }: ExternalServiceParams) => {
+ try {
+ const res = await patch({
+ axios: axiosInstance,
+ url: `${commentUrl}/${incidentId}`,
+ data: { [field]: comment.comment },
+ });
+
+ return {
+ commentId: comment.commentId,
+ pushedDate: new Date(addTimeZoneToDate(res.data.result.sys_updated_on)).toISOString(),
+ };
+ } catch (error) {
+ throw new Error(
+ getErrorMessage(
+ i18n.NAME,
+ `Unable to create comment at incident with id ${incidentId}. Error: ${error.message}`
+ )
+ );
+ }
+ };
+
+ return {
+ getIncident,
+ createIncident,
+ updateIncident,
+ createComment,
+ };
+};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/transformers.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/transformers.ts
deleted file mode 100644
index dc0a03fab8c71..0000000000000
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/transformers.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-import { TransformerArgs } from './types';
-import * as i18n from './translations';
-
-export const informationCreated = ({
- value,
- date,
- user,
- ...rest
-}: TransformerArgs): TransformerArgs => ({
- value: `${value} ${i18n.FIELD_INFORMATION('create', date, user)}`,
- ...rest,
-});
-
-export const informationUpdated = ({
- value,
- date,
- user,
- ...rest
-}: TransformerArgs): TransformerArgs => ({
- value: `${value} ${i18n.FIELD_INFORMATION('update', date, user)}`,
- ...rest,
-});
-
-export const informationAdded = ({
- value,
- date,
- user,
- ...rest
-}: TransformerArgs): TransformerArgs => ({
- value: `${value} ${i18n.FIELD_INFORMATION('add', date, user)}`,
- ...rest,
-});
-
-export const append = ({ value, previousValue, ...rest }: TransformerArgs): TransformerArgs => ({
- value: previousValue ? `${previousValue} \r\n${value}` : `${value}`,
- ...rest,
-});
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/translations.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/translations.ts
index 3b216a6c3260a..3d6138169c4cc 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/translations.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/translations.ts
@@ -6,77 +6,6 @@
import { i18n } from '@kbn/i18n';
-export const API_URL_REQUIRED = i18n.translate(
- 'xpack.actions.builtin.servicenow.servicenowApiNullError',
- {
- defaultMessage: 'ServiceNow [apiUrl] is required',
- }
-);
-
-export const WHITE_LISTED_ERROR = (message: string) =>
- i18n.translate('xpack.actions.builtin.servicenow.servicenowApiWhitelistError', {
- defaultMessage: 'error configuring servicenow action: {message}',
- values: {
- message,
- },
- });
-
-export const NAME = i18n.translate('xpack.actions.builtin.servicenowTitle', {
+export const NAME = i18n.translate('xpack.actions.builtin.case.servicenowTitle', {
defaultMessage: 'ServiceNow',
});
-
-export const MAPPING_EMPTY = i18n.translate('xpack.actions.builtin.servicenow.emptyMapping', {
- defaultMessage: '[casesConfiguration.mapping]: expected non-empty but got empty',
-});
-
-export const ERROR_POSTING = i18n.translate(
- 'xpack.actions.builtin.servicenow.postingErrorMessage',
- {
- defaultMessage: 'error posting servicenow event',
- }
-);
-
-export const RETRY_POSTING = (status: number) =>
- i18n.translate('xpack.actions.builtin.servicenow.postingRetryErrorMessage', {
- defaultMessage: 'error posting servicenow event: http status {status}, retry later',
- values: {
- status,
- },
- });
-
-export const UNEXPECTED_STATUS = (status: number) =>
- i18n.translate('xpack.actions.builtin.servicenow.postingUnexpectedErrorMessage', {
- defaultMessage: 'error posting servicenow event: unexpected status {status}',
- values: {
- status,
- },
- });
-
-export const FIELD_INFORMATION = (
- mode: string,
- date: string | undefined,
- user: string | undefined
-) => {
- switch (mode) {
- case 'create':
- return i18n.translate('xpack.actions.builtin.servicenow.informationCreated', {
- values: { date, user },
- defaultMessage: '(created at {date} by {user})',
- });
- case 'update':
- return i18n.translate('xpack.actions.builtin.servicenow.informationUpdated', {
- values: { date, user },
- defaultMessage: '(updated at {date} by {user})',
- });
- case 'add':
- return i18n.translate('xpack.actions.builtin.servicenow.informationAdded', {
- values: { date, user },
- defaultMessage: '(added at {date} by {user})',
- });
- default:
- return i18n.translate('xpack.actions.builtin.servicenow.informationDefault', {
- values: { date, user },
- defaultMessage: '(created at {date} by {user})',
- });
- }
-};
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts
index c5ef282aeffa7..d8476b7dca54a 100644
--- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/types.ts
@@ -4,100 +4,18 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { TypeOf } from '@kbn/config-schema';
+export {
+ ExternalIncidentServiceConfiguration as ServiceNowPublicConfigurationType,
+ ExternalIncidentServiceSecretConfiguration as ServiceNowSecretConfigurationType,
+} from '../case/types';
-import {
- ConfigSchema,
- SecretsSchema,
- ParamsSchema,
- CasesConfigurationSchema,
- MapEntrySchema,
- CommentSchema,
-} from './schema';
-
-import { ServiceNow } from './lib';
-import { Incident, IncidentResponse } from './lib/types';
-
-// config definition
-export type ConfigType = TypeOf;
-
-// secrets definition
-export type SecretsType = TypeOf;
-
-export type ExecutorParams = TypeOf;
-
-export type CasesConfigurationType = TypeOf;
-export type MapEntry = TypeOf;
-export type Comment = TypeOf;
-
-export type Mapping = Map>;
-
-export interface Params extends ExecutorParams {
- incident: Record;
+export interface CreateIncidentRequest {
+ summary: string;
+ description: string;
}
-export interface CreateHandlerArguments {
- serviceNow: ServiceNow;
- params: Params;
- comments: Comment[];
- mapping: Mapping;
-}
-
-export type UpdateHandlerArguments = CreateHandlerArguments & {
- incidentId: string;
-};
-
-export type IncidentHandlerArguments = CreateHandlerArguments & {
- incidentId: string | null;
-};
-export interface HandlerResponse extends IncidentResponse {
- comments?: SimpleComment[];
-}
-
-export interface SimpleComment {
- commentId: string;
- pushedDate: string;
-}
-
-export interface AppendFieldArgs {
- value: string;
- prefix?: string;
- suffix?: string;
-}
-
-export interface KeyAny {
- [index: string]: unknown;
-}
-
-export interface AppendInformationFieldArgs {
- value: string;
- user: string;
- date: string;
- mode: string;
-}
-
-export interface TransformerArgs {
- value: string;
- date?: string;
- user?: string;
- previousValue?: string;
-}
-
-export interface PrepareFieldsForTransformArgs {
- params: Params;
- mapping: Mapping;
- defaultPipes?: string[];
-}
-
-export interface PipedField {
- key: string;
- value: string;
- actionType: string;
- pipes: string[];
-}
+export type UpdateIncidentRequest = Partial;
-export interface TransformFieldsArgs {
- params: Params;
- fields: PipedField[];
- currentIncident?: Incident;
+export interface CreateCommentRequest {
+ [key: string]: string;
}
diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/validators.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/validators.ts
new file mode 100644
index 0000000000000..7226071392bc6
--- /dev/null
+++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/validators.ts
@@ -0,0 +1,13 @@
+/*
+ * 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.
+ */
+
+import { validateCommonConfig, validateCommonSecrets } from '../case/validators';
+import { ExternalServiceValidation } from '../case/types';
+
+export const validate: ExternalServiceValidation = {
+ config: validateCommonConfig,
+ secrets: validateCommonSecrets,
+};
diff --git a/x-pack/legacy/plugins/apm/CONTRIBUTING.md b/x-pack/plugins/apm/CONTRIBUTING.md
similarity index 100%
rename from x-pack/legacy/plugins/apm/CONTRIBUTING.md
rename to x-pack/plugins/apm/CONTRIBUTING.md
diff --git a/x-pack/plugins/apm/common/apm_saved_object_constants.ts b/x-pack/plugins/apm/common/apm_saved_object_constants.ts
index 0529d90fe940a..eb16db7715fed 100644
--- a/x-pack/plugins/apm/common/apm_saved_object_constants.ts
+++ b/x-pack/plugins/apm/common/apm_saved_object_constants.ts
@@ -5,7 +5,7 @@
*/
// the types have to match the names of the saved object mappings
-// in /x-pack/legacy/plugins/apm/mappings.json
+// in /x-pack/plugins/apm/mappings.json
// APM indices
export const APM_INDICES_SAVED_OBJECT_TYPE = 'apm-indices';
diff --git a/x-pack/legacy/plugins/apm/public/utils/pickKeys.ts b/x-pack/plugins/apm/common/utils/pick_keys.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/pickKeys.ts
rename to x-pack/plugins/apm/common/utils/pick_keys.ts
diff --git a/x-pack/legacy/plugins/apm/dev_docs/github_commands.md b/x-pack/plugins/apm/dev_docs/github_commands.md
similarity index 100%
rename from x-pack/legacy/plugins/apm/dev_docs/github_commands.md
rename to x-pack/plugins/apm/dev_docs/github_commands.md
diff --git a/x-pack/legacy/plugins/apm/dev_docs/typescript.md b/x-pack/plugins/apm/dev_docs/typescript.md
similarity index 83%
rename from x-pack/legacy/plugins/apm/dev_docs/typescript.md
rename to x-pack/plugins/apm/dev_docs/typescript.md
index 6858e93ec09e0..6de61b665a1b1 100644
--- a/x-pack/legacy/plugins/apm/dev_docs/typescript.md
+++ b/x-pack/plugins/apm/dev_docs/typescript.md
@@ -4,8 +4,8 @@ Kibana and X-Pack are very large TypeScript projects, and it comes at a cost. Ed
To run the optimization:
-`$ node x-pack/legacy/plugins/apm/scripts/optimize-tsconfig`
+`$ node x-pack/plugins/apm/scripts/optimize-tsconfig`
To undo the optimization:
-`$ node x-pack/legacy/plugins/apm/scripts/unoptimize-tsconfig`
+`$ node x-pack/plugins/apm/scripts/unoptimize-tsconfig`
diff --git a/x-pack/legacy/plugins/apm/dev_docs/vscode_setup.md b/x-pack/plugins/apm/dev_docs/vscode_setup.md
similarity index 83%
rename from x-pack/legacy/plugins/apm/dev_docs/vscode_setup.md
rename to x-pack/plugins/apm/dev_docs/vscode_setup.md
index e1901b3855f73..1c80d1476520d 100644
--- a/x-pack/legacy/plugins/apm/dev_docs/vscode_setup.md
+++ b/x-pack/plugins/apm/dev_docs/vscode_setup.md
@@ -1,6 +1,6 @@
### Visual Studio Code
-When using [Visual Studio Code](https://code.visualstudio.com/) with APM it's best to set up a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) and add the `x-pack/legacy/plugins/apm` directory, the `x-pack` directory, and the root of the Kibana repository to the workspace. This makes it so you can navigate and search within APM and use the wider workspace roots when you need to widen your search.
+When using [Visual Studio Code](https://code.visualstudio.com/) with APM it's best to set up a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) and add the `x-pack/plugins/apm` directory, the `x-pack` directory, and the root of the Kibana repository to the workspace. This makes it so you can navigate and search within APM and use the wider workspace roots when you need to widen your search.
#### Using the Jest extension
@@ -25,7 +25,7 @@ If you have a workspace configured as described above you should have:
in your Workspace settings, and:
```json
-"jest.pathToJest": "node scripts/jest.js --testPathPattern=legacy/plugins/apm",
+"jest.pathToJest": "node scripts/jest.js --testPathPattern=plugins/apm",
"jest.rootPath": "../../.."
```
@@ -40,7 +40,7 @@ To make the [VSCode debugger](https://vscode.readthedocs.io/en/latest/editor/deb
"type": "node",
"name": "APM Jest",
"request": "launch",
- "args": ["--runInBand", "--testPathPattern=legacy/plugins/apm"],
+ "args": ["--runInBand", "--testPathPattern=plugins/apm"],
"cwd": "${workspaceFolder}/../../..",
"console": "internalConsole",
"internalConsoleOptions": "openOnSessionStart",
diff --git a/x-pack/legacy/plugins/apm/e2e/.gitignore b/x-pack/plugins/apm/e2e/.gitignore
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/.gitignore
rename to x-pack/plugins/apm/e2e/.gitignore
diff --git a/x-pack/legacy/plugins/apm/e2e/README.md b/x-pack/plugins/apm/e2e/README.md
similarity index 84%
rename from x-pack/legacy/plugins/apm/e2e/README.md
rename to x-pack/plugins/apm/e2e/README.md
index a891d64539a3f..b630747ac2d3e 100644
--- a/x-pack/legacy/plugins/apm/e2e/README.md
+++ b/x-pack/plugins/apm/e2e/README.md
@@ -3,7 +3,7 @@
**Run E2E tests**
```sh
-x-pack/legacy/plugins/apm/e2e/run-e2e.sh
+x-pack/plugins/apm/e2e/run-e2e.sh
```
_Starts Kibana, APM Server, Elasticsearch (with sample data) and runs the tests_
@@ -16,9 +16,9 @@ The Jenkins CI uses a shell script to prepare Kibana:
```shell
# Prepare and run Kibana locally
-$ x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh
+$ x-pack/plugins/apm/e2e/ci/prepare-kibana.sh
# Build Docker image for Kibana
-$ docker build --tag cypress --build-arg NODE_VERSION=$(cat .node-version) x-pack/legacy/plugins/apm/e2e/ci
+$ docker build --tag cypress --build-arg NODE_VERSION=$(cat .node-version) x-pack/plugins/apm/e2e/ci
# Run Docker image
$ docker run --rm -t --user "$(id -u):$(id -g)" \
-v `pwd`:/app --network="host" \
diff --git a/x-pack/legacy/plugins/apm/e2e/ci/Dockerfile b/x-pack/plugins/apm/e2e/ci/Dockerfile
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/ci/Dockerfile
rename to x-pack/plugins/apm/e2e/ci/Dockerfile
diff --git a/x-pack/legacy/plugins/apm/e2e/ci/entrypoint.sh b/x-pack/plugins/apm/e2e/ci/entrypoint.sh
similarity index 90%
rename from x-pack/legacy/plugins/apm/e2e/ci/entrypoint.sh
rename to x-pack/plugins/apm/e2e/ci/entrypoint.sh
index ae5155d966e58..3349aa74dadb9 100755
--- a/x-pack/legacy/plugins/apm/e2e/ci/entrypoint.sh
+++ b/x-pack/plugins/apm/e2e/ci/entrypoint.sh
@@ -21,9 +21,9 @@ npm config set cache ${HOME}
# --exclude=packages/ \
# --exclude=built_assets --exclude=target \
# --exclude=data /app ${HOME}/
-#cd ${HOME}/app/x-pack/legacy/plugins/apm/e2e/cypress
+#cd ${HOME}/app/x-pack/plugins/apm/e2e/cypress
-cd /app/x-pack/legacy/plugins/apm/e2e
+cd /app/x-pack/plugins/apm/e2e
## Install dependencies for cypress
CI=true npm install
yarn install
diff --git a/x-pack/legacy/plugins/apm/e2e/ci/kibana.e2e.yml b/x-pack/plugins/apm/e2e/ci/kibana.e2e.yml
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/ci/kibana.e2e.yml
rename to x-pack/plugins/apm/e2e/ci/kibana.e2e.yml
diff --git a/x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh b/x-pack/plugins/apm/e2e/ci/prepare-kibana.sh
similarity index 95%
rename from x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh
rename to x-pack/plugins/apm/e2e/ci/prepare-kibana.sh
index 6df17bd51e0e8..637f8fa9b4c74 100755
--- a/x-pack/legacy/plugins/apm/e2e/ci/prepare-kibana.sh
+++ b/x-pack/plugins/apm/e2e/ci/prepare-kibana.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e
-E2E_DIR="x-pack/legacy/plugins/apm/e2e"
+E2E_DIR="x-pack/plugins/apm/e2e"
echo "1/3 Install dependencies ..."
# shellcheck disable=SC1091
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress.json b/x-pack/plugins/apm/e2e/cypress.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress.json
rename to x-pack/plugins/apm/e2e/cypress.json
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/fixtures/example.json b/x-pack/plugins/apm/e2e/cypress/fixtures/example.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/fixtures/example.json
rename to x-pack/plugins/apm/e2e/cypress/fixtures/example.json
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/integration/apm.feature b/x-pack/plugins/apm/e2e/cypress/integration/apm.feature
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/integration/apm.feature
rename to x-pack/plugins/apm/e2e/cypress/integration/apm.feature
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/integration/helpers.ts b/x-pack/plugins/apm/e2e/cypress/integration/helpers.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/integration/helpers.ts
rename to x-pack/plugins/apm/e2e/cypress/integration/helpers.ts
diff --git a/x-pack/plugins/apm/e2e/cypress/integration/snapshots.js b/x-pack/plugins/apm/e2e/cypress/integration/snapshots.js
new file mode 100644
index 0000000000000..a462f4a504145
--- /dev/null
+++ b/x-pack/plugins/apm/e2e/cypress/integration/snapshots.js
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
+module.exports = {
+ APM: {
+ 'Transaction duration charts': {
+ '1': '500 ms',
+ '2': '250 ms',
+ '3': '0 ms'
+ }
+ },
+ __version: '4.2.0'
+};
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/plugins/index.js b/x-pack/plugins/apm/e2e/cypress/plugins/index.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/plugins/index.js
rename to x-pack/plugins/apm/e2e/cypress/plugins/index.js
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/support/commands.js b/x-pack/plugins/apm/e2e/cypress/support/commands.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/support/commands.js
rename to x-pack/plugins/apm/e2e/cypress/support/commands.js
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/support/index.ts b/x-pack/plugins/apm/e2e/cypress/support/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/support/index.ts
rename to x-pack/plugins/apm/e2e/cypress/support/index.ts
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/support/step_definitions/apm.ts b/x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/support/step_definitions/apm.ts
rename to x-pack/plugins/apm/e2e/cypress/support/step_definitions/apm.ts
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/typings/index.d.ts b/x-pack/plugins/apm/e2e/cypress/typings/index.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/typings/index.d.ts
rename to x-pack/plugins/apm/e2e/cypress/typings/index.d.ts
diff --git a/x-pack/legacy/plugins/apm/e2e/cypress/webpack.config.js b/x-pack/plugins/apm/e2e/cypress/webpack.config.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/cypress/webpack.config.js
rename to x-pack/plugins/apm/e2e/cypress/webpack.config.js
diff --git a/x-pack/legacy/plugins/apm/e2e/ingest-data/replay.js b/x-pack/plugins/apm/e2e/ingest-data/replay.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/ingest-data/replay.js
rename to x-pack/plugins/apm/e2e/ingest-data/replay.js
diff --git a/x-pack/legacy/plugins/apm/e2e/package.json b/x-pack/plugins/apm/e2e/package.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/package.json
rename to x-pack/plugins/apm/e2e/package.json
diff --git a/x-pack/legacy/plugins/apm/e2e/run-e2e.sh b/x-pack/plugins/apm/e2e/run-e2e.sh
similarity index 98%
rename from x-pack/legacy/plugins/apm/e2e/run-e2e.sh
rename to x-pack/plugins/apm/e2e/run-e2e.sh
index 7c17c14dc9601..818d45abb0e65 100755
--- a/x-pack/legacy/plugins/apm/e2e/run-e2e.sh
+++ b/x-pack/plugins/apm/e2e/run-e2e.sh
@@ -27,7 +27,7 @@ cd ${E2E_DIR}
# Ask user to start Kibana
##################################################
echo "\n${bold}To start Kibana please run the following command:${normal}
-node ./scripts/kibana --no-base-path --dev --no-dev-config --config x-pack/legacy/plugins/apm/e2e/ci/kibana.e2e.yml"
+node ./scripts/kibana --no-base-path --dev --no-dev-config --config x-pack/plugins/apm/e2e/ci/kibana.e2e.yml"
#
# Create tmp folder
diff --git a/x-pack/legacy/plugins/apm/e2e/tsconfig.json b/x-pack/plugins/apm/e2e/tsconfig.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/tsconfig.json
rename to x-pack/plugins/apm/e2e/tsconfig.json
diff --git a/x-pack/legacy/plugins/apm/e2e/yarn.lock b/x-pack/plugins/apm/e2e/yarn.lock
similarity index 100%
rename from x-pack/legacy/plugins/apm/e2e/yarn.lock
rename to x-pack/plugins/apm/e2e/yarn.lock
diff --git a/x-pack/plugins/apm/kibana.json b/x-pack/plugins/apm/kibana.json
index d79df74eb6f24..1a0ad67c7b696 100644
--- a/x-pack/plugins/apm/kibana.json
+++ b/x-pack/plugins/apm/kibana.json
@@ -1,13 +1,23 @@
{
"id": "apm",
- "server": true,
"version": "8.0.0",
"kibanaVersion": "kibana",
- "configPath": [
- "xpack",
- "apm"
+ "requiredPlugins": [
+ "features",
+ "apm_oss",
+ "data",
+ "home",
+ "licensing",
+ "triggers_actions_ui"
+ ],
+ "optionalPlugins": [
+ "cloud",
+ "usageCollection",
+ "taskManager",
+ "actions",
+ "alerting"
],
+ "server": true,
"ui": true,
- "requiredPlugins": ["apm_oss", "data", "home", "licensing"],
- "optionalPlugins": ["cloud", "usageCollection", "taskManager","actions", "alerting"]
+ "configPath": ["xpack", "apm"]
}
diff --git a/x-pack/plugins/apm/public/application/index.tsx b/x-pack/plugins/apm/public/application/index.tsx
new file mode 100644
index 0000000000000..c3738329219a8
--- /dev/null
+++ b/x-pack/plugins/apm/public/application/index.tsx
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+import { ApmRoute } from '@elastic/apm-rum-react';
+import React from 'react';
+import ReactDOM from 'react-dom';
+import { Route, Router, Switch } from 'react-router-dom';
+import styled from 'styled-components';
+import { CoreStart, AppMountParameters } from '../../../../../src/core/public';
+import { ApmPluginSetupDeps } from '../plugin';
+import { ApmPluginContext } from '../context/ApmPluginContext';
+import { LicenseProvider } from '../context/LicenseContext';
+import { LoadingIndicatorProvider } from '../context/LoadingIndicatorContext';
+import { LocationProvider } from '../context/LocationContext';
+import { MatchedRouteProvider } from '../context/MatchedRouteContext';
+import { UrlParamsProvider } from '../context/UrlParamsContext';
+import { AlertsContextProvider } from '../../../triggers_actions_ui/public';
+import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';
+import { px, unit, units } from '../style/variables';
+import { UpdateBreadcrumbs } from '../components/app/Main/UpdateBreadcrumbs';
+import { APMIndicesPermission } from '../components/app/APMIndicesPermission';
+import { ScrollToTopOnPathChange } from '../components/app/Main/ScrollToTopOnPathChange';
+import { routes } from '../components/app/Main/route_config';
+import { history } from '../utils/history';
+import { ConfigSchema } from '..';
+import 'react-vis/dist/style.css';
+
+const MainContainer = styled.div`
+ min-width: ${px(unit * 50)};
+ padding: ${px(units.plus)};
+ height: 100%;
+`;
+
+const App = () => {
+ return (
+
+
+
+
+
+ {routes.map((route, i) => (
+
+ ))}
+
+
+
+ );
+};
+
+const ApmAppRoot = ({
+ core,
+ deps,
+ routerHistory,
+ config
+}: {
+ core: CoreStart;
+ deps: ApmPluginSetupDeps;
+ routerHistory: typeof history;
+ config: ConfigSchema;
+}) => {
+ const i18nCore = core.i18n;
+ const plugins = deps;
+ const apmPluginContextValue = {
+ config,
+ core,
+ plugins
+ };
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+/**
+ * This module is rendered asynchronously in the Kibana platform.
+ */
+export const renderApp = (
+ core: CoreStart,
+ deps: ApmPluginSetupDeps,
+ { element }: AppMountParameters,
+ config: ConfigSchema
+) => {
+ ReactDOM.render(
+ ,
+ element
+ );
+ return () => ReactDOM.unmountComponentAtNode(element);
+};
diff --git a/x-pack/legacy/plugins/apm/public/components/app/APMIndicesPermission/__test__/APMIndicesPermission.test.tsx b/x-pack/plugins/apm/public/components/app/APMIndicesPermission/__test__/APMIndicesPermission.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/APMIndicesPermission/__test__/APMIndicesPermission.test.tsx
rename to x-pack/plugins/apm/public/components/app/APMIndicesPermission/__test__/APMIndicesPermission.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/APMIndicesPermission/index.tsx b/x-pack/plugins/apm/public/components/app/APMIndicesPermission/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/APMIndicesPermission/index.tsx
rename to x-pack/plugins/apm/public/components/app/APMIndicesPermission/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
index 33774c941ffd6..5982346d97b89 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ErrorTabs.tsx
@@ -6,7 +6,7 @@
import { i18n } from '@kbn/i18n';
import { isEmpty } from 'lodash';
-import { APMError } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
export interface ErrorTab {
key: 'log_stacktrace' | 'exception_stacktrace' | 'metadata';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.test.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.test.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx
index 75e518a278aea..faec93013886c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/ExceptionStacktrace.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { EuiTitle } from '@elastic/eui';
-import { Exception } from '../../../../../../../../plugins/apm/typings/es_schemas/raw/error_raw';
+import { Exception } from '../../../../../typings/es_schemas/raw/error_raw';
import { Stacktrace } from '../../../shared/Stacktrace';
import { CauseStacktrace } from '../../../shared/Stacktrace/CauseStacktrace';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__snapshots__/index.test.tsx.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__snapshots__/index.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__snapshots__/index.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/__snapshots__/index.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.test.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.test.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx
index 490bf472065e3..9e2fd776e67a3 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/DetailView/index.tsx
@@ -20,8 +20,8 @@ import React from 'react';
import styled from 'styled-components';
import { first } from 'lodash';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ErrorGroupAPIResponse } from '../../../../../../../../plugins/apm/server/lib/errors/get_error_group';
-import { APMError } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { ErrorGroupAPIResponse } from '../../../../../server/lib/errors/get_error_group';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { px, unit, units } from '../../../../style/variables';
import { DiscoverErrorLink } from '../../../shared/Links/DiscoverLinks/DiscoverErrorLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
index ccd720ceee075..c40c711a590be 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
@@ -17,7 +17,7 @@ import theme from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
import React, { Fragment } from 'react';
import styled from 'styled-components';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../plugins/apm/common/i18n';
+import { NOT_AVAILABLE_LABEL } from '../../../../common/i18n';
import { useFetcher } from '../../../hooks/useFetcher';
import { fontFamilyCode, fontSizes, px, units } from '../../../style/variables';
import { ApmHeader } from '../../shared/ApmHeader';
@@ -25,7 +25,7 @@ import { DetailView } from './DetailView';
import { ErrorDistribution } from './Distribution';
import { useLocation } from '../../../hooks/useLocation';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
+import { useTrackPageview } from '../../../../../observability/public';
const Titles = styled.div`
margin-bottom: ${px(units.plus)};
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/List.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/__snapshots__/List.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx
index 250b9a5d188d0..695d3463d3b3d 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/List/index.tsx
@@ -9,9 +9,9 @@ import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import React, { useMemo } from 'react';
import styled from 'styled-components';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
+import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ErrorGroupListAPIResponse } from '../../../../../../../../plugins/apm/server/lib/errors/get_error_groups';
+import { ErrorGroupListAPIResponse } from '../../../../../server/lib/errors/get_error_groups';
import {
fontFamilyCode,
fontSizes,
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
rename to x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
index 8c5a4545f1043..604893952d9d6 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
@@ -17,8 +17,8 @@ import { useFetcher } from '../../../hooks/useFetcher';
import { ErrorDistribution } from '../ErrorGroupDetails/Distribution';
import { ErrorGroupList } from './List';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { useTrackPageview } from '../../../../../observability/public';
+import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
const ErrorGroupOverview: React.FC = () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Home/Home.test.tsx b/x-pack/plugins/apm/public/components/app/Home/Home.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Home/Home.test.tsx
rename to x-pack/plugins/apm/public/components/app/Home/Home.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap b/x-pack/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap
index 2b1f835a14f4a..9f461eeb5b6fc 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap
+++ b/x-pack/plugins/apm/public/components/app/Home/__snapshots__/Home.test.tsx.snap
@@ -5,7 +5,6 @@ exports[`Home component should render services 1`] = `
value={
Object {
"config": Object {
- "indexPatternTitle": "apm-*",
"serviceMapEnabled": true,
"ui": Object {
"enabled": false,
@@ -46,7 +45,6 @@ exports[`Home component should render traces 1`] = `
value={
Object {
"config": Object {
- "indexPatternTitle": "apm-*",
"serviceMapEnabled": true,
"ui": Object {
"enabled": false,
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Home/index.tsx b/x-pack/plugins/apm/public/components/app/Home/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Home/index.tsx
rename to x-pack/plugins/apm/public/components/app/Home/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/ProvideBreadcrumbs.tsx b/x-pack/plugins/apm/public/components/app/Main/ProvideBreadcrumbs.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/ProvideBreadcrumbs.tsx
rename to x-pack/plugins/apm/public/components/app/Main/ProvideBreadcrumbs.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/ScrollToTopOnPathChange.tsx b/x-pack/plugins/apm/public/components/app/Main/ScrollToTopOnPathChange.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/ScrollToTopOnPathChange.tsx
rename to x-pack/plugins/apm/public/components/app/Main/ScrollToTopOnPathChange.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.test.tsx b/x-pack/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.test.tsx
rename to x-pack/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.tsx b/x-pack/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.tsx
rename to x-pack/plugins/apm/public/components/app/Main/UpdateBreadcrumbs.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/__snapshots__/UpdateBreadcrumbs.test.tsx.snap b/x-pack/plugins/apm/public/components/app/Main/__snapshots__/UpdateBreadcrumbs.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/__snapshots__/UpdateBreadcrumbs.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/Main/__snapshots__/UpdateBreadcrumbs.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/__test__/ProvideBreadcrumbs.test.tsx b/x-pack/plugins/apm/public/components/app/Main/__test__/ProvideBreadcrumbs.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/__test__/ProvideBreadcrumbs.test.tsx
rename to x-pack/plugins/apm/public/components/app/Main/__test__/ProvideBreadcrumbs.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/route_config/index.tsx b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/route_config/index.tsx
rename to x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx
index c87e56fe9eff6..6d1db8c5dc6d4 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Main/route_config/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import React from 'react';
import { Redirect, RouteComponentProps } from 'react-router-dom';
-import { SERVICE_NODE_NAME_MISSING } from '../../../../../../../../plugins/apm/common/service_nodes';
+import { SERVICE_NODE_NAME_MISSING } from '../../../../../common/service_nodes';
import { ErrorGroupDetails } from '../../ErrorGroupDetails';
import { ServiceDetails } from '../../ServiceDetails';
import { TransactionDetails } from '../../TransactionDetails';
@@ -20,7 +20,7 @@ import { ApmIndices } from '../../Settings/ApmIndices';
import { toQuery } from '../../../shared/Links/url_helpers';
import { ServiceNodeMetrics } from '../../ServiceNodeMetrics';
import { resolveUrlParams } from '../../../../context/UrlParamsContext/resolveUrlParams';
-import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
+import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../../common/i18n';
import { TraceLink } from '../../TraceLink';
import { CustomizeUI } from '../../Settings/CustomizeUI';
import {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/route_config/route_handlers/agent_configuration.tsx b/x-pack/plugins/apm/public/components/app/Main/route_config/route_handlers/agent_configuration.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/route_config/route_handlers/agent_configuration.tsx
rename to x-pack/plugins/apm/public/components/app/Main/route_config/route_handlers/agent_configuration.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Main/route_config/route_names.tsx b/x-pack/plugins/apm/public/components/app/Main/route_config/route_names.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Main/route_config/route_names.tsx
rename to x-pack/plugins/apm/public/components/app/Main/route_config/route_names.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx
similarity index 82%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx
index 7e8d057a7be6c..a1ccb04e3c42a 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.tsx
@@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
-import { AlertType } from '../../../../../../../../../plugins/apm/common/alert_types';
-import { AlertAdd } from '../../../../../../../../../plugins/triggers_actions_ui/public';
+import { AlertType } from '../../../../../../common/alert_types';
+import { AlertAdd } from '../../../../../../../triggers_actions_ui/public';
type AlertAddProps = React.ComponentProps;
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
index 92b325ab00d35..75c6c79bc804a 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx
@@ -12,7 +12,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
-import { AlertType } from '../../../../../../../../plugins/apm/common/alert_types';
+import { AlertType } from '../../../../../common/alert_types';
import { AlertingFlyout } from './AlertingFlyout';
import { useApmPluginContext } from '../../../../hooks/useApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx
index 131bb7f65d4b3..7ab2f7bac8ae2 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceDetailTabs.tsx
@@ -7,10 +7,7 @@
import { EuiTabs } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
-import {
- isJavaAgentName,
- isRumAgentName
-} from '../../../../../../../plugins/apm/common/agent_name';
+import { isJavaAgentName, isRumAgentName } from '../../../../common/agent_name';
import { useAgentName } from '../../../hooks/useAgentName';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { useUrlParams } from '../../../hooks/useUrlParams';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/TransactionSelect.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/TransactionSelect.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/TransactionSelect.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/TransactionSelect.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx
index cc5c62e25b491..b7480a42ba94b 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx
@@ -6,7 +6,7 @@
import { i18n } from '@kbn/i18n';
import React, { Component } from 'react';
-import { toMountPoint } from '../../../../../../../../../../src/plugins/kibana_react/public';
+import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public';
import { startMLJob } from '../../../../../services/rest/ml';
import { IUrlParams } from '../../../../../context/UrlParamsContext/types';
import { MLJobLink } from '../../../../shared/Links/MachineLearningLinks/MLJobLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/view.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/view.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/view.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/view.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx
index 85254bee12e13..3bbd8a01d0549 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/WatcherFlyout.tsx
@@ -30,12 +30,13 @@ import { padLeft, range } from 'lodash';
import moment from 'moment-timezone';
import React, { Component } from 'react';
import styled from 'styled-components';
-import { toMountPoint } from '../../../../../../../../../src/plugins/kibana_react/public';
+import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { KibanaLink } from '../../../shared/Links/KibanaLink';
import { createErrorGroupWatch, Schedule } from './createErrorGroupWatch';
import { ElasticDocsLink } from '../../../shared/Links/ElasticDocsLink';
import { ApmPluginContext } from '../../../../context/ApmPluginContext';
+import { getApmIndexPatternTitle } from '../../../../services/rest/index_pattern';
type ScheduleKey = keyof Schedule;
@@ -149,11 +150,7 @@ export class WatcherFlyout extends Component<
this.setState({ slackUrl: event.target.value });
};
- public createWatch = ({
- indexPatternTitle
- }: {
- indexPatternTitle: string;
- }) => () => {
+ public createWatch = () => {
const { serviceName } = this.props.urlParams;
const { core } = this.context;
@@ -190,19 +187,21 @@ export class WatcherFlyout extends Component<
unit: 'h'
};
- return createErrorGroupWatch({
- http: core.http,
- emails,
- schedule,
- serviceName,
- slackUrl,
- threshold: this.state.threshold,
- timeRange,
- apmIndexPatternTitle: indexPatternTitle
- })
- .then((id: string) => {
- this.props.onClose();
- this.addSuccessToast(id);
+ return getApmIndexPatternTitle()
+ .then(indexPatternTitle => {
+ return createErrorGroupWatch({
+ http: core.http,
+ emails,
+ schedule,
+ serviceName,
+ slackUrl,
+ threshold: this.state.threshold,
+ timeRange,
+ apmIndexPatternTitle: indexPatternTitle
+ }).then((id: string) => {
+ this.props.onClose();
+ this.addSuccessToast(id);
+ });
})
.catch(e => {
// eslint-disable-next-line
@@ -613,26 +612,20 @@ export class WatcherFlyout extends Component<
-
- {({ config }) => {
- return (
-
- {i18n.translate(
- 'xpack.apm.serviceDetails.enableErrorReportsPanel.createWatchButtonLabel',
- {
- defaultMessage: 'Create watch'
- }
- )}
-
- );
- }}
-
+ this.createWatch()}
+ fill
+ disabled={
+ !this.state.actions.email && !this.state.actions.slack
+ }
+ >
+ {i18n.translate(
+ 'xpack.apm.serviceDetails.enableErrorReportsPanel.createWatchButtonLabel',
+ {
+ defaultMessage: 'Create watch'
+ }
+ )}
+
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/__snapshots__/createErrorGroupWatch.test.ts.snap b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/__snapshots__/createErrorGroupWatch.test.ts.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/__snapshots__/createErrorGroupWatch.test.ts.snap
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/__snapshots__/createErrorGroupWatch.test.ts.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/createErrorGroupWatch.test.ts b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/createErrorGroupWatch.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/createErrorGroupWatch.test.ts
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/createErrorGroupWatch.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/esResponse.ts b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/esResponse.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/esResponse.ts
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/__test__/esResponse.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts
index 690db9fcdd8d6..d45453e24f1c9 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts
+++ b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/createErrorGroupWatch.ts
@@ -17,7 +17,7 @@ import {
ERROR_LOG_MESSAGE,
PROCESSOR_EVENT,
SERVICE_NAME
-} from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../../common/elasticsearch_fieldnames';
import { createWatch } from '../../../../services/rest/watcher';
function getSlackPathUrl(slackUrl?: string) {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceDetails/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/BetaBadge.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/BetaBadge.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/BetaBadge.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/BetaBadge.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Controls.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx
index 53c86f92ee557..ad77434bca9f4 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Cytoscape.tsx
@@ -19,7 +19,7 @@ import {
cytoscapeOptions,
nodeHeight
} from './cytoscapeOptions';
-import { useUiTracker } from '../../../../../../../plugins/observability/public';
+import { useUiTracker } from '../../../../../observability/public';
export const CytoscapeContext = createContext(
undefined
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/EmptyBanner.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/EmptyBanner.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/EmptyBanner.test.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/EmptyBanner.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/EmptyBanner.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/EmptyBanner.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/EmptyBanner.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/EmptyBanner.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/LoadingOverlay.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/LoadingOverlay.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/LoadingOverlay.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/LoadingOverlay.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Buttons.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx
index 491ebdc5aad15..bc3434f277d1c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Contents.tsx
@@ -12,7 +12,7 @@ import {
} from '@elastic/eui';
import cytoscape from 'cytoscape';
import React from 'react';
-import { SERVICE_FRAMEWORK_NAME } from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+import { SERVICE_FRAMEWORK_NAME } from '../../../../../common/elasticsearch_fieldnames';
import { Buttons } from './Buttons';
import { Info } from './Info';
import { ServiceMetricFetcher } from './ServiceMetricFetcher';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx
index e1df3b474e9de..541f4f6a1e775 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Info.tsx
@@ -12,7 +12,7 @@ import styled from 'styled-components';
import {
SPAN_SUBTYPE,
SPAN_TYPE
-} from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../../common/elasticsearch_fieldnames';
const ItemRow = styled.div`
line-height: 2;
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Popover.stories.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Popover.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/Popover.stories.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/Popover.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx
index 697aa6a1b652b..5e6412333a2e1 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricFetcher.tsx
@@ -5,7 +5,7 @@
*/
import React from 'react';
-import { ServiceNodeMetrics } from '../../../../../../../../plugins/apm/common/service_map';
+import { ServiceNodeMetrics } from '../../../../../common/service_map';
import { useFetcher } from '../../../../hooks/useFetcher';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { ServiceMetricList } from './ServiceMetricList';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx
index 056af68cc8173..3cee986261a68 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/ServiceMetricList.tsx
@@ -15,7 +15,7 @@ import { i18n } from '@kbn/i18n';
import { isNumber } from 'lodash';
import React from 'react';
import styled from 'styled-components';
-import { ServiceNodeMetrics } from '../../../../../../../../plugins/apm/common/service_map';
+import { ServiceNodeMetrics } from '../../../../../common/service_map';
import { asDuration, asPercent, tpmUnit } from '../../../../utils/formatters';
function LoadingSpinner() {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx
index 102b135f3cd1f..1c9d5092bfcf5 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Popover/index.tsx
@@ -14,7 +14,7 @@ import React, {
useRef,
useState
} from 'react';
-import { SERVICE_NAME } from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+import { SERVICE_NAME } from '../../../../../common/elasticsearch_fieldnames';
import { CytoscapeContext } from '../Cytoscape';
import { Contents } from './Contents';
import { animationOptions } from '../cytoscapeOptions';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscape-layout-test-response.json b/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape-layout-test-response.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscape-layout-test-response.json
rename to x-pack/plugins/apm/public/components/app/ServiceMap/cytoscape-layout-test-response.json
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts
rename to x-pack/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts
index e9942a327b69e..554f84f0ad236 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/cytoscapeOptions.ts
@@ -9,7 +9,7 @@ import { CSSProperties } from 'react';
import {
SERVICE_NAME,
SPAN_DESTINATION_SERVICE_RESOURCE
-} from '../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../common/elasticsearch_fieldnames';
import { defaultIcon, iconForNode } from './icons';
// IE 11 does not properly load some SVGs or draw certain shapes. This causes
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons.ts
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts
index 321b39dabbbd5..9fe5cbd23b07c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons.ts
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/icons.ts
@@ -5,12 +5,12 @@
*/
import cytoscape from 'cytoscape';
-import { isRumAgentName } from '../../../../../../../plugins/apm/common/agent_name';
+import { isRumAgentName } from '../../../../common/agent_name';
import {
AGENT_NAME,
SPAN_SUBTYPE,
SPAN_TYPE
-} from '../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../common/elasticsearch_fieldnames';
import awsIcon from './icons/aws.svg';
import cassandraIcon from './icons/cassandra.svg';
import darkIcon from './icons/dark.svg';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/aws.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/aws.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/aws.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/aws.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/cassandra.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/cassandra.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/cassandra.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/cassandra.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/dark.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/dark.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/dark.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/dark.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/database.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/database.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/database.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/database.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/default.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/default.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/default.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/default.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/documents.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/documents.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/documents.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/documents.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/dot-net.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/dot-net.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/dot-net.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/dot-net.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/elasticsearch.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/elasticsearch.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/elasticsearch.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/elasticsearch.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/globe.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/globe.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/globe.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/globe.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/go.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/go.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/go.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/go.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/graphql.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/graphql.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/graphql.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/graphql.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/grpc.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/grpc.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/grpc.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/grpc.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/handlebars.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/handlebars.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/handlebars.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/handlebars.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/java.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/java.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/java.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/java.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/kafka.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/kafka.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/kafka.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/kafka.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/mongodb.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/mongodb.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/mongodb.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/mongodb.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/mysql.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/mysql.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/mysql.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/mysql.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/nodejs.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/nodejs.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/nodejs.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/nodejs.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/php.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/php.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/php.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/php.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/postgresql.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/postgresql.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/postgresql.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/postgresql.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/python.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/python.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/python.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/python.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/redis.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/redis.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/redis.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/redis.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/ruby.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/ruby.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/ruby.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/ruby.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/rumjs.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/rumjs.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/rumjs.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/rumjs.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/websocket.svg b/x-pack/plugins/apm/public/components/app/ServiceMap/icons/websocket.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/icons/websocket.svg
rename to x-pack/plugins/apm/public/components/app/ServiceMap/icons/websocket.svg
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/index.test.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.test.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/index.test.tsx
index d93caa601f0b6..c7e25269511bf 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/index.test.tsx
@@ -6,7 +6,7 @@
import { render } from '@testing-library/react';
import React, { FunctionComponent } from 'react';
-import { License } from '../../../../../../../plugins/licensing/common/license';
+import { License } from '../../../../../licensing/common/license';
import { LicenseContext } from '../../../context/LicenseContext';
import { ServiceMap } from './';
import { MockApmPluginContextWrapper } from '../../../context/ApmPluginContext/MockApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx
index 94e42f1b91160..b57f0b047c613 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx
@@ -10,7 +10,7 @@ import React from 'react';
import {
invalidLicenseMessage,
isValidPlatinumLicense
-} from '../../../../../../../plugins/apm/common/service_map';
+} from '../../../../common/service_map';
import { useFetcher } from '../../../hooks/useFetcher';
import { useLicense } from '../../../hooks/useLicense';
import { useUrlParams } from '../../../hooks/useUrlParams';
@@ -23,7 +23,7 @@ import { EmptyBanner } from './EmptyBanner';
import { Popover } from './Popover';
import { useRefDimensions } from './useRefDimensions';
import { BetaBadge } from './BetaBadge';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
+import { useTrackPageview } from '../../../../../observability/public';
interface ServiceMapProps {
serviceName?: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMap/useRefDimensions.ts b/x-pack/plugins/apm/public/components/app/ServiceMap/useRefDimensions.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMap/useRefDimensions.ts
rename to x-pack/plugins/apm/public/components/app/ServiceMap/useRefDimensions.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceMetrics/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceMetrics/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx
index 060e635e83549..0fb8c00a2b162 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceMetrics/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMetrics/index.tsx
@@ -16,7 +16,7 @@ import { useServiceMetricCharts } from '../../../hooks/useServiceMetricCharts';
import { MetricsChart } from '../../shared/charts/MetricsChart';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
interface ServiceMetricsProps {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceNodeMetrics/index.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceNodeMetrics/index.test.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx
index 2bf26946932ea..3929c153ae419 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceNodeMetrics/index.tsx
@@ -20,7 +20,7 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import { FormattedMessage } from '@kbn/i18n/react';
-import { SERVICE_NODE_NAME_MISSING } from '../../../../../../../plugins/apm/common/service_nodes';
+import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes';
import { ApmHeader } from '../../shared/ApmHeader';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useAgentName } from '../../../hooks/useAgentName';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx
index 3af1a70ef3fdc..4e57cb47691be 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceNodeOverview/index.tsx
@@ -13,9 +13,9 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
-import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../../../../plugins/apm/common/i18n';
-import { SERVICE_NODE_NAME_MISSING } from '../../../../../../../plugins/apm/common/service_nodes';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { UNIDENTIFIED_SERVICE_NODES_LABEL } from '../../../../common/i18n';
+import { SERVICE_NODE_NAME_MISSING } from '../../../../common/service_nodes';
+import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { ManagedTable, ITableColumn } from '../../shared/ManagedTable';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/NoServicesMessage.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/NoServicesMessage.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/NoServicesMessage.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/NoServicesMessage.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/List.test.js
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/__snapshots__/List.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/props.json b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/props.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/props.json
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/__test__/props.json
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx
index 1ac29c5626e3a..7e2d03ad35899 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/ServiceList/index.tsx
@@ -9,8 +9,8 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import styled from 'styled-components';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ServiceListAPIResponse } from '../../../../../../../../plugins/apm/server/lib/services/get_services';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
+import { ServiceListAPIResponse } from '../../../../../server/lib/services/get_services';
+import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
import { fontSizes, truncate } from '../../../../style/variables';
import { asDecimal, convertTo } from '../../../../utils/formatters';
import { ManagedTable } from '../../../shared/ManagedTable';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/NoServicesMessage.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/NoServicesMessage.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/NoServicesMessage.test.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/NoServicesMessage.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/ServiceOverview.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/NoServicesMessage.test.tsx.snap b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/NoServicesMessage.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/NoServicesMessage.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/NoServicesMessage.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/ServiceOverview.test.tsx.snap b/x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/ServiceOverview.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/ServiceOverview.test.tsx.snap
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/__test__/__snapshots__/ServiceOverview.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ServiceOverview/index.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx
rename to x-pack/plugins/apm/public/components/app/ServiceOverview/index.tsx
index 52bc414a93a23..99b169e3ec361 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/ServiceOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceOverview/index.tsx
@@ -9,13 +9,13 @@ import { EuiLink } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect, useMemo } from 'react';
import url from 'url';
-import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/public';
+import { toMountPoint } from '../../../../../../../src/plugins/kibana_react/public';
import { useFetcher } from '../../../hooks/useFetcher';
import { NoServicesMessage } from './NoServicesMessage';
import { ServiceList } from './ServiceList';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { useTrackPageview } from '../../../../../observability/public';
+import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/FormRowSelect.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/FormRowSelect.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/FormRowSelect.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/FormRowSelect.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx
index 43002c79aa2b4..f4b942c7f46eb 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/ServicePage/ServicePage.tsx
@@ -16,11 +16,11 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { isString } from 'lodash';
import { EuiButtonEmpty } from '@elastic/eui';
-import { AgentConfigurationIntake } from '../../../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+import { AgentConfigurationIntake } from '../../../../../../../common/agent_configuration/configuration_types';
import {
omitAllOption,
getOptionLabel
-} from '../../../../../../../../../../plugins/apm/common/agent_configuration/all_option';
+} from '../../../../../../../common/agent_configuration/all_option';
import { useFetcher, FETCH_STATUS } from '../../../../../../hooks/useFetcher';
import { FormRowSelect } from './FormRowSelect';
import { APMLink } from '../../../../../shared/Links/apm/APMLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx
index baab600145b81..fcd75a05b01d9 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingFormRow.tsx
@@ -17,12 +17,12 @@ import {
EuiIconTip
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { SettingDefinition } from '../../../../../../../../../../plugins/apm/common/agent_configuration/setting_definitions/types';
-import { isValid } from '../../../../../../../../../../plugins/apm/common/agent_configuration/setting_definitions';
+import { SettingDefinition } from '../../../../../../../common/agent_configuration/setting_definitions/types';
+import { isValid } from '../../../../../../../common/agent_configuration/setting_definitions';
import {
amountAndUnitToString,
amountAndUnitToObject
-} from '../../../../../../../../../../plugins/apm/common/agent_configuration/amount_and_unit';
+} from '../../../../../../../common/agent_configuration/amount_and_unit';
import { SelectWithPlaceholder } from '../../../../../shared/SelectWithPlaceholder';
function FormRow({
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
index 6d76b69600333..e41bdaf0c9c09 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
@@ -23,19 +23,19 @@ import { i18n } from '@kbn/i18n';
import { EuiButtonEmpty } from '@elastic/eui';
import { EuiCallOut } from '@elastic/eui';
import { FETCH_STATUS } from '../../../../../../hooks/useFetcher';
-import { AgentName } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/fields/agent';
+import { AgentName } from '../../../../../../../typings/es_schemas/ui/fields/agent';
import { history } from '../../../../../../utils/history';
-import { AgentConfigurationIntake } from '../../../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+import { AgentConfigurationIntake } from '../../../../../../../common/agent_configuration/configuration_types';
import {
filterByAgent,
settingDefinitions,
isValid
-} from '../../../../../../../../../../plugins/apm/common/agent_configuration/setting_definitions';
+} from '../../../../../../../common/agent_configuration/setting_definitions';
import { saveConfig } from './saveConfig';
import { useApmPluginContext } from '../../../../../../hooks/useApmPluginContext';
-import { useUiTracker } from '../../../../../../../../../../plugins/observability/public';
+import { useUiTracker } from '../../../../../../../../observability/public';
import { SettingFormRow } from './SettingFormRow';
-import { getOptionLabel } from '../../../../../../../../../../plugins/apm/common/agent_configuration/all_option';
+import { getOptionLabel } from '../../../../../../../common/agent_configuration/all_option';
function removeEmpty(obj: T): T {
return Object.fromEntries(
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts
index 7e3bcd68699be..5f7354bf6f713 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/saveConfig.ts
@@ -6,11 +6,11 @@
import { i18n } from '@kbn/i18n';
import { NotificationsStart } from 'kibana/public';
-import { AgentConfigurationIntake } from '../../../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+import { AgentConfigurationIntake } from '../../../../../../../common/agent_configuration/configuration_types';
import {
getOptionLabel,
omitAllOption
-} from '../../../../../../../../../../plugins/apm/common/agent_configuration/all_option';
+} from '../../../../../../../common/agent_configuration/all_option';
import { callApmApi } from '../../../../../../services/rest/createCallApmApi';
export async function saveConfig({
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx
index 531e557b6ef86..089bc58f50a88 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.stories.tsx
@@ -13,7 +13,7 @@
import { storiesOf } from '@storybook/react';
import React from 'react';
import { HttpSetup } from 'kibana/public';
-import { AgentConfiguration } from '../../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+import { AgentConfiguration } from '../../../../../../common/agent_configuration/configuration_types';
import { FETCH_STATUS } from '../../../../../hooks/useFetcher';
import { createCallApmApi } from '../../../../../services/rest/createCallApmApi';
import { AgentConfigurationCreateEdit } from './index';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx
index 638e518563f8c..3a6f94b975800 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/index.tsx
@@ -13,7 +13,7 @@ import { history } from '../../../../../utils/history';
import {
AgentConfigurationIntake,
AgentConfiguration
-} from '../../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+} from '../../../../../../common/agent_configuration/configuration_types';
import { ServicePage } from './ServicePage/ServicePage';
import { SettingsPage } from './SettingsPage/SettingsPage';
import { fromQuery, toQuery } from '../../../../shared/Links/url_helpers';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx
index 267aaddc93f76..6a1a472562305 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/ConfirmDeleteModal.tsx
@@ -9,8 +9,8 @@ import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
import { NotificationsStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { AgentConfigurationListAPIResponse } from '../../../../../../../../../plugins/apm/server/lib/settings/agent_configuration/list_configurations';
-import { getOptionLabel } from '../../../../../../../../../plugins/apm/common/agent_configuration/all_option';
+import { AgentConfigurationListAPIResponse } from '../../../../../../server/lib/settings/agent_configuration/list_configurations';
+import { getOptionLabel } from '../../../../../../common/agent_configuration/all_option';
import { callApmApi } from '../../../../../services/rest/createCallApmApi';
import { useApmPluginContext } from '../../../../../hooks/useApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx
index 6d5f65121d8fd..9eaa7786baca0 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/List/index.tsx
@@ -20,10 +20,10 @@ import { FETCH_STATUS } from '../../../../../hooks/useFetcher';
import { ITableColumn, ManagedTable } from '../../../../shared/ManagedTable';
import { LoadingStatePrompt } from '../../../../shared/LoadingStatePrompt';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { AgentConfigurationListAPIResponse } from '../../../../../../../../../plugins/apm/server/lib/settings/agent_configuration/list_configurations';
+import { AgentConfigurationListAPIResponse } from '../../../../../../server/lib/settings/agent_configuration/list_configurations';
import { TimestampTooltip } from '../../../../shared/TimestampTooltip';
import { px, units } from '../../../../../style/variables';
-import { getOptionLabel } from '../../../../../../../../../plugins/apm/common/agent_configuration/all_option';
+import { getOptionLabel } from '../../../../../../common/agent_configuration/all_option';
import {
createAgentConfigurationHref,
editAgentConfigurationHref
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx
index 8171e339adc82..4349e542449cc 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/index.tsx
@@ -17,7 +17,7 @@ import {
import { isEmpty } from 'lodash';
import { useFetcher } from '../../../../hooks/useFetcher';
import { AgentConfigurationList } from './List';
-import { useTrackPageview } from '../../../../../../../../plugins/observability/public';
+import { useTrackPageview } from '../../../../../../observability/public';
import { createAgentConfigurationHref } from '../../../shared/Links/apm/agentConfigurationLinks';
export function AgentConfigurations() {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
similarity index 80%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
index 272c4b3add415..b03960861e0ad 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.test.tsx
@@ -4,15 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { render, wait } from '@testing-library/react';
+import { render } from '@testing-library/react';
import React from 'react';
import { ApmIndices } from '.';
import * as hooks from '../../../../hooks/useFetcher';
import { MockApmPluginContextWrapper } from '../../../../context/ApmPluginContext/MockApmPluginContext';
describe('ApmIndices', () => {
- it('should not get stuck in infinite loop', async () => {
- spyOn(hooks, 'useFetcher').and.returnValue({
+ it('should not get stuck in infinite loop', () => {
+ const spy = spyOn(hooks, 'useFetcher').and.returnValue({
data: undefined,
status: 'loading'
});
@@ -30,6 +30,6 @@ describe('ApmIndices', () => {
`);
- await wait();
+ expect(spy).toHaveBeenCalledTimes(2);
});
});
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/ApmIndices/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CreateCustomLinkButton.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CreateCustomLinkButton.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CreateCustomLinkButton.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CreateCustomLinkButton.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/DeleteButton.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/DeleteButton.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/DeleteButton.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/DeleteButton.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/Documentation.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/Documentation.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/Documentation.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/Documentation.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx
index fb8ffe6722c87..9c244e3cde411 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FiltersSection.tsx
@@ -19,7 +19,7 @@ import React from 'react';
import {
Filter,
FilterKey
-} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+} from '../../../../../../../common/custom_link/custom_link_types';
import {
DEFAULT_OPTION,
FILTER_SELECT_OPTIONS,
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FlyoutFooter.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FlyoutFooter.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FlyoutFooter.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/FlyoutFooter.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx
index 8edfb176a1af8..8fed838a48261 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkPreview.tsx
@@ -17,8 +17,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { debounce } from 'lodash';
-import { Filter } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Filter } from '../../../../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
import { callApmApi } from '../../../../../../services/rest/createCallApmApi';
import { replaceTemplateVariables, convertFiltersToQuery } from './helper';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx
index 630f7148ad408..210033888d90c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/LinkSection.tsx
@@ -12,7 +12,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
-import { CustomLink } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { CustomLink } from '../../../../../../../common/custom_link/custom_link_types';
import { Documentation } from './Documentation';
interface InputField {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts
index 0a63cfcff9aa5..49e381aab675d 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.test.ts
@@ -7,7 +7,7 @@ import {
getSelectOptions,
replaceTemplateVariables
} from '../CustomLinkFlyout/helper';
-import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
describe('Custom link helper', () => {
describe('getSelectOptions', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts
index 7bfdbf1655e0d..8c35b8fe77506 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/helper.ts
@@ -6,12 +6,12 @@
import { i18n } from '@kbn/i18n';
import Mustache from 'mustache';
import { isEmpty, get } from 'lodash';
-import { FILTER_OPTIONS } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_filter_options';
+import { FILTER_OPTIONS } from '../../../../../../../common/custom_link/custom_link_filter_options';
import {
Filter,
FilterKey
-} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+} from '../../../../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
interface FilterSelectOption {
value: 'DEFAULT' | FilterKey;
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx
index 0b25a0a79edd9..150147d9af405 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/index.tsx
@@ -14,7 +14,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useState } from 'react';
-import { Filter } from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { Filter } from '../../../../../../../common/custom_link/custom_link_types';
import { useApmPluginContext } from '../../../../../../hooks/useApmPluginContext';
import { FiltersSection } from './FiltersSection';
import { FlyoutFooter } from './FlyoutFooter';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts
index 9cbaf16320a6b..685b3ab022950 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkFlyout/saveCustomLink.ts
@@ -9,7 +9,7 @@ import { NotificationsStart } from 'kibana/public';
import {
Filter,
CustomLink
-} from '../../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+} from '../../../../../../../common/custom_link/custom_link_types';
import { callApmApi } from '../../../../../../services/rest/createCallApmApi';
export async function saveCustomLink({
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx
index 68e6ee52af0b0..d68fb757e53d1 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/CustomLinkTable.tsx
@@ -13,7 +13,7 @@ import {
EuiSpacer
} from '@elastic/eui';
import { isEmpty } from 'lodash';
-import { CustomLink } from '../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { CustomLink } from '../../../../../../common/custom_link/custom_link_types';
import { units, px } from '../../../../../style/variables';
import { ManagedTable } from '../../../../shared/ManagedTable';
import { TimestampTooltip } from '../../../../shared/TimestampTooltip';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/EmptyPrompt.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/EmptyPrompt.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/EmptyPrompt.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/EmptyPrompt.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/Title.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/Title.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/Title.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/Title.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx
similarity index 99%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx
index e5c20b260e097..32a08f5ffaf7c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.test.tsx
@@ -8,7 +8,7 @@ import { fireEvent, render, wait, RenderResult } from '@testing-library/react';
import React from 'react';
import { act } from 'react-dom/test-utils';
import * as apmApi from '../../../../../services/rest/createCallApmApi';
-import { License } from '../../../../../../../../../plugins/licensing/common/license';
+import { License } from '../../../../../../../licensing/common/license';
import * as hooks from '../../../../../hooks/useFetcher';
import { LicenseContext } from '../../../../../context/LicenseContext';
import { CustomLinkOverview } from '.';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx
index e9a915e0f59bc..b94ce513bc210 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/CustomLink/index.tsx
@@ -8,7 +8,7 @@ import { EuiPanel, EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { isEmpty } from 'lodash';
import React, { useEffect, useState } from 'react';
import { i18n } from '@kbn/i18n';
-import { CustomLink } from '../../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { CustomLink } from '../../../../../../common/custom_link/custom_link_types';
import { useLicense } from '../../../../../hooks/useLicense';
import { useFetcher, FETCH_STATUS } from '../../../../../hooks/useFetcher';
import { CustomLinkFlyout } from './CustomLinkFlyout';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/CustomizeUI/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/Settings/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/Settings/index.tsx
rename to x-pack/plugins/apm/public/components/app/Settings/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TraceLink/__test__/TraceLink.test.tsx b/x-pack/plugins/apm/public/components/app/TraceLink/__test__/TraceLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TraceLink/__test__/TraceLink.test.tsx
rename to x-pack/plugins/apm/public/components/app/TraceLink/__test__/TraceLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TraceLink/index.tsx b/x-pack/plugins/apm/public/components/app/TraceLink/index.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/TraceLink/index.tsx
rename to x-pack/plugins/apm/public/components/app/TraceLink/index.tsx
index f0301f8917d10..04d830f4649d4 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TraceLink/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TraceLink/index.tsx
@@ -9,8 +9,8 @@ import React from 'react';
import { Redirect } from 'react-router-dom';
import styled from 'styled-components';
import url from 'url';
-import { TRACE_ID } from '../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { TRACE_ID } from '../../../../common/elasticsearch_fieldnames';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher';
import { useUrlParams } from '../../../hooks/useUrlParams';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/TraceList.tsx b/x-pack/plugins/apm/public/components/app/TraceOverview/TraceList.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/TraceOverview/TraceList.tsx
rename to x-pack/plugins/apm/public/components/app/TraceOverview/TraceList.tsx
index 91f3051acf077..92d5a38cc11ca 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/TraceList.tsx
+++ b/x-pack/plugins/apm/public/components/app/TraceOverview/TraceList.tsx
@@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
import React from 'react';
import styled from 'styled-components';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ITransactionGroup } from '../../../../../../../plugins/apm/server/lib/transaction_groups/transform';
+import { ITransactionGroup } from '../../../../server/lib/transaction_groups/transform';
import { fontSizes, truncate } from '../../../style/variables';
import { convertTo } from '../../../utils/formatters';
import { EmptyMessage } from '../../shared/EmptyMessage';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx
rename to x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx
index bfbad78a5c026..a7fa927f9e9b1 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TraceOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TraceOverview/index.tsx
@@ -9,9 +9,9 @@ import React, { useMemo } from 'react';
import { FETCH_STATUS, useFetcher } from '../../../hooks/useFetcher';
import { TraceList } from './TraceList';
import { useUrlParams } from '../../../hooks/useUrlParams';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
+import { useTrackPageview } from '../../../../../observability/public';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { PROJECTION } from '../../../../common/projections/typings';
export function TraceOverview() {
const { urlParams, uiFilters } = useUrlParams();
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
index 08682fb3be842..7ad0a77505b9d 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/__test__/distribution.test.ts
@@ -6,7 +6,7 @@
import { getFormattedBuckets } from '../index';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { IBucket } from '../../../../../../../../../plugins/apm/server/lib/transactions/distribution/get_buckets/transform';
+import { IBucket } from '../../../../../../server/lib/transactions/distribution/get_buckets/transform';
describe('Distribution', () => {
it('getFormattedBuckets', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx
index e70133aabb679..b7dbfbdbd7d7e 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/Distribution/index.tsx
@@ -10,9 +10,9 @@ import d3 from 'd3';
import React, { FunctionComponent, useCallback } from 'react';
import { isEmpty } from 'lodash';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TransactionDistributionAPIResponse } from '../../../../../../../../plugins/apm/server/lib/transactions/distribution';
+import { TransactionDistributionAPIResponse } from '../../../../../server/lib/transactions/distribution';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { IBucket } from '../../../../../../../../plugins/apm/server/lib/transactions/distribution/get_buckets/transform';
+import { IBucket } from '../../../../../server/lib/transactions/distribution/get_buckets/transform';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { getDurationFormatter } from '../../../../utils/formatters';
// @ts-ignore
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/ErrorCount.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/ErrorCount.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/ErrorCount.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/ErrorCount.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx
index 4e105957f5f9d..1db8e02e38692 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/MaybeViewTraceLink.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { EuiButton, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { Transaction as ITransaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction as ITransaction } from '../../../../../typings/es_schemas/ui/transaction';
import { TransactionDetailLink } from '../../../shared/Links/apm/TransactionDetailLink';
import { IWaterfall } from './WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/PercentOfParent.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/PercentOfParent.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/PercentOfParent.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/PercentOfParent.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx
index 9026dd90ddceb..27e0584c696c1 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/TransactionTabs.tsx
@@ -8,7 +8,7 @@ import { EuiSpacer, EuiTab, EuiTabs } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { Location } from 'history';
import React from 'react';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers';
import { history } from '../../../../utils/history';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
index 030729522f35e..ae908b25cc615 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_agent_marks.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import { getAgentMarks } from '../get_agent_marks';
describe('getAgentMarks', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts
index 1dcb1598662c9..2bc64e30b4f7e 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_agent_marks.ts
@@ -5,7 +5,7 @@
*/
import { sortBy } from 'lodash';
-import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
import { Mark } from '.';
// Extends Mark without adding new properties to it.
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
similarity index 89%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
index a9694efcbcae7..ad54cec5c26a7 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { isEmpty } from 'lodash';
-import { ErrorRaw } from '../../../../../../../../../../plugins/apm/typings/es_schemas/raw/error_raw';
+import { ErrorRaw } from '../../../../../../../typings/es_schemas/raw/error_raw';
import {
IWaterfallError,
IServiceColors
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/index.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/index.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/index.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/ServiceLegends.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/ServiceLegends.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/ServiceLegends.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/ServiceLegends.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
index 6e58dbc5b6ea3..bbc457450e475 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/FlyoutTopLevelProperties.tsx
@@ -9,8 +9,8 @@ import React from 'react';
import {
SERVICE_NAME,
TRANSACTION_NAME
-} from '../../../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { Transaction } from '../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+} from '../../../../../../../common/elasticsearch_fieldnames';
+import { Transaction } from '../../../../../../../typings/es_schemas/ui/transaction';
import { TransactionDetailLink } from '../../../../../shared/Links/apm/TransactionDetailLink';
import { StickyProperties } from '../../../../../shared/StickyProperties';
import { TransactionOverviewLink } from '../../../../../shared/Links/apm/TransactionOverviewLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/ResponsiveFlyout.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/ResponsiveFlyout.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/ResponsiveFlyout.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/ResponsiveFlyout.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx
index 6200d5f098ad5..7a08a84bf30ba 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/DatabaseContext.tsx
@@ -18,7 +18,7 @@ import SyntaxHighlighter, {
// @ts-ignore
import { xcode } from 'react-syntax-highlighter/dist/styles';
import styled from 'styled-components';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
import {
borderRadius,
fontFamilyCode,
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx
index 438e88df3351d..28564481074fa 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/HttpContext.tsx
@@ -17,7 +17,7 @@ import {
unit,
units
} from '../../../../../../../style/variables';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
const ContextUrl = styled.div`
padding: ${px(units.half)} ${px(unit)};
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
similarity index 86%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
index 621497a0b22e0..d49959c5cbffb 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/StickySpanProperties.tsx
@@ -6,14 +6,14 @@
import { i18n } from '@kbn/i18n';
import React from 'react';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import {
SPAN_NAME,
TRANSACTION_NAME,
SERVICE_NAME
-} from '../../../../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../../../../plugins/apm/common/i18n';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+} from '../../../../../../../../common/elasticsearch_fieldnames';
+import { NOT_AVAILABLE_LABEL } from '../../../../../../../../common/i18n';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
import { StickyProperties } from '../../../../../../shared/StickyProperties';
import { TransactionOverviewLink } from '../../../../../../shared/Links/apm/TransactionOverviewLink';
import { TransactionDetailLink } from '../../../../../../shared/Links/apm/TransactionDetailLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/TruncateHeightSection.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/TruncateHeightSection.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/TruncateHeightSection.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/TruncateHeightSection.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx
index f57ddb5cf69a2..1da22516629f2 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SpanFlyout/index.tsx
@@ -25,8 +25,8 @@ import { px, units } from '../../../../../../../style/variables';
import { Summary } from '../../../../../../shared/Summary';
import { TimestampTooltip } from '../../../../../../shared/TimestampTooltip';
import { DurationSummaryItem } from '../../../../../../shared/Summary/DurationSummaryItem';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import { DiscoverSpanLink } from '../../../../../../shared/Links/DiscoverLinks/DiscoverSpanLink';
import { Stacktrace } from '../../../../../../shared/Stacktrace';
import { ResponsiveFlyout } from '../ResponsiveFlyout';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.stories.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.stories.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/SyncBadge.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx
index 85cf0b642530f..87ecb96f74735 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/DroppedSpansWarning.tsx
@@ -7,7 +7,7 @@
import { EuiCallOut, EuiHorizontalRule } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import { ElasticDocsLink } from '../../../../../../shared/Links/ElasticDocsLink';
export function DroppedSpansWarning({
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx
index e24414bb28d52..5fb679818f0a7 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/TransactionFlyout/index.tsx
@@ -16,7 +16,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import { TransactionActionMenu } from '../../../../../../shared/TransactionActionMenu/TransactionActionMenu';
import { TransactionSummary } from '../../../../../../shared/Summary/TransactionSummary';
import { FlyoutTopLevelProperties } from '../FlyoutTopLevelProperties';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallFlyout.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallFlyout.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallFlyout.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallFlyout.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx
index 5c6e0cc5ce435..d8edcce46c2d7 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/WaterfallItem.tsx
@@ -10,13 +10,13 @@ import styled from 'styled-components';
import { EuiIcon, EuiText, EuiTitle, EuiToolTip } from '@elastic/eui';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { i18n } from '@kbn/i18n';
-import { isRumAgentName } from '../../../../../../../../../../plugins/apm/common/agent_name';
+import { isRumAgentName } from '../../../../../../../common/agent_name';
import { px, unit, units } from '../../../../../../style/variables';
import { asDuration } from '../../../../../../utils/formatters';
import { ErrorCount } from '../../ErrorCount';
import { IWaterfallItem } from './waterfall_helpers/waterfall_helpers';
import { ErrorOverviewLink } from '../../../../../shared/Links/apm/ErrorOverviewLink';
-import { TRACE_ID } from '../../../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+import { TRACE_ID } from '../../../../../../../common/elasticsearch_fieldnames';
import { SyncBadge } from './SyncBadge';
import { Margins } from '../../../../../shared/charts/Timeline';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/__snapshots__/waterfall_helpers.test.ts.snap b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/__snapshots__/waterfall_helpers.test.ts.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/__snapshots__/waterfall_helpers.test.ts.snap
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/__snapshots__/waterfall_helpers.test.ts.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/spans.json b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/spans.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/spans.json
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/spans.json
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/transaction.json b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/transaction.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/transaction.json
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/mock_responses/transaction.json
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts
index e0a01e9422c85..75304932ed2ba 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts
@@ -5,8 +5,8 @@
*/
import { groupBy } from 'lodash';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
import {
getClockSkew,
getOrderedWaterfallItems,
@@ -15,7 +15,7 @@ import {
IWaterfallTransaction,
IWaterfallError
} from './waterfall_helpers';
-import { APMError } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../../../../typings/es_schemas/ui/apm_error';
describe('waterfall_helpers', () => {
describe('getWaterfall', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts
index 73193cc7c9dbb..8ddce66f0b853 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts
@@ -16,10 +16,10 @@ import {
zipObject
} from 'lodash';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TraceAPIResponse } from '../../../../../../../../../../../plugins/apm/server/lib/traces/get_trace';
-import { APMError } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
-import { Span } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
-import { Transaction } from '../../../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { TraceAPIResponse } from '../../../../../../../../server/lib/traces/get_trace';
+import { APMError } from '../../../../../../../../typings/es_schemas/ui/apm_error';
+import { Span } from '../../../../../../../../typings/es_schemas/ui/span';
+import { Transaction } from '../../../../../../../../typings/es_schemas/ui/transaction';
interface IWaterfallGroup {
[key: string]: IWaterfallItem[];
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx
index f681f4dfc675a..87710fb9b8d96 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TraceAPIResponse } from '../../../../../../../../../plugins/apm/server/lib/traces/get_trace';
+import { TraceAPIResponse } from '../../../../../../server/lib/traces/get_trace';
import { WaterfallContainer } from './index';
import {
location,
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/__tests__/ErrorCount.test.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/__tests__/ErrorCount.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/__tests__/ErrorCount.test.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/__tests__/ErrorCount.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx
index 1082052c6929d..056e9cdb75148 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/index.tsx
@@ -17,7 +17,7 @@ import { i18n } from '@kbn/i18n';
import { Location } from 'history';
import React, { useEffect, useState } from 'react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { IBucket } from '../../../../../../../../plugins/apm/server/lib/transactions/distribution/get_buckets/transform';
+import { IBucket } from '../../../../../server/lib/transactions/distribution/get_buckets/transform';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import { history } from '../../../../utils/history';
import { fromQuery, toQuery } from '../../../shared/Links/url_helpers';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
index e2634be0e0be8..2544dc2a1a77c 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionDetails/index.tsx
@@ -26,8 +26,8 @@ import { useUrlParams } from '../../../hooks/useUrlParams';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { TransactionBreakdown } from '../../shared/TransactionBreakdown';
import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { useTrackPageview } from '../../../../../observability/public';
+import { PROJECTION } from '../../../../common/projections/typings';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { HeightRetainer } from '../../shared/HeightRetainer';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/List/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionOverview/List/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/List/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionOverview/List/index.tsx
index 16fda7c600906..e3b33f11d0805 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/List/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionOverview/List/index.tsx
@@ -8,9 +8,9 @@ import { EuiIcon, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useMemo } from 'react';
import styled from 'styled-components';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
+import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ITransactionGroup } from '../../../../../../../../plugins/apm/server/lib/transaction_groups/transform';
+import { ITransactionGroup } from '../../../../../server/lib/transaction_groups/transform';
import { fontFamilyCode, truncate } from '../../../../style/variables';
import { asDecimal, convertTo } from '../../../../utils/formatters';
import { ImpactBar } from '../../../shared/ImpactBar';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/__jest__/TransactionOverview.test.tsx b/x-pack/plugins/apm/public/components/app/TransactionOverview/__jest__/TransactionOverview.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/__jest__/TransactionOverview.test.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionOverview/__jest__/TransactionOverview.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx b/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx
rename to x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx
index b008c98417867..60aac3fcdfeef 100644
--- a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/TransactionOverview/index.tsx
@@ -27,10 +27,10 @@ import { getHasMLJob } from '../../../services/rest/ml';
import { history } from '../../../utils/history';
import { useLocation } from '../../../hooks/useLocation';
import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
-import { useTrackPageview } from '../../../../../../../plugins/observability/public';
+import { useTrackPageview } from '../../../../../observability/public';
import { fromQuery, toQuery } from '../../shared/Links/url_helpers';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { PROJECTION } from '../../../../common/projections/typings';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useServiceTransactionTypes } from '../../../hooks/useServiceTransactionTypes';
import { TransactionTypeFilter } from '../../shared/LocalUIFilters/TransactionTypeFilter';
diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/useRedirect.ts b/x-pack/plugins/apm/public/components/app/TransactionOverview/useRedirect.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/app/TransactionOverview/useRedirect.ts
rename to x-pack/plugins/apm/public/components/app/TransactionOverview/useRedirect.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ApmHeader/index.tsx b/x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ApmHeader/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ApmHeader/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/DatePicker/__test__/DatePicker.test.tsx b/x-pack/plugins/apm/public/components/shared/DatePicker/__test__/DatePicker.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/DatePicker/__test__/DatePicker.test.tsx
rename to x-pack/plugins/apm/public/components/shared/DatePicker/__test__/DatePicker.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/DatePicker/index.tsx b/x-pack/plugins/apm/public/components/shared/DatePicker/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/DatePicker/index.tsx
rename to x-pack/plugins/apm/public/components/shared/DatePicker/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/EmptyMessage.tsx b/x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/EmptyMessage.tsx
rename to x-pack/plugins/apm/public/components/shared/EmptyMessage.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/EnvironmentBadge/index.tsx b/x-pack/plugins/apm/public/components/shared/EnvironmentBadge/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/EnvironmentBadge/index.tsx
rename to x-pack/plugins/apm/public/components/shared/EnvironmentBadge/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx b/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx
rename to x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx
index e911011f0979c..d17b3b7689b19 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/EnvironmentFilter/index.tsx
@@ -15,7 +15,7 @@ import { fromQuery, toQuery } from '../Links/url_helpers';
import {
ENVIRONMENT_ALL,
ENVIRONMENT_NOT_DEFINED
-} from '../../../../../../../plugins/apm/common/environment_filter_values';
+} from '../../../../common/environment_filter_values';
function updateEnvironmentUrl(
location: ReturnType,
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.stories.tsx b/x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.stories.tsx
rename to x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx b/x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx
index b7e23c2979cb8..658def7ddbb57 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx
@@ -7,8 +7,8 @@ import React from 'react';
import { EuiFieldNumber } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { isFinite } from 'lodash';
-import { ForLastExpression } from '../../../../../../../plugins/triggers_actions_ui/public';
-import { ALERT_TYPES_CONFIG } from '../../../../../../../plugins/apm/common/alert_types';
+import { ForLastExpression } from '../../../../../triggers_actions_ui/public';
+import { ALERT_TYPES_CONFIG } from '../../../../common/alert_types';
import { ServiceAlertTrigger } from '../ServiceAlertTrigger';
import { PopoverExpression } from '../ServiceAlertTrigger/PopoverExpression';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ErrorStatePrompt.tsx b/x-pack/plugins/apm/public/components/shared/ErrorStatePrompt.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ErrorStatePrompt.tsx
rename to x-pack/plugins/apm/public/components/shared/ErrorStatePrompt.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/EuiTabLink.tsx b/x-pack/plugins/apm/public/components/shared/EuiTabLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/EuiTabLink.tsx
rename to x-pack/plugins/apm/public/components/shared/EuiTabLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/HeightRetainer/index.tsx b/x-pack/plugins/apm/public/components/shared/HeightRetainer/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/HeightRetainer/index.tsx
rename to x-pack/plugins/apm/public/components/shared/HeightRetainer/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js b/x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js
rename to x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/ImpactBar.test.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap b/x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/ImpactBar/__test__/__snapshots__/ImpactBar.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/index.tsx b/x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ImpactBar/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ImpactBar/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx b/x-pack/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx
rename to x-pack/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx
index 4de07f75ff84f..d33960fe5196b 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx
+++ b/x-pack/plugins/apm/public/components/shared/KeyValueTable/FormattedValue.tsx
@@ -8,7 +8,7 @@ import theme from '@elastic/eui/dist/eui_theme_light.json';
import { isBoolean, isNumber, isObject } from 'lodash';
import React from 'react';
import styled from 'styled-components';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../plugins/apm/common/i18n';
+import { NOT_AVAILABLE_LABEL } from '../../../../common/i18n';
const EmptyValue = styled.span`
color: ${theme.euiColorMediumShade};
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx b/x-pack/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx
rename to x-pack/plugins/apm/public/components/shared/KeyValueTable/__test__/KeyValueTable.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/index.tsx b/x-pack/plugins/apm/public/components/shared/KeyValueTable/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/KeyValueTable/index.tsx
rename to x-pack/plugins/apm/public/components/shared/KeyValueTable/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js b/x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js
rename to x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js
index 5ad256efe0945..93a95c844a975 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js
+++ b/x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/ClickOutside.js
@@ -27,6 +27,7 @@ export default class ClickOutside extends Component {
};
render() {
+ // eslint-disable-next-line no-unused-vars
const { onClickOutside, ...restProps } = this.props;
return (
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestion.js b/x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestion.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestion.js
rename to x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestion.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestions.js b/x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestions.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestions.js
rename to x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/Suggestions.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js b/x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js
rename to x-pack/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts b/x-pack/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts
rename to x-pack/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts
index 19a9ae9538ad6..f4628524cced5 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts
+++ b/x-pack/plugins/apm/public/components/shared/KueryBar/get_bool_filter.ts
@@ -4,14 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { ESFilter } from '../../../../../../../plugins/apm/typings/elasticsearch';
+import { ESFilter } from '../../../../typings/elasticsearch';
import {
TRANSACTION_TYPE,
ERROR_GROUP_ID,
PROCESSOR_EVENT,
TRANSACTION_NAME,
SERVICE_NAME
-} from '../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../common/elasticsearch_fieldnames';
import { IUrlParams } from '../../../context/UrlParamsContext/types';
export function getBoolFilter(urlParams: IUrlParams) {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx b/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx
rename to x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx
index dba31822dd23e..2622d08d4779d 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/KueryBar/index.tsx
@@ -21,7 +21,7 @@ import {
QuerySuggestion,
esKuery,
IIndexPattern
-} from '../../../../../../../../src/plugins/data/public';
+} from '../../../../../../../src/plugins/data/public';
const Container = styled.div`
margin-bottom: 10px;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LicensePrompt/LicensePrompt.stories.tsx b/x-pack/plugins/apm/public/components/shared/LicensePrompt/LicensePrompt.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LicensePrompt/LicensePrompt.stories.tsx
rename to x-pack/plugins/apm/public/components/shared/LicensePrompt/LicensePrompt.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LicensePrompt/index.tsx b/x-pack/plugins/apm/public/components/shared/LicensePrompt/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LicensePrompt/index.tsx
rename to x-pack/plugins/apm/public/components/shared/LicensePrompt/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx
similarity index 85%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx
index 806d9f73369c3..05e4080d5d0b7 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverErrorLink.tsx
@@ -8,8 +8,8 @@ import React from 'react';
import {
ERROR_GROUP_ID,
SERVICE_NAME
-} from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { APMError } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+} from '../../../../../common/elasticsearch_fieldnames';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
import { DiscoverLink } from './DiscoverLink';
function getDiscoverQuery(error: APMError, kuery?: string) {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx
index 6dc93292956fa..b58a450d26644 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverLink.tsx
@@ -11,7 +11,7 @@ import url from 'url';
import rison, { RisonValue } from 'rison-node';
import { useLocation } from '../../../../hooks/useLocation';
import { getTimepickerRisonData } from '../rison_helpers';
-import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../../../../plugins/apm/common/index_pattern_constants';
+import { APM_STATIC_INDEX_PATTERN_ID } from '../../../../../common/index_pattern_constants';
import { useApmPluginContext } from '../../../../hooks/useApmPluginContext';
import { AppMountContextBasePath } from '../../../../context/ApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx
similarity index 79%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx
index 8fe5be28def22..ac9e33b3acd69 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverSpanLink.tsx
@@ -5,8 +5,8 @@
*/
import React from 'react';
-import { SPAN_ID } from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { Span } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { SPAN_ID } from '../../../../../common/elasticsearch_fieldnames';
+import { Span } from '../../../../../typings/es_schemas/ui/span';
import { DiscoverLink } from './DiscoverLink';
function getDiscoverQuery(span: Span) {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx
similarity index 85%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx
index b0af33fd7d7f7..a5f4df7dbac1b 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/DiscoverTransactionLink.tsx
@@ -9,8 +9,8 @@ import {
PROCESSOR_EVENT,
TRACE_ID,
TRANSACTION_ID
-} from '../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+} from '../../../../../common/elasticsearch_fieldnames';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { DiscoverLink } from './DiscoverLink';
export function getDiscoverQuery(transaction: Transaction) {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
index eeb9fd20a4bcb..acf8d89432b23 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorButton.test.tsx
@@ -6,7 +6,7 @@
import { shallow, ShallowWrapper } from 'enzyme';
import React from 'react';
-import { APMError } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
import { DiscoverErrorLink } from '../DiscoverErrorLink';
describe('DiscoverErrorLink without kuery', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
index eeb9fd20a4bcb..acf8d89432b23 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverErrorLink.test.tsx
@@ -6,7 +6,7 @@
import { shallow, ShallowWrapper } from 'enzyme';
import React from 'react';
-import { APMError } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
import { DiscoverErrorLink } from '../DiscoverErrorLink';
describe('DiscoverErrorLink without kuery', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
index 759caa785c1af..ea79fe12ff0bd 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverLinks.integration.test.tsx
@@ -6,9 +6,9 @@
import { Location } from 'history';
import React from 'react';
-import { APMError } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
-import { Span } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
-import { Transaction } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
+import { Span } from '../../../../../../typings/es_schemas/ui/span';
+import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
import { getRenderedHref } from '../../../../../utils/testHelpers';
import { DiscoverErrorLink } from '../DiscoverErrorLink';
import { DiscoverSpanLink } from '../DiscoverSpanLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx
index d72925c1956a4..5769ca34a9a87 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionButton.test.tsx
@@ -6,7 +6,7 @@
import { shallow } from 'enzyme';
import React from 'react';
-import { Transaction } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
import {
DiscoverTransactionLink,
getDiscoverQuery
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
index 15a92474fcc6d..2f65cf7734631 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/DiscoverTransactionLink.test.tsx
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Transaction } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
// @ts-ignore
import configureStore from '../../../../../store/config/configureStore';
import { getDiscoverQuery } from '../DiscoverTransactionLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorButton.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverErrorLink.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionButton.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionButton.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionButton.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionButton.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/__snapshots__/DiscoverTransactionLink.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mockTransaction.json b/x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mockTransaction.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mockTransaction.json
rename to x-pack/plugins/apm/public/components/shared/Links/DiscoverLinks/__test__/mockTransaction.json
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/ElasticDocsLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/ElasticDocsLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/ElasticDocsLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/ElasticDocsLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/InfraLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/InfraLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/InfraLink.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/InfraLink.tsx
index 7efe5cb96cfbd..0ae9f64dc24ef 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/InfraLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/InfraLink.tsx
@@ -10,7 +10,7 @@ import url from 'url';
import { fromQuery } from './url_helpers';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { AppMountContextBasePath } from '../../../context/ApmPluginContext';
-import { InfraAppId } from '../../../../../../../plugins/infra/public';
+import { InfraAppId } from '../../../../../infra/public';
interface InfraQueryParams {
time?: number;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/KibanaLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/KibanaLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/KibanaLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/KibanaLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/KibanaLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/KibanaLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/KibanaLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/KibanaLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx
index ecf788ddd2e69..81c5d17d491c0 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLJobLink.tsx
@@ -5,7 +5,7 @@
*/
import React from 'react';
-import { getMlJobId } from '../../../../../../../../plugins/apm/common/ml_job_constants';
+import { getMlJobId } from '../../../../../common/ml_job_constants';
import { MLLink } from './MLLink';
interface Props {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/MachineLearningLinks/MLLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/SetupInstructionsLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/SetupInstructionsLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/SetupInstructionsLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/SetupInstructionsLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/APMLink.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/APMLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/APMLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/APMLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/APMLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ErrorDetailLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorDetailLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ErrorDetailLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ErrorDetailLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx
index fcc0dc7d26695..ebcf220994cda 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ErrorOverviewLink.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
import { APMQueryParams } from '../url_helpers';
interface Props extends APMLinkExtendProps {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ExternalLinks.test.ts b/x-pack/plugins/apm/public/components/shared/Links/apm/ExternalLinks.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ExternalLinks.test.ts
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ExternalLinks.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ExternalLinks.ts b/x-pack/plugins/apm/public/components/shared/Links/apm/ExternalLinks.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ExternalLinks.ts
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ExternalLinks.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/HomeLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/HomeLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/HomeLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/HomeLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
index 7d21e1efa44f2..bd3e3b36a8601 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/MetricOverviewLink.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
interface Props extends APMLinkExtendProps {
serviceName: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ServiceMapLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx
index 527c3da9e7e1c..1473221cca2be 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeMetricOverviewLink.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
interface Props extends APMLinkExtendProps {
serviceName: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
index db1b6ec117bf4..b479ab77e1127 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceNodeOverviewLink.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
interface Props extends APMLinkExtendProps {
serviceName: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx
index 101f1602506aa..577209a26e46b 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/ServiceOverviewLink.tsx
@@ -12,7 +12,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
const ServiceOverviewLink = (props: APMLinkExtendProps) => {
const { urlParams } = useUrlParams();
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/SettingsLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/SettingsLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/SettingsLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/SettingsLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
index 371544c142a2d..dc4519365cbc2 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TraceOverviewLink.tsx
@@ -12,7 +12,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
const TraceOverviewLink = (props: APMLinkExtendProps) => {
const { urlParams } = useUrlParams();
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx
index 784f9b36ff621..6278336751851 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionDetailLink.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
interface Props extends APMLinkExtendProps {
serviceName: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx
index af60a0a748445..ccef83ee73fb8 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/TransactionOverviewLink.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
-import { pickKeys } from '../../../../utils/pickKeys';
+import { pickKeys } from '../../../../../common/utils/pick_keys';
interface Props extends APMLinkExtendProps {
serviceName: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx b/x-pack/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx
index 0c747e0773a69..6885e44f1ad1f 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Links/apm/agentConfigurationLinks.tsx
@@ -5,7 +5,7 @@
*/
import { getAPMHref } from './APMLink';
-import { AgentConfigurationIntake } from '../../../../../../../../plugins/apm/common/agent_configuration/configuration_types';
+import { AgentConfigurationIntake } from '../../../../../common/agent_configuration/configuration_types';
import { history } from '../../../../utils/history';
export function editAgentConfigurationHref(
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/rison_helpers.ts b/x-pack/plugins/apm/public/components/shared/Links/rison_helpers.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/rison_helpers.ts
rename to x-pack/plugins/apm/public/components/shared/Links/rison_helpers.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/url_helpers.test.tsx b/x-pack/plugins/apm/public/components/shared/Links/url_helpers.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/url_helpers.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Links/url_helpers.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Links/url_helpers.ts b/x-pack/plugins/apm/public/components/shared/Links/url_helpers.ts
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/components/shared/Links/url_helpers.ts
rename to x-pack/plugins/apm/public/components/shared/Links/url_helpers.ts
index c7d71d0b6dac5..b296302c47edf 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Links/url_helpers.ts
+++ b/x-pack/plugins/apm/public/components/shared/Links/url_helpers.ts
@@ -6,8 +6,8 @@
import { parse, stringify } from 'query-string';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { LocalUIFilterName } from '../../../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
-import { url } from '../../../../../../../../src/plugins/kibana_utils/public';
+import { LocalUIFilterName } from '../../../../server/lib/ui_filters/local_ui_filters/config';
+import { url } from '../../../../../../../src/plugins/kibana_utils/public';
export function toQuery(search?: string): APMQueryParamsRaw {
return search ? parse(search.slice(1), { sort: false }) : {};
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LoadingStatePrompt.tsx b/x-pack/plugins/apm/public/components/shared/LoadingStatePrompt.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LoadingStatePrompt.tsx
rename to x-pack/plugins/apm/public/components/shared/LoadingStatePrompt.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterBadgeList.tsx b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterBadgeList.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterBadgeList.tsx
rename to x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterBadgeList.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterTitleButton.tsx b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterTitleButton.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterTitleButton.tsx
rename to x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterTitleButton.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/index.tsx b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/Filter/index.tsx
rename to x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/TransactionTypeFilter/index.tsx b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/TransactionTypeFilter/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/TransactionTypeFilter/index.tsx
rename to x-pack/plugins/apm/public/components/shared/LocalUIFilters/TransactionTypeFilter/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/index.tsx b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/index.tsx
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/index.tsx
rename to x-pack/plugins/apm/public/components/shared/LocalUIFilters/index.tsx
index cede3e394cfab..2c755009ed13a 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/LocalUIFilters/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/LocalUIFilters/index.tsx
@@ -14,10 +14,10 @@ import {
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { LocalUIFilterName } from '../../../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
+import { LocalUIFilterName } from '../../../../server/lib/ui_filters/local_ui_filters/config';
import { Filter } from './Filter';
import { useLocalUIFilters } from '../../../hooks/useLocalUIFilters';
-import { PROJECTION } from '../../../../../../../plugins/apm/common/projections/typings';
+import { PROJECTION } from '../../../../common/projections/typings';
interface Props {
projection: PROJECTION;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js b/x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js
rename to x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/ManagedTable.test.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap b/x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/ManagedTable/__test__/__snapshots__/ManagedTable.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/index.tsx b/x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ManagedTable/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ManagedTable/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
index 258788252379a..1913cf79c7935 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/__test__/ErrorMetadata.test.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { ErrorMetadata } from '..';
import { render } from '@testing-library/react';
-import { APMError } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../../typings/es_schemas/ui/apm_error';
import {
expectTextsInDocument,
expectTextsNotInDocument
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx
index ce991d8b0dc00..7cae42a94322b 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/index.tsx
@@ -6,7 +6,7 @@
import React, { useMemo } from 'react';
import { ERROR_METADATA_SECTIONS } from './sections';
-import { APMError } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
+import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
import { getSectionsWithRows } from '../helper';
import { MetadataTable } from '..';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/sections.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/sections.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/sections.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/ErrorMetadata/sections.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/Section.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/Section.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/Section.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
index 0059b7b8fb4b3..a46539fe72fcb 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/__test__/SpanMetadata.test.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { SpanMetadata } from '..';
-import { Span } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { Span } from '../../../../../../typings/es_schemas/ui/span';
import {
expectTextsInDocument,
expectTextsNotInDocument
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx
index 2134f12531a7a..abef083e39b9e 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/index.tsx
@@ -6,7 +6,7 @@
import React, { useMemo } from 'react';
import { SPAN_METADATA_SECTIONS } from './sections';
-import { Span } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { Span } from '../../../../../typings/es_schemas/ui/span';
import { getSectionsWithRows } from '../helper';
import { MetadataTable } from '..';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/sections.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/sections.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/sections.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/SpanMetadata/sections.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
index 3d78f36db9786..8ae46d359efc3 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/__test__/TransactionMetadata.test.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { TransactionMetadata } from '..';
import { render } from '@testing-library/react';
-import { Transaction } from '../../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../../typings/es_schemas/ui/transaction';
import {
expectTextsInDocument,
expectTextsNotInDocument
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx
index 6f93de4e87e49..86ecbba6a0aaa 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/index.tsx
@@ -6,7 +6,7 @@
import React, { useMemo } from 'react';
import { TRANSACTION_METADATA_SECTIONS } from './sections';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { getSectionsWithRows } from '../helper';
import { MetadataTable } from '..';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/sections.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/sections.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/sections.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/TransactionMetadata/sections.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/MetadataTable.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/Section.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
index b65b52bf30a5c..e754f7163ca11 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/__test__/helper.test.ts
@@ -6,7 +6,7 @@
import { getSectionsWithRows, filterSectionsByTerm } from '../helper';
import { LABELS, HTTP, SERVICE } from '../sections';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
describe('MetadataTable Helper', () => {
const sections = [
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/helper.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/helper.ts
similarity index 85%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/helper.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/helper.ts
index ef329abafa61b..a8678ee596e43 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/helper.ts
+++ b/x-pack/plugins/apm/public/components/shared/MetadataTable/helper.ts
@@ -6,9 +6,9 @@
import { get, pick, isEmpty } from 'lodash';
import { Section } from './sections';
-import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
-import { APMError } from '../../../../../../../plugins/apm/typings/es_schemas/ui/apm_error';
-import { Span } from '../../../../../../../plugins/apm/typings/es_schemas/ui/span';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
+import { APMError } from '../../../../typings/es_schemas/ui/apm_error';
+import { Span } from '../../../../typings/es_schemas/ui/span';
import { flattenObject, KeyValuePair } from '../../../utils/flattenObject';
export type SectionsWithRows = ReturnType;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/index.tsx b/x-pack/plugins/apm/public/components/shared/MetadataTable/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/index.tsx
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/sections.ts b/x-pack/plugins/apm/public/components/shared/MetadataTable/sections.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/MetadataTable/sections.ts
rename to x-pack/plugins/apm/public/components/shared/MetadataTable/sections.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/SelectWithPlaceholder/index.tsx b/x-pack/plugins/apm/public/components/shared/SelectWithPlaceholder/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/SelectWithPlaceholder/index.tsx
rename to x-pack/plugins/apm/public/components/shared/SelectWithPlaceholder/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ServiceAlertTrigger/PopoverExpression/index.tsx b/x-pack/plugins/apm/public/components/shared/ServiceAlertTrigger/PopoverExpression/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ServiceAlertTrigger/PopoverExpression/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ServiceAlertTrigger/PopoverExpression/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/ServiceAlertTrigger/index.tsx b/x-pack/plugins/apm/public/components/shared/ServiceAlertTrigger/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/ServiceAlertTrigger/index.tsx
rename to x-pack/plugins/apm/public/components/shared/ServiceAlertTrigger/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.test.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx
index eab414ad47c2c..6dfc8778fe1fc 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/CauseStacktrace.tsx
@@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n';
import { EuiAccordion, EuiTitle } from '@elastic/eui';
import { px, unit } from '../../../style/variables';
import { Stacktrace } from '.';
-import { IStackframe } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
// @ts-ignore Styled Components has trouble inferring the types of the default props here.
const Accordion = styled(EuiAccordion)`
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Context.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/Context.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Context.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/Context.tsx
index d289539ca44b1..d48f4b4f51a6a 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Context.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/Context.tsx
@@ -22,7 +22,7 @@ import { registerLanguage } from 'react-syntax-highlighter/dist/light';
// @ts-ignore
import { xcode } from 'react-syntax-highlighter/dist/styles';
import styled from 'styled-components';
-import { IStackframeWithLineContext } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframeWithLineContext } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { borderRadius, px, unit, units } from '../../../style/variables';
registerLanguage('javascript', javascript);
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
index daa722255bdf3..4467fe7ad615e 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/FrameHeading.tsx
@@ -7,7 +7,7 @@
import theme from '@elastic/eui/dist/eui_theme_light.json';
import React, { Fragment } from 'react';
import styled from 'styled-components';
-import { IStackframe } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { fontFamilyCode, fontSize, px, units } from '../../../style/variables';
const FileDetails = styled.div`
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.test.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx
index be6595153aa77..009e97358428c 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/LibraryStacktrace.tsx
@@ -8,7 +8,7 @@ import { EuiAccordion } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import styled from 'styled-components';
-import { IStackframe } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { Stackframe } from './Stackframe';
import { px, unit } from '../../../style/variables';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx
index 404d474a7960a..4c55add56bc40 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/Stackframe.tsx
@@ -11,7 +11,7 @@ import { EuiAccordion } from '@elastic/eui';
import {
IStackframe,
IStackframeWithLineContext
-} from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+} from '../../../../typings/es_schemas/raw/fields/stackframe';
import {
borderRadius,
fontFamilyCode,
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Variables.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/Variables.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Variables.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/Variables.tsx
index 0786116a659c7..ec5fb39f83f8c 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/Variables.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/Variables.tsx
@@ -10,7 +10,7 @@ import { EuiAccordion } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { borderRadius, px, unit, units } from '../../../style/variables';
-import { IStackframe } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { KeyValueTable } from '../KeyValueTable';
import { flattenObject } from '../../../utils/flattenObject';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx
index 1b2268326e6be..478f9cfe921d9 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/Stackframe.test.tsx
@@ -6,7 +6,7 @@
import { mount, ReactWrapper, shallow } from 'enzyme';
import React from 'react';
-import { IStackframe } from '../../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../../typings/es_schemas/raw/fields/stackframe';
import { Stackframe } from '../Stackframe';
import stacktracesMock from './stacktraces.json';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/Stackframe.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/Stackframe.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/Stackframe.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/Stackframe.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/index.test.ts.snap b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/index.test.ts.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/index.test.ts.snap
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/__snapshots__/index.test.ts.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts
index 9b6d74033e1c5..22357b9590887 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/index.test.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { IStackframe } from '../../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../../typings/es_schemas/raw/fields/stackframe';
import { getGroupedStackframes } from '../index';
import stacktracesMock from './stacktraces.json';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraces.json b/x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraces.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraces.json
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/__test__/stacktraces.json
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/index.tsx b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/index.tsx
rename to x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx
index 141ed544a6166..b6435f7c42183 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Stacktrace/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Stacktrace/index.tsx
@@ -8,7 +8,7 @@ import { EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { isEmpty, last } from 'lodash';
import React, { Fragment } from 'react';
-import { IStackframe } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/stackframe';
+import { IStackframe } from '../../../../typings/es_schemas/raw/fields/stackframe';
import { EmptyMessage } from '../../shared/EmptyMessage';
import { LibraryStacktrace } from './LibraryStacktrace';
import { Stackframe } from './Stackframe';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js b/x-pack/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js
rename to x-pack/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js
index 08283dee3825d..b6acb6904f865 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js
+++ b/x-pack/plugins/apm/public/components/shared/StickyProperties/StickyProperties.test.js
@@ -7,10 +7,7 @@
import React from 'react';
import { StickyProperties } from './index';
import { shallow } from 'enzyme';
-import {
- USER_ID,
- URL_FULL
-} from '../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+import { USER_ID, URL_FULL } from '../../../../common/elasticsearch_fieldnames';
import { mockMoment } from '../../../utils/testHelpers';
describe('StickyProperties', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap b/x-pack/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/StickyProperties/__snapshots__/StickyProperties.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/index.tsx b/x-pack/plugins/apm/public/components/shared/StickyProperties/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/StickyProperties/index.tsx
rename to x-pack/plugins/apm/public/components/shared/StickyProperties/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/DurationSummaryItem.tsx b/x-pack/plugins/apm/public/components/shared/Summary/DurationSummaryItem.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/DurationSummaryItem.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/DurationSummaryItem.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.tsx b/x-pack/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/ErrorCountSummaryItemBadge.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/__test__/HttpInfoSummaryItem.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/index.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/index.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpInfoSummaryItem/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/__test__/HttpStatusBadge.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/index.tsx b/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/index.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/statusCodes.ts b/x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/statusCodes.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/HttpStatusBadge/statusCodes.ts
rename to x-pack/plugins/apm/public/components/shared/Summary/HttpStatusBadge/statusCodes.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionResultSummaryItem.tsx b/x-pack/plugins/apm/public/components/shared/Summary/TransactionResultSummaryItem.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionResultSummaryItem.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/TransactionResultSummaryItem.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionSummary.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/TransactionSummary.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionSummary.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/TransactionSummary.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx b/x-pack/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx
index f0fe57e46f2fe..f24a806426510 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/TransactionSummary.tsx
@@ -4,12 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
-import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { Summary } from './';
import { TimestampTooltip } from '../TimestampTooltip';
import { DurationSummaryItem } from './DurationSummaryItem';
import { ErrorCountSummaryItemBadge } from './ErrorCountSummaryItemBadge';
-import { isRumAgentName } from '../../../../../../../plugins/apm/common/agent_name';
+import { isRumAgentName } from '../../../../common/agent_name';
import { HttpInfoSummaryItem } from './HttpInfoSummaryItem';
import { TransactionResultSummaryItem } from './TransactionResultSummaryItem';
import { UserAgentSummaryItem } from './UserAgentSummaryItem';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx b/x-pack/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx
index 10a6bcc1ef7bd..8173170b72f23 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/UserAgentSummaryItem.tsx
@@ -9,7 +9,7 @@ import styled from 'styled-components';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { UserAgent } from '../../../../../../../plugins/apm/typings/es_schemas/raw/fields/user_agent';
+import { UserAgent } from '../../../../typings/es_schemas/raw/fields/user_agent';
type UserAgentSummaryItemProps = UserAgent;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts b/x-pack/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts
rename to x-pack/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts
index 05fb73a9e2749..e1615934cd92e 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts
+++ b/x-pack/plugins/apm/public/components/shared/Summary/__fixtures__/transactions.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
export const httpOk: Transaction = {
'@timestamp': '0',
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx b/x-pack/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/__test__/ErrorCountSummaryItemBadge.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/Summary/index.tsx b/x-pack/plugins/apm/public/components/shared/Summary/index.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/Summary/index.tsx
rename to x-pack/plugins/apm/public/components/shared/Summary/index.tsx
index ef99f3a4933a7..ce6935d1858aa 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/Summary/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/Summary/index.tsx
@@ -8,7 +8,7 @@ import { EuiFlexGrid, EuiFlexItem } from '@elastic/eui';
import styled from 'styled-components';
import euiLightVars from '@elastic/eui/dist/eui_theme_light.json';
import { px, units } from '../../../../public/style/variables';
-import { Maybe } from '../../../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../../../typings/common';
interface Props {
items: Array>;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx b/x-pack/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TimestampTooltip/__test__/index.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TimestampTooltip/index.tsx b/x-pack/plugins/apm/public/components/shared/TimestampTooltip/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TimestampTooltip/index.tsx
rename to x-pack/plugins/apm/public/components/shared/TimestampTooltip/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx
index 8df6d952cfacd..49f8fddb303bd 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.test.tsx
@@ -5,10 +5,10 @@
*/
import React from 'react';
import { render, act, fireEvent } from '@testing-library/react';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { CustomLinkPopover } from './CustomLinkPopover';
import { expectTextsInDocument } from '../../../../utils/testHelpers';
-import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { CustomLink } from '../../../../../common/custom_link/custom_link_types';
describe('CustomLinkPopover', () => {
const customLinks = [
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx
index 3aed1b7ac2953..a63c226a5c46e 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkPopover.tsx
@@ -12,8 +12,8 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
-import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { CustomLink } from '../../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { CustomLinkSection } from './CustomLinkSection';
import { ManageCustomLink } from './ManageCustomLink';
import { px } from '../../../../style/variables';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx
similarity index 85%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx
index d429fa56894eb..6cf8b9ee5e98a 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.test.tsx
@@ -10,8 +10,8 @@ import {
expectTextsInDocument,
expectTextsNotInDocument
} from '../../../../utils/testHelpers';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
-import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
+import { CustomLink } from '../../../../../common/custom_link/custom_link_types';
describe('CustomLinkSection', () => {
const customLinks = [
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx
similarity index 86%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx
index bd00bcf600ffe..e22f4b4a37745 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/CustomLinkSection.tsx
@@ -7,8 +7,8 @@ import { EuiLink, EuiText } from '@elastic/eui';
import Mustache from 'mustache';
import React from 'react';
import styled from 'styled-components';
-import { CustomLink } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { CustomLink } from '../../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { px, truncate, units } from '../../../../style/variables';
const LinkContainer = styled.li`
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/ManageCustomLink.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx
index 9d1eeb9a3136d..c7a2d77d85fa6 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.test.tsx
@@ -7,13 +7,13 @@
import React from 'react';
import { render, act, fireEvent } from '@testing-library/react';
import { CustomLink } from '.';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
import {
expectTextsInDocument,
expectTextsNotInDocument
} from '../../../../utils/testHelpers';
-import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
+import { CustomLink as CustomLinkType } from '../../../../../common/custom_link/custom_link_types';
describe('Custom links', () => {
it('shows empty message when no custom link is available', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx
index 38b672a181fce..710b2175e3377 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/CustomLink/index.tsx
@@ -15,12 +15,12 @@ import {
import { i18n } from '@kbn/i18n';
import styled from 'styled-components';
import { isEmpty } from 'lodash';
-import { CustomLink as CustomLinkType } from '../../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { CustomLink as CustomLinkType } from '../../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import {
ActionMenuDivider,
SectionSubtitle
-} from '../../../../../../../../plugins/observability/public';
+} from '../../../../../../observability/public';
import { CustomLinkSection } from './CustomLinkSection';
import { ManageCustomLink } from './ManageCustomLink';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx
index 7ebfe26b83630..c9376cdc01b5b 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx
@@ -7,8 +7,8 @@
import { EuiButtonEmpty } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { FunctionComponent, useMemo, useState } from 'react';
-import { Filter } from '../../../../../../../plugins/apm/common/custom_link/custom_link_types';
-import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Filter } from '../../../../common/custom_link/custom_link_types';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import {
ActionMenu,
ActionMenuDivider,
@@ -17,7 +17,7 @@ import {
SectionLinks,
SectionSubtitle,
SectionTitle
-} from '../../../../../../../plugins/observability/public';
+} from '../../../../../observability/public';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { useFetcher } from '../../../hooks/useFetcher';
import { useLocation } from '../../../hooks/useLocation';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
index 8dc2076eab5b5..cda602204469c 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/TransactionActionMenu.test.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { render, fireEvent, act, wait } from '@testing-library/react';
import { TransactionActionMenu } from '../TransactionActionMenu';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import * as Transactions from './mockData';
import {
expectTextsNotInDocument,
@@ -15,7 +15,7 @@ import {
} from '../../../../utils/testHelpers';
import * as hooks from '../../../../hooks/useFetcher';
import { LicenseContext } from '../../../../context/LicenseContext';
-import { License } from '../../../../../../../../plugins/licensing/common/license';
+import { License } from '../../../../../../licensing/common/license';
import { MockApmPluginContextWrapper } from '../../../../context/ApmPluginContext/MockApmPluginContext';
import * as apmApi from '../../../../services/rest/createCallApmApi';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/__snapshots__/TransactionActionMenu.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/mockData.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
index 3032dd1704f4e..b2f6f39e0b596 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/__test__/sections.test.ts
@@ -5,7 +5,7 @@
*/
import { Location } from 'history';
import { getSections } from '../sections';
-import { Transaction } from '../../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../../typings/es_schemas/ui/transaction';
import { AppMountContextBasePath } from '../../../../context/ApmPluginContext';
describe('Transaction action menu', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts
rename to x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts
index ffdf0b485da64..2c2f4bfcadd7d 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts
+++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/sections.ts
@@ -8,7 +8,7 @@ import { Location } from 'history';
import { pick, isEmpty } from 'lodash';
import moment from 'moment';
import url from 'url';
-import { Transaction } from '../../../../../../../plugins/apm/typings/es_schemas/ui/transaction';
+import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { IUrlParams } from '../../../context/UrlParamsContext/types';
import { getDiscoverHref } from '../Links/DiscoverLinks/DiscoverLink';
import { getDiscoverQuery } from '../Links/DiscoverLinks/DiscoverTransactionLink';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx
similarity index 81%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx
index 50ea169c017f9..966cc64fde505 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownGraph/index.tsx
@@ -7,17 +7,14 @@
import React, { useMemo } from 'react';
import numeral from '@elastic/numeral';
import { throttle } from 'lodash';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
-import {
- Coordinate,
- TimeSeries
-} from '../../../../../../../../plugins/apm/typings/timeseries';
-import { Maybe } from '../../../../../../../../plugins/apm/typings/common';
+import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
+import { Coordinate, TimeSeries } from '../../../../../typings/timeseries';
+import { Maybe } from '../../../../../typings/common';
import { TransactionLineChart } from '../../charts/TransactionCharts/TransactionLineChart';
import { asPercent } from '../../../../utils/formatters';
import { unit } from '../../../../style/variables';
import { isValidCoordinateValue } from '../../../../utils/isValidCoordinateValue';
-import { useUiTracker } from '../../../../../../../../plugins/observability/public';
+import { useUiTracker } from '../../../../../../observability/public';
interface Props {
timeseries: TimeSeries[];
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownHeader.tsx b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownHeader.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownHeader.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownHeader.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx
index 91f5f4e0a7176..c4a8e07fb3004 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/TransactionBreakdownKpiList.tsx
@@ -13,10 +13,7 @@ import {
EuiIcon
} from '@elastic/eui';
import styled from 'styled-components';
-import {
- FORMATTERS,
- InfraFormatterType
-} from '../../../../../../../plugins/infra/public';
+import { FORMATTERS, InfraFormatterType } from '../../../../../infra/public';
interface TransactionBreakdownKpi {
name: string;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx
index 85f5f83fb920e..be5860190c11e 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionBreakdown/index.tsx
@@ -11,7 +11,7 @@ import { TransactionBreakdownHeader } from './TransactionBreakdownHeader';
import { TransactionBreakdownKpiList } from './TransactionBreakdownKpiList';
import { TransactionBreakdownGraph } from './TransactionBreakdownGraph';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
-import { useUiTracker } from '../../../../../../../plugins/observability/public';
+import { useUiTracker } from '../../../../../observability/public';
const emptyMessage = i18n.translate('xpack.apm.transactionBreakdown.noData', {
defaultMessage: 'No data within this time range.'
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.stories.tsx b/x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.stories.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.stories.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.stories.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx b/x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx
rename to x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx
index 077e6535a8b21..1e9fbd2c1c135 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx
@@ -7,11 +7,11 @@ import React from 'react';
import { map } from 'lodash';
import { EuiFieldNumber, EuiSelect } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { ForLastExpression } from '../../../../../../../plugins/triggers_actions_ui/public';
+import { ForLastExpression } from '../../../../../triggers_actions_ui/public';
import {
TRANSACTION_ALERT_AGGREGATION_TYPES,
ALERT_TYPES_CONFIG
-} from '../../../../../../../plugins/apm/common/alert_types';
+} from '../../../../common/alert_types';
import { ServiceAlertTrigger } from '../ServiceAlertTrigger';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useServiceTransactionTypes } from '../../../hooks/useServiceTransactionTypes';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx
index ec6168df5b134..6eff4759b2e7c 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/AnnotationsPlot.tsx
@@ -14,8 +14,8 @@ import {
EuiText
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { Maybe } from '../../../../../../../../plugins/apm/typings/common';
-import { Annotation } from '../../../../../../../../plugins/apm/common/annotations';
+import { Maybe } from '../../../../../typings/common';
+import { Annotation } from '../../../../../common/annotations';
import { PlotValues, SharedPlot } from './plotUtils';
import { asAbsoluteDateTime } from '../../../../utils/formatters';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/InteractivePlot.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/InteractivePlot.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/InteractivePlot.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/InteractivePlot.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/SelectionMarker.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/SelectionMarker.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/SelectionMarker.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/SelectionMarker.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/StaticPlot.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/StaticPlot.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/StaticPlot.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/StaticPlot.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/StatusText.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/StatusText.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/StatusText.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/StatusText.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/VoronoiPlot.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/VoronoiPlot.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/VoronoiPlot.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/VoronoiPlot.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getEmptySeries.ts b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getEmptySeries.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getEmptySeries.ts
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getEmptySeries.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.test.ts b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.test.ts
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.ts b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.ts
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/getTimezoneOffsetInMs.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/index.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/index.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts
index bfc5c7c243f31..b130deed7f098 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts
+++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.test.ts
@@ -6,10 +6,7 @@
// @ts-ignore
import * as plotUtils from './plotUtils';
-import {
- TimeSeries,
- Coordinate
-} from '../../../../../../../../plugins/apm/typings/timeseries';
+import { TimeSeries, Coordinate } from '../../../../../typings/timeseries';
describe('plotUtils', () => {
describe('getPlotValues', () => {
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx
index c489c270d19ac..64350a5741647 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/plotUtils.tsx
@@ -11,10 +11,7 @@ import d3 from 'd3';
import PropTypes from 'prop-types';
import React from 'react';
-import {
- TimeSeries,
- Coordinate
-} from '../../../../../../../../plugins/apm/typings/timeseries';
+import { TimeSeries, Coordinate } from '../../../../../typings/timeseries';
import { unit } from '../../../../style/variables';
import { getDomainTZ, getTimeTicksTZ } from '../helper/timezone';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/CustomPlot.test.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/CustomPlot.test.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/CustomPlot.test.js
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/CustomPlot.test.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/__snapshots__/CustomPlot.test.js.snap b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/__snapshots__/CustomPlot.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/__snapshots__/CustomPlot.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/__snapshots__/CustomPlot.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json
rename to x-pack/plugins/apm/public/components/shared/charts/CustomPlot/test/responseWithData.json
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/SingleRect.js b/x-pack/plugins/apm/public/components/shared/charts/Histogram/SingleRect.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/SingleRect.js
rename to x-pack/plugins/apm/public/components/shared/charts/Histogram/SingleRect.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/Histogram.test.js b/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/Histogram.test.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/Histogram.test.js
rename to x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/Histogram.test.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap b/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
rename to x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/response.json b/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/response.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/__test__/response.json
rename to x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/response.json
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/index.js b/x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Histogram/index.js
rename to x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Legend/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/Legend/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Legend/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Legend/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx
similarity index 90%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx
index 2ceac87d9aab3..862f2a8987067 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/MetricsChart/index.tsx
@@ -6,7 +6,7 @@
import { EuiTitle } from '@elastic/eui';
import React from 'react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { GenericMetricsChart } from '../../../../../../../../plugins/apm/server/lib/metrics/transform_metrics_chart';
+import { GenericMetricsChart } from '../../../../../server/lib/metrics/transform_metrics_chart';
// @ts-ignore
import CustomPlot from '../CustomPlot';
import {
@@ -17,10 +17,10 @@ import {
getFixedByteFormatter,
asDuration
} from '../../../../utils/formatters';
-import { Coordinate } from '../../../../../../../../plugins/apm/typings/timeseries';
+import { Coordinate } from '../../../../../typings/timeseries';
import { isValidCoordinateValue } from '../../../../utils/isValidCoordinateValue';
import { useChartsSync } from '../../../../hooks/useChartsSync';
-import { Maybe } from '../../../../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../../../../typings/common';
interface Props {
start: Maybe;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/LastTickValue.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/LastTickValue.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/LastTickValue.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/LastTickValue.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/AgentMarker.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/AgentMarker.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/AgentMarker.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/AgentMarker.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx
index 48265ce7c80a8..51368a4fb946d 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/ErrorMarker.tsx
@@ -11,7 +11,7 @@ import styled from 'styled-components';
import {
TRACE_ID,
TRANSACTION_ID
-} from '../../../../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../../../../common/elasticsearch_fieldnames';
import { useUrlParams } from '../../../../../hooks/useUrlParams';
import { px, unit, units } from '../../../../../style/variables';
import { asDuration } from '../../../../../utils/formatters';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/AgentMarker.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/AgentMarker.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/AgentMarker.test.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/AgentMarker.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/ErrorMarker.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/ErrorMarker.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/ErrorMarker.test.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/ErrorMarker.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/Marker.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/Marker.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/Marker.test.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/Marker.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/AgentMarker.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/AgentMarker.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/AgentMarker.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/AgentMarker.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/ErrorMarker.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/ErrorMarker.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/ErrorMarker.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/ErrorMarker.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/Marker.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/Marker.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/Marker.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/__test__/__snapshots__/Marker.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Marker/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Marker/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Timeline.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/Timeline.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/Timeline.test.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/Timeline.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/TimelineAxis.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/TimelineAxis.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/TimelineAxis.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/TimelineAxis.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/VerticalLines.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/VerticalLines.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/VerticalLines.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/VerticalLines.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/__snapshots__/Timeline.test.tsx.snap b/x-pack/plugins/apm/public/components/shared/charts/Timeline/__snapshots__/Timeline.test.tsx.snap
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/__snapshots__/Timeline.test.tsx.snap
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/__snapshots__/Timeline.test.tsx.snap
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/Timeline/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/plotUtils.ts b/x-pack/plugins/apm/public/components/shared/charts/Timeline/plotUtils.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Timeline/plotUtils.ts
rename to x-pack/plugins/apm/public/components/shared/charts/Timeline/plotUtils.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/Tooltip/index.js b/x-pack/plugins/apm/public/components/shared/charts/Tooltip/index.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/Tooltip/index.js
rename to x-pack/plugins/apm/public/components/shared/charts/Tooltip/index.js
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.test.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.test.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/ChoroplethToolTip.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/ChoroplethToolTip.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/ChoroplethToolTip.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/ChoroplethToolTip.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/ChoroplethMap/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/DurationByCountryMap/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/DurationByCountryMap/index.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/DurationByCountryMap/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/DurationByCountryMap/index.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx
index c9c31b05e264c..27c829f63cf0a 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/TransactionLineChart/index.tsx
@@ -8,7 +8,7 @@ import React, { useCallback } from 'react';
import {
Coordinate,
RectCoordinate
-} from '../../../../../../../../../plugins/apm/typings/timeseries';
+} from '../../../../../../typings/timeseries';
import { useChartsSync } from '../../../../../hooks/useChartsSync';
// @ts-ignore
import CustomPlot from '../../CustomPlot';
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
rename to x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
index 368a39e4ad228..b0555da705a30 100644
--- a/x-pack/legacy/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
+++ b/x-pack/plugins/apm/public/components/shared/charts/TransactionCharts/index.tsx
@@ -19,11 +19,8 @@ import { Location } from 'history';
import React, { Component } from 'react';
import { isEmpty, flatten } from 'lodash';
import styled from 'styled-components';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../../../plugins/apm/common/i18n';
-import {
- Coordinate,
- TimeSeries
-} from '../../../../../../../../plugins/apm/typings/timeseries';
+import { NOT_AVAILABLE_LABEL } from '../../../../../common/i18n';
+import { Coordinate, TimeSeries } from '../../../../../typings/timeseries';
import { ITransactionChartData } from '../../../../selectors/chartSelectors';
import { IUrlParams } from '../../../../context/UrlParamsContext/types';
import {
@@ -42,7 +39,7 @@ import {
TRANSACTION_PAGE_LOAD,
TRANSACTION_ROUTE_CHANGE,
TRANSACTION_REQUEST
-} from '../../../../../../../../plugins/apm/common/transaction_types';
+} from '../../../../../common/transaction_types';
interface TransactionChartProps {
hasMLJob: boolean;
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/helper/__test__/timezone.test.ts b/x-pack/plugins/apm/public/components/shared/charts/helper/__test__/timezone.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/helper/__test__/timezone.test.ts
rename to x-pack/plugins/apm/public/components/shared/charts/helper/__test__/timezone.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/charts/helper/timezone.ts b/x-pack/plugins/apm/public/components/shared/charts/helper/timezone.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/charts/helper/timezone.ts
rename to x-pack/plugins/apm/public/components/shared/charts/helper/timezone.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.test.tsx b/x-pack/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.test.tsx
rename to x-pack/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.ts b/x-pack/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.ts
rename to x-pack/plugins/apm/public/components/shared/useDelayedVisibility/Delayed/index.ts
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/index.test.tsx b/x-pack/plugins/apm/public/components/shared/useDelayedVisibility/index.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/index.test.tsx
rename to x-pack/plugins/apm/public/components/shared/useDelayedVisibility/index.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/index.ts b/x-pack/plugins/apm/public/components/shared/useDelayedVisibility/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/components/shared/useDelayedVisibility/index.ts
rename to x-pack/plugins/apm/public/components/shared/useDelayedVisibility/index.ts
diff --git a/x-pack/legacy/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx b/x-pack/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx
rename to x-pack/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx
index cc2e382611628..865e3dbe6dafc 100644
--- a/x-pack/legacy/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx
+++ b/x-pack/plugins/apm/public/context/ApmPluginContext/MockApmPluginContext.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import { ApmPluginContext, ApmPluginContextValue } from '.';
import { createCallApmApi } from '../../services/rest/createCallApmApi';
-import { ConfigSchema } from '../../new-platform/plugin';
+import { ConfigSchema } from '../..';
const mockCore = {
chrome: {
@@ -30,7 +30,6 @@ const mockCore = {
};
const mockConfig: ConfigSchema = {
- indexPatternTitle: 'apm-*',
serviceMapEnabled: true,
ui: {
enabled: false
diff --git a/x-pack/legacy/plugins/apm/public/context/ApmPluginContext/index.tsx b/x-pack/plugins/apm/public/context/ApmPluginContext/index.tsx
similarity index 87%
rename from x-pack/legacy/plugins/apm/public/context/ApmPluginContext/index.tsx
rename to x-pack/plugins/apm/public/context/ApmPluginContext/index.tsx
index acc3886586889..37304d292540d 100644
--- a/x-pack/legacy/plugins/apm/public/context/ApmPluginContext/index.tsx
+++ b/x-pack/plugins/apm/public/context/ApmPluginContext/index.tsx
@@ -6,7 +6,8 @@
import { createContext } from 'react';
import { AppMountContext } from 'kibana/public';
-import { ApmPluginSetupDeps, ConfigSchema } from '../../new-platform/plugin';
+import { ConfigSchema } from '../..';
+import { ApmPluginSetupDeps } from '../../plugin';
export type AppMountContextBasePath = AppMountContext['core']['http']['basePath'];
diff --git a/x-pack/legacy/plugins/apm/public/context/ChartsSyncContext.tsx b/x-pack/plugins/apm/public/context/ChartsSyncContext.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/ChartsSyncContext.tsx
rename to x-pack/plugins/apm/public/context/ChartsSyncContext.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx b/x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
rename to x-pack/plugins/apm/public/context/LicenseContext/InvalidLicenseNotification.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx b/x-pack/plugins/apm/public/context/LicenseContext/index.tsx
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx
rename to x-pack/plugins/apm/public/context/LicenseContext/index.tsx
index 62cdbd3bbc995..e6615a2fc98bf 100644
--- a/x-pack/legacy/plugins/apm/public/context/LicenseContext/index.tsx
+++ b/x-pack/plugins/apm/public/context/LicenseContext/index.tsx
@@ -6,7 +6,7 @@
import React from 'react';
import useObservable from 'react-use/lib/useObservable';
-import { ILicense } from '../../../../../../plugins/licensing/public';
+import { ILicense } from '../../../../licensing/public';
import { useApmPluginContext } from '../../hooks/useApmPluginContext';
import { InvalidLicenseNotification } from './InvalidLicenseNotification';
diff --git a/x-pack/legacy/plugins/apm/public/context/LoadingIndicatorContext.tsx b/x-pack/plugins/apm/public/context/LoadingIndicatorContext.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/LoadingIndicatorContext.tsx
rename to x-pack/plugins/apm/public/context/LoadingIndicatorContext.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/LocationContext.tsx b/x-pack/plugins/apm/public/context/LocationContext.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/LocationContext.tsx
rename to x-pack/plugins/apm/public/context/LocationContext.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/MatchedRouteContext.tsx b/x-pack/plugins/apm/public/context/MatchedRouteContext.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/MatchedRouteContext.tsx
rename to x-pack/plugins/apm/public/context/MatchedRouteContext.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/MockUrlParamsContextProvider.tsx b/x-pack/plugins/apm/public/context/UrlParamsContext/MockUrlParamsContextProvider.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/MockUrlParamsContextProvider.tsx
rename to x-pack/plugins/apm/public/context/UrlParamsContext/MockUrlParamsContextProvider.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx b/x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx
rename to x-pack/plugins/apm/public/context/UrlParamsContext/__tests__/UrlParamsContext.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/constants.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/constants.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/constants.ts
rename to x-pack/plugins/apm/public/context/UrlParamsContext/constants.ts
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/helpers.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts
similarity index 97%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/helpers.ts
rename to x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts
index b80db0e9ae073..f1e45fe45255d 100644
--- a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/helpers.ts
+++ b/x-pack/plugins/apm/public/context/UrlParamsContext/helpers.ts
@@ -7,7 +7,7 @@
import { compact, pick } from 'lodash';
import datemath from '@elastic/datemath';
import { IUrlParams } from './types';
-import { ProcessorEvent } from '../../../../../../plugins/apm/common/processor_event';
+import { ProcessorEvent } from '../../../common/processor_event';
interface PathParams {
processorEvent?: ProcessorEvent;
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/index.tsx b/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx
similarity index 92%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/index.tsx
rename to x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx
index 588936039c2bc..7a929380bce37 100644
--- a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/index.tsx
+++ b/x-pack/plugins/apm/public/context/UrlParamsContext/index.tsx
@@ -16,13 +16,13 @@ import { uniqueId, mapValues } from 'lodash';
import { IUrlParams } from './types';
import { getParsedDate } from './helpers';
import { resolveUrlParams } from './resolveUrlParams';
-import { UIFilters } from '../../../../../../plugins/apm/typings/ui_filters';
+import { UIFilters } from '../../../typings/ui_filters';
import {
localUIFilterNames,
LocalUIFilterName
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
-import { pickKeys } from '../../utils/pickKeys';
+} from '../../../server/lib/ui_filters/local_ui_filters/config';
+import { pickKeys } from '../../../common/utils/pick_keys';
import { useDeepObjectIdentity } from '../../hooks/useDeepObjectIdentity';
interface TimeRange {
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts
rename to x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts
index f022d2084583b..34af18431a2df 100644
--- a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts
+++ b/x-pack/plugins/apm/public/context/UrlParamsContext/resolveUrlParams.ts
@@ -18,8 +18,8 @@ import {
import { toQuery } from '../../components/shared/Links/url_helpers';
import { TIMEPICKER_DEFAULTS } from './constants';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { localUIFilterNames } from '../../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
-import { pickKeys } from '../../utils/pickKeys';
+import { localUIFilterNames } from '../../../server/lib/ui_filters/local_ui_filters/config';
+import { pickKeys } from '../../../common/utils/pick_keys';
type TimeUrlParams = Pick<
IUrlParams,
diff --git a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/types.ts b/x-pack/plugins/apm/public/context/UrlParamsContext/types.ts
similarity index 83%
rename from x-pack/legacy/plugins/apm/public/context/UrlParamsContext/types.ts
rename to x-pack/plugins/apm/public/context/UrlParamsContext/types.ts
index acde09308ab46..78fe662b88d75 100644
--- a/x-pack/legacy/plugins/apm/public/context/UrlParamsContext/types.ts
+++ b/x-pack/plugins/apm/public/context/UrlParamsContext/types.ts
@@ -5,8 +5,8 @@
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { LocalUIFilterName } from '../../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
-import { ProcessorEvent } from '../../../../../../plugins/apm/common/processor_event';
+import { LocalUIFilterName } from '../../../server/lib/ui_filters/local_ui_filters/config';
+import { ProcessorEvent } from '../../../common/processor_event';
export type IUrlParams = {
detailTab?: string;
diff --git a/x-pack/legacy/plugins/apm/public/new-platform/featureCatalogueEntry.ts b/x-pack/plugins/apm/public/featureCatalogueEntry.ts
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/new-platform/featureCatalogueEntry.ts
rename to x-pack/plugins/apm/public/featureCatalogueEntry.ts
index 7a150de6d5d02..f76c6f5169dc5 100644
--- a/x-pack/legacy/plugins/apm/public/new-platform/featureCatalogueEntry.ts
+++ b/x-pack/plugins/apm/public/featureCatalogueEntry.ts
@@ -5,7 +5,7 @@
*/
import { i18n } from '@kbn/i18n';
-import { FeatureCatalogueCategory } from '../../../../../../src/plugins/home/public';
+import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public';
export const featureCatalogueEntry = {
id: 'apm',
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useAgentName.ts b/x-pack/plugins/apm/public/hooks/useAgentName.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useAgentName.ts
rename to x-pack/plugins/apm/public/hooks/useAgentName.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useApmPluginContext.ts b/x-pack/plugins/apm/public/hooks/useApmPluginContext.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useApmPluginContext.ts
rename to x-pack/plugins/apm/public/hooks/useApmPluginContext.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.test.ts b/x-pack/plugins/apm/public/hooks/useAvgDurationByBrowser.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.test.ts
rename to x-pack/plugins/apm/public/hooks/useAvgDurationByBrowser.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.ts b/x-pack/plugins/apm/public/hooks/useAvgDurationByBrowser.ts
similarity index 83%
rename from x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.ts
rename to x-pack/plugins/apm/public/hooks/useAvgDurationByBrowser.ts
index 256c2fa68bfbc..5d0c9d1435798 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.ts
+++ b/x-pack/plugins/apm/public/hooks/useAvgDurationByBrowser.ts
@@ -8,9 +8,9 @@ import theme from '@elastic/eui/dist/eui_theme_light.json';
import { useFetcher } from './useFetcher';
import { useUrlParams } from './useUrlParams';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { AvgDurationByBrowserAPIResponse } from '../../../../../plugins/apm/server/lib/transactions/avg_duration_by_browser';
-import { TimeSeries } from '../../../../../plugins/apm/typings/timeseries';
-import { getVizColorForIndex } from '../../../../../plugins/apm/common/viz_colors';
+import { AvgDurationByBrowserAPIResponse } from '../../server/lib/transactions/avg_duration_by_browser';
+import { TimeSeries } from '../../typings/timeseries';
+import { getVizColorForIndex } from '../../common/viz_colors';
function toTimeSeries(data?: AvgDurationByBrowserAPIResponse): TimeSeries[] {
if (!data) {
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByCountry.ts b/x-pack/plugins/apm/public/hooks/useAvgDurationByCountry.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByCountry.ts
rename to x-pack/plugins/apm/public/hooks/useAvgDurationByCountry.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useCallApi.ts b/x-pack/plugins/apm/public/hooks/useCallApi.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useCallApi.ts
rename to x-pack/plugins/apm/public/hooks/useCallApi.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useChartsSync.tsx b/x-pack/plugins/apm/public/hooks/useChartsSync.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useChartsSync.tsx
rename to x-pack/plugins/apm/public/hooks/useChartsSync.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useComponentId.tsx b/x-pack/plugins/apm/public/hooks/useComponentId.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useComponentId.tsx
rename to x-pack/plugins/apm/public/hooks/useComponentId.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useDeepObjectIdentity.ts b/x-pack/plugins/apm/public/hooks/useDeepObjectIdentity.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useDeepObjectIdentity.ts
rename to x-pack/plugins/apm/public/hooks/useDeepObjectIdentity.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useDynamicIndexPattern.ts b/x-pack/plugins/apm/public/hooks/useDynamicIndexPattern.ts
similarity index 89%
rename from x-pack/legacy/plugins/apm/public/hooks/useDynamicIndexPattern.ts
rename to x-pack/plugins/apm/public/hooks/useDynamicIndexPattern.ts
index ee3d2e81f259f..9a95bd925d6e1 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useDynamicIndexPattern.ts
+++ b/x-pack/plugins/apm/public/hooks/useDynamicIndexPattern.ts
@@ -5,7 +5,7 @@
*/
import { useFetcher } from './useFetcher';
-import { ProcessorEvent } from '../../../../../plugins/apm/common/processor_event';
+import { ProcessorEvent } from '../../common/processor_event';
export function useDynamicIndexPattern(
processorEvent: ProcessorEvent | undefined
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useFetcher.integration.test.tsx b/x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useFetcher.integration.test.tsx
rename to x-pack/plugins/apm/public/hooks/useFetcher.integration.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useFetcher.test.tsx b/x-pack/plugins/apm/public/hooks/useFetcher.test.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useFetcher.test.tsx
rename to x-pack/plugins/apm/public/hooks/useFetcher.test.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useFetcher.tsx b/x-pack/plugins/apm/public/hooks/useFetcher.tsx
similarity index 98%
rename from x-pack/legacy/plugins/apm/public/hooks/useFetcher.tsx
rename to x-pack/plugins/apm/public/hooks/useFetcher.tsx
index 95cebd6b2a465..5d5128d969aad 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useFetcher.tsx
+++ b/x-pack/plugins/apm/public/hooks/useFetcher.tsx
@@ -9,7 +9,7 @@
import React, { useContext, useEffect, useState, useMemo } from 'react';
import { i18n } from '@kbn/i18n';
import { IHttpFetchError } from 'src/core/public';
-import { toMountPoint } from '../../../../../../src/plugins/kibana_react/public';
+import { toMountPoint } from '../../../../../src/plugins/kibana_react/public';
import { LoadingIndicatorContext } from '../context/LoadingIndicatorContext';
import { APMClient, callApmApi } from '../services/rest/createCallApmApi';
import { useApmPluginContext } from './useApmPluginContext';
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useKibanaUrl.ts b/x-pack/plugins/apm/public/hooks/useKibanaUrl.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useKibanaUrl.ts
rename to x-pack/plugins/apm/public/hooks/useKibanaUrl.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useLicense.ts b/x-pack/plugins/apm/public/hooks/useLicense.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useLicense.ts
rename to x-pack/plugins/apm/public/hooks/useLicense.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useLoadingIndicator.ts b/x-pack/plugins/apm/public/hooks/useLoadingIndicator.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useLoadingIndicator.ts
rename to x-pack/plugins/apm/public/hooks/useLoadingIndicator.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useLocalUIFilters.ts b/x-pack/plugins/apm/public/hooks/useLocalUIFilters.ts
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/hooks/useLocalUIFilters.ts
rename to x-pack/plugins/apm/public/hooks/useLocalUIFilters.ts
index 9f14b2b25fc94..1dfd3ec7c3ee3 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useLocalUIFilters.ts
+++ b/x-pack/plugins/apm/public/hooks/useLocalUIFilters.ts
@@ -7,18 +7,18 @@
import { omit } from 'lodash';
import { useFetcher } from './useFetcher';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { LocalUIFiltersAPIResponse } from '../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters';
+import { LocalUIFiltersAPIResponse } from '../../server/lib/ui_filters/local_ui_filters';
import { useUrlParams } from './useUrlParams';
import {
LocalUIFilterName,
localUIFilters
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../../plugins/apm/server/lib/ui_filters/local_ui_filters/config';
+} from '../../server/lib/ui_filters/local_ui_filters/config';
import { history } from '../utils/history';
import { toQuery, fromQuery } from '../components/shared/Links/url_helpers';
import { removeUndefinedProps } from '../context/UrlParamsContext/helpers';
-import { PROJECTION } from '../../../../../plugins/apm/common/projections/typings';
-import { pickKeys } from '../utils/pickKeys';
+import { PROJECTION } from '../../common/projections/typings';
+import { pickKeys } from '../../common/utils/pick_keys';
import { useCallApi } from './useCallApi';
const getInitialData = (
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useLocation.tsx b/x-pack/plugins/apm/public/hooks/useLocation.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useLocation.tsx
rename to x-pack/plugins/apm/public/hooks/useLocation.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useMatchedRoutes.tsx b/x-pack/plugins/apm/public/hooks/useMatchedRoutes.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useMatchedRoutes.tsx
rename to x-pack/plugins/apm/public/hooks/useMatchedRoutes.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useServiceMetricCharts.ts b/x-pack/plugins/apm/public/hooks/useServiceMetricCharts.ts
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/hooks/useServiceMetricCharts.ts
rename to x-pack/plugins/apm/public/hooks/useServiceMetricCharts.ts
index 72618a6254f4c..ebcd6ab063708 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useServiceMetricCharts.ts
+++ b/x-pack/plugins/apm/public/hooks/useServiceMetricCharts.ts
@@ -5,7 +5,7 @@
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { MetricsChartsByAgentAPIResponse } from '../../../../../plugins/apm/server/lib/metrics/get_metrics_chart_data_by_agent';
+import { MetricsChartsByAgentAPIResponse } from '../../server/lib/metrics/get_metrics_chart_data_by_agent';
import { IUrlParams } from '../context/UrlParamsContext/types';
import { useUiFilters } from '../context/UrlParamsContext';
import { useFetcher } from './useFetcher';
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useServiceTransactionTypes.tsx b/x-pack/plugins/apm/public/hooks/useServiceTransactionTypes.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useServiceTransactionTypes.tsx
rename to x-pack/plugins/apm/public/hooks/useServiceTransactionTypes.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useTransactionBreakdown.ts b/x-pack/plugins/apm/public/hooks/useTransactionBreakdown.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useTransactionBreakdown.ts
rename to x-pack/plugins/apm/public/hooks/useTransactionBreakdown.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useTransactionCharts.ts b/x-pack/plugins/apm/public/hooks/useTransactionCharts.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useTransactionCharts.ts
rename to x-pack/plugins/apm/public/hooks/useTransactionCharts.ts
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useTransactionDistribution.ts b/x-pack/plugins/apm/public/hooks/useTransactionDistribution.ts
similarity index 93%
rename from x-pack/legacy/plugins/apm/public/hooks/useTransactionDistribution.ts
rename to x-pack/plugins/apm/public/hooks/useTransactionDistribution.ts
index 9a93a2334924a..152980b5655d6 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useTransactionDistribution.ts
+++ b/x-pack/plugins/apm/public/hooks/useTransactionDistribution.ts
@@ -8,7 +8,7 @@ import { IUrlParams } from '../context/UrlParamsContext/types';
import { useFetcher } from './useFetcher';
import { useUiFilters } from '../context/UrlParamsContext';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TransactionDistributionAPIResponse } from '../../../../../plugins/apm/server/lib/transactions/distribution';
+import { TransactionDistributionAPIResponse } from '../../server/lib/transactions/distribution';
const INITIAL_DATA = {
buckets: [] as TransactionDistributionAPIResponse['buckets'],
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useTransactionList.ts b/x-pack/plugins/apm/public/hooks/useTransactionList.ts
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/hooks/useTransactionList.ts
rename to x-pack/plugins/apm/public/hooks/useTransactionList.ts
index 6ede77023790b..e048e8fe0e3cb 100644
--- a/x-pack/legacy/plugins/apm/public/hooks/useTransactionList.ts
+++ b/x-pack/plugins/apm/public/hooks/useTransactionList.ts
@@ -9,7 +9,7 @@ import { IUrlParams } from '../context/UrlParamsContext/types';
import { useUiFilters } from '../context/UrlParamsContext';
import { useFetcher } from './useFetcher';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TransactionGroupListAPIResponse } from '../../../../../plugins/apm/server/lib/transaction_groups';
+import { TransactionGroupListAPIResponse } from '../../server/lib/transaction_groups';
const getRelativeImpact = (
impact: number,
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useUrlParams.tsx b/x-pack/plugins/apm/public/hooks/useUrlParams.tsx
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useUrlParams.tsx
rename to x-pack/plugins/apm/public/hooks/useUrlParams.tsx
diff --git a/x-pack/legacy/plugins/apm/public/hooks/useWaterfall.ts b/x-pack/plugins/apm/public/hooks/useWaterfall.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/hooks/useWaterfall.ts
rename to x-pack/plugins/apm/public/hooks/useWaterfall.ts
diff --git a/x-pack/legacy/plugins/apm/public/icon.svg b/x-pack/plugins/apm/public/icon.svg
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/icon.svg
rename to x-pack/plugins/apm/public/icon.svg
diff --git a/x-pack/legacy/plugins/apm/public/images/apm-ml-anomaly-detection-example.png b/x-pack/plugins/apm/public/images/apm-ml-anomaly-detection-example.png
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/images/apm-ml-anomaly-detection-example.png
rename to x-pack/plugins/apm/public/images/apm-ml-anomaly-detection-example.png
diff --git a/x-pack/plugins/apm/public/index.ts b/x-pack/plugins/apm/public/index.ts
index 47f138b25f36c..4ac06e1eb8a1c 100644
--- a/x-pack/plugins/apm/public/index.ts
+++ b/x-pack/plugins/apm/public/index.ts
@@ -4,11 +4,22 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { ApmPlugin } from './plugin';
+import {
+ PluginInitializer,
+ PluginInitializerContext
+} from '../../../../src/core/public';
+import { ApmPlugin, ApmPluginSetup, ApmPluginStart } from './plugin';
-// This exports static code and TypeScript types,
-// as well as, Kibana Platform `plugin()` initializer.
-export function plugin() {
- return new ApmPlugin();
+export interface ConfigSchema {
+ serviceMapEnabled: boolean;
+ ui: {
+ enabled: boolean;
+ };
}
-export { ApmPluginSetup, ApmPluginStart } from './types';
+
+export const plugin: PluginInitializer = (
+ pluginInitializerContext: PluginInitializerContext
+) => new ApmPlugin(pluginInitializerContext);
+
+export { ApmPluginSetup, ApmPluginStart };
+export { getTraceUrl } from './components/shared/Links/apm/ExternalLinks';
diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts
index 83f238a4d991d..f13c8853d0582 100644
--- a/x-pack/plugins/apm/public/plugin.ts
+++ b/x-pack/plugins/apm/public/plugin.ts
@@ -3,17 +3,131 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
-import { ApmPluginSetup, ApmPluginStart } from './types';
+
+import { i18n } from '@kbn/i18n';
+import {
+ AppMountParameters,
+ CoreSetup,
+ CoreStart,
+ Plugin,
+ PluginInitializerContext
+} from '../../../../src/core/public';
+import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils';
+
+import {
+ PluginSetupContract as AlertingPluginPublicSetup,
+ PluginStartContract as AlertingPluginPublicStart
+} from '../../alerting/public';
+import { FeaturesPluginSetup } from '../../features/public';
+import {
+ DataPublicPluginSetup,
+ DataPublicPluginStart
+} from '../../../../src/plugins/data/public';
+import { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
+import { LicensingPluginSetup } from '../../licensing/public';
+import {
+ TriggersAndActionsUIPublicPluginSetup,
+ TriggersAndActionsUIPublicPluginStart
+} from '../../triggers_actions_ui/public';
+import { ConfigSchema } from '.';
+import { createCallApmApi } from './services/rest/createCallApmApi';
+import { featureCatalogueEntry } from './featureCatalogueEntry';
+import { AlertType } from '../common/alert_types';
+import { ErrorRateAlertTrigger } from './components/shared/ErrorRateAlertTrigger';
+import { TransactionDurationAlertTrigger } from './components/shared/TransactionDurationAlertTrigger';
+import { setHelpExtension } from './setHelpExtension';
+import { toggleAppLinkInNav } from './toggleAppLinkInNav';
+import { setReadonlyBadge } from './updateBadge';
+import { createStaticIndexPattern } from './services/rest/index_pattern';
+
+export type ApmPluginSetup = void;
+export type ApmPluginStart = void;
+
+export interface ApmPluginSetupDeps {
+ alerting?: AlertingPluginPublicSetup;
+ data: DataPublicPluginSetup;
+ features: FeaturesPluginSetup;
+ home: HomePublicPluginSetup;
+ licensing: LicensingPluginSetup;
+ triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
+}
+
+export interface ApmPluginStartDeps {
+ alerting?: AlertingPluginPublicStart;
+ data: DataPublicPluginStart;
+ home: void;
+ licensing: void;
+ triggers_actions_ui: TriggersAndActionsUIPublicPluginStart;
+}
export class ApmPlugin implements Plugin {
- public setup(core: CoreSetup): ApmPluginSetup {
- return {};
+ private readonly initializerContext: PluginInitializerContext;
+ constructor(initializerContext: PluginInitializerContext) {
+ this.initializerContext = initializerContext;
}
+ public setup(core: CoreSetup, plugins: ApmPluginSetupDeps) {
+ const config = this.initializerContext.config.get();
+ const pluginSetupDeps = plugins;
+
+ pluginSetupDeps.home.environment.update({ apmUi: true });
+ pluginSetupDeps.home.featureCatalogue.register(featureCatalogueEntry);
- public start(core: CoreStart): ApmPluginStart {
- return {};
+ core.application.register({
+ id: 'apm',
+ title: 'APM',
+ order: 8100,
+ euiIconType: 'apmApp',
+ appRoute: '/app/apm',
+ icon: 'plugins/apm/public/icon.svg',
+ category: DEFAULT_APP_CATEGORIES.observability,
+
+ async mount(params: AppMountParameters) {
+ // Load application bundle
+ const { renderApp } = await import('./application');
+ // Get start services
+ const [coreStart] = await core.getStartServices();
+
+ // render APM feedback link in global help menu
+ setHelpExtension(coreStart);
+ setReadonlyBadge(coreStart);
+
+ // Automatically creates static index pattern and stores as saved object
+ createStaticIndexPattern().catch(e => {
+ // eslint-disable-next-line no-console
+ console.log('Error creating static index pattern', e);
+ });
+
+ return renderApp(coreStart, pluginSetupDeps, params, config);
+ }
+ });
}
+ public start(core: CoreStart, plugins: ApmPluginStartDeps) {
+ createCallApmApi(core.http);
- public stop() {}
+ toggleAppLinkInNav(core, this.initializerContext.config.get());
+
+ plugins.triggers_actions_ui.alertTypeRegistry.register({
+ id: AlertType.ErrorRate,
+ name: i18n.translate('xpack.apm.alertTypes.errorRate', {
+ defaultMessage: 'Error rate'
+ }),
+ iconClass: 'bell',
+ alertParamsExpression: ErrorRateAlertTrigger,
+ validate: () => ({
+ errors: []
+ })
+ });
+
+ plugins.triggers_actions_ui.alertTypeRegistry.register({
+ id: AlertType.TransactionDuration,
+ name: i18n.translate('xpack.apm.alertTypes.transactionDuration', {
+ defaultMessage: 'Transaction duration'
+ }),
+ iconClass: 'bell',
+ alertParamsExpression: TransactionDurationAlertTrigger,
+ validate: () => ({
+ errors: []
+ })
+ });
+ }
}
diff --git a/x-pack/legacy/plugins/apm/public/selectors/__tests__/chartSelectors.test.ts b/x-pack/plugins/apm/public/selectors/__tests__/chartSelectors.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/selectors/__tests__/chartSelectors.test.ts
rename to x-pack/plugins/apm/public/selectors/__tests__/chartSelectors.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/selectors/__tests__/mockData/anomalyData.ts b/x-pack/plugins/apm/public/selectors/__tests__/mockData/anomalyData.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/selectors/__tests__/mockData/anomalyData.ts
rename to x-pack/plugins/apm/public/selectors/__tests__/mockData/anomalyData.ts
diff --git a/x-pack/legacy/plugins/apm/public/selectors/chartSelectors.ts b/x-pack/plugins/apm/public/selectors/chartSelectors.ts
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/selectors/chartSelectors.ts
rename to x-pack/plugins/apm/public/selectors/chartSelectors.ts
index d60b63e243d71..e6ef9361ee52a 100644
--- a/x-pack/legacy/plugins/apm/public/selectors/chartSelectors.ts
+++ b/x-pack/plugins/apm/public/selectors/chartSelectors.ts
@@ -10,14 +10,14 @@ import { difference, zipObject } from 'lodash';
import mean from 'lodash.mean';
import { rgba } from 'polished';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { TimeSeriesAPIResponse } from '../../../../../plugins/apm/server/lib/transactions/charts';
+import { TimeSeriesAPIResponse } from '../../server/lib/transactions/charts';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { ApmTimeSeriesResponse } from '../../../../../plugins/apm/server/lib/transactions/charts/get_timeseries_data/transform';
+import { ApmTimeSeriesResponse } from '../../server/lib/transactions/charts/get_timeseries_data/transform';
import {
Coordinate,
RectCoordinate,
TimeSeries
-} from '../../../../../plugins/apm/typings/timeseries';
+} from '../../typings/timeseries';
import { asDecimal, tpmUnit, convertTo } from '../utils/formatters';
import { IUrlParams } from '../context/UrlParamsContext/types';
import { getEmptySeries } from '../components/shared/charts/CustomPlot/getEmptySeries';
diff --git a/x-pack/legacy/plugins/apm/public/services/__test__/SessionStorageMock.ts b/x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/services/__test__/SessionStorageMock.ts
rename to x-pack/plugins/apm/public/services/__test__/SessionStorageMock.ts
diff --git a/x-pack/legacy/plugins/apm/public/services/__test__/callApi.test.ts b/x-pack/plugins/apm/public/services/__test__/callApi.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/services/__test__/callApi.test.ts
rename to x-pack/plugins/apm/public/services/__test__/callApi.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/services/__test__/callApmApi.test.ts b/x-pack/plugins/apm/public/services/__test__/callApmApi.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/services/__test__/callApmApi.test.ts
rename to x-pack/plugins/apm/public/services/__test__/callApmApi.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/services/rest/callApi.ts b/x-pack/plugins/apm/public/services/rest/callApi.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/services/rest/callApi.ts
rename to x-pack/plugins/apm/public/services/rest/callApi.ts
diff --git a/x-pack/legacy/plugins/apm/public/services/rest/createCallApmApi.ts b/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts
similarity index 89%
rename from x-pack/legacy/plugins/apm/public/services/rest/createCallApmApi.ts
rename to x-pack/plugins/apm/public/services/rest/createCallApmApi.ts
index 2fffb40d353fc..1027e8b885d71 100644
--- a/x-pack/legacy/plugins/apm/public/services/rest/createCallApmApi.ts
+++ b/x-pack/plugins/apm/public/services/rest/createCallApmApi.ts
@@ -6,9 +6,9 @@
import { HttpSetup } from 'kibana/public';
import { callApi, FetchOptions } from './callApi';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { APMAPI } from '../../../../../../plugins/apm/server/routes/create_apm_api';
+import { APMAPI } from '../../../server/routes/create_apm_api';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { Client } from '../../../../../../plugins/apm/server/routes/typings';
+import { Client } from '../../../server/routes/typings';
export type APMClient = Client;
export type APMClientOptions = Omit & {
diff --git a/x-pack/legacy/plugins/apm/public/services/rest/index_pattern.ts b/x-pack/plugins/apm/public/services/rest/index_pattern.ts
similarity index 76%
rename from x-pack/legacy/plugins/apm/public/services/rest/index_pattern.ts
rename to x-pack/plugins/apm/public/services/rest/index_pattern.ts
index 1efcc98bbbd66..ac7a0d3cf734b 100644
--- a/x-pack/legacy/plugins/apm/public/services/rest/index_pattern.ts
+++ b/x-pack/plugins/apm/public/services/rest/index_pattern.ts
@@ -12,3 +12,9 @@ export const createStaticIndexPattern = async () => {
pathname: '/api/apm/index_pattern/static'
});
};
+
+export const getApmIndexPatternTitle = async () => {
+ return await callApmApi({
+ pathname: '/api/apm/index_pattern/title'
+ });
+};
diff --git a/x-pack/legacy/plugins/apm/public/services/rest/ml.ts b/x-pack/plugins/apm/public/services/rest/ml.ts
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/services/rest/ml.ts
rename to x-pack/plugins/apm/public/services/rest/ml.ts
index 0cd1bdf907531..b333a08d2eb05 100644
--- a/x-pack/legacy/plugins/apm/public/services/rest/ml.ts
+++ b/x-pack/plugins/apm/public/services/rest/ml.ts
@@ -9,14 +9,14 @@ import {
PROCESSOR_EVENT,
SERVICE_NAME,
TRANSACTION_TYPE
-} from '../../../../../../plugins/apm/common/elasticsearch_fieldnames';
+} from '../../../common/elasticsearch_fieldnames';
import {
getMlJobId,
getMlPrefix,
encodeForMlApi
-} from '../../../../../../plugins/apm/common/ml_job_constants';
+} from '../../../common/ml_job_constants';
import { callApi } from './callApi';
-import { ESFilter } from '../../../../../../plugins/apm/typings/elasticsearch';
+import { ESFilter } from '../../../typings/elasticsearch';
import { callApmApi } from './createCallApmApi';
interface MlResponseItem {
diff --git a/x-pack/legacy/plugins/apm/public/services/rest/watcher.ts b/x-pack/plugins/apm/public/services/rest/watcher.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/services/rest/watcher.ts
rename to x-pack/plugins/apm/public/services/rest/watcher.ts
diff --git a/x-pack/legacy/plugins/apm/public/new-platform/setHelpExtension.ts b/x-pack/plugins/apm/public/setHelpExtension.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/new-platform/setHelpExtension.ts
rename to x-pack/plugins/apm/public/setHelpExtension.ts
diff --git a/x-pack/legacy/plugins/apm/public/style/variables.ts b/x-pack/plugins/apm/public/style/variables.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/style/variables.ts
rename to x-pack/plugins/apm/public/style/variables.ts
diff --git a/x-pack/legacy/plugins/apm/public/new-platform/toggleAppLinkInNav.ts b/x-pack/plugins/apm/public/toggleAppLinkInNav.ts
similarity index 91%
rename from x-pack/legacy/plugins/apm/public/new-platform/toggleAppLinkInNav.ts
rename to x-pack/plugins/apm/public/toggleAppLinkInNav.ts
index c807cebf97525..8204e1a022d7e 100644
--- a/x-pack/legacy/plugins/apm/public/new-platform/toggleAppLinkInNav.ts
+++ b/x-pack/plugins/apm/public/toggleAppLinkInNav.ts
@@ -5,7 +5,7 @@
*/
import { CoreStart } from 'kibana/public';
-import { ConfigSchema } from './plugin';
+import { ConfigSchema } from '.';
export function toggleAppLinkInNav(core: CoreStart, { ui }: ConfigSchema) {
if (ui.enabled === false) {
diff --git a/x-pack/legacy/plugins/apm/public/new-platform/updateBadge.ts b/x-pack/plugins/apm/public/updateBadge.ts
similarity index 99%
rename from x-pack/legacy/plugins/apm/public/new-platform/updateBadge.ts
rename to x-pack/plugins/apm/public/updateBadge.ts
index b3e29bb891c23..10849754313c4 100644
--- a/x-pack/legacy/plugins/apm/public/new-platform/updateBadge.ts
+++ b/x-pack/plugins/apm/public/updateBadge.ts
@@ -10,7 +10,6 @@ import { CoreStart } from 'kibana/public';
export function setReadonlyBadge({ application, chrome }: CoreStart) {
const canSave = application.capabilities.apm.save;
const { setBadge } = chrome;
-
setBadge(
!canSave
? {
diff --git a/x-pack/legacy/plugins/apm/public/utils/__test__/flattenObject.test.ts b/x-pack/plugins/apm/public/utils/__test__/flattenObject.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/__test__/flattenObject.test.ts
rename to x-pack/plugins/apm/public/utils/__test__/flattenObject.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/flattenObject.ts b/x-pack/plugins/apm/public/utils/flattenObject.ts
similarity index 94%
rename from x-pack/legacy/plugins/apm/public/utils/flattenObject.ts
rename to x-pack/plugins/apm/public/utils/flattenObject.ts
index 020bfec2cbd6a..295ea1f9f900f 100644
--- a/x-pack/legacy/plugins/apm/public/utils/flattenObject.ts
+++ b/x-pack/plugins/apm/public/utils/flattenObject.ts
@@ -5,7 +5,7 @@
*/
import { compact, isObject } from 'lodash';
-import { Maybe } from '../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../typings/common';
export interface KeyValuePair {
key: string;
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/__test__/datetime.test.ts b/x-pack/plugins/apm/public/utils/formatters/__test__/datetime.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/__test__/datetime.test.ts
rename to x-pack/plugins/apm/public/utils/formatters/__test__/datetime.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/__test__/duration.test.ts b/x-pack/plugins/apm/public/utils/formatters/__test__/duration.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/__test__/duration.test.ts
rename to x-pack/plugins/apm/public/utils/formatters/__test__/duration.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/__test__/formatters.test.ts b/x-pack/plugins/apm/public/utils/formatters/__test__/formatters.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/__test__/formatters.test.ts
rename to x-pack/plugins/apm/public/utils/formatters/__test__/formatters.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/__test__/size.test.ts b/x-pack/plugins/apm/public/utils/formatters/__test__/size.test.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/__test__/size.test.ts
rename to x-pack/plugins/apm/public/utils/formatters/__test__/size.test.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/datetime.ts b/x-pack/plugins/apm/public/utils/formatters/datetime.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/datetime.ts
rename to x-pack/plugins/apm/public/utils/formatters/datetime.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/duration.ts b/x-pack/plugins/apm/public/utils/formatters/duration.ts
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/duration.ts
rename to x-pack/plugins/apm/public/utils/formatters/duration.ts
index 681d876ca3beb..39341e1ff4443 100644
--- a/x-pack/legacy/plugins/apm/public/utils/formatters/duration.ts
+++ b/x-pack/plugins/apm/public/utils/formatters/duration.ts
@@ -7,10 +7,10 @@
import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { memoize } from 'lodash';
-import { NOT_AVAILABLE_LABEL } from '../../../../../../plugins/apm/common/i18n';
+import { NOT_AVAILABLE_LABEL } from '../../../common/i18n';
import { asDecimal, asInteger } from './formatters';
import { TimeUnit } from './datetime';
-import { Maybe } from '../../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../../typings/common';
interface FormatterOptions {
defaultValue?: string;
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/formatters.ts b/x-pack/plugins/apm/public/utils/formatters/formatters.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/formatters.ts
rename to x-pack/plugins/apm/public/utils/formatters/formatters.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/index.ts b/x-pack/plugins/apm/public/utils/formatters/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/index.ts
rename to x-pack/plugins/apm/public/utils/formatters/index.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/formatters/size.ts b/x-pack/plugins/apm/public/utils/formatters/size.ts
similarity index 95%
rename from x-pack/legacy/plugins/apm/public/utils/formatters/size.ts
rename to x-pack/plugins/apm/public/utils/formatters/size.ts
index 8fe6ebf3e573d..2cdf8af1d46de 100644
--- a/x-pack/legacy/plugins/apm/public/utils/formatters/size.ts
+++ b/x-pack/plugins/apm/public/utils/formatters/size.ts
@@ -5,7 +5,7 @@
*/
import { memoize } from 'lodash';
import { asDecimal } from './formatters';
-import { Maybe } from '../../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../../typings/common';
function asKilobytes(value: number) {
return `${asDecimal(value / 1000)} KB`;
diff --git a/x-pack/legacy/plugins/apm/public/utils/getRangeFromTimeSeries.ts b/x-pack/plugins/apm/public/utils/getRangeFromTimeSeries.ts
similarity index 88%
rename from x-pack/legacy/plugins/apm/public/utils/getRangeFromTimeSeries.ts
rename to x-pack/plugins/apm/public/utils/getRangeFromTimeSeries.ts
index 4301ead2fc79f..1865d5ae574a7 100644
--- a/x-pack/legacy/plugins/apm/public/utils/getRangeFromTimeSeries.ts
+++ b/x-pack/plugins/apm/public/utils/getRangeFromTimeSeries.ts
@@ -5,7 +5,7 @@
*/
import { flatten } from 'lodash';
-import { TimeSeries } from '../../../../../plugins/apm/typings/timeseries';
+import { TimeSeries } from '../../typings/timeseries';
export const getRangeFromTimeSeries = (timeseries: TimeSeries[]) => {
const dataPoints = flatten(timeseries.map(series => series.data));
diff --git a/x-pack/legacy/plugins/apm/public/utils/history.ts b/x-pack/plugins/apm/public/utils/history.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/history.ts
rename to x-pack/plugins/apm/public/utils/history.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/httpStatusCodeToColor.ts b/x-pack/plugins/apm/public/utils/httpStatusCodeToColor.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/public/utils/httpStatusCodeToColor.ts
rename to x-pack/plugins/apm/public/utils/httpStatusCodeToColor.ts
diff --git a/x-pack/legacy/plugins/apm/public/utils/isValidCoordinateValue.ts b/x-pack/plugins/apm/public/utils/isValidCoordinateValue.ts
similarity index 84%
rename from x-pack/legacy/plugins/apm/public/utils/isValidCoordinateValue.ts
rename to x-pack/plugins/apm/public/utils/isValidCoordinateValue.ts
index f7c13603c3535..c36efc232b782 100644
--- a/x-pack/legacy/plugins/apm/public/utils/isValidCoordinateValue.ts
+++ b/x-pack/plugins/apm/public/utils/isValidCoordinateValue.ts
@@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { Maybe } from '../../../../../plugins/apm/typings/common';
+import { Maybe } from '../../typings/common';
export const isValidCoordinateValue = (value: Maybe): value is number =>
value !== null && value !== undefined;
diff --git a/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx b/x-pack/plugins/apm/public/utils/testHelpers.tsx
similarity index 96%
rename from x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
rename to x-pack/plugins/apm/public/utils/testHelpers.tsx
index 36c0e18777bfd..def41a1cabd61 100644
--- a/x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
+++ b/x-pack/plugins/apm/public/utils/testHelpers.tsx
@@ -16,14 +16,14 @@ import { render, waitForElement } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { MemoryRouter } from 'react-router-dom';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { APMConfig } from '../../../../../plugins/apm/server';
+import { APMConfig } from '../../server';
import { LocationProvider } from '../context/LocationContext';
-import { PromiseReturnType } from '../../../../../plugins/apm/typings/common';
+import { PromiseReturnType } from '../../typings/common';
import {
ESFilter,
ESSearchResponse,
ESSearchRequest
-} from '../../../../../plugins/apm/typings/elasticsearch';
+} from '../../typings/elasticsearch';
import { MockApmPluginContextWrapper } from '../context/ApmPluginContext/MockApmPluginContext';
export function toJson(wrapper: ReactWrapper) {
diff --git a/x-pack/legacy/plugins/apm/readme.md b/x-pack/plugins/apm/readme.md
similarity index 92%
rename from x-pack/legacy/plugins/apm/readme.md
rename to x-pack/plugins/apm/readme.md
index e8e2514c83fcb..62465e920d793 100644
--- a/x-pack/legacy/plugins/apm/readme.md
+++ b/x-pack/plugins/apm/readme.md
@@ -32,7 +32,7 @@ _Docker Compose is required_
### E2E (Cypress) tests
```sh
-x-pack/legacy/plugins/apm/e2e/run-e2e.sh
+x-pack/plugins/apm/e2e/run-e2e.sh
```
_Starts Kibana (:5701), APM Server (:8201) and Elasticsearch (:9201). Ingests sample data into Elasticsearch via APM Server and runs the Cypress tests_
@@ -94,13 +94,13 @@ _Note: Run the following commands from `kibana/`._
#### Prettier
```
-yarn prettier "./x-pack/legacy/plugins/apm/**/*.{tsx,ts,js}" --write
+yarn prettier "./x-pack/plugins/apm/**/*.{tsx,ts,js}" --write
```
#### ESLint
```
-yarn eslint ./x-pack/legacy/plugins/apm --fix
+yarn eslint ./x-pack/plugins/apm --fix
```
### Setup default APM users
@@ -117,7 +117,7 @@ For testing purposes APM uses 3 custom users:
To create the users with the correct roles run the following script:
```sh
-node x-pack/legacy/plugins/apm/scripts/setup-kibana-security.js --role-suffix
+node x-pack/plugins/apm/scripts/setup-kibana-security.js --role-suffix
```
The users will be created with the password specified in kibana.dev.yml for `elasticsearch.password`
diff --git a/x-pack/legacy/plugins/apm/scripts/.gitignore b/x-pack/plugins/apm/scripts/.gitignore
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/.gitignore
rename to x-pack/plugins/apm/scripts/.gitignore
diff --git a/x-pack/legacy/plugins/apm/scripts/kibana-security/setup-custom-kibana-user-role.ts b/x-pack/plugins/apm/scripts/kibana-security/setup-custom-kibana-user-role.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/kibana-security/setup-custom-kibana-user-role.ts
rename to x-pack/plugins/apm/scripts/kibana-security/setup-custom-kibana-user-role.ts
diff --git a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig.js b/x-pack/plugins/apm/scripts/optimize-tsconfig.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/optimize-tsconfig.js
rename to x-pack/plugins/apm/scripts/optimize-tsconfig.js
diff --git a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/optimize.js b/x-pack/plugins/apm/scripts/optimize-tsconfig/optimize.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/optimize.js
rename to x-pack/plugins/apm/scripts/optimize-tsconfig/optimize.js
diff --git a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/paths.js b/x-pack/plugins/apm/scripts/optimize-tsconfig/paths.js
similarity index 90%
rename from x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/paths.js
rename to x-pack/plugins/apm/scripts/optimize-tsconfig/paths.js
index cab55a2526202..aeccd403c5ce6 100644
--- a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/paths.js
+++ b/x-pack/plugins/apm/scripts/optimize-tsconfig/paths.js
@@ -5,7 +5,7 @@
*/
const path = require('path');
-const xpackRoot = path.resolve(__dirname, '../../../../..');
+const xpackRoot = path.resolve(__dirname, '../../../..');
const kibanaRoot = path.resolve(xpackRoot, '..');
const tsconfigTpl = path.resolve(__dirname, './tsconfig.json');
diff --git a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/tsconfig.json b/x-pack/plugins/apm/scripts/optimize-tsconfig/tsconfig.json
similarity index 60%
rename from x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/tsconfig.json
rename to x-pack/plugins/apm/scripts/optimize-tsconfig/tsconfig.json
index 8f6b0f35e4b52..5e05d3962eccb 100644
--- a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/tsconfig.json
+++ b/x-pack/plugins/apm/scripts/optimize-tsconfig/tsconfig.json
@@ -1,11 +1,10 @@
{
"include": [
"./plugins/apm/**/*",
- "./legacy/plugins/apm/**/*",
"./typings/**/*"
],
"exclude": [
"**/__fixtures__/**/*",
- "./legacy/plugins/apm/e2e/cypress/**/*"
+ "./plugins/apm/e2e/cypress/**/*"
]
}
diff --git a/x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/unoptimize.js b/x-pack/plugins/apm/scripts/optimize-tsconfig/unoptimize.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/optimize-tsconfig/unoptimize.js
rename to x-pack/plugins/apm/scripts/optimize-tsconfig/unoptimize.js
diff --git a/x-pack/legacy/plugins/apm/scripts/package.json b/x-pack/plugins/apm/scripts/package.json
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/package.json
rename to x-pack/plugins/apm/scripts/package.json
diff --git a/x-pack/legacy/plugins/apm/scripts/setup-kibana-security.js b/x-pack/plugins/apm/scripts/setup-kibana-security.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/setup-kibana-security.js
rename to x-pack/plugins/apm/scripts/setup-kibana-security.js
diff --git a/x-pack/legacy/plugins/apm/scripts/storybook.js b/x-pack/plugins/apm/scripts/storybook.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/storybook.js
rename to x-pack/plugins/apm/scripts/storybook.js
diff --git a/x-pack/legacy/plugins/apm/scripts/unoptimize-tsconfig.js b/x-pack/plugins/apm/scripts/unoptimize-tsconfig.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/unoptimize-tsconfig.js
rename to x-pack/plugins/apm/scripts/unoptimize-tsconfig.js
diff --git a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data.js b/x-pack/plugins/apm/scripts/upload-telemetry-data.js
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/upload-telemetry-data.js
rename to x-pack/plugins/apm/scripts/upload-telemetry-data.js
diff --git a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/download-telemetry-template.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/download-telemetry-template.ts
similarity index 100%
rename from x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/download-telemetry-template.ts
rename to x-pack/plugins/apm/scripts/upload-telemetry-data/download-telemetry-template.ts
diff --git a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts
similarity index 97%
rename from x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts
rename to x-pack/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts
index 8d76063a7fdf6..390609996874b 100644
--- a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts
+++ b/x-pack/plugins/apm/scripts/upload-telemetry-data/generate-sample-documents.ts
@@ -18,7 +18,7 @@ import {
CollectTelemetryParams,
collectDataTelemetry
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../../plugins/apm/server/lib/apm_telemetry/collect_data_telemetry';
+} from '../../server/lib/apm_telemetry/collect_data_telemetry';
interface GenerateOptions {
days: number;
diff --git a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/index.ts b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts
similarity index 98%
rename from x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/index.ts
rename to x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts
index bdc57eac412fc..4f69a3a3bd213 100644
--- a/x-pack/legacy/plugins/apm/scripts/upload-telemetry-data/index.ts
+++ b/x-pack/plugins/apm/scripts/upload-telemetry-data/index.ts
@@ -25,7 +25,7 @@ import { Logger } from 'kibana/server';
// @ts-ignore
import consoleStamp from 'console-stamp';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { CollectTelemetryParams } from '../../../../../plugins/apm/server/lib/apm_telemetry/collect_data_telemetry';
+import { CollectTelemetryParams } from '../../server/lib/apm_telemetry/collect_data_telemetry';
import { downloadTelemetryTemplate } from './download-telemetry-template';
import mapping from '../../mappings.json';
import { generateSampleDocuments } from './generate-sample-documents';
diff --git a/x-pack/plugins/apm/server/feature.ts b/x-pack/plugins/apm/server/feature.ts
new file mode 100644
index 0000000000000..ae0f5510cd80e
--- /dev/null
+++ b/x-pack/plugins/apm/server/feature.ts
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+import { i18n } from '@kbn/i18n';
+
+export const APM_FEATURE = {
+ id: 'apm',
+ name: i18n.translate('xpack.apm.featureRegistry.apmFeatureName', {
+ defaultMessage: 'APM'
+ }),
+ order: 900,
+ icon: 'apmApp',
+ navLinkId: 'apm',
+ app: ['apm', 'kibana'],
+ catalogue: ['apm'],
+ // see x-pack/plugins/features/common/feature_kibana_privileges.ts
+ privileges: {
+ all: {
+ app: ['apm', 'kibana'],
+ api: [
+ 'apm',
+ 'apm_write',
+ 'actions-read',
+ 'actions-all',
+ 'alerting-read',
+ 'alerting-all'
+ ],
+ catalogue: ['apm'],
+ savedObject: {
+ all: ['alert', 'action', 'action_task_params'],
+ read: []
+ },
+ ui: [
+ 'show',
+ 'save',
+ 'alerting:show',
+ 'actions:show',
+ 'alerting:save',
+ 'actions:save',
+ 'alerting:delete',
+ 'actions:delete'
+ ]
+ },
+ read: {
+ app: ['apm', 'kibana'],
+ api: [
+ 'apm',
+ 'actions-read',
+ 'actions-all',
+ 'alerting-read',
+ 'alerting-all'
+ ],
+ catalogue: ['apm'],
+ savedObject: {
+ all: ['alert', 'action', 'action_task_params'],
+ read: []
+ },
+ ui: [
+ 'show',
+ 'alerting:show',
+ 'actions:show',
+ 'alerting:save',
+ 'actions:save',
+ 'alerting:delete',
+ 'actions:delete'
+ ]
+ }
+ }
+};
diff --git a/x-pack/plugins/apm/server/index.ts b/x-pack/plugins/apm/server/index.ts
index 77655568a7e9c..9009008790631 100644
--- a/x-pack/plugins/apm/server/index.ts
+++ b/x-pack/plugins/apm/server/index.ts
@@ -73,4 +73,4 @@ export type APMConfig = ReturnType