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

Update detector details component #504

Merged
4 changes: 2 additions & 2 deletions cypress/integration/1_detectors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,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', {
Expand All @@ -364,7 +364,7 @@ describe('Detectors', () => {
);
});

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', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -37,23 +37,13 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
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 ? (
<EuiLink onClick={() => window.open(`dashboards#/view/${dashboardId}`, '_blank')}>
{`${name} summary`}
<EuiIcon type={'popout'} />
</EuiLink>
) : (
'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 (
<ContentPanel
title={'Detector details'}
Expand All @@ -68,16 +58,43 @@ export const DetectorBasicDetailsView: React.FC<DetectorBasicDetailsViewProps> =
}
>
<EuiSpacer size={'l'} />
{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) => (
<EuiText>{ind}</EuiText>
))}
</>
),
},
{ label: 'Log type', content: detector_type.toLowerCase() },
{
label: 'Detector dashboard',
content: (dashboardId ? (
<EuiLink onClick={() => window.open(`dashboards#/view/${dashboardId}`, '_blank')}>
{`${name} summary`}
<EuiIcon type={'popout'} />
</EuiLink>
) : (
'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}
</ContentPanel>
);
Expand Down
Loading