diff --git a/cypress/integration/1_detectors.spec.js b/cypress/integration/1_detectors.spec.js index 780a05b50..81a33f2cc 100644 --- a/cypress/integration/1_detectors.spec.js +++ b/cypress/integration/1_detectors.spec.js @@ -339,7 +339,7 @@ describe('Detectors', () => { cy.contains('Active rules (13)'); }); - it('...should update field mappings if data source is changed', () => { + it('...should show field mappings if data source is changed', () => { // Click on detector name cy.contains(detectorName).click({ force: true }); cy.waitForPageLoad('detector-details', { @@ -365,7 +365,7 @@ describe('Detectors', () => { cy.get('.reviewFieldMappings').should('be.visible'); }); - it('...should update field mappings if rule selection is changed', () => { + it('...should show field mappings if rule selection is changed', () => { // Click on detector name cy.contains(detectorName).click({ force: true }); cy.waitForPageLoad('detector-details', { diff --git a/public/pages/Detectors/components/DetectorBasicDetailsView/DetectorBasicDetailsView.tsx b/public/pages/Detectors/components/DetectorBasicDetailsView/DetectorBasicDetailsView.tsx index a8eb24151..146ffd4a6 100644 --- a/public/pages/Detectors/components/DetectorBasicDetailsView/DetectorBasicDetailsView.tsx +++ b/public/pages/Detectors/components/DetectorBasicDetailsView/DetectorBasicDetailsView.tsx @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { EuiButton, EuiSpacer, EuiLink, EuiIcon } from '@elastic/eui'; +import { EuiButton, EuiSpacer, EuiLink, EuiIcon, EuiText } from '@elastic/eui'; import React from 'react'; import { ContentPanel } from '../../../../components/ContentPanel'; import { createTextDetailsGroup, parseSchedule } from '../../../../utils/helpers'; @@ -37,23 +37,13 @@ export const DetectorBasicDetailsView: React.FC = const lastUpdated = last_update_time ? moment(last_update_time).format('YYYY-MM-DDTHH:mm') : undefined; - const firstTextDetailsGroupEntries = [ - { label: 'Detector name', content: name }, - { label: 'Log type', content: detector_type.toLowerCase() }, - { label: 'Data source', content: inputs[0].detector_input.indices[0] }, - { - label: 'Detector dashboard', - content: (dashboardId ? ( - window.open(`dashboards#/view/${dashboardId}`, '_blank')}> - {`${name} summary`} - - - ) : ( - 'Not available for this log type' - )) as any, - }, - ]; - + const totalSelected = detector.inputs.reduce((sum, inputObj) => { + return ( + sum + + inputObj.detector_input.custom_rules.length + + inputObj.detector_input.pre_packaged_rules.length + ); + }, 0); return ( = } > - {createTextDetailsGroup(firstTextDetailsGroupEntries, 4)} - {createTextDetailsGroup( - [ - { label: 'Description', content: inputs[0].detector_input.description }, - { label: 'Detector schedule', content: detectorSchedule }, - { label: 'Created at', content: createdAt || DEFAULT_EMPTY_DATA }, - { label: 'Last updated time', content: lastUpdated || DEFAULT_EMPTY_DATA }, - ], - 4 - )} + {createTextDetailsGroup([ + { label: 'Detector name', content: name }, + { + label: 'Description', + content: inputs[0].detector_input.description || DEFAULT_EMPTY_DATA, + }, + { label: 'Detector schedule', content: detectorSchedule }, + ])} + {createTextDetailsGroup([ + { + label: 'Data source', + content: ( + <> + {inputs[0].detector_input.indices.map((ind: string) => ( + {ind} + ))} + + ), + }, + { label: 'Log type', content: detector_type.toLowerCase() }, + { + label: 'Detector dashboard', + content: (dashboardId ? ( + window.open(`dashboards#/view/${dashboardId}`, '_blank')}> + {`${name} summary`} + + + ) : ( + 'Not available for this log type' + )) as any, + }, + ])} + {createTextDetailsGroup([ + { label: 'Detection rules', content: totalSelected }, + { label: 'Created at', content: createdAt || DEFAULT_EMPTY_DATA }, + { label: 'Last updated time', content: lastUpdated || DEFAULT_EMPTY_DATA }, + ])} {rulesCanFold ? children : null} ); diff --git a/public/pages/Detectors/components/DetectorBasicDetailsView/__snapshots__/DetectorBasicDetailsView.test.tsx.snap b/public/pages/Detectors/components/DetectorBasicDetailsView/__snapshots__/DetectorBasicDetailsView.test.tsx.snap index a8558fe23..d91290cfb 100644 --- a/public/pages/Detectors/components/DetectorBasicDetailsView/__snapshots__/DetectorBasicDetailsView.test.tsx.snap +++ b/public/pages/Detectors/components/DetectorBasicDetailsView/__snapshots__/DetectorBasicDetailsView.test.tsx.snap @@ -120,7 +120,7 @@ Object {
- Log type + Description
@@ -130,14 +130,59 @@ Object { >
- detector_type + detectorDescription
+
+
+
+ +
+
+
+ Every 1 minute +
+
+
+
+ +
+
@@ -171,7 +216,11 @@ Object { data-test-subj="text-details-group-content-data-source" id="some_html_id" > - .windows +
+ .windows +
@@ -196,7 +245,7 @@ Object {
- Detector dashboard + Log type
@@ -206,21 +255,14 @@ Object { >
- Not available for this log type + detector_type
- -
-
@@ -241,7 +283,7 @@ Object {
- Description + Detector dashboard
@@ -251,14 +293,21 @@ Object { >
- detectorDescription + Not available for this log type
+ +
+
@@ -279,7 +328,7 @@ Object {
- Detector schedule + Detection rules
@@ -289,10 +338,10 @@ Object { >
- Every 1 undefined + 2
@@ -497,7 +546,7 @@ Object {
- Log type + Description
@@ -507,14 +556,59 @@ Object { >
- detector_type + detectorDescription
+
+
+
+ +
+
+
+ Every 1 minute +
+
+
+
+ +
+
@@ -548,7 +642,11 @@ Object { data-test-subj="text-details-group-content-data-source" id="some_html_id" > - .windows +
+ .windows +
@@ -573,7 +671,7 @@ Object {
- Detector dashboard + Log type
@@ -583,21 +681,14 @@ Object { >
- Not available for this log type + detector_type
- -
-
@@ -618,7 +709,7 @@ Object {
- Description + Detector dashboard
@@ -628,14 +719,21 @@ Object { >
- detectorDescription + Not available for this log type
+ +
+
@@ -656,7 +754,7 @@ Object {
- Detector schedule + Detection rules
@@ -666,10 +764,10 @@ Object { >
- Every 1 undefined + 2
diff --git a/public/pages/Detectors/components/DetectorRulesView/DetectorRulesView.tsx b/public/pages/Detectors/components/DetectorRulesView/DetectorRulesView.tsx index a8ec85ac6..43be000d6 100644 --- a/public/pages/Detectors/components/DetectorRulesView/DetectorRulesView.tsx +++ b/public/pages/Detectors/components/DetectorRulesView/DetectorRulesView.tsx @@ -110,7 +110,7 @@ export const DetectorRulesView: React.FC = (props) => { }); }, [services, props.detector]); - const getDetectionRulesTitle = () => `View detection rules (${totalSelected})`; + const getDetectionRulesTitle = () => `View detection rules`; const onShowRuleDetails = (rule: RuleTableItem) => { setFlyoutData(() => rule); diff --git a/public/pages/Detectors/components/DetectorRulesView/__snapshots__/DetectorRulesView.test.tsx.snap b/public/pages/Detectors/components/DetectorRulesView/__snapshots__/DetectorRulesView.test.tsx.snap index 3f059e572..1c68baff9 100644 --- a/public/pages/Detectors/components/DetectorRulesView/__snapshots__/DetectorRulesView.test.tsx.snap +++ b/public/pages/Detectors/components/DetectorRulesView/__snapshots__/DetectorRulesView.test.tsx.snap @@ -60,7 +60,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ diff --git a/public/pages/Detectors/components/UpdateAlertConditions/__snapshots__/UpdateAlertConditions.test.tsx.snap b/public/pages/Detectors/components/UpdateAlertConditions/__snapshots__/UpdateAlertConditions.test.tsx.snap index 735f7d5f9..78bd34098 100644 --- a/public/pages/Detectors/components/UpdateAlertConditions/__snapshots__/UpdateAlertConditions.test.tsx.snap +++ b/public/pages/Detectors/components/UpdateAlertConditions/__snapshots__/UpdateAlertConditions.test.tsx.snap @@ -65,7 +65,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -267,7 +267,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -492,7 +492,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -673,7 +673,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -877,7 +877,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ diff --git a/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap b/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap index 544a33e24..5c9c692f6 100644 --- a/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap +++ b/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap @@ -65,7 +65,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -262,7 +262,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -437,7 +437,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -989,7 +989,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -1240,7 +1240,7 @@ exports[` spec renders the component 1`] = ` "schedule": Object { "period": Object { "interval": 1, - "unit": "minute", + "unit": "MINUTES", }, }, "triggers": Array [ @@ -1521,7 +1521,7 @@ exports[` spec renders the component 1`] = ` }, ] } - value="minute" + value="MINUTES" > spec renders the component 1`] = ` data-test-subj="detector-schedule-unit-select" onChange={[Function]} onMouseUp={[Function]} - value="minute" + value="MINUTES" >