diff --git a/CHANGELOG.md b/CHANGELOG.md index 642b2bb228..ee09984e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ All notable changes to the Wazuh app project will be documented in this file. - Support for Wazuh 4.8.1 +### Fixed + +- Fixed home KPI links with custom or index pattern whose title is different to the id [#6777](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6777) + ## Wazuh v4.8.0 - OpenSearch Dashboards 2.10.0 - Revision 12 ### Added diff --git a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts index 693641ed99..c1b74c3919 100644 --- a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts +++ b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-service.ts @@ -10,7 +10,7 @@ interface Last24HoursAlerts { field: string; name: string; }; - indexPatternName: string; + indexPatternId: string; } /** @@ -44,7 +44,7 @@ export const getLast24HoursAlerts = async ( field: isCluster ? 'cluster.name' : 'manager.name', name: clusterValue, }, - indexPatternName: currentIndexPattern.title, + indexPatternId: currentIndexPattern.id, }; } catch (error) { return Promise.reject(error); diff --git a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx index 6deceb47f4..be1296e816 100644 --- a/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx +++ b/plugins/main/public/controllers/overview/components/last-alerts-stat/last-alerts-stat.tsx @@ -56,7 +56,7 @@ export function LastAlertsStat({ severity }: { severity: string }) { useEffect(() => { const getCountLastAlerts = async () => { try { - const { indexPatternName, cluster, count } = await getLast24HoursAlerts( + const { indexPatternId, cluster, count } = await getLast24HoursAlerts( severityLabel[severity].ruleLevelRange, ); setCountLastAlerts(count); @@ -81,13 +81,13 @@ export function LastAlertsStat({ severity }: { severity: string }) { const destURL = core.application.getUrlForApp(discoverLocation.app, { path: `${ discoverLocation.basePath - }#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternName}',view:discover))&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternName}',key:${ + }#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${indexPatternId}',view:discover))&_g=(filters:!(('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternId}',key:${ cluster.field },negate:!f,params:(query:${ cluster.name }),type:phrase),query:(match_phrase:(${cluster.field}:${ cluster.name - }))),('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'wazuh-alerts-*',key:rule.level,negate:!f,params:(gte:${ + }))),('$state':(store:globalState),meta:(alias:!n,disabled:!f,index:'${indexPatternId}',key:rule.level,negate:!f,params:(gte:${ severityLabel[severity].ruleLevelRange.minRuleLevel },lte:${ severityLabel[severity].ruleLevelRange.maxRuleLevel || '!n' diff --git a/plugins/main/public/controllers/overview/components/stats.test.tsx b/plugins/main/public/controllers/overview/components/stats.test.tsx index 1b794f8842..0e03c26535 100644 --- a/plugins/main/public/controllers/overview/components/stats.test.tsx +++ b/plugins/main/public/controllers/overview/components/stats.test.tsx @@ -24,7 +24,7 @@ jest.mock( }), ); -jest.mock('react-use/lib/useObservable', () => () => { }); +jest.mock('react-use/lib/useObservable', () => () => {}); jest.mock('./last-alerts-stat/last-alerts-service', () => ({ getLast24HoursAlerts: jest.fn().mockReturnValue({ count: 100, @@ -32,7 +32,7 @@ jest.mock('./last-alerts-stat/last-alerts-service', () => ({ field: 'cluster.name', name: 'master', }, - indexPatternName: 'wazuh-alerts-*', + indexPatternId: 'wazuh-alerts-*', }), })); @@ -43,14 +43,14 @@ jest.mock('../../../kibana-services', () => ({ getUrlForApp: () => 'http://url', }, uiSettings: { - get: () => true - } + get: () => true, + }, }), })); jest.mock('../../../react-services/common-services', () => ({ getErrorOrchestrator: () => ({ - handleError: options => { }, + handleError: options => {}, }), }));