Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { ON_CLICK_IMAGE } from '@kbn/ui-actions-plugin/common/trigger_ids';
import { ON_CLICK_IMAGE, ON_OPEN_PANEL_MENU } from '@kbn/ui-actions-plugin/common/trigger_ids';

export const IMAGE_EMBEDDABLE_TYPE = 'image';
export const ADD_IMAGE_EMBEDDABLE_ACTION_ID = 'create_image_embeddable';
export const IMAGE_EMBEDDABLE_SUPPORTED_TRIGGERS = [ON_CLICK_IMAGE];
export const IMAGE_EMBEDDABLE_SUPPORTED_TRIGGERS = [ON_CLICK_IMAGE, ON_OPEN_PANEL_MENU];
export const DEFAULT_OBJECT_FIT = 'contain'; // CSS spec defaults to fill but embeddable has historically defaulted to contain
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import type { SearchResponseIncompleteWarning } from '@kbn/search-response-warnings/src/types';
import type { DocViewFilterFn } from '@kbn/unified-doc-viewer/types';
import { ON_APPLY_FILTER } from '@kbn/ui-actions-plugin/common/trigger_ids';
import { ON_APPLY_FILTER, ON_OPEN_PANEL_MENU } from '@kbn/ui-actions-plugin/common/trigger_ids';
import type { DiscoverServices } from '../build_services';
import { SearchEmbeddablFieldStatsTableComponent } from './components/search_embeddable_field_stats_table_component';
import { SearchEmbeddableGridComponent } from './components/search_embeddable_grid_component';
Expand Down Expand Up @@ -279,9 +279,7 @@ export const getSearchEmbeddableFactory = ({
serializeState: () => serialize(savedObjectId$.getValue()),
getInspectorAdapters: () => searchEmbeddable.stateManager.inspectorAdapters.getValue(),
supportedTriggers: () => {
// No triggers are supported, but this is still required to pass the drilldown
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should definitely have tipped us off that this was a bad code smell. Happy to see it removed!

// compatibilty check and ensure top-level drilldowns (e.g. URL) work as expected
return [];
return [ON_OPEN_PANEL_MENU];
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
import type { HasSupportedTriggers } from '@kbn/presentation-publishing';
import {
ON_APPLY_FILTER,
ON_OPEN_PANEL_MENU,
ON_SELECT_RANGE,
ON_CLICK_VALUE,
} from '@kbn/ui-actions-plugin/common/trigger_ids';

export function getEmbeddableTriggers(embeddable: HasSupportedTriggers) {
return [ON_OPEN_PANEL_MENU, ...ensureNestedTriggers(embeddable.supportedTriggers())];
return ensureNestedTriggers(embeddable.supportedTriggers());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ describe('drilldown registry', () => {
);
}

test('should throw when there is no intersection with supported triggers', () => {
expect(() => {
registry.getSchema([]);
}).toThrow();
});

test('should include drilldowns that intersect with supported triggers', () => {
const onClickDrilldownsSchema = registry.getSchema(['ON_CLICK']);
const drilldownsJoiSchema = onClickDrilldownsSchema.getPropSchemas().drilldowns?.getSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export function getDrilldownRegistry() {
)
);

if (drilldownSchemas.length === 0) {
throw new Error(
'Supported triggers do not intersect with registered drilldowns. Remove drilldown schema from your embeddable schema.'
);
}

return schema.object({
drilldowns: schema.maybe(
schema.arrayOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ import React, { useEffect, useMemo, useRef } from 'react';
import { BehaviorSubject, map, merge, switchMap } from 'rxjs';
import { useErrorTextStyle } from '@kbn/react-hooks';
import { VISUALIZE_APP_NAME, VISUALIZE_EMBEDDABLE_TYPE } from '@kbn/visualizations-common';
import { ON_APPLY_FILTER, ON_SELECT_RANGE } from '@kbn/ui-actions-plugin/common/trigger_ids';
import {
ON_APPLY_FILTER,
ON_OPEN_PANEL_MENU,
ON_SELECT_RANGE,
} from '@kbn/ui-actions-plugin/common/trigger_ids';
import type { VisualizeEmbeddableState } from '../../common/embeddable/types';
import { VIS_EVENT_TO_TRIGGER } from './events';
import { getInspector, getUiActions, getUsageCollection } from '../services';
Expand Down Expand Up @@ -251,7 +255,12 @@ export const getVisualizeEmbeddableFactory: (deps: {
dataViews$: new BehaviorSubject<DataView[] | undefined>(initialDataViews),
projectRoutingOverrides$,
rendered$: hasRendered$,
supportedTriggers: () => [ACTION_CONVERT_TO_LENS, ON_APPLY_FILTER, ON_SELECT_RANGE],
supportedTriggers: () => [
ON_OPEN_PANEL_MENU,
ACTION_CONVERT_TO_LENS,
ON_APPLY_FILTER,
ON_SELECT_RANGE,
],
serializeState: () => {
// In the visualize editor, linkedToLibrary should always be false to force the full state to be serialized,
// instead of just passing a reference to the linked saved object. Other contexts like dashboards should
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type {
LensInternalApi,
LensRuntimeState,
} from '@kbn/lens-common';
import { ON_OPEN_PANEL_MENU } from '@kbn/ui-actions-plugin/common/trigger_ids';
import { APP_ID, getEditPath } from '../../../common/constants';
import type { LensEmbeddableStartServices } from '../types';
import {
Expand All @@ -49,11 +50,15 @@ function getSupportedTriggers(
visualizationMap: LensEmbeddableStartServices['visualizationMap']
) {
return () => {
const panelTriggers = [ON_OPEN_PANEL_MENU];
const currentState = getState();
if (currentState.attributes?.visualizationType) {
return visualizationMap[currentState.attributes.visualizationType]?.triggers || [];
return [
...panelTriggers,
...(visualizationMap[currentState.attributes.visualizationType]?.triggers ?? []),
];
}
return [];
return panelTriggers;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import {
initializeUnsavedChanges,
} from '@kbn/presentation-publishing';
import { BehaviorSubject, merge } from 'rxjs';
import { ON_APPLY_FILTER, ON_CLICK_VALUE } from '@kbn/ui-actions-plugin/common/trigger_ids';
import {
ON_APPLY_FILTER,
ON_CLICK_VALUE,
ON_OPEN_PANEL_MENU,
} from '@kbn/ui-actions-plugin/common/trigger_ids';
import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
import type { MapApi } from './types';
import { SavedMap } from '../routes/map_page';
Expand Down Expand Up @@ -181,7 +185,7 @@ export const mapEmbeddableFactory: EmbeddableFactory<MapEmbeddableState, MapApi>
...projectRoutingManager.api,
serializeState,
supportedTriggers: () => {
return [ON_APPLY_FILTER, ON_CLICK_VALUE];
return [ON_OPEN_PANEL_MENU, ON_APPLY_FILTER, ON_CLICK_VALUE];
},
});

Expand Down
Loading