From 5c7d36298a056986481fa49feb355fb8e6d0918a Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Mon, 30 Sep 2024 08:26:59 -0300
Subject: [PATCH 1/7] Remove font-size property from welcome.scss
---
plugins/main/public/components/common/welcome/welcome.scss | 1 -
1 file changed, 1 deletion(-)
diff --git a/plugins/main/public/components/common/welcome/welcome.scss b/plugins/main/public/components/common/welcome/welcome.scss
index 9058ab441c..0ce9e18dda 100644
--- a/plugins/main/public/components/common/welcome/welcome.scss
+++ b/plugins/main/public/components/common/welcome/welcome.scss
@@ -6,7 +6,6 @@
.wz-welcome-page .euiCard .euiText,
.wz-module-body .euiCard .euiText {
- font-size: 12px;
font-family: sans-serif;
}
From 4811fce69f69d322bf2f79786d40aab481c90c97 Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Mon, 30 Sep 2024 08:27:07 -0300
Subject: [PATCH 2/7] Refactor LastAlertsStat component for readability
---
.../last-alerts-stat/last-alerts-stat.tsx | 61 ++++++++++---------
1 file changed, 32 insertions(+), 29 deletions(-)
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 e1113790d5..f9e905eed9 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
@@ -1,26 +1,28 @@
-import React, { useState, useEffect } from 'react';
import {
- EuiStat,
EuiFlexItem,
EuiLink,
- EuiToolTip,
+ EuiStat,
EuiText,
+ EuiToolTip,
} from '@elastic/eui';
-import { getLast24HoursAlerts } from './last-alerts-service';
+import { useEffect, useState } from 'react';
+import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
import { UI_COLOR_STATUS } from '../../../../../common/constants';
+import {
+ FILTER_OPERATOR,
+ PatternDataSourceFilterManager,
+} from '../../../../components/common/data-source/pattern/pattern-data-source-filter-manager';
import { getCore } from '../../../../kibana-services';
-import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
import {
- ErrorHandler,
ErrorFactory,
+ ErrorHandler,
HttpError,
} from '../../../../react-services/error-management';
-import {
- FILTER_OPERATOR,
- PatternDataSourceFilterManager,
-} from '../../../../components/common/data-source/pattern/pattern-data-source-filter-manager';
+import { getLast24HoursAlerts } from './last-alerts-service';
-export function LastAlertsStat({ severity }: { severity: string }) {
+type SeverityLevelKey = 'low' | 'medium' | 'high' | 'critical';
+
+export function LastAlertsStat({ severity }: { severity: SeverityLevelKey }) {
const [countLastAlerts, setCountLastAlerts] = useState(null);
const [discoverLocation, setDiscoverLocation] = useState('');
const severityLabel = {
@@ -53,15 +55,20 @@ export function LastAlertsStat({ severity }: { severity: string }) {
color: UI_COLOR_STATUS.danger,
ruleLevelRange: {
minRuleLevel: 15,
+ maxRuleLevel: undefined,
},
},
- };
+ } as const;
+
+ const ruleLevelRange = severityLabel[severity].ruleLevelRange;
+ const maxRuleLevel = ruleLevelRange.maxRuleLevel;
+ const minRuleLevel = ruleLevelRange.minRuleLevel;
useEffect(() => {
const getCountLastAlerts = async () => {
try {
const { indexPatternId, cluster, count } = await getLast24HoursAlerts(
- severityLabel[severity].ruleLevelRange,
+ ruleLevelRange,
);
setCountLastAlerts(count);
const core = getCore();
@@ -82,10 +89,7 @@ export function LastAlertsStat({ severity }: { severity: string }) {
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS_BETWEEN,
'rule.level',
- [
- severityLabel[severity].ruleLevelRange.minRuleLevel,
- severityLabel[severity].ruleLevelRange.maxRuleLevel,
- ],
+ [minRuleLevel, maxRuleLevel],
indexPatternId,
);
const predefinedFilters =
@@ -117,13 +121,9 @@ export function LastAlertsStat({ severity }: { severity: string }) {
-
+
{'Rule level ' +
- severityLabel[severity].ruleLevelRange.minRuleLevel +
- (severityLabel[severity].ruleLevelRange.maxRuleLevel
- ? ' to ' + severityLabel[severity].ruleLevelRange.maxRuleLevel
- : ' or higher')}
+ minRuleLevel +
+ (maxRuleLevel ? ' to ' + maxRuleLevel : ' or higher')}
From 9192941d7e0b9b8695024f87203a678286698e0f Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Tue, 1 Oct 2024 10:35:49 -0300
Subject: [PATCH 3/7] Fix Merge Conflict
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa376214f9..70eb276317 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Changed the registration id of the Settings application for compatibility with OpenSearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938)
- Changed Malware detection dashboard visualizations [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964)
- Changed malware feature description [#7036](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7036)
+- Changed the font size of the kpi subtitles and the features descriptions [#7027](https://github.com/wazuh/wazuh-dashboard-plugins/issues/7027)
### Fixed
From ec815c76294f6494d90a0bd64a0219f738ff21f3 Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Mon, 30 Sep 2024 10:10:16 -0300
Subject: [PATCH 4/7] Refactor LastAlertsStat component and severities object
---
.../last-alerts-stat/last-alerts-stat.tsx | 128 +++++++++---------
1 file changed, 66 insertions(+), 62 deletions(-)
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 f9e905eed9..c8d251dfab 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
@@ -1,68 +1,72 @@
+import React, { useState, useEffect } from 'react';
import {
+ EuiStat,
EuiFlexItem,
EuiLink,
- EuiStat,
- EuiText,
EuiToolTip,
+ EuiText,
} from '@elastic/eui';
-import { useEffect, useState } from 'react';
-import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
+import { getLast24HoursAlerts } from './last-alerts-service';
import { UI_COLOR_STATUS } from '../../../../../common/constants';
-import {
- FILTER_OPERATOR,
- PatternDataSourceFilterManager,
-} from '../../../../components/common/data-source/pattern/pattern-data-source-filter-manager';
import { getCore } from '../../../../kibana-services';
+import { RedirectAppLinks } from '../../../../../../../src/plugins/opensearch_dashboards_react/public';
import {
- ErrorFactory,
ErrorHandler,
+ ErrorFactory,
HttpError,
} from '../../../../react-services/error-management';
-import { getLast24HoursAlerts } from './last-alerts-service';
+import {
+ FILTER_OPERATOR,
+ PatternDataSourceFilterManager,
+} from '../../../../components/common/data-source/pattern/pattern-data-source-filter-manager';
-type SeverityLevelKey = 'low' | 'medium' | 'high' | 'critical';
+type SeverityKey = 'low' | 'medium' | 'high' | 'critical';
-export function LastAlertsStat({ severity }: { severity: SeverityLevelKey }) {
- const [countLastAlerts, setCountLastAlerts] = useState(null);
- const [discoverLocation, setDiscoverLocation] = useState('');
- const severityLabel = {
- low: {
- label: 'Low',
- color: UI_COLOR_STATUS.success,
- ruleLevelRange: {
- minRuleLevel: 0,
- maxRuleLevel: 6,
- },
+const severities = {
+ low: {
+ label: 'Low',
+ color: UI_COLOR_STATUS.success,
+ ruleLevelRange: {
+ minRuleLevel: 0,
+ maxRuleLevel: 6,
},
- medium: {
- label: 'Medium',
- color: UI_COLOR_STATUS.info,
- ruleLevelRange: {
- minRuleLevel: 7,
- maxRuleLevel: 11,
- },
+ },
+ medium: {
+ label: 'Medium',
+ color: UI_COLOR_STATUS.info,
+ ruleLevelRange: {
+ minRuleLevel: 7,
+ maxRuleLevel: 11,
},
- high: {
- label: 'High',
- color: UI_COLOR_STATUS.warning,
- ruleLevelRange: {
- minRuleLevel: 12,
- maxRuleLevel: 14,
- },
+ },
+ high: {
+ label: 'High',
+ color: UI_COLOR_STATUS.warning,
+ ruleLevelRange: {
+ minRuleLevel: 12,
+ maxRuleLevel: 14,
},
- critical: {
- label: 'Critical',
- color: UI_COLOR_STATUS.danger,
- ruleLevelRange: {
- minRuleLevel: 15,
- maxRuleLevel: undefined,
- },
+ },
+ critical: {
+ label: 'Critical',
+ color: UI_COLOR_STATUS.danger,
+ ruleLevelRange: {
+ minRuleLevel: 15,
+ maxRuleLevel: undefined,
},
- } as const;
+ },
+} as const;
+
+export function LastAlertsStat({
+ severity: severityKey,
+}: {
+ severity: SeverityKey;
+}) {
+ const [countLastAlerts, setCountLastAlerts] = useState(null);
+ const [discoverLocation, setDiscoverLocation] = useState('');
- const ruleLevelRange = severityLabel[severity].ruleLevelRange;
- const maxRuleLevel = ruleLevelRange.maxRuleLevel;
- const minRuleLevel = ruleLevelRange.minRuleLevel;
+ const severity = severities[severityKey];
+ const ruleLevelRange = severity.ruleLevelRange;
useEffect(() => {
const getCountLastAlerts = async () => {
@@ -89,7 +93,7 @@ export function LastAlertsStat({ severity }: { severity: SeverityLevelKey }) {
PatternDataSourceFilterManager.createFilter(
FILTER_OPERATOR.IS_BETWEEN,
'rule.level',
- [minRuleLevel, maxRuleLevel],
+ [ruleLevelRange.minRuleLevel, ruleLevelRange.maxRuleLevel],
indexPatternId,
);
const predefinedFilters =
@@ -121,16 +125,19 @@ export function LastAlertsStat({ severity }: { severity: SeverityLevelKey }) {
@@ -138,20 +145,17 @@ export function LastAlertsStat({ severity }: { severity: SeverityLevelKey }) {
}
- description={`${severityLabel[severity].label} severity`}
+ description={`${severity.label} severity`}
descriptionElement='h3'
- titleColor={severityLabel[severity].color}
+ titleColor={severity.color}
textAlign='center'
/>
-
+
{'Rule level ' +
- minRuleLevel +
- (maxRuleLevel ? ' to ' + maxRuleLevel : ' or higher')}
+ ruleLevelRange.minRuleLevel +
+ (ruleLevelRange.maxRuleLevel
+ ? ' to ' + ruleLevelRange.maxRuleLevel
+ : ' or higher')}
From a71dfc7d60ebb655b808c6f21a1cd57128fe40bf Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Mon, 30 Sep 2024 10:32:11 -0300
Subject: [PATCH 5/7] Update font size for KPI subtitles and feature
descriptions
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70eb276317..a94d836602 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Changed the registration id of the Settings application for compatibility with OpenSearch Dashboard 2.16.0 [#6938](https://github.com/wazuh/wazuh-dashboard-plugins/pull/6938)
- Changed Malware detection dashboard visualizations [#6964](https://github.com/wazuh/wazuh-dashboard-plugins/issues/6964)
- Changed malware feature description [#7036](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7036)
-- Changed the font size of the kpi subtitles and the features descriptions [#7027](https://github.com/wazuh/wazuh-dashboard-plugins/issues/7027)
+- Changed the font size of the kpi subtitles and the features descriptions [#7033](https://github.com/wazuh/wazuh-dashboard-plugins/pull/7033)
### Fixed
From 66c0e49fd7e2fbd64da72b2582b5c5b75e8dd91a Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Tue, 1 Oct 2024 10:32:03 -0300
Subject: [PATCH 6/7] Update text size to 's' in LastAlertsStat component
---
.../overview/components/last-alerts-stat/last-alerts-stat.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 c8d251dfab..4f51cf8600 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
@@ -150,7 +150,7 @@ export function LastAlertsStat({
titleColor={severity.color}
textAlign='center'
/>
-
+
{'Rule level ' +
ruleLevelRange.minRuleLevel +
(ruleLevelRange.maxRuleLevel
From f8c56c41bdc6c28865db8692031ce9988f5d3b48 Mon Sep 17 00:00:00 2001
From: Guido Modarelli
Date: Tue, 1 Oct 2024 10:56:50 -0300
Subject: [PATCH 7/7] Update class size to "small" in Stats component snapshot
---
.../overview/components/__snapshots__/stats.test.tsx.snap | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/plugins/main/public/controllers/overview/components/__snapshots__/stats.test.tsx.snap b/plugins/main/public/controllers/overview/components/__snapshots__/stats.test.tsx.snap
index 29b8d3d0da..4b0953aba0 100644
--- a/plugins/main/public/controllers/overview/components/__snapshots__/stats.test.tsx.snap
+++ b/plugins/main/public/controllers/overview/components/__snapshots__/stats.test.tsx.snap
@@ -139,7 +139,7 @@ exports[`Stats component renders correctly to match the snapshot 1`] = `