Skip to content
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

Refactor Asset Inventory to prepare for "grouping" feature #215963

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

albertoblaz
Copy link
Contributor

@albertoblaz albertoblaz commented Mar 25, 2025

Summary

Preparation work to close

PR followed up by:

The purpose of this PR is to split content (& complexity) between the top-level <AllAssets> and AssetInventoryDataTable that now only encapsulates all things table related. This comes in preparation for the upcoming grouping functionality where <AssetInventoryDataTable> will be replaced with <AssetInventoryTableSection>, which renders a recursive structure compounded by "groups" that end up rendering such data table.

On top of that, I've renamed the domain-specific components to start all with "AssetInventory" (equivalent kebab-case renaming with their file names). We're also reusing the same "Inventory" page title that Onboarding uses.

The outcome will be a much cleaner and predictable component tree similar to the diagram below:

Screenshot 2025-03-25 at 22 48 32

Checklist

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

No risk since feature is not publicly available yet.

@albertoblaz albertoblaz added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Cloud Security Cloud Security team related v9.1.0 labels Mar 25, 2025
@albertoblaz albertoblaz self-assigned this Mar 25, 2025
Copy link
Contributor Author

@albertoblaz albertoblaz left a comment

Choose a reason for hiding this comment

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

Notes for reviewers down below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted barrel file because it's irrelevant and also hurts performance

