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

Add standard modules filters management #6534

Merged
merged 44 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
786f4b3
Added useIndexPattern from AppState on discover component
Machi3mfl Feb 21, 2024
7edce86
Added factory, handler and data source class with unit tests
Machi3mfl Feb 29, 2024
082c9b3
Improved data source management
Machi3mfl Mar 1, 2024
c6a3981
Added classes and components to select pattern
Machi3mfl Mar 4, 2024
32368a2
Add select feature and unit tests
Machi3mfl Mar 6, 2024
38cb589
Added unit tests
Machi3mfl Mar 6, 2024
d1bcbd2
Change wz-pattern-selector props, data source like dependency
Machi3mfl Mar 11, 2024
14a5397
Merge branch '4.9.0' into feat/6434-handle-index-pattern-selector-dis…
Machi3mfl Mar 11, 2024
e674789
Update unit tests
Machi3mfl Mar 11, 2024
e4dfbd0
Merge branch '4.9.0' into feat/6434-handle-index-pattern-selector-dis…
Machi3mfl Mar 11, 2024
9393d8a
Fix data source selector import
Machi3mfl Mar 13, 2024
6366001
Update CHANGELOG
Machi3mfl Mar 13, 2024
4c92a17
Merge branch '4.9.0' into feat/6434-handle-index-pattern-selector-dis…
Machi3mfl Mar 19, 2024
4906af5
Adapting types in factory, repository and data source
Machi3mfl Mar 19, 2024
2ccbccc
Creating solution using data source in vulnerabilities
Machi3mfl Mar 19, 2024
d11cd35
Adding data source filter manager
Machi3mfl Mar 19, 2024
a4e1b65
Applying data source filter manager in dashboard and inventory
Machi3mfl Mar 19, 2024
4352d81
Created data source hook
Machi3mfl Mar 21, 2024
fc9dbcf
Using use data source hook on vuls inventory and dashboard tabs
Machi3mfl Mar 21, 2024
69b38b9
Merge branch '4.9.0' into feat/6499-standard-module-filters-management
Machi3mfl Mar 21, 2024
3cba1d1
Applied use data source
Machi3mfl Mar 21, 2024
77910bb
Applying in discover
Machi3mfl Mar 21, 2024
4d96a8e
Update data source types to simplify
Machi3mfl Mar 25, 2024
89a4274
Update data source selector component
Machi3mfl Mar 25, 2024
22d04fe
Update and clean types
Machi3mfl Mar 25, 2024
42cd72f
Fixed all vuls tabs with new typo
Machi3mfl Mar 26, 2024
72b04e1
Update data source with inner filter manager
Machi3mfl Mar 26, 2024
5af0f23
Implement in vulnerability detection tabs
Machi3mfl Mar 26, 2024
2ac433c
Fix unit tests
Machi3mfl Mar 27, 2024
3c7c259
Update use search bar hook props
Machi3mfl Mar 27, 2024
4a959f4
Apply hook on vuls tabs
Machi3mfl Mar 27, 2024
750cb88
Applied use data source in tabs and added hide remove filter button i…
Machi3mfl Mar 31, 2024
55687f2
Remove hide close filter button via js
Machi3mfl Mar 31, 2024
691b0d0
Add new controllerBy value to pinned agent
Machi3mfl Mar 31, 2024
c36af3f
Adapt use-search-bar to data source
Machi3mfl Mar 31, 2024
e5c9c2f
Fix unit tests
Machi3mfl Mar 31, 2024
dca123a
Merge branch '4.9.0' into feat/6499-standard-module-filters-management
Machi3mfl Mar 31, 2024
90f8335
Merge branch '4.9.0' into feat/6499-standard-module-filters-management
Machi3mfl Apr 3, 2024
c43ad2b
Fix error on merge 4.9.0
Machi3mfl Apr 3, 2024
1a34f33
Add hide remove filter in search bar
Machi3mfl Apr 3, 2024
fcd0ad5
Merge branch '4.9.0' into feat/6499-standard-module-filters-management
asteriscos Apr 4, 2024
009eece
Merge branch '4.9.0' into feat/6499-standard-module-filters-management
asteriscos Apr 4, 2024
904c03f
Remove unused code
Machi3mfl Apr 4, 2024
6198d11
Solve requested changes
Machi3mfl Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions plugins/main/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ export enum WAZUH_MENU_SETTINGS_SECTIONS_ID {
ABOUT = 'about',
}

