Skip to content

Commit d99ab90

Browse files
authored
Merge branch '4.9.0' into fix/6693-cannot-perform-a-react-state-update-on-an-unmounted-component
2 parents 63b284f + c921f7e commit d99ab90

File tree

12 files changed

+158
-146
lines changed

12 files changed

+158
-146
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ All notable changes to the Wazuh app project will be documented in this file.
2121

2222
### Changed
2323

24-
- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691)
24+
- Removed embedded discover [#6120](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6120) [#6235](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6235) [#6254](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6254) [#6285](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6285) [#6288](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6288) [#6290](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6290) [#6289](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6289) [#6286](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6286) [#6275](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6275) [#6287](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6297](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6297) [#6291](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6287) [#6459](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6459) [#6434](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6434) [#6504](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6504) [#6649](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6649) [#6506](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6506) [#6537](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6537) [#6528](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6528) [#6675](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6675) [#6674](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6674) [#6558](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6558) [#6685](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6685) [#6691](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6691)
2525
- Develop logic of a new index for the fim module [#6227](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6227)
2626
- Allow editing groups for an agent from Endpoints Summary [#6250](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6250)
2727
- Change how the configuration is managed in the backend side [#6337](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6337) [#6519](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6519) [#6573](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6573)

plugins/main/public/components/agents/prompts/prompt-select-agent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const PromptSelectAgent = ({ body, title }: PromptSelectAgentProps) => {
2727
<EuiEmptyPrompt
2828
iconType='watchesApp'
2929
title={<h2>{title}</h2>}
30-
body={body && <p>{body}</p>}
30+
body={body && <>{body}</>}
3131
actions={
3232
<EuiButton color='primary' fill onClick={openAgentSelector}>
3333
Select agent

plugins/main/public/components/common/data-source/hooks/use-data-source.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,25 @@ export function useDataSource<
140140

141141
useEffect(() => {
142142
if (dataSourceFilterManager && dataSource) {
143-
const filteredPinnedAgent = dataSourceFilterManager
144-
.getFilters()
145-
.filter(
146-
(filter: tFilter) =>
147-
filter.meta.controlledBy !==
148-
PinnedAgentManager.FILTER_CONTROLLED_PINNED_AGENT_KEY,
149-
);
150143
if (pinnedAgentManager.isPinnedAgent()) {
151144
const pinnedAgent = PatternDataSourceFilterManager.getPinnedAgentFilter(
152145
dataSource.id,
153146
);
154147

155-
dataSourceFilterManager.setFilters([
156-
...filteredPinnedAgent,
157-
...pinnedAgent,
158-
]);
148+
dataSourceFilterManager.addFilters([...pinnedAgent]);
159149
} else {
160-
dataSourceFilterManager.setFilters([...filteredPinnedAgent]);
150+
const pinnedAgentFilter = dataSourceFilterManager
151+
.getFilters()
152+
.filter(
153+
(filter: tFilter) =>
154+
filter.meta.controlledBy ===
155+
PinnedAgentManager.FILTER_CONTROLLED_PINNED_AGENT_KEY,
156+
);
157+
158+
if(pinnedAgentFilter.length){
159+
dataSourceFilterManager.removeFilter(pinnedAgentFilter[0])
160+
}
161+
161162
}
162163
}
163164
}, [JSON.stringify(pinnedAgent)]);

plugins/main/public/components/common/data-source/pattern/pattern-data-source-filter-manager.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ export class PatternDataSourceFilterManager
198198
);
199199
}
200200

201+
addFilters(filter: tFilter) {
202+
this.filterManager.addFilters(filter);
203+
}
204+
205+
removeAll() {
206+
this.filterManager.setFilters([]);
207+
}
208+
201209
/**
202210
* Concatenate the filters to fetch the data from the data source
203211
* @returns
@@ -217,24 +225,16 @@ export class PatternDataSourceFilterManager
217225
* @returns
218226
*/
219227
createFilter(field: string, value: string): tFilter {
220-
return this.generateFilter(field, value, this.dataSource.id);
228+
return this.generateFilter(field, value, this.dataSource.id) as tFilter;
221229
}
222230

223231
/**
224232
* Search the the field and value received and remove the filter when exists
225233
* @param field
226234
* @param value
227235
*/
228-
removeFilter(field: string, value: string): void {
229-
let filters = this.filterManager.getFilters();
230-
const filterIndex = filters.findIndex(
231-
f => f.meta?.key === field && f.meta?.value === value,
232-
);
233-
// only remove when exists the filter
234-
if (filterIndex > -1) {
235-
filters.splice(filterIndex, 1);
236-
this.setFilters(filters);
237-
}
236+
removeFilter(filter: tFilter): void {
237+
this.filterManager.removeFilter(filter);
238238
}
239239

240240
/**
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
import { PatternDataSourceRepository } from '../pattern-data-source-repository';
2-
import { tDataSource, tParsedIndexPattern } from '../../index'
3-
2+
import { tDataSource, tParsedIndexPattern } from '../../index';
43

54
export class VulnerabilitiesDataSourceRepository extends PatternDataSourceRepository {
6-
constructor() {
7-
super();
8-
}
9-
10-
async get(id: string) {
11-
const dataSource = await super.get(id);
12-
if (this.validate(dataSource)) {
13-
return dataSource;
14-
} else {
15-
throw new Error('Vulnerabilities index pattern not found');
16-
}
17-
}
5+
constructor() {
6+
super();
7+
}
188

19-
async getAll() {
20-
const indexs = await super.getAll();
21-
return indexs.filter(this.validate);
22-
}
23-
24-
validate(dataSource): boolean {
25-
// check if the dataSource has the id or the title have the vulnerabilities word
26-
const fieldsToCheck = ['id', 'attributes.title'];
27-
// must check in the object and the attributes
28-
for (const field of fieldsToCheck) {
29-
if (dataSource[field] && dataSource[field].toLowerCase().includes('vulnerabilities')) {
30-
return true;
31-
}
32-
}
33-
return false;
9+
async get(id: string) {
10+
const dataSource = await super.get(id);
11+
if (this.validate(dataSource)) {
12+
return dataSource;
13+
} else {
14+
throw new Error('Vulnerabilities index pattern not found');
3415
}
16+
}
3517

36-
getDefault(){
37-
console.warn('getDefault not implemented for vulnerabilities data source repository');
38-
return Promise.resolve(null);
39-
}
18+
async getAll() {
19+
const indexs = await super.getAll();
20+
return indexs.filter(this.validate);
21+
}
4022

41-
setDefault(dataSource: tParsedIndexPattern){
42-
console.warn('setDefault not implemented for vulnerabilities data source repository');
43-
return;
23+
validate(dataSource): boolean {
24+
// check if the dataSource has the id or the title have the vulnerabilities word
25+
const fieldsToCheck = ['id', 'attributes.title'];
26+
// must check in the object and the attributes
27+
for (const field of fieldsToCheck) {
28+
if (
29+
dataSource[field] &&
30+
dataSource[field].toLowerCase().includes('vulnerabilities')
31+
) {
32+
return true;
33+
}
4434
}
35+
return false;
36+
}
37+
38+
getDefault() {
39+
return Promise.resolve(null);
40+
}
4541

46-
}
42+
setDefault(dataSource: tParsedIndexPattern) {
43+
return;
44+
}
45+
}
Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,81 @@
1-
import { Filter } from "../../../../../../src/plugins/data/common";
2-
import { FilterManager } from "../../../../../../src/plugins/data/public";
1+
import { Filter } from '../../../../../../src/plugins/data/common';
2+
import { FilterManager } from '../../../../../../src/plugins/data/public';
33

44
export type tSearchParams = {
5-
filters?: Filter[];
6-
query?: any;
7-
pagination?: {
8-
pageIndex?: number;
9-
pageSize?: number;
10-
};
11-
fields?: string[],
12-
sorting?: {
13-
columns: {
14-
id: string;
15-
direction: 'asc' | 'desc';
16-
}[];
17-
};
18-
dateRange?: {
19-
from: string;
20-
to: string;
21-
};
22-
aggs?: any;
23-
}
5+
filters?: Filter[];
6+
query?: any;
7+
pagination?: {
8+
pageIndex?: number;
9+
pageSize?: number;
10+
};
11+
fields?: string[];
12+
sorting?: {
13+
columns: {
14+
id: string;
15+
direction: 'asc' | 'desc';
16+
}[];
17+
};
18+
dateRange?: {
19+
from: string;
20+
to: string;
21+
};
22+
aggs?: any;
23+
};
2424

2525
export type tFilter = Filter;
2626

2727
// create a new type using the FilterManager type but only the getFilters, setFilters, addFilters, getUpdates$
28-
export type tFilterManager = Pick<FilterManager, 'getFilters' | 'setFilters' | 'addFilters' | 'getUpdates$'>;
28+
export type tFilterManager = Pick<
29+
FilterManager,
30+
'getFilters' | 'setFilters' | 'addFilters' | 'getUpdates$' | 'removeFilter'
31+
>;
2932

3033
export type tDataSource = {
31-
id: string;
32-
title: string;
33-
select(): Promise<void>;
34-
getFields(): any[];
35-
getFixedFilters: () => tFilter[];
36-
getFetchFilters: () => tFilter[];
37-
fetch: (params: tSearchParams) => Promise<any>;
38-
toJSON(): object;
39-
}
34+
id: string;
35+
title: string;
36+
select(): Promise<void>;
37+
getFields(): any[];
38+
getFixedFilters: () => tFilter[];
39+
getFetchFilters: () => tFilter[];
40+
fetch: (params: tSearchParams) => Promise<any>;
41+
toJSON(): object;
42+
};
4043

4144
export interface IDataSourceFactoryConstructor<T extends tDataSource> {
42-
new(id: T['id'], title: T['title']): T;
45+
new (id: T['id'], title: T['title']): T;
4346
}
4447

4548
export type tDataSourceFactory<T extends object, K extends tDataSource> = {
46-
create: (DataSourceType: IDataSourceFactoryConstructor<K>, data: T) => Promise<K>;
47-
createAll: (DataSourceType: IDataSourceFactoryConstructor<K>, data: T[]) => Promise<K[]>;
48-
}
49+
create: (
50+
DataSourceType: IDataSourceFactoryConstructor<K>,
51+
data: T,
52+
) => Promise<K>;
53+
createAll: (
54+
DataSourceType: IDataSourceFactoryConstructor<K>,
55+
data: T[],
56+
) => Promise<K[]>;
57+
};
4958

5059
export type tDataSourceFilterManager = {
51-
fetch: () => Promise<any>;
52-
setFilters: (filters: tFilter[]) => void;
53-
getFilters: () => tFilter[];
54-
getFixedFilters: () => tFilter[];
55-
getFetchFilters: () => tFilter[];
56-
}
60+
fetch: () => Promise<any>;
61+
setFilters: (filters: tFilter[]) => void;
62+
getFilters: () => tFilter[];
63+
getFixedFilters: () => tFilter[];
64+
getFetchFilters: () => tFilter[];
65+
};
5766

5867
export type tDataSourceRepository<T extends object> = {
59-
get(id: string): Promise<T>;
60-
getAll(): Promise<T[]>;
61-
setDefault(dataSourceData: T): void;
62-
getDefault(): Promise<T | null>;
63-
}
64-
68+
get(id: string): Promise<T>;
69+
getAll(): Promise<T[]>;
70+
setDefault(dataSourceData: T): void;
71+
getDefault(): Promise<T | null>;
72+
};
6573

6674
export type tDataSourceSelector<T extends tDataSource> = {
67-
existsDataSource: (id: string) => Promise<boolean>;
68-
getFirstValidDataSource: () => Promise<T>;
69-
getAllDataSources: () => Promise<T[]>;
70-
getDataSource: (id: string) => Promise<T>;
71-
getSelectedDataSource: () => Promise<T>;
72-
selectDataSource: (id: string) => Promise<void>;
73-
}
75+
existsDataSource: (id: string) => Promise<boolean>;
76+
getFirstValidDataSource: () => Promise<T>;
77+
getAllDataSources: () => Promise<T[]>;
78+
getDataSource: (id: string) => Promise<T>;
79+
getSelectedDataSource: () => Promise<T>;
80+
selectDataSource: (id: string) => Promise<void>;
81+
};

plugins/main/public/components/common/search-bar/search-bar-service.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,24 @@ export const hideCloseButtonOnFixedFilters = (
178178
filter?.value === filterValue &&
179179
filter?.index === index,
180180
);
181+
const removeButton = element.querySelector('.euiBadge__iconButton');
182+
const badgeButton = element.querySelector(
183+
'.euiBadge__content .euiBadge__childButton',
184+
) as HTMLElement;
181185
if (filter) {
182-
// hide the remove button
183-
const iconButton = element.querySelector(
184-
'.euiBadge__iconButton',
185-
) as HTMLElement;
186-
iconButton?.style?.setProperty('display', 'none');
187-
// change the cursor to not-allowed
188-
const badgeButton = element.querySelector(
189-
'.euiBadge__content .euiBadge__childButton',
190-
) as HTMLElement;
191-
badgeButton?.style?.setProperty('cursor', 'not-allowed');
192-
// remove the popup on click to prevent the filter from being removed
193-
element.addEventListener('click', event => {
194-
event.preventDefault();
195-
event.stopPropagation();
186+
$(removeButton).addClass('hide-close-button');
187+
$(removeButton).on('click', ev => {
188+
ev.stopPropagation();
196189
});
190+
$(badgeButton).on('click', ev => {
191+
ev.stopPropagation();
192+
});
193+
$(badgeButton).css('cursor', 'not-allowed');
194+
} else {
195+
$(removeButton).removeClass('hide-close-button');
196+
$(removeButton).off('click');
197+
$(badgeButton).off('click');
198+
$(badgeButton).css('cursor', 'pointer');
197199
}
198200
});
199201
};

plugins/main/public/components/common/search-bar/use-search-bar.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,27 @@ const useSearchBarConfiguration = (
5858
useState<IndexPattern>(indexPattern);
5959
const TIMEOUT_MILISECONDS = 100;
6060

61-
const hideRemoveFilter = (retry: number = 0) => {
61+
const hideRemoveFilter = (filters, retry: number = 0) => {
62+
const allFilters = filters;
6263
let elements = document.querySelectorAll(
6364
'.wz-search-bar .globalFilterItem',
6465
);
65-
if ((!elements || !filters.length) && retry < 10) {
66+
// when the filters are not empty in DOM and the length is equal to the filters length
67+
if (elements.length > 0 && elements.length === allFilters.length) {
68+
hideCloseButtonOnFixedFilters(allFilters, elements);
69+
} else if (retry < 10) {
6670
// the setTimeout is used to wait for the DOM elements to be rendered
6771
setTimeout(() => {
6872
// this is a workaround to hide the close button on fixed filters via vanilla js
69-
hideRemoveFilter(++retry);
73+
hideRemoveFilter(allFilters, ++retry);
7074
}, TIMEOUT_MILISECONDS);
71-
} else {
72-
hideCloseButtonOnFixedFilters(filters, elements);
7375
}
7476
};
7577

7678
useLayoutEffect(() => {
7779
setTimeout(() => {
7880
// this is a workaround to hide the close button on fixed filters via vanilla js
79-
hideRemoveFilter();
81+
hideRemoveFilter(filters);
8082
}, TIMEOUT_MILISECONDS);
8183
}, [filters]);
8284

0 commit comments

Comments
 (0)