Skip to content

Commit 8f1bb77

Browse files
Refactor embeddable transform registration and fix CONTEXT_MENU_TRIGGER import
1 parent 607ab19 commit 8f1bb77

4 files changed

Lines changed: 38 additions & 15 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { getTransformIn } from './get_transform_in';
9+
import { getTransformOut } from './get_transform_out';
10+
11+
export function getTransforms() {
12+
return {
13+
transformIn: getTransformIn(),
14+
transformOut: getTransformOut(),
15+
};
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { DrilldownTransforms } from '@kbn/embeddable-plugin/common';
9+
import { getTransformIn } from './get_transform_in';
10+
import { getTransformOut } from './get_transform_out';
11+
12+
export function getTransforms(drilldownTransforms: DrilldownTransforms) {
13+
return {
14+
transformIn: getTransformIn(drilldownTransforms.transformIn),
15+
transformOut: getTransformOut(drilldownTransforms.transformOut),
16+
};
17+
}

x-pack/solutions/observability/plugins/synthetics/public/apps/embeddables/stats_overview/stats_overview_embeddable_factory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
99

1010
import React, { useEffect } from 'react';
1111
import type { DefaultEmbeddableApi, EmbeddableFactory } from '@kbn/embeddable-plugin/public';
12-
import { CONTEXT_MENU_TRIGGER } from '@kbn/embeddable-plugin/public';
12+
import { CONTEXT_MENU_TRIGGER } from '@kbn/ui-actions-plugin/common/trigger_ids';
1313
import type {
1414
PublishesWritableTitle,
1515
PublishesTitle,

x-pack/solutions/observability/plugins/synthetics/server/plugin.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { SavedObjectsClient } from '@kbn/core/server';
1717
import { mappingFromFieldMap } from '@kbn/alerting-plugin/common';
1818
import { Dataset } from '@kbn/rule-registry-plugin/server';
1919
import { schema } from '@kbn/config-schema';
20-
import type { DrilldownTransforms } from '@kbn/embeddable-plugin/common';
2120
import { serializedTitlesSchema } from '@kbn/presentation-publishing-schemas';
2221
import { SyncGlobalParamsPrivateLocationsTask } from './tasks/sync_global_params_task';
2322
import type {
@@ -36,11 +35,9 @@ import { syntheticsServiceApiKey } from './saved_objects/service_api_key';
3635
import { SYNTHETICS_RULE_TYPES_ALERT_CONTEXT } from '../common/constants/synthetics_alerts';
3736
import { syntheticsRuleTypeFieldMap } from './alert_rules/common';
3837
import { SyncPrivateLocationMonitorsTask } from './tasks/sync_private_locations_monitors_task';
39-
import { getTransformIn as getStatsTransformIn } from '../common/embeddables/stats_overview/get_transform_in';
40-
import { getTransformOut as getStatsTransformOut } from '../common/embeddables/stats_overview/get_transform_out';
38+
import { getTransforms as getStatsTransforms } from '../common/embeddables/stats_overview/get_transforms';
4139
import { SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE } from '../common/embeddables/stats_overview/constants';
42-
import { getTransformIn as getMonitorsTransformIn } from '../common/embeddables/monitors_overview/get_transform_in';
43-
import { getTransformOut as getMonitorsTransformOut } from '../common/embeddables/monitors_overview/get_transform_out';
40+
import { getTransforms as getMonitorsTransforms } from '../common/embeddables/monitors_overview/get_transforms';
4441
import { SYNTHETICS_MONITORS_EMBEDDABLE } from '../common/embeddables/monitors_overview/constants';
4542
import { statsOverviewCustomStateSchema, syntheticsMonitorsEmbeddableSchema } from './schemas';
4643

@@ -120,13 +117,9 @@ export class Plugin implements PluginType {
120117

121118
// Register transforms and schema for SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE
122119
plugins.embeddable.registerTransforms(SYNTHETICS_STATS_OVERVIEW_EMBEDDABLE, {
123-
getTransforms: (drilldownTransforms: DrilldownTransforms) => ({
124-
transformIn: getStatsTransformIn(drilldownTransforms.transformIn),
125-
transformOut: getStatsTransformOut(drilldownTransforms.transformOut),
126-
}),
120+
getTransforms: getStatsTransforms,
127121
getSchema: (getDrilldownsSchema) => {
128122
const drilldownsSchema = getDrilldownsSchema(['CONTEXT_MENU_TRIGGER']);
129-
// Combine custom state, titles, and drilldowns schemas
130123
return schema.allOf(
131124
[statsOverviewCustomStateSchema, serializedTitlesSchema, drilldownsSchema],
132125
{ meta: { description: 'Synthetics stats overview embeddable schema' } }
@@ -136,10 +129,7 @@ export class Plugin implements PluginType {
136129

137130
// Register transforms and schema for SYNTHETICS_MONITORS_EMBEDDABLE
138131
plugins.embeddable.registerTransforms(SYNTHETICS_MONITORS_EMBEDDABLE, {
139-
getTransforms: () => ({
140-
transformIn: getMonitorsTransformIn(),
141-
transformOut: getMonitorsTransformOut(),
142-
}),
132+
getTransforms: getMonitorsTransforms,
143133
getSchema: () => syntheticsMonitorsEmbeddableSchema,
144134
});
145135

0 commit comments

Comments
 (0)