Skip to content

Commit

Permalink
Merge branch 'main' into timepickerChecksUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko authored Dec 2, 2022
2 parents bee5c67 + ecc165c commit 4f4e096
Show file tree
Hide file tree
Showing 35 changed files with 1,116 additions and 227 deletions.
3 changes: 1 addition & 2 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
linux_deadlock: `${SECURITY_SOLUTION_DOCS}ts-management.html#linux-deadlock`,
},
packageActionTroubleshooting: {
// TODO: Pending to be updated when docs are ready
es_connection: '',
es_connection: `${SECURITY_SOLUTION_DOCS}ts-management.html`,
},
responseActions: `${SECURITY_SOLUTION_DOCS}response-actions.html`,
configureEndpointIntegrationPolicy: `${SECURITY_SOLUTION_DOCS}configure-endpoint-integration-policy.html`,
Expand Down
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} />,
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
buildRequiredFieldsDescription,
buildAlertSuppressionDescription,
} from './helpers';
import { buildMlJobsDescription } from './ml_job_description';
import { buildMlJobsDescription } from './build_ml_jobs_description';
import { buildActionsDescription } from './actions_description';
import { buildThrottleDescription } from './throttle_description';
import { THREAT_QUERY_LABEL } from './translations';
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,6 @@ export const NEW_TERMS_TYPE_DESCRIPTION = i18n.translate(
}
);

export const ML_RUN_JOB_LABEL = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.mlRunJobLabel',
{
defaultMessage: 'Run job',
}
);

export const ML_STOP_JOB_LABEL = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.mlStopJobLabel',
{
defaultMessage: 'Stop job',
}
);

export const ML_JOB_STARTED = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.mlJobStartedDescription',
{
defaultMessage: 'Started',
}
);

export const ML_JOB_STOPPED = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.mlJobStoppedDescription',
{
defaultMessage: 'Stopped',
}
);

export const THRESHOLD_RESULTS_ALL = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.thresholdResultsAllDescription',
{
Expand Down
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';
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();
});
});
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);
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';
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);
Loading

0 comments on commit 4f4e096

Please sign in to comment.