wazuh-dashboard-plugins icon indicating copy to clipboard operation
wazuh-dashboard-plugins copied to clipboard

[Remove discover] Handle index pattern selected on discover

Open Machi3mfl opened this issue 1 year ago • 2 comments

Description

Make the search bar use the index selected in the index pattern selector.

Screenshot 2024-02-20 at 12 39 23

Preconditions

The user must add a custom index pattern in the App Settings > Index pattern section

Screenshot 2024-02-20 at 12 40 24

That will show the index pattern selector in the header.

Uses cases

  • When the user selects the index pattern using the selector. The discover (events tab) must use the selected index pattern.

Discover

  • When the discover component receives a default index pattern like prop. The discover must use it (The component has to receive the default index pattern with an IndexPattern type)
  • When the discover component does not receive a default index pattern like prop the component must get the current index pattern from the AppState.

before

type WazuhDiscoverProps {
  indexPatternName: string
  tableColumns: tDataGridColumn
}

after

type WazuhDiscoverProps {
  indexPatternName: IndexPattern
  tableColumns: tDataGridColumn
}

Tasks

  • [x] Research about index pattern selector feature
  • [ ] Create a generic index pattern selector component

Machi3mfl avatar Feb 20 '24 15:02 Machi3mfl

Error use case

When the index pattern doesn't find indices by the pattern ID the index pattern doesn't change and maintains the current selection.

Screenshot 2024-02-21 at 15 48 29

Solution

Change the error message and make it more clear explaining the problem. Like OSD does in the Dashboard Management > Index pattern section

Screenshot 2024-02-22 at 11 57 52

Machi3mfl avatar Feb 23 '24 13:02 Machi3mfl

Current use case

  • Get the list of index patterns
  • Validate index patterns
  • Select an index pattern

Tasks

  • [x] Create a generic artifact to manage the different data sources separating them by domain
    • For instance: Have a data source that has the responsibility to manage the index patterns
  • [x] Create unit tests for all classes, components, etc
Screenshot 2024-03-11 at 17 38 37

Proposed solution

sequenceDiagram
    participant DataSourceFactory
    participant DataSourceHandler
    participant DataSourceInstance
    DataSourceFactory->>DataSourceHandler: the factory is received by the handler using a dependency injection 
    DataSourceHandler->>DataSourceInstance: the handler can return the list of data sources created by the factory

In this way, we can create different types of data sources, and each is responsible for itself

Machi3mfl avatar Feb 29 '24 21:02 Machi3mfl

Pending tasks

  • [ ] Update documentation in the previous comment
  • [ ] Add wz-data-source-selector unit test

Machi3mfl avatar Mar 11 '24 21:03 Machi3mfl