-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution] Add Host/User flyout in One Discover. #199279
Merged
logeekal
merged 30 commits into
elastic:main
from
logeekal:feat/entity_flyout_discover_context_final
Nov 29, 2024
+728
−81
Merged
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ac84386
incremental app wrapper working
logeekal 3a46b0e
fix: user+host flyout
logeekal 2580c51
remove unnecessary change
logeekal 27ee1fc
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine fb53790
discover shared lazy modules
logeekal 8a385b6
fix: types
logeekal 0a7eaed
fix: better lazy loading and feature access
logeekal a57d5bf
fix: types
logeekal 6a8a7d9
createSecurityProfileProvider is not async
logeekal d9cd681
types: fix
logeekal f134206
fix: more types + some renames
logeekal 9a23ccc
fix: tests
logeekal 89b4dbb
pass security services correctly
logeekal b5392bf
Merge branch 'main' into feat/entity_flyout_discover_context_final
logeekal ab7a6ed
Merge branch 'main' into feat/entity_flyout_discover_context_final
logeekal cf289a4
fix: types
logeekal f7df1b0
PR feeback 1
logeekal f6fdc45
PR Feedback: discoverShared plugin
logeekal df8e005
fix: remove redux store init
logeekal 5824506
add isInSecurityApp hook
logeekal c4bece2
fix: discover tsconfig
logeekal 371c220
fix: correct security solution services in app wrapper
logeekal 9198449
Merge branch 'main' into feat/entity_flyout_discover_context_final
logeekal 4ef1600
Merge main → current branch
logeekal 4aaa456
fix: CellActionsContext + isTimeline
logeekal 7af2969
fix: PR feedback
logeekal cbbb094
fix: types
logeekal 652ba54
Merge branch 'main' into feat/entity_flyout_discover_context_final
logeekal 6ae2a61
fix: types
logeekal 5c42105
Merge branch 'main' into feat/entity_flyout_discover_context_final
logeekal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
...ublic/context_awareness/profile_providers/security/accessors/get_app_wrapper_accessor.tsx
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,17 @@ | ||
/* | ||
* 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 { SecuritySolutionAppWrapperFeature } from '@kbn/discover-shared-plugin/public'; | ||
|
||
export const createAppWrapperAccessor = async ( | ||
appWrapperFeature?: SecuritySolutionAppWrapperFeature | ||
) => { | ||
if (!appWrapperFeature) return undefined; | ||
return appWrapperFeature.getWrapper(); | ||
}; |
57 changes: 57 additions & 0 deletions
57
...ontext_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.test.tsx
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,57 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { SecuritySolutionCellRenderFeature } from '@kbn/discover-shared-plugin/public'; | ||
import { DataGridCellValueElementProps } from '@kbn/unified-data-table'; | ||
import { createCellRendererAccessor } from './get_cell_renderer_accessor'; | ||
import { render } from '@testing-library/react'; | ||
|
||
const cellRendererFeature: SecuritySolutionCellRenderFeature = { | ||
id: 'security-solution-cell-render', | ||
getRender: async () => (fieldName: string) => { | ||
if (fieldName === 'host.name') { | ||
return (props: DataGridCellValueElementProps) => { | ||
return <div data-test-subj="cell-render-feature">{props.columnId}</div>; | ||
}; | ||
} | ||
}, | ||
}; | ||
|
||
const mockCellProps = { | ||
columnId: 'host.name', | ||
row: { | ||
id: '1', | ||
raw: {}, | ||
flattened: {}, | ||
}, | ||
} as DataGridCellValueElementProps; | ||
|
||
describe('getCellRendererAccessort', () => { | ||
it('should return a cell renderer', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(cellRendererFeature); | ||
expect(getCellRenderer).toBeDefined(); | ||
const CellRenderer = getCellRenderer?.('host.name') as React.FC<DataGridCellValueElementProps>; | ||
expect(CellRenderer).toBeDefined(); | ||
const { getByTestId } = render(<CellRenderer {...mockCellProps} />); | ||
expect(getByTestId('cell-render-feature')).toBeVisible(); | ||
expect(getByTestId('cell-render-feature')).toHaveTextContent('host.name'); | ||
}); | ||
|
||
it('should return undefined if cellRendererFeature is not defined', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(); | ||
expect(getCellRenderer).toBeUndefined(); | ||
}); | ||
|
||
it('should return undefined if cellRendererGetter returns undefined', async () => { | ||
const getCellRenderer = await createCellRendererAccessor(cellRendererFeature); | ||
const cellRenderer = getCellRenderer?.('user.name'); | ||
expect(cellRenderer).toBeUndefined(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
...lic/context_awareness/profile_providers/security/accessors/get_cell_renderer_accessor.tsx
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", 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 React from 'react'; | ||
import { SecuritySolutionCellRenderFeature } from '@kbn/discover-shared-plugin/public'; | ||
import { DataGridCellValueElementProps } from '@kbn/unified-data-table'; | ||
|
||
export const createCellRendererAccessor = async ( | ||
cellRendererFeature?: SecuritySolutionCellRenderFeature | ||
) => { | ||
if (!cellRendererFeature) return undefined; | ||
const cellRendererGetter = await cellRendererFeature.getRender(); | ||
function getCellRenderer(fieldName: string) { | ||
if (!cellRendererFeature) return undefined; | ||
davismcphee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const CellRenderer = cellRendererGetter(fieldName); | ||
if (!CellRenderer) return undefined; | ||
return React.memo(function SecuritySolutionCellRenderer(props: DataGridCellValueElementProps) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I see where the |
||
return <CellRenderer {...props} />; | ||
}); | ||
} | ||
|
||
return getCellRenderer; | ||
}; |
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
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 |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
"kbn_references": [ | ||
"@kbn/discover-utils", | ||
"@kbn/core", | ||
"@kbn/unified-data-table", | ||
] | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elastic/kibana-data-discovery
Changed this to
FunctionComponent
because previous type does not accept memoized components.FunctionComponent
is more inclusive.Please let me know if you would keep this a function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see an issue with this, although we do already memoize cell renderers here, so it's likely not necessary to memoize again:
kibana/packages/kbn-unified-data-table/src/utils/get_render_cell_value.tsx
Line 166 in 7538565
If we make this change, it might even make sense to go all the way and just accept
ComponentType
, but not really a strong opinion.