export const AUTHORIZED_AGENTS = 'authorized-agents';
export const DATA_SOURCE_FILTER_CONTROLLED_EXCLUDE_SERVER = 'exclude-server';
export const AUTHORIZED_AGENTS = 'hidden-authorized-agents';
export const DATA_SOURCE_FILTER_CONTROLLED_EXCLUDE_SERVER = 'hidden-exclude-server';
export const DATA_SOURCE_FILTER_CONTROLLED_PINNED_AGENT = 'pinned-agent';
export const DATA_SOURCE_FILTER_CONTROLLED_CLUSTER_MANAGER = 'cluster-manager';
export const DATA_SOURCE_FILTER_CONTROLLED_VULNERABILITIES_RULE_GROUP = 'vulnerabilities-rule-group';

// Wazuh links
export const WAZUH_LINK_GITHUB = 'https://github.com/wazuh';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React from 'react';
import { useEffect, useState } from 'react';
import {
EuiFormRow,
EuiSelect,
} from '@elastic/eui';
import {
tDataSource,
tDataSourceSelector,
PatternDataSourceFactory,
PatternDataSource,
AlertsDataSourceRepository,
tParsedIndexPattern
} from '../../index';
import {
ErrorHandler,
ErrorFactory,
HttpError,
} from '../../../../../react-services/error-management';
import {
PatternDataSourceSelector,
} from '../../pattern/pattern-data-source-selector';

type tWzDataSourceSelector<T extends tParsedIndexPattern, K extends tDataSource> = {
name: 'string';
onChange?: (dataSource: T) => void;
dataSourceSelector?: tDataSourceSelector<K>;
}

const WzDataSourceSelector = (props: tWzDataSourceSelector<tParsedIndexPattern, PatternDataSource>) => {
const { onChange, name = 'data source', dataSourceSelector: defaultDataSourceSelector } = props;
const [dataSourceList, setDataSourceList] = useState<tDataSource[] | []>([]);
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
const [selectedPattern, setSelectedPattern] = useState<tDataSource>();
const [isLoading, setIsLoading] = useState(false);
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
const [dataSourceSelector, setDataSourceSelector] = useState<tDataSourceSelector<PatternDataSource> | undefined>(defaultDataSourceSelector);

useEffect(() => {
init();
}, [])

async function init() {
let selector;
let dataSources;
setIsLoading(true);
if(!dataSourceSelector){
const factory = new PatternDataSourceFactory();
const repository = new AlertsDataSourceRepository();
dataSources = await factory.createAll(PatternDataSource,await repository.getAll());
selector = new PatternDataSourceSelector(dataSources, repository);
setDataSourceSelector(selector);
}
const defaultIndexPattern = await selector.getSelectedDataSource();
dataSources = await selector.getAllDataSources();
setSelectedPattern(defaultIndexPattern);
setDataSourceList(dataSources);
setIsLoading(false);
}

async function selectDataSource(e) {
const dataSourceId = e.target.value;
if(!dataSourceSelector){
throw new Error('Data source selector not initialized');
};
try {
await dataSourceSelector.selectDataSource(dataSourceId);
const selected = await dataSourceSelector.getSelectedDataSource();
setSelectedPattern(await dataSourceSelector.getDataSource(dataSourceId));
onChange && onChange(selected.toJSON());
} catch (error) {
const searchError = ErrorFactory.create(HttpError, {
error,
message: `Error selecting the ${name.toLowerCase()} '${dataSourceId}`
});
ErrorHandler.handleError(searchError);
}
}

return (
<EuiFormRow>
<EuiSelect
options={dataSourceList.map((item) => {
return { value: item.id, text: item.title };
})}
value={selectedPattern?.id}
onChange={selectDataSource}
aria-label={name}
/>
</EuiFormRow>
);
}

export default WzDataSourceSelector;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './use-data-source';
Loading
Loading