forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] One Discover - Enable Security Solution Expandabl…
…e Flyout in One Discover entities (elastic#189633) >[!Note] > This Change is only applicable to Serverless Security Solution as of now. In follow-up PRs, support will be added to ESS as well based data-sources such as index or intergrations. ## Summary Resolves elastic#189151 This PR is foundation for the work described in elastic#186783. This just enables expandable flyout for entity details, which is currently only used in security solution, in discover as well. As a part of **One Discover** work, we need to make sure that cell rendering in Discover should behave exactly like it does in security solution. To enable this, a new `shared-browser` package `@kbn/security-solution-common` in `x-pack/packages/security-solution` has been created which can used to share components between `security solution` and `discover`. Below is the usage pattern ```mermaid flowchart TD disc-utils[@kbn/discover-utils] --> sscommon sscommon[@kbn/security-solution-common] --> ssplugin[security_solution] sscommon[@kbn/security-solution-common] --> discover[discover] disc-utils[@kbn/discover-utils] --> discover ``` ## Desk Testing Guide. 1. Enable Security profile in serverless by adding below to `kibana.yml` ```yaml discover.experimental.enabledProfiles: ['security-root-profile'] ``` 2. Load Some data 4. Navigate to discover and add `host.name` as one of the column. 5. Should open an expandable flyout as shown below. https://github.com/user-attachments/assets/92b84c89-8769-45dd-bf7e-a9fe527fdcf0 ## Code Review Guide Most of the changes in the PR are code-organization. There are NO changes in security solution but only the changes to import statements. You can focus regarding the changes in below packages: - x-pack/packages/security-solution/common - packages/kbn-discover-utils - packages/kbn-expandable-flyout --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
5075b04
commit 9293bc1
Showing
160 changed files
with
966 additions
and
317 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/kbn-discover-utils/src/utils/get_field_value.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { DataTableRecord } from '../types'; | ||
import { getFieldValue } from './get_field_value'; | ||
|
||
const dataTableRecord: DataTableRecord = { | ||
id: '1', | ||
raw: {}, | ||
flattened: { | ||
'field1.value': 'value1', | ||
'field2.value': ['value2'], | ||
}, | ||
}; | ||
|
||
describe('getFieldValue', () => { | ||
it('should return the value of field correctly', () => { | ||
expect(getFieldValue(dataTableRecord, 'field1.value')).toBe('value1'); | ||
}); | ||
|
||
it('should return the first value of field correctly if field has a value of Array type', () => { | ||
expect(getFieldValue(dataTableRecord, 'field2.value')).toBe('value2'); | ||
}); | ||
|
||
it('should return undefined when field is not available', () => { | ||
expect(getFieldValue(dataTableRecord, 'field3.value')).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { DataTableRecord } from '../types'; | ||
|
||
export const getFieldValue = (record: DataTableRecord, field: string) => { | ||
const value = record.flattened[field]; | ||
return Array.isArray(value) ? value[0] : value; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
export const useExpandableFlyoutApi = jest.fn(() => ({ | ||
openFlyout: jest.fn(), | ||
closeFlyout: jest.fn(), | ||
openPanels: jest.fn(), | ||
openRightPanel: jest.fn(), | ||
openLeftPanel: jest.fn(), | ||
openPreviewPanel: jest.fn(), | ||
closeRightPanel: jest.fn(), | ||
closeLeftPanel: jest.fn(), | ||
closePreviewPanel: jest.fn(), | ||
closePanels: jest.fn(), | ||
previousPreviewPanel: jest.fn(), | ||
})); | ||
|
||
export const useExpandableFlyoutState = jest.fn(); | ||
|
||
export const ExpandableFlyoutProvider = jest.fn(({ children }: React.PropsWithChildren<{}>) => { | ||
return <>{children}</>; | ||
}); | ||
|
||
export const withExpandableFlyoutProvider = <T extends object>( | ||
Component: React.ComponentType<T> | ||
) => { | ||
return (props: T) => { | ||
return <Component {...props} />; | ||
}; | ||
}; | ||
|
||
export const ExpandableFlyout = jest.fn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* 2.0 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { render } from '@testing-library/react'; | ||
import { useExpandableFlyoutApi } from './hooks/use_expandable_flyout_api'; | ||
import React from 'react'; | ||
import { withExpandableFlyoutProvider } from './with_provider'; | ||
|
||
const TestComponent = () => { | ||
useExpandableFlyoutApi(); | ||
|
||
return <div data-test-subj="test-comp" />; | ||
}; | ||
|
||
describe('withExpandableFlyoutProvider', () => { | ||
it('should throw when rendered without Expandable Provider', () => { | ||
expect(() => render(<TestComponent />)).toThrow(); | ||
}); | ||
|
||
it('should not throw when rendered with Expandable Provider', () => { | ||
const TestComponentWithProvider = withExpandableFlyoutProvider(TestComponent); | ||
expect(() => render(<TestComponentWithProvider />)).not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ComponentType } from 'react'; | ||
import { ExpandableFlyoutContextProviderProps } from './context'; | ||
import { ExpandableFlyoutProvider } from './provider'; | ||
|
||
export const withExpandableFlyoutProvider = <Props extends {}>( | ||
Component: ComponentType<Props>, | ||
expandableProviderProps?: ExpandableFlyoutContextProviderProps | ||
) => { | ||
return (props: Props) => { | ||
return ( | ||
<ExpandableFlyoutProvider {...(expandableProviderProps ?? {})}> | ||
<Component {...props} /> | ||
</ExpandableFlyoutProvider> | ||
); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.