Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pageLoadAssetSize:
visTypeTable: 18999
visTypeTagcloud: 7876
visTypeTimelion: 12512
visTypeTimeseries: 19665
visTypeTimeseries: 20000
visTypeVega: 38538
visTypeVislib: 14679
visTypeXy: 32342
Expand Down
1 change: 1 addition & 0 deletions src/platform/plugins/shared/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ export {
ADD_PANEL_ANNOTATION_GROUP,
ADD_PANEL_OTHER_GROUP,
ADD_PANEL_VISUALIZATION_GROUP,
ADD_PANEL_LEGACY_GROUP,
} from './ui_actions/add_panel_groups';
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ export const ADD_PANEL_OTHER_GROUP = {
getIconType: () => 'empty',
order: -1, // Given an item that doesn't specify a group is assigned zero, this forces other to come after all intentionally grouped section
};

export const ADD_PANEL_LEGACY_GROUP = {
id: 'legacy',
getDisplayName: () =>
i18n.translate('embeddableApi.common.constants.grouping.legacy', {
defaultMessage: 'Legacy',
}),
getIconType: () => 'empty',
order: -10, // Given an item that doesn't specify a group is assigned zero, this forces other to come after all intentionally grouped section
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"usageCollection",
"unifiedSearch",
"expressionXY",
"uiActions",
"embeddable"
],
"optionalPlugins": [
"home"
Expand Down
3 changes: 3 additions & 0 deletions src/platform/plugins/shared/vis_types/timeseries/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ dependsOn:
- '@kbn/lens-common'
- '@kbn/expression-xy-plugin'
- '@kbn/event-annotation-common'
- '@kbn/ui-actions-plugin'
- '@kbn/presentation-publishing'
- '@kbn/presentation-containers'
tags:
- plugin
- prod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { ActionDefinition } from '@kbn/ui-actions-plugin/public/actions';
import { apiHasAppContext, type EmbeddableApiContext } from '@kbn/presentation-publishing';
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';

import { ADD_PANEL_LEGACY_GROUP } from '@kbn/embeddable-plugin/public';
import { apiIsPresentationContainer } from '@kbn/presentation-containers';
import { TSVB_ICON, TSVB_DESCRIPTION, TSVB_TITLE } from './metrics_type';

export const CREATE_TSVB_PANEL = 'CREATE_TSVB_PANEL';

/**
* Factory that creates the action definition used to add a new Time Series Visual Builder (TSVB)
* panel from within an embeddable container (e.g. a dashboard). The returned action integrates
* with the embeddable infrastructure and leverages the state transfer service to open the
* Visualize editor pre-seeded for creating a TSVB visualization.
*
* Behavior:
* - Always compatible (no preconditions).
* - Navigates to the Visualize editor with:
* - A metrics visualization type (`#/create?type=metrics`).
* - Originating app id and path (when available) for proper back navigation.
* - The current search session id to preserve query context.
*
* Icon, display name, and tooltip are sourced from TSVB-specific constants to keep
* presentation concerns centralized.
*
* @remarks
* The action purposefully does not perform capability checks itself; external registries
* may wrap or filter it based on user privileges. The `apiHasAppContext` guard ensures
* safe extraction of app-related navigation state when the embeddable supplies that context.
*
* @public
*/
export const addTSVBPanelAction = (deps: {
data: DataPublicPluginStart;
embeddable: EmbeddableStart;
}): ActionDefinition<EmbeddableApiContext> => ({
id: CREATE_TSVB_PANEL,
grouping: [ADD_PANEL_LEGACY_GROUP],
order: 30,
getIconType: () => TSVB_ICON,
isCompatible: async ({ embeddable }) => apiIsPresentationContainer(embeddable),
execute: async ({ embeddable }: EmbeddableApiContext) => {
const stateTransferService = deps.embeddable.getStateTransfer();
stateTransferService.navigateToEditor('visualize', {
path: '#/create?type=metrics',
state: {
originatingApp: apiHasAppContext(embeddable) ? embeddable.getAppContext().currentAppId : '',
originatingPath: apiHasAppContext(embeddable)
? embeddable.getAppContext().getCurrentPath?.()
: undefined,
searchSessionId: deps.data.search.session.getSessionId(),
},
});
},
getDisplayName: () => TSVB_TITLE,
getDisplayNameTooltip: () => TSVB_DESCRIPTION,
});
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ async function getUsedIndexPatterns(params: VisParams): Promise<DataView[]> {
return resolvedIndexPatterns;
}

export const TSVB_ICON = 'visVisualBuilder';
export const TSVB_TITLE = i18n.translate('visTypeTimeseries.kbnVisTypes.metricsTitle', {
defaultMessage: 'TSVB',
});
export const TSVB_DESCRIPTION = i18n.translate('visTypeTimeseries.kbnVisTypes.metricsDescription', {
defaultMessage: 'Create visualizations using time series data.',
});

export const metricsVisDefinition: VisTypeDefinition<
TimeseriesVisParams | TimeseriesVisDefaultParams
> = {
name: VIS_TYPE,
title: i18n.translate('visTypeTimeseries.kbnVisTypes.metricsTitle', { defaultMessage: 'TSVB' }),
description: i18n.translate('visTypeTimeseries.kbnVisTypes.metricsDescription', {
defaultMessage: 'Create visualizations using time series data.',
}),
icon: 'visVisualBuilder',
title: TSVB_TITLE,
description: TSVB_DESCRIPTION,
icon: TSVB_ICON,
group: VisGroups.LEGACY,
order: 10,
visConfig: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import type { IUiSettingsClient } from '@kbn/core/public';
import type { HttpSetup } from '@kbn/core-http-browser';
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import { ADD_PANEL_TRIGGER, type UiActionsStart } from '@kbn/ui-actions-plugin/public';
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';
import type { VisTypeTimeseriesPublicConfig } from '../server/config';

import { EditorController, TSVB_EDITOR_NAME } from './application/editor_controller';
Expand All @@ -38,6 +40,7 @@ import {
setUnifiedSearchStart,
} from './services';
import { getTimeseriesVisRenderer } from './timeseries_vis_renderer';
import { CREATE_TSVB_PANEL } from './add_tsvb_panel_action';

/** @internal */
export interface MetricsPluginSetupDependencies {
Expand All @@ -53,6 +56,8 @@ export interface MetricsPluginStartDependencies {
charts: ChartsPluginStart;
usageCollection: UsageCollectionStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
uiActions: UiActionsStart;
embeddable: EmbeddableStart;
}

/** @internal */
Expand Down Expand Up @@ -105,6 +110,8 @@ export class MetricsPlugin implements Plugin<void, void> {
usageCollection,
fieldFormats,
unifiedSearch,
uiActions,
embeddable,
}: MetricsPluginStartDependencies
) {
setCharts(charts);
Expand All @@ -115,5 +122,11 @@ export class MetricsPlugin implements Plugin<void, void> {
setDataViewsStart(dataViews);
setCoreStart(core);
setUsageCollectionStart(usageCollection);

uiActions.registerActionAsync(CREATE_TSVB_PANEL, async () => {
const { addTSVBPanelAction } = await import('./add_tsvb_panel_action');
return addTSVBPanelAction({ data, embeddable });
});
uiActions.attachAction(ADD_PANEL_TRIGGER, CREATE_TSVB_PANEL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"@kbn/lens-common",
"@kbn/expression-xy-plugin",
"@kbn/event-annotation-common",
"@kbn/ui-actions-plugin",
"@kbn/presentation-publishing",
"@kbn/presentation-containers",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
panelGroupByOrder.set(order, panelGroupTitle);
}

expect(panelGroupByOrder.size).to.eql(3);
expect(panelGroupByOrder.size).to.eql(4);

expect([...panelGroupByOrder.values()]).to.eql([
'visualizationsGroup',
'annotation-and-navigationGroup',
'observabilityGroup',
'legacyGroup',
]);

// Any changes to the number of panels needs to be audited by @elastic/kibana-presentation
expect(panelTypes.length).to.eql(11);
expect(panelTypes.length).to.eql(12);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
panelGroupByOrder.set(order, panelGroupTitle);
}

expect(panelGroupByOrder.size).to.eql(4);
expect(panelGroupByOrder.size).to.eql(5);

expect([...panelGroupByOrder.values()]).to.eql([
'visualizationsGroup',
'annotation-and-navigationGroup',
'mlGroup',
'observabilityGroup',
'legacyGroup',
]);

// Any changes to the number of panels needs to be audited by @elastic/kibana-presentation
expect(panelTypes.length).to.eql(21);
expect(panelTypes.length).to.eql(22);
});
});
}
Loading