-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into timepickerChecksUrl
- Loading branch information
Showing
35 changed files
with
1,116 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...olution/public/detections/components/rules/description_step/build_ml_jobs_description.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import type { ListItems } from './types'; | ||
import { MlJobsDescription } from '../ml_jobs_description'; | ||
|
||
export const buildMlJobsDescription = (jobIds: string[], label: string): ListItems => ({ | ||
title: label, | ||
description: <MlJobsDescription jobIds={jobIds} />, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
..._solution/public/detections/components/rules/description_step/ml_job_description.test.tsx
This file was deleted.
Oops, something went wrong.
150 changes: 0 additions & 150 deletions
150
...urity_solution/public/detections/components/rules/description_step/ml_job_description.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/security_solution/public/detections/components/rules/ml_audit_icon/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { MlAuditIcon } from './ml_audit_icon'; |
27 changes: 27 additions & 0 deletions
27
...security_solution/public/detections/components/rules/ml_audit_icon/ml_audit_icon.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { MlAuditIcon } from './ml_audit_icon'; | ||
|
||
describe('MlAuditIcon', () => { | ||
it('should render null if message is undefined', () => { | ||
const { container } = render(<MlAuditIcon message={undefined} />); | ||
|
||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
it('should render tooltip with message text when hover over the icon', async () => { | ||
render(<MlAuditIcon message={{ text: 'mock audit text' }} />); | ||
|
||
userEvent.hover(screen.getByTestId('mlJobAuditIcon')); | ||
|
||
expect(await screen.findByText('mock audit text')).toBeInTheDocument(); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
...gins/security_solution/public/detections/components/rules/ml_audit_icon/ml_audit_icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { FC } from 'react'; | ||
import React, { memo } from 'react'; | ||
import { EuiIcon, EuiToolTip } from '@elastic/eui'; | ||
|
||
import type { MlSummaryJob } from '@kbn/ml-plugin/public'; | ||
|
||
enum MessageLevels { | ||
info = 'info', | ||
warning = 'warning', | ||
error = 'error', | ||
} | ||
|
||
interface MlAuditIconProps { | ||
message: MlSummaryJob['auditMessage']; | ||
} | ||
|
||
const MlAuditIconComponent: FC<MlAuditIconProps> = ({ message }) => { | ||
if (!message) { | ||
return null; | ||
} | ||
|
||
let color = 'primary'; | ||
let icon = 'alert'; | ||
|
||
if (message.level === MessageLevels.info) { | ||
icon = 'iInCircle'; | ||
} else if (message.level === MessageLevels.warning) { | ||
color = 'warning'; | ||
} else if (message.level === MessageLevels.error) { | ||
color = 'danger'; | ||
} | ||
|
||
return ( | ||
<EuiToolTip content={message.text}> | ||
<EuiIcon data-test-subj="mlJobAuditIcon" type={icon} color={color} /> | ||
</EuiToolTip> | ||
); | ||
}; | ||
|
||
export const MlAuditIcon = memo(MlAuditIconComponent); |
8 changes: 8 additions & 0 deletions
8
x-pack/plugins/security_solution/public/detections/components/rules/ml_job_link/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { MlJobLink } from './ml_job_link'; |
41 changes: 41 additions & 0 deletions
41
.../plugins/security_solution/public/detections/components/rules/ml_job_link/ml_job_link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { memo } from 'react'; | ||
import styled from 'styled-components'; | ||
import { EuiLink } from '@elastic/eui'; | ||
|
||
import { ML_PAGES, useMlHref } from '@kbn/ml-plugin/public'; | ||
import { useKibana } from '../../../../common/lib/kibana'; | ||
|
||
const StyledJobEuiLInk = styled(EuiLink)` | ||
margin-right: ${({ theme }) => theme.eui.euiSizeS}; | ||
`; | ||
|
||
interface MlJobLinkProps { | ||
jobId: string; | ||
} | ||
|
||
const MlJobLinkComponent: React.FC<MlJobLinkProps> = ({ jobId }) => { | ||
const { | ||
services: { http, ml }, | ||
} = useKibana(); | ||
const jobUrl = useMlHref(ml, http.basePath.get(), { | ||
page: ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE, | ||
pageState: { | ||
jobId: [jobId], | ||
}, | ||
}); | ||
|
||
return ( | ||
<StyledJobEuiLInk data-test-subj="machineLearningJobLink" href={jobUrl} target="_blank"> | ||
<span data-test-subj="machineLearningJobId">{jobId}</span> | ||
</StyledJobEuiLInk> | ||
); | ||
}; | ||
|
||
export const MlJobLink = memo(MlJobLinkComponent); |
Oops, something went wrong.