Skip to content

Commit d4231ed

Browse files
dej611angorayc
authored andcommitted
[SecuritySolutions][Lens][Embeddable] Use the correct Lens typeguard for the new embeddable (elastic#204189)
## Summary Fixes elastic#180726 Use the new `isLensApi` helper in place of the previous system. Co-authored-by: Angela Chuang <[email protected]>
1 parent 82a4dff commit d4231ed

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

x-pack/solutions/security/plugins/security_solution/public/app/actions/copy_to_clipboard/lens/copy_to_clipboard.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import type { CellValueContext, IEmbeddable } from '@kbn/embeddable-plugin/publi
99
import { isErrorEmbeddable } from '@kbn/embeddable-plugin/public';
1010
import { createAction } from '@kbn/ui-actions-plugin/public';
1111
import copy from 'copy-to-clipboard';
12+
import { isLensApi } from '@kbn/lens-plugin/public';
1213
import { isInSecurityApp } from '../../../../common/hooks/is_in_security_app';
1314
import { KibanaServices } from '../../../../common/lib/kibana';
14-
import { fieldHasCellActions, isCountField, isLensEmbeddable } from '../../utils';
15+
import { fieldHasCellActions, isCountField } from '../../utils';
1516
import { COPY_TO_CLIPBOARD, COPY_TO_CLIPBOARD_ICON, COPY_TO_CLIPBOARD_SUCCESS } from '../constants';
1617

1718
export const ACTION_ID = 'embeddable_copyToClipboard';
@@ -39,7 +40,7 @@ export const createCopyToClipboardLensAction = ({ order }: { order?: number }) =
3940
getDisplayName: () => COPY_TO_CLIPBOARD,
4041
isCompatible: async ({ embeddable, data }) =>
4142
!isErrorEmbeddable(embeddable as IEmbeddable) &&
42-
isLensEmbeddable(embeddable as IEmbeddable) &&
43+
isLensApi(embeddable) &&
4344
isDataColumnsValid(data) &&
4445
isInSecurityApp(currentAppId),
4546
execute: async ({ data }) => {

x-pack/solutions/security/plugins/security_solution/public/app/actions/filter/lens/create_action.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import type { CellValueContext, IEmbeddable } from '@kbn/embeddable-plugin/publi
1616
import { createAction } from '@kbn/ui-actions-plugin/public';
1717
import { ACTION_INCOMPATIBLE_VALUE_WARNING } from '@kbn/cell-actions/src/actions/translations';
1818
import { i18n } from '@kbn/i18n';
19+
import { isLensApi } from '@kbn/lens-plugin/public';
1920
import { isInSecurityApp } from '../../../../common/hooks/is_in_security_app';
2021
import { timelineSelectors } from '../../../../timelines/store';
21-
import { fieldHasCellActions, isLensEmbeddable } from '../../utils';
22+
import { fieldHasCellActions } from '../../utils';
2223
import { TimelineId } from '../../../../../common/types';
2324
import { DefaultCellActionTypes } from '../../constants';
2425
import type { SecurityAppStore } from '../../../../common/store';
@@ -79,7 +80,7 @@ export const createFilterLensAction = ({
7980
type: DefaultCellActionTypes.FILTER,
8081
isCompatible: async ({ embeddable, data }) =>
8182
!isErrorEmbeddable(embeddable as IEmbeddable) &&
82-
isLensEmbeddable(embeddable as IEmbeddable) &&
83+
isLensApi(embeddable) &&
8384
isDataColumnsValid(data) &&
8485
isInSecurityApp(currentAppId),
8586
execute: async ({ data }) => {

x-pack/solutions/security/plugins/security_solution/public/app/actions/utils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
import type { IEmbeddable } from '@kbn/embeddable-plugin/public';
8-
import { isLensApi } from '@kbn/lens-plugin/public';
97
import type { Serializable } from '@kbn/utility-types';
108

119
// All cell actions are disabled for these fields in Security
@@ -16,12 +14,6 @@ const FIELDS_WITHOUT_CELL_ACTIONS = [
1614
'kibana.alert.reason',
1715
];
1816

19-
// @TODO: this is a temporary fix. It needs a better refactor on the consumer side here to
20-
// adapt to the new Embeddable architecture
21-
export const isLensEmbeddable = (embeddable: IEmbeddable): embeddable is IEmbeddable => {
22-
return isLensApi(embeddable);
23-
};
24-
2517
export const fieldHasCellActions = (field?: string): boolean => {
2618
return !!field && !FIELDS_WITHOUT_CELL_ACTIONS.includes(field);
2719
};

0 commit comments

Comments
 (0)