@@ -49,7 +46,6 @@ export const AssetInventorySearchBar = ({
showFilterBar={false}
showQueryInput={true}
showDatePicker={false}
isLoading={loading}
indexPatterns={[dataView]}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isLoading is removed because it's dummy in Unified Search. The component only waits for the data view object propagated via the indexPatterns array prop

defaultMessage="Inventory"
/>
<TechnicalPreviewBadge />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

<AssetInventoryTitle> is now the only title used both in <AllAssets> page and during the Onboarding phase.

It includes now the tech-preview badge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved useDataView outside of use_asset_inventory_url_state because it's a general-purpose hook that has nothing to do with the URL state management

@albertoblaz albertoblaz force-pushed the asset-inv-groupby-refactor branch from b63817a to 8b9b238 Compare March 25, 2025 23:43
@albertoblaz albertoblaz marked this pull request as ready for review March 25, 2025 23:45
@albertoblaz albertoblaz requested a review from a team as a code owner March 25, 2025 23:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 8.9MB 8.9MB -165.0B

cc @albertoblaz

Copy link
Contributor

@opauloh opauloh left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@JordanSh JordanSh left a comment

Choose a reason for hiding this comment

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

Thank you for this effort! 💪

@albertoblaz albertoblaz merged commit e7bc3b5 into elastic:main Mar 26, 2025
11 checks passed
@albertoblaz albertoblaz deleted the asset-inv-groupby-refactor branch March 26, 2025 15:29
albertoblaz added a commit that referenced this pull request Mar 31, 2025
## Summary

Closes #202092

Depends on:

- #213212
- #215963
- #216354

Add a "Group by" menu dropdown on the right side of the data grid to
render rows grouped recursively with a maximum of 3 group levels i.e.
entities grouped by type (1), category (2), risk(3). It supports
grouping by custom fields as in Findings.

Pagination state of each recursive group is kept locally, while the
top-level group's pagination is kept in the URL query-string. This is to
preserve consistency with the data-table's pagination state which is
also kept in the URL.

### Component hierarchy

<img width="1389" alt="Screenshot 2025-03-28 at 16 00 31"
src="https://github.com/user-attachments/assets/d4c30849-5d76-4589-867f-718847e11e8b"
/>

### Screenshots

<details><summary>TBD Menu Dropdown</summary>
</details> 

<details><summary>Group by none</summary>
<img width="1374" alt="Screenshot 2025-03-26 at 17 00 58"
src="https://github.com/user-attachments/assets/5b319f7b-d63a-4bce-bf24-15549cda254d"
/>
</details>

<details><summary>TBD Group by entity type</summary>
</details>

<details><summary>TBD Group by source</summary>
</details>

<details><summary>TBD Group by entity type, then source</summary>
</details>

<details><summary>TBD Group by source, then entity type</summary>
</details>

<details><summary>TBD Group by cloud account</summary>
</details>

<details><summary>Group by custom field (entity.id)</summary>
<img width="1348" alt="Screenshot 2025-03-26 at 17 02 45"
src="https://github.com/user-attachments/assets/46dc1f25-2bd4-4571-888d-5becf011b7c6"
/>
</details>

> [!IMPORTANT]
> We can't group by asset criticality at the moment because the field is
not present in the current dataset.

<details><summary>TBD Group by asset criticality</summary>
</details>

### Definition of done

- [x] Add a toggle to switch between **DataGrid** and **Group by View**
visualizations.
- [x] Implement the **Group by View** using the `@kbn/grouping` package
for consistency and reusability.
- [x] Provide a dropdown menu to select grouping fields, including:
(updated as per [this
epic](elastic/security-team#10344))
- ~~**Asset type (asset.type)**~~ -> **Asset criticality
(asset.criticality)**
- ~~**Asset category (asset.category)**~~ -> **Entity type
(entity.category)**
- ~~**Risk (host.risk.calculated_level)**~~ -> **Cloud account
(cloud.account.id)**
  - ~~**Criticality (asset.criticality)**~~ -> **Source (entity.type)**
- **Custom field**: Allow users to input/select a custom field for
grouping.
- [x] Display the following information for each group row:
  - The grouped term value.
  - The count of assets in that group.
- A button to expand the group and view the assets in a filtered
**DataGrid**.
- [x] Ensure group expansion dynamically displays assets in a DataGrid
filtered by the selected grouping field.
- [x] **Pagination**: Display 10 groups per page by default, with
pagination controls to navigate between pages.
- [x] **Rows per page dropdown**: Allow users to adjust the number of
groups displayed per page (options: 10, 25, 50, 100).

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Risks

No risk since code is still hidden behind the *Enable Asset Inventory*
advanced setting and the beta *Cloud Asset* integration must be
installed.

---------

Co-authored-by: kibanamachine <[email protected]>
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
…15963)

## Summary

Preparation work to close 
- elastic#202092.

PR followed up by:
- elastic#212955

The purpose of this PR is to split content (& complexity) between the
top-level `<AllAssets>` and `AssetInventoryDataTable` that now only
encapsulates all things table related. This comes in preparation for the
upcoming grouping functionality where `<AssetInventoryDataTable>` will
be replaced with `<AssetInventoryTableSection>`, which renders a
recursive structure compounded by "groups" that end up rendering such
data table.

On top of that, I've renamed the domain-specific components to start all
with "AssetInventory" (equivalent kebab-case renaming with their file
names). We're also reusing the same "Inventory" page title that
Onboarding uses.

The outcome will be a much cleaner and predictable component tree
similar to the diagram below:

<img width="842" alt="Screenshot 2025-03-25 at 22 48 32"
src="https://github.com/user-attachments/assets/c5fbe773-03a3-41f0-adc4-6d353cf3eb71"
/>

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

No risk since feature is not publicly available yet.
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
## Summary

Closes elastic#202092

Depends on:

- elastic#213212
- elastic#215963
- elastic#216354

Add a "Group by" menu dropdown on the right side of the data grid to
render rows grouped recursively with a maximum of 3 group levels i.e.
entities grouped by type (1), category (2), risk(3). It supports
grouping by custom fields as in Findings.

Pagination state of each recursive group is kept locally, while the
top-level group's pagination is kept in the URL query-string. This is to
preserve consistency with the data-table's pagination state which is
also kept in the URL.

### Component hierarchy

<img width="1389" alt="Screenshot 2025-03-28 at 16 00 31"
src="https://github.com/user-attachments/assets/d4c30849-5d76-4589-867f-718847e11e8b"
/>

### Screenshots

<details><summary>TBD Menu Dropdown</summary>
</details> 

<details><summary>Group by none</summary>
<img width="1374" alt="Screenshot 2025-03-26 at 17 00 58"
src="https://github.com/user-attachments/assets/5b319f7b-d63a-4bce-bf24-15549cda254d"
/>
</details>

<details><summary>TBD Group by entity type</summary>
</details>

<details><summary>TBD Group by source</summary>
</details>

<details><summary>TBD Group by entity type, then source</summary>
</details>

<details><summary>TBD Group by source, then entity type</summary>
</details>

<details><summary>TBD Group by cloud account</summary>
</details>

<details><summary>Group by custom field (entity.id)</summary>
<img width="1348" alt="Screenshot 2025-03-26 at 17 02 45"
src="https://github.com/user-attachments/assets/46dc1f25-2bd4-4571-888d-5becf011b7c6"
/>
</details>

> [!IMPORTANT]
> We can't group by asset criticality at the moment because the field is
not present in the current dataset.

<details><summary>TBD Group by asset criticality</summary>
</details>

### Definition of done

- [x] Add a toggle to switch between **DataGrid** and **Group by View**
visualizations.
- [x] Implement the **Group by View** using the `@kbn/grouping` package
for consistency and reusability.
- [x] Provide a dropdown menu to select grouping fields, including:
(updated as per [this
epic](elastic/security-team#10344))
- ~~**Asset type (asset.type)**~~ -> **Asset criticality
(asset.criticality)**
- ~~**Asset category (asset.category)**~~ -> **Entity type
(entity.category)**
- ~~**Risk (host.risk.calculated_level)**~~ -> **Cloud account
(cloud.account.id)**
  - ~~**Criticality (asset.criticality)**~~ -> **Source (entity.type)**
- **Custom field**: Allow users to input/select a custom field for
grouping.
- [x] Display the following information for each group row:
  - The grouped term value.
  - The count of assets in that group.
- A button to expand the group and view the assets in a filtered
**DataGrid**.
- [x] Ensure group expansion dynamically displays assets in a DataGrid
filtered by the selected grouping field.
- [x] **Pagination**: Display 10 groups per page by default, with
pagination controls to navigate between pages.
- [x] **Rows per page dropdown**: Allow users to adjust the number of
groups displayed per page (options: 10, 25, 50, 100).

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Risks

No risk since code is still hidden behind the *Enable Asset Inventory*
advanced setting and the beta *Cloud Asset* integration must be
installed.

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting refactoring release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants