(defaultFields);
-
- const onChangeCb = useCallback(
- (
- key: keyof ServiceNowSIRFieldsType,
- value: ServiceNowSIRFieldsType[keyof ServiceNowSIRFieldsType]
- ) => {
- onChange({ ...fields, [key]: value });
- },
- [fields, onChange]
- );
-
- const onChoicesSuccess = (values: Choice[]) => {
- setChoices(
- values.reduce(
- (acc, value) => ({
- ...acc,
- [value.element]: [...(acc[value.element] != null ? acc[value.element] : []), value],
- }),
- defaultFields
- )
- );
- };
-
- const { isLoading: isLoadingChoices } = useGetChoices({
- http,
- toastNotifications: notifications.toasts,
- connector,
- fields: useGetChoicesFields,
- onSuccess: onChoicesSuccess,
- });
-
- const categoryOptions = useMemo(() => choicesToEuiOptions(choices.category), [choices.category]);
- const priorityOptions = useMemo(() => choicesToEuiOptions(choices.priority), [choices.priority]);
-
- const subcategoryOptions = useMemo(
- () =>
- choicesToEuiOptions(
- choices.subcategory.filter((choice) => choice.dependent_value === category)
- ),
- [choices.subcategory, category]
- );
-
- const listItems = useMemo(
- () => [
- ...(destIp != null && destIp
- ? [
- {
- title: i18n.DEST_IP,
- description: i18n.ALERT_FIELD_ENABLED_TEXT,
- },
- ]
- : []),
- ...(sourceIp != null && sourceIp
- ? [
- {
- title: i18n.SOURCE_IP,
- description: i18n.ALERT_FIELD_ENABLED_TEXT,
- },
- ]
- : []),
- ...(malwareUrl != null && malwareUrl
- ? [
- {
- title: i18n.MALWARE_URL,
- description: i18n.ALERT_FIELD_ENABLED_TEXT,
- },
- ]
- : []),
- ...(malwareHash != null && malwareHash
- ? [
- {
- title: i18n.MALWARE_HASH,
- description: i18n.ALERT_FIELD_ENABLED_TEXT,
- },
- ]
- : []),
- ...(priority != null && priority.length > 0
- ? [
- {
- title: i18n.PRIORITY,
- description: priorityOptions.find((option) => `${option.value}` === priority)?.text,
- },
- ]
- : []),
- ...(category != null && category.length > 0
- ? [
- {
- title: i18n.CATEGORY,
- description: categoryOptions.find((option) => `${option.value}` === category)?.text,
- },
- ]
- : []),
- ...(subcategory != null && subcategory.length > 0
- ? [
- {
- title: i18n.SUBCATEGORY,
- description: subcategoryOptions.find((option) => `${option.value}` === subcategory)
- ?.text,
- },
- ]
- : []),
- ],
- [
- category,
- categoryOptions,
- destIp,
- malwareHash,
- malwareUrl,
- priority,
- priorityOptions,
- sourceIp,
- subcategory,
- subcategoryOptions,
- ]
- );
-
- // Set field at initialization
- useEffect(() => {
- if (init.current) {
- init.current = false;
- onChange({ category, destIp, malwareHash, malwareUrl, priority, sourceIp, subcategory });
- }
- }, [category, destIp, malwareHash, malwareUrl, onChange, priority, sourceIp, subcategory]);
-
- return isEdit ? (
-
-
-
-
- <>
-
-
- onChangeCb('destIp', e.target.checked)}
- />
-
-
- onChangeCb('sourceIp', e.target.checked)}
- />
-
-
-
-
- onChangeCb('malwareUrl', e.target.checked)}
- />
-
-
- onChangeCb('malwareHash', e.target.checked)}
- />
-
-
- >
-
-
-
-
-
-
- onChangeCb('priority', e.target.value)}
- />
-
-
-
-
-
-
- onChange({ ...fields, category: e.target.value, subcategory: null })}
- />
-
-
-
-
- onChangeCb('subcategory', e.target.value)}
- />
-
-
-
-
- ) : (
-
- );
-};
-
-// eslint-disable-next-line import/no-default-export
-export { ServiceNowSIRFieldsComponent as default };
diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/translations.ts b/x-pack/plugins/cases/public/components/connectors/servicenow/translations.ts
deleted file mode 100644
index fc48ecf17f2c6..0000000000000
--- a/x-pack/plugins/cases/public/components/connectors/servicenow/translations.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 { i18n } from '@kbn/i18n';
-
-export const URGENCY = i18n.translate('xpack.cases.connectors.serviceNow.urgencySelectFieldLabel', {
- defaultMessage: 'Urgency',
-});
-
-export const SEVERITY = i18n.translate(
- 'xpack.cases.connectors.serviceNow.severitySelectFieldLabel',
- {
- defaultMessage: 'Severity',
- }
-);
-
-export const IMPACT = i18n.translate('xpack.cases.connectors.serviceNow.impactSelectFieldLabel', {
- defaultMessage: 'Impact',
-});
-
-export const CHOICES_API_ERROR = i18n.translate(
- 'xpack.cases.connectors.serviceNow.unableToGetChoicesMessage',
- {
- defaultMessage: 'Unable to get choices',
- }
-);
-
-export const MALWARE_URL = i18n.translate('xpack.cases.connectors.serviceNow.malwareURLTitle', {
- defaultMessage: 'Malware URL',
-});
-
-export const MALWARE_HASH = i18n.translate('xpack.cases.connectors.serviceNow.malwareHashTitle', {
- defaultMessage: 'Malware Hash',
-});
-
-export const CATEGORY = i18n.translate('xpack.cases.connectors.serviceNow.categoryTitle', {
- defaultMessage: 'Category',
-});
-
-export const SUBCATEGORY = i18n.translate('xpack.cases.connectors.serviceNow.subcategoryTitle', {
- defaultMessage: 'Subcategory',
-});
-
-export const SOURCE_IP = i18n.translate('xpack.cases.connectors.serviceNow.sourceIPTitle', {
- defaultMessage: 'Source IP',
-});
-
-export const DEST_IP = i18n.translate('xpack.cases.connectors.serviceNow.destinationIPTitle', {
- defaultMessage: 'Destination IP',
-});
-
-export const PRIORITY = i18n.translate(
- 'xpack.cases.connectors.serviceNow.prioritySelectFieldTitle',
- {
- defaultMessage: 'Priority',
- }
-);
-
-export const ALERT_FIELDS_LABEL = i18n.translate(
- 'xpack.cases.connectors.serviceNow.alertFieldsTitle',
- {
- defaultMessage: 'Select Observables to push',
- }
-);
-
-export const ALERT_FIELD_ENABLED_TEXT = i18n.translate(
- 'xpack.cases.connectors.serviceNow.alertFieldEnabledText',
- {
- defaultMessage: 'Yes',
- }
-);
diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/types.ts b/x-pack/plugins/cases/public/components/connectors/servicenow/types.ts
deleted file mode 100644
index fd1af62f7bb2a..0000000000000
--- a/x-pack/plugins/cases/public/components/connectors/servicenow/types.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * 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 interface Choice {
- value: string;
- label: string;
- dependent_value: string;
- element: string;
-}
-
-export type Fields = Record;
diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.test.tsx b/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.test.tsx
deleted file mode 100644
index ed4577dd0114b..0000000000000
--- a/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.test.tsx
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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 { renderHook } from '@testing-library/react-hooks';
-
-import { useKibana } from '../../../common/lib/kibana';
-import { ActionConnector } from '../../../containers/types';
-import { choices } from '../mock';
-import { useGetChoices, UseGetChoices, UseGetChoicesProps } from './use_get_choices';
-import * as api from './api';
-
-jest.mock('./api');
-jest.mock('../../../common/lib/kibana');
-
-const useKibanaMock = useKibana as jest.Mocked;
-const onSuccess = jest.fn();
-const fields = ['priority'];
-
-const connector = {
- secrets: {
- username: 'user',
- password: 'pass',
- },
- id: 'test',
- actionTypeId: '.servicenow',
- name: 'ServiceNow',
- isPreconfigured: false,
- config: {
- apiUrl: 'https://dev94428.service-now.com/',
- },
-} as ActionConnector;
-
-describe('useGetChoices', () => {
- const { services } = useKibanaMock();
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- it('init', async () => {
- const { result, waitForNextUpdate } = renderHook(() =>
- useGetChoices({
- http: services.http,
- connector,
- toastNotifications: services.notifications.toasts,
- fields,
- onSuccess,
- })
- );
-
- await waitForNextUpdate();
-
- expect(result.current).toEqual({
- isLoading: false,
- choices,
- });
- });
-
- it('returns an empty array when connector is not presented', async () => {
- const { result } = renderHook(() =>
- useGetChoices({
- http: services.http,
- connector: undefined,
- toastNotifications: services.notifications.toasts,
- fields,
- onSuccess,
- })
- );
-
- expect(result.current).toEqual({
- isLoading: false,
- choices: [],
- });
- });
-
- it('it calls onSuccess', async () => {
- const { waitForNextUpdate } = renderHook(() =>
- useGetChoices({
- http: services.http,
- connector,
- toastNotifications: services.notifications.toasts,
- fields,
- onSuccess,
- })
- );
-
- await waitForNextUpdate();
-
- expect(onSuccess).toHaveBeenCalledWith(choices);
- });
-
- it('it displays an error when service fails', async () => {
- const spyOnGetChoices = jest.spyOn(api, 'getChoices');
- spyOnGetChoices.mockResolvedValue(
- Promise.resolve({
- actionId: 'test',
- status: 'error',
- serviceMessage: 'An error occurred',
- })
- );
-
- const { waitForNextUpdate } = renderHook(() =>
- useGetChoices({
- http: services.http,
- connector,
- toastNotifications: services.notifications.toasts,
- fields,
- onSuccess,
- })
- );
-
- await waitForNextUpdate();
-
- expect(services.notifications.toasts.addDanger).toHaveBeenCalledWith({
- text: 'An error occurred',
- title: 'Unable to get choices',
- });
- });
-
- it('it displays an error when http throws an error', async () => {
- const spyOnGetChoices = jest.spyOn(api, 'getChoices');
- spyOnGetChoices.mockImplementation(() => {
- throw new Error('An error occurred');
- });
-
- renderHook(() =>
- useGetChoices({
- http: services.http,
- connector,
- toastNotifications: services.notifications.toasts,
- fields,
- onSuccess,
- })
- );
-
- expect(services.notifications.toasts.addDanger).toHaveBeenCalledWith({
- text: 'An error occurred',
- title: 'Unable to get choices',
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.tsx b/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.tsx
deleted file mode 100644
index a979f96d84ab2..0000000000000
--- a/x-pack/plugins/cases/public/components/connectors/servicenow/use_get_choices.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 { useState, useEffect, useRef } from 'react';
-import { HttpSetup, ToastsApi } from 'kibana/public';
-import { ActionConnector } from '../../../containers/types';
-import { getChoices } from './api';
-import { Choice } from './types';
-import * as i18n from './translations';
-
-export interface UseGetChoicesProps {
- http: HttpSetup;
- toastNotifications: Pick<
- ToastsApi,
- 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'
- >;
- connector?: ActionConnector;
- fields: string[];
- onSuccess?: (choices: Choice[]) => void;
-}
-
-export interface UseGetChoices {
- choices: Choice[];
- isLoading: boolean;
-}
-
-export const useGetChoices = ({
- http,
- connector,
- toastNotifications,
- fields,
- onSuccess,
-}: UseGetChoicesProps): UseGetChoices => {
- const [isLoading, setIsLoading] = useState(false);
- const [choices, setChoices] = useState([]);
- const didCancel = useRef(false);
- const abortCtrl = useRef(new AbortController());
-
- useEffect(() => {
- const fetchData = async () => {
- if (!connector) {
- setIsLoading(false);
- return;
- }
-
- try {
- abortCtrl.current = new AbortController();
- setIsLoading(true);
-
- const res = await getChoices({
- http,
- signal: abortCtrl.current.signal,
- connectorId: connector.id,
- fields,
- });
-
- if (!didCancel.current) {
- setIsLoading(false);
- setChoices(res.data ?? []);
- if (res.status && res.status === 'error') {
- toastNotifications.addDanger({
- title: i18n.CHOICES_API_ERROR,
- text: `${res.serviceMessage ?? res.message}`,
- });
- } else if (onSuccess) {
- onSuccess(res.data ?? []);
- }
- }
- } catch (error) {
- if (!didCancel.current) {
- setIsLoading(false);
- if (error.name !== 'AbortError') {
- toastNotifications.addDanger({
- title: i18n.CHOICES_API_ERROR,
- text: error.message,
- });
- }
- }
- }
- };
-
- didCancel.current = false;
- abortCtrl.current.abort();
- fetchData();
-
- return () => {
- didCancel.current = true;
- abortCtrl.current.abort();
- };
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [http, connector, toastNotifications, fields]);
-
- return {
- choices,
- isLoading,
- };
-};
diff --git a/x-pack/plugins/cases/public/components/connectors/types.ts b/x-pack/plugins/cases/public/components/connectors/types.ts
deleted file mode 100644
index fc2f66d331700..0000000000000
--- a/x-pack/plugins/cases/public/components/connectors/types.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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 {
- ActionType as ThirdPartySupportedActions,
- CaseField,
- ActionConnector,
- ConnectorTypeFields,
-} from '../../../common';
-
-export { ThirdPartyField as AllThirdPartyFields } from '../../../common';
-export type CaseActionConnector = ActionConnector;
-
-export interface ThirdPartyField {
- label: string;
- validSourceFields: CaseField[];
- defaultSourceField: CaseField;
- defaultActionType: ThirdPartySupportedActions;
-}
-
-export interface ConnectorConfiguration {
- name: string;
- logo: string;
-}
-
-export interface CaseConnector {
- id: string;
- fieldsComponent: React.LazyExoticComponent<
- React.ComponentType>
- > | null;
-}
-
-export interface CaseConnectorsRegistry {
- has: (id: string) => boolean;
- register: (
- connector: CaseConnector
- ) => void;
- get: (id: string) => CaseConnector;
- list: () => CaseConnector[];
-}
-
-export interface ConnectorFieldsProps {
- isEdit?: boolean;
- connector: CaseActionConnector;
- fields: TFields;
- onChange: (fields: TFields) => void;
-}
diff --git a/x-pack/plugins/cases/public/components/create/connector.test.tsx b/x-pack/plugins/cases/public/components/create/connector.test.tsx
deleted file mode 100644
index db9e5ffac1533..0000000000000
--- a/x-pack/plugins/cases/public/components/create/connector.test.tsx
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { act, waitFor } from '@testing-library/react';
-import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { connectorsMock } from '../../containers/mock';
-import { Connector } from './connector';
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { useGetIncidentTypes } from '../connectors/resilient/use_get_incident_types';
-import { useGetSeverity } from '../connectors/resilient/use_get_severity';
-import { useGetChoices } from '../connectors/servicenow/use_get_choices';
-import { incidentTypes, severity, choices } from '../connectors/mock';
-import { schema, FormProps } from './schema';
-
-jest.mock('../../common/lib/kibana', () => {
- return {
- useKibana: () => ({
- services: {
- notifications: {},
- http: {},
- },
- }),
- };
-});
-jest.mock('../../containers/configure/use_connectors');
-jest.mock('../connectors/resilient/use_get_incident_types');
-jest.mock('../connectors/resilient/use_get_severity');
-jest.mock('../connectors/servicenow/use_get_choices');
-
-const useConnectorsMock = useConnectors as jest.Mock;
-const useGetIncidentTypesMock = useGetIncidentTypes as jest.Mock;
-const useGetSeverityMock = useGetSeverity as jest.Mock;
-const useGetChoicesMock = useGetChoices as jest.Mock;
-
-const useGetIncidentTypesResponse = {
- isLoading: false,
- incidentTypes,
-};
-
-const useGetSeverityResponse = {
- isLoading: false,
- severity,
-};
-
-const useGetChoicesResponse = {
- isLoading: false,
- choices,
-};
-
-describe('Connector', () => {
- let globalForm: FormHook;
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { connectorId: connectorsMock[0].id, fields: null },
- schema: {
- connectorId: schema.connectorId,
- fields: schema.fields,
- },
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- useConnectorsMock.mockReturnValue({ loading: false, connectors: connectorsMock });
- useGetIncidentTypesMock.mockReturnValue(useGetIncidentTypesResponse);
- useGetSeverityMock.mockReturnValue(useGetSeverityResponse);
- useGetChoicesMock.mockReturnValue(useGetChoicesResponse);
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseConnectors"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="connector-fields"]`).exists()).toBeTruthy();
-
- await waitFor(() => {
- expect(wrapper.find(`button[data-test-subj="dropdown-connectors"]`).first().text()).toBe(
- 'My Connector'
- );
- });
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-sn-itsm"]`).exists()).toBeTruthy();
- });
- });
-
- it('it is loading when fetching connectors', async () => {
- useConnectorsMock.mockReturnValue({ loading: true, connectors: connectorsMock });
- const wrapper = mount(
-
-
-
- );
-
- expect(
- wrapper.find('[data-test-subj="dropdown-connectors"]').first().prop('isLoading')
- ).toEqual(true);
- });
-
- it('it is disabled when fetching connectors', async () => {
- useConnectorsMock.mockReturnValue({ loading: true, connectors: connectorsMock });
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find('[data-test-subj="dropdown-connectors"]').first().prop('disabled')).toEqual(
- true
- );
- });
-
- it('it is disabled and loading when passing loading as true', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(
- wrapper.find('[data-test-subj="dropdown-connectors"]').first().prop('isLoading')
- ).toEqual(true);
- expect(wrapper.find('[data-test-subj="dropdown-connectors"]').first().prop('disabled')).toEqual(
- true
- );
- });
-
- it(`it should change connector`, async () => {
- const wrapper = mount(
-
-
-
- );
-
- await waitFor(() => {
- expect(wrapper.find(`[data-test-subj="connector-fields-resilient"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-resilient-2"]`).simulate('click');
- wrapper.update();
- });
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-resilient"]`).exists()).toBeTruthy();
- });
-
- act(() => {
- ((wrapper.find(EuiComboBox).props() as unknown) as {
- onChange: (a: EuiComboBoxOptionOption[]) => void;
- }).onChange([{ value: '19', label: 'Denial of Service' }]);
- });
-
- act(() => {
- wrapper
- .find('select[data-test-subj="severitySelect"]')
- .first()
- .simulate('change', {
- target: { value: '4' },
- });
- });
-
- await waitFor(() => {
- expect(globalForm.getFormData()).toEqual({
- connectorId: 'resilient-2',
- fields: { incidentTypes: ['19'], severityCode: '4' },
- });
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/connector.tsx b/x-pack/plugins/cases/public/components/create/connector.tsx
deleted file mode 100644
index 9b6063a7bf9b9..0000000000000
--- a/x-pack/plugins/cases/public/components/create/connector.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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, useCallback } from 'react';
-import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
-
-import { ConnectorTypes } from '../../../common';
-import { UseField, useFormData, FieldHook, useFormContext } from '../../common/shared_imports';
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { ConnectorSelector } from '../connector_selector/form';
-import { ConnectorFieldsForm } from '../connectors/fields_form';
-import { ActionConnector } from '../../containers/types';
-import { getConnectorById } from '../configure_cases/utils';
-import { FormProps } from './schema';
-
-interface Props {
- isLoading: boolean;
- hideConnectorServiceNowSir?: boolean;
-}
-
-interface ConnectorsFieldProps {
- connectors: ActionConnector[];
- field: FieldHook;
- isEdit: boolean;
- hideConnectorServiceNowSir?: boolean;
-}
-
-const ConnectorFields = ({
- connectors,
- isEdit,
- field,
- hideConnectorServiceNowSir = false,
-}: ConnectorsFieldProps) => {
- const [{ connectorId }] = useFormData({ watch: ['connectorId'] });
- const { setValue } = field;
- let connector = getConnectorById(connectorId, connectors) ?? null;
- if (
- connector &&
- hideConnectorServiceNowSir &&
- connector.actionTypeId === ConnectorTypes.serviceNowSIR
- ) {
- connector = null;
- }
- return (
-
- );
-};
-
-const ConnectorComponent: React.FC = ({ hideConnectorServiceNowSir = false, isLoading }) => {
- const { getFields } = useFormContext();
- const { loading: isLoadingConnectors, connectors } = useConnectors();
- const handleConnectorChange = useCallback(
- (newConnector) => {
- const { fields } = getFields();
- fields.setValue(null);
- },
- [getFields]
- );
-
- return (
-
-
-
-
-
-
-
-
- );
-};
-
-ConnectorComponent.displayName = 'ConnectorComponent';
-
-export const Connector = memo(ConnectorComponent);
diff --git a/x-pack/plugins/cases/public/components/create/description.test.tsx b/x-pack/plugins/cases/public/components/create/description.test.tsx
deleted file mode 100644
index fcd1f82d64a53..0000000000000
--- a/x-pack/plugins/cases/public/components/create/description.test.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { act } from '@testing-library/react';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { Description } from './description';
-import { schema, FormProps } from './schema';
-
-describe('Description', () => {
- let globalForm: FormHook;
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { description: 'My description' },
- schema: {
- description: schema.description,
- },
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseDescription"]`).exists()).toBeTruthy();
- });
-
- it('it changes the description', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await act(async () => {
- wrapper
- .find(`[data-test-subj="caseDescription"] textarea`)
- .first()
- .simulate('change', { target: { value: 'My new description' } });
- });
-
- expect(globalForm.getFormData()).toEqual({ description: 'My new description' });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/description.tsx b/x-pack/plugins/cases/public/components/create/description.tsx
deleted file mode 100644
index 0a7102cff1ad5..0000000000000
--- a/x-pack/plugins/cases/public/components/create/description.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 { MarkdownEditorForm } from '../markdown_editor';
-import { UseField } from '../../common/shared_imports';
-interface Props {
- isLoading: boolean;
-}
-
-export const fieldName = 'description';
-
-const DescriptionComponent: React.FC = ({ isLoading }) => (
-
-);
-
-DescriptionComponent.displayName = 'DescriptionComponent';
-
-export const Description = memo(DescriptionComponent);
diff --git a/x-pack/plugins/cases/public/components/create/flyout.test.tsx b/x-pack/plugins/cases/public/components/create/flyout.test.tsx
deleted file mode 100644
index 5187029ab60c7..0000000000000
--- a/x-pack/plugins/cases/public/components/create/flyout.test.tsx
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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, { ReactNode } from 'react';
-import { mount } from 'enzyme';
-
-import { CreateCaseFlyout } from './flyout';
-import { TestProviders } from '../../common/mock';
-
-jest.mock('../create/form_context', () => {
- return {
- FormContext: ({
- children,
- onSuccess,
- }: {
- children: ReactNode;
- onSuccess: ({ id }: { id: string }) => Promise;
- }) => {
- return (
- <>
-
- {children}
- >
- );
- },
- };
-});
-
-jest.mock('../create/form', () => {
- return {
- CreateCaseForm: () => {
- return <>{'form'}>;
- },
- };
-});
-
-jest.mock('../create/submit_button', () => {
- return {
- SubmitCaseButton: () => {
- return <>{'Submit'}>;
- },
- };
-});
-
-const onCloseFlyout = jest.fn();
-const onSuccess = jest.fn();
-const defaultProps = {
- onCloseFlyout,
- onSuccess,
-};
-
-describe('CreateCaseFlyout', () => {
- beforeEach(() => {
- jest.resetAllMocks();
- });
-
- it('renders', () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj='create-case-flyout']`).exists()).toBeTruthy();
- });
-
- it('Closing modal calls onCloseCaseModal', () => {
- const wrapper = mount(
-
-
-
- );
-
- wrapper.find('.euiFlyout__closeButton').first().simulate('click');
- expect(onCloseFlyout).toBeCalled();
- });
-
- it('pass the correct props to FormContext component', () => {
- const wrapper = mount(
-
-
-
- );
-
- const props = wrapper.find('FormContext').props();
- expect(props).toEqual(
- expect.objectContaining({
- onSuccess,
- })
- );
- });
-
- it('onSuccess called when creating a case', () => {
- const wrapper = mount(
-
-
-
- );
-
- wrapper.find(`[data-test-subj='form-context-on-success']`).first().simulate('click');
- expect(onSuccess).toHaveBeenCalledWith({ id: 'case-id' });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/flyout.tsx b/x-pack/plugins/cases/public/components/create/flyout.tsx
deleted file mode 100644
index 8ed09865e9eab..0000000000000
--- a/x-pack/plugins/cases/public/components/create/flyout.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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 { EuiFlyout, EuiFlyoutHeader, EuiTitle, EuiFlyoutBody } from '@elastic/eui';
-
-import { FormContext } from '../create/form_context';
-import { CreateCaseForm } from '../create/form';
-import { SubmitCaseButton } from '../create/submit_button';
-import { Case } from '../../containers/types';
-import * as i18n from '../../common/translations';
-
-export interface CreateCaseModalProps {
- onCloseFlyout: () => void;
- onSuccess: (theCase: Case) => Promise;
- afterCaseCreated?: (theCase: Case) => Promise;
-}
-
-const Container = styled.div`
- ${({ theme }) => `
- margin-top: ${theme.eui.euiSize};
- text-align: right;
- `}
-`;
-
-const StyledFlyout = styled(EuiFlyout)`
- ${({ theme }) => `
- z-index: ${theme.eui.euiZModal};
- `}
-`;
-
-// Adding bottom padding because timeline's
-// bottom bar gonna hide the submit button.
-const FormWrapper = styled.div`
- padding-bottom: 50px;
-`;
-
-const CreateCaseFlyoutComponent: React.FC = ({
- onSuccess,
- afterCaseCreated,
- onCloseFlyout,
-}) => {
- return (
-
-
-
- {i18n.CREATE_TITLE}
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export const CreateCaseFlyout = memo(CreateCaseFlyoutComponent);
-
-CreateCaseFlyout.displayName = 'CreateCaseFlyout';
diff --git a/x-pack/plugins/cases/public/components/create/form.test.tsx b/x-pack/plugins/cases/public/components/create/form.test.tsx
deleted file mode 100644
index 9e59924bdf483..0000000000000
--- a/x-pack/plugins/cases/public/components/create/form.test.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { act, waitFor } from '@testing-library/react';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { useGetTags } from '../../containers/use_get_tags';
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { connectorsMock } from '../../containers/mock';
-import { schema, FormProps } from './schema';
-import { CreateCaseForm } from './form';
-
-jest.mock('../../containers/use_get_tags');
-jest.mock('../../containers/configure/use_connectors');
-const useGetTagsMock = useGetTags as jest.Mock;
-const useConnectorsMock = useConnectors as jest.Mock;
-
-const initialCaseValue: FormProps = {
- description: '',
- tags: [],
- title: '',
- connectorId: 'none',
- fields: null,
- syncAlerts: true,
-};
-
-describe('CreateCaseForm', () => {
- let globalForm: FormHook;
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: initialCaseValue,
- options: { stripEmptyFields: false },
- schema,
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- useGetTagsMock.mockReturnValue({ tags: ['test'] });
- useConnectorsMock.mockReturnValue({ loading: false, connectors: connectorsMock });
- });
-
- it('it renders with steps', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="case-creation-form-steps"]`).exists()).toBeTruthy();
- });
-
- it('it renders without steps', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="case-creation-form-steps"]`).exists()).toBeFalsy();
- });
-
- it('it renders all form fields', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseTitle"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseTags"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseDescription"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseSyncAlerts"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseConnectors"]`).exists()).toBeTruthy();
- });
-
- it('should render spinner when loading', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await act(async () => {
- globalForm.setFieldValue('title', 'title');
- globalForm.setFieldValue('description', 'description');
- globalForm.submit();
- // For some weird reason this is needed to pass the test.
- // It does not do anything useful
- await wrapper.find(`[data-test-subj="caseTitle"]`);
- await wrapper.update();
- await waitFor(() => {
- expect(
- wrapper.find(`[data-test-subj="create-case-loading-spinner"]`).exists()
- ).toBeTruthy();
- });
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/form.tsx b/x-pack/plugins/cases/public/components/create/form.tsx
deleted file mode 100644
index a81ecf32576a9..0000000000000
--- a/x-pack/plugins/cases/public/components/create/form.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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, { useMemo } from 'react';
-import { EuiLoadingSpinner, EuiSteps } from '@elastic/eui';
-import styled, { css } from 'styled-components';
-
-import { useFormContext } from '../../common/shared_imports';
-
-import { Title } from './title';
-import { Description } from './description';
-import { Tags } from './tags';
-import { Connector } from './connector';
-import * as i18n from './translations';
-import { SyncAlertsToggle } from './sync_alerts_toggle';
-
-interface ContainerProps {
- big?: boolean;
-}
-
-const Container = styled.div.attrs((props) => props)`
- ${({ big, theme }) => css`
- margin-top: ${big ? theme.eui?.euiSizeXL ?? '32px' : theme.eui?.euiSize ?? '16px'};
- `}
-`;
-
-const MySpinner = styled(EuiLoadingSpinner)`
- position: absolute;
- top: 50%;
- left: 50%;
- z-index: 99;
-`;
-
-interface Props {
- hideConnectorServiceNowSir?: boolean;
- withSteps?: boolean;
-}
-
-export const CreateCaseForm: React.FC = React.memo(
- ({ hideConnectorServiceNowSir = false, withSteps = true }) => {
- const { isSubmitting } = useFormContext();
-
- const firstStep = useMemo(
- () => ({
- title: i18n.STEP_ONE_TITLE,
- children: (
- <>
-
-
-
-
-
-
-
- >
- ),
- }),
- [isSubmitting]
- );
-
- const secondStep = useMemo(
- () => ({
- title: i18n.STEP_TWO_TITLE,
- children: (
-
-
-
- ),
- }),
- [isSubmitting]
- );
-
- const thirdStep = useMemo(
- () => ({
- title: i18n.STEP_THREE_TITLE,
- children: (
-
-
-
- ),
- }),
- [hideConnectorServiceNowSir, isSubmitting]
- );
-
- const allSteps = useMemo(() => [firstStep, secondStep, thirdStep], [
- firstStep,
- secondStep,
- thirdStep,
- ]);
-
- return (
- <>
- {isSubmitting && }
- {withSteps ? (
-
- ) : (
- <>
- {firstStep.children}
- {secondStep.children}
- {thirdStep.children}
- >
- )}
- >
- );
- }
-);
-
-CreateCaseForm.displayName = 'CreateCaseForm';
diff --git a/x-pack/plugins/cases/public/components/create/form_context.test.tsx b/x-pack/plugins/cases/public/components/create/form_context.test.tsx
deleted file mode 100644
index 207ff6207e09d..0000000000000
--- a/x-pack/plugins/cases/public/components/create/form_context.test.tsx
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * 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 { mount, ReactWrapper } from 'enzyme';
-import { act, waitFor } from '@testing-library/react';
-import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
-
-import { ConnectorTypes } from '../../../common';
-import { TestProviders } from '../../common/mock';
-import { usePostCase } from '../../containers/use_post_case';
-import { useGetTags } from '../../containers/use_get_tags';
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { useCaseConfigure } from '../../containers/configure/use_configure';
-import { connectorsMock } from '../../containers/configure/mock';
-import { useGetIncidentTypes } from '../connectors/resilient/use_get_incident_types';
-import { useGetSeverity } from '../connectors/resilient/use_get_severity';
-import { useGetIssueTypes } from '../connectors/jira/use_get_issue_types';
-import { useGetChoices } from '../connectors/servicenow/use_get_choices';
-import { useGetFieldsByIssueType } from '../connectors/jira/use_get_fields_by_issue_type';
-import { useCaseConfigureResponse } from '../configure_cases/__mock__';
-import {
- sampleConnectorData,
- sampleData,
- sampleTags,
- useGetIncidentTypesResponse,
- useGetSeverityResponse,
- useGetIssueTypesResponse,
- useGetFieldsByIssueTypeResponse,
- useGetChoicesResponse,
-} from './mock';
-import { FormContext } from './form_context';
-import { CreateCaseForm } from './form';
-import { SubmitCaseButton } from './submit_button';
-import { usePostPushToService } from '../../containers/use_post_push_to_service';
-
-const sampleId = 'case-id';
-
-jest.mock('../../containers/use_post_case');
-jest.mock('../../containers/use_post_push_to_service');
-jest.mock('../../containers/use_get_tags');
-jest.mock('../../containers/configure/use_connectors');
-jest.mock('../../containers/configure/use_configure');
-jest.mock('../connectors/resilient/use_get_incident_types');
-jest.mock('../connectors/resilient/use_get_severity');
-jest.mock('../connectors/jira/use_get_issue_types');
-jest.mock('../connectors/jira/use_get_fields_by_issue_type');
-jest.mock('../connectors/jira/use_get_single_issue');
-jest.mock('../connectors/jira/use_get_issues');
-jest.mock('../connectors/servicenow/use_get_choices');
-
-const useConnectorsMock = useConnectors as jest.Mock;
-const useCaseConfigureMock = useCaseConfigure as jest.Mock;
-const usePostCaseMock = usePostCase as jest.Mock;
-const usePostPushToServiceMock = usePostPushToService as jest.Mock;
-const useGetIncidentTypesMock = useGetIncidentTypes as jest.Mock;
-const useGetSeverityMock = useGetSeverity as jest.Mock;
-const useGetIssueTypesMock = useGetIssueTypes as jest.Mock;
-const useGetFieldsByIssueTypeMock = useGetFieldsByIssueType as jest.Mock;
-const useGetChoicesMock = useGetChoices as jest.Mock;
-const postCase = jest.fn();
-const pushCaseToExternalService = jest.fn();
-
-const defaultPostCase = {
- isLoading: false,
- isError: false,
- postCase,
-};
-
-const defaultPostPushToService = {
- isLoading: false,
- isError: false,
- pushCaseToExternalService,
-};
-
-const fillForm = (wrapper: ReactWrapper) => {
- wrapper
- .find(`[data-test-subj="caseTitle"] input`)
- .first()
- .simulate('change', { target: { value: sampleData.title } });
-
- wrapper
- .find(`[data-test-subj="caseDescription"] textarea`)
- .first()
- .simulate('change', { target: { value: sampleData.description } });
-
- act(() => {
- ((wrapper.find(EuiComboBox).props() as unknown) as {
- onChange: (a: EuiComboBoxOptionOption[]) => void;
- }).onChange(sampleTags.map((tag) => ({ label: tag })));
- });
-};
-
-describe('Create case', () => {
- const fetchTags = jest.fn();
- const onFormSubmitSuccess = jest.fn();
- const afterCaseCreated = jest.fn();
-
- beforeEach(() => {
- jest.resetAllMocks();
- postCase.mockResolvedValue({
- id: sampleId,
- ...sampleData,
- });
- usePostCaseMock.mockImplementation(() => defaultPostCase);
- usePostPushToServiceMock.mockImplementation(() => defaultPostPushToService);
- useConnectorsMock.mockReturnValue(sampleConnectorData);
- useCaseConfigureMock.mockImplementation(() => useCaseConfigureResponse);
- useGetIncidentTypesMock.mockReturnValue(useGetIncidentTypesResponse);
- useGetSeverityMock.mockReturnValue(useGetSeverityResponse);
- useGetIssueTypesMock.mockReturnValue(useGetIssueTypesResponse);
- useGetFieldsByIssueTypeMock.mockReturnValue(useGetFieldsByIssueTypeResponse);
- useGetChoicesMock.mockReturnValue(useGetChoicesResponse);
-
- (useGetTags as jest.Mock).mockImplementation(() => ({
- tags: sampleTags,
- fetchTags,
- }));
- });
-
- describe('Step 1 - Case Fields', () => {
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseTitle"]`).first().exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseDescription"]`).first().exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseTags"]`).first().exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="caseConnectors"]`).first().exists()).toBeTruthy();
- expect(
- wrapper.find(`[data-test-subj="case-creation-form-steps"]`).first().exists()
- ).toBeTruthy();
- });
-
- it('should post case on submit click', async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- await waitFor(() => expect(postCase).toBeCalledWith(sampleData));
- });
-
- it('should toggle sync settings', async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- wrapper.find('[data-test-subj="caseSyncAlerts"] button').first().simulate('click');
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
-
- await waitFor(() =>
- expect(postCase).toBeCalledWith({ ...sampleData, settings: { syncAlerts: false } })
- );
- });
-
- it('it should select the default connector set in the configuration', async () => {
- useCaseConfigureMock.mockImplementation(() => ({
- ...useCaseConfigureResponse,
- connector: {
- id: 'servicenow-1',
- name: 'SN',
- type: ConnectorTypes.serviceNowITSM,
- fields: null,
- },
- persistLoading: false,
- }));
-
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- await act(async () => {
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- });
-
- await waitFor(() =>
- expect(postCase).toBeCalledWith({
- ...sampleData,
- connector: {
- fields: {
- impact: null,
- severity: null,
- urgency: null,
- category: null,
- subcategory: null,
- },
- id: 'servicenow-1',
- name: 'My Connector',
- type: '.servicenow',
- },
- })
- );
- });
-
- it('it should default to none if the default connector does not exist in connectors', async () => {
- useCaseConfigureMock.mockImplementation(() => ({
- ...useCaseConfigureResponse,
- connector: {
- id: 'not-exist',
- name: 'SN',
- type: ConnectorTypes.serviceNowITSM,
- fields: null,
- },
- persistLoading: false,
- }));
-
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- await waitFor(() => {
- expect(postCase).toBeCalledWith(sampleData);
- expect(pushCaseToExternalService).not.toHaveBeenCalled();
- });
- });
- });
-
- describe('Step 2 - Connector Fields', () => {
- it(`it should submit and push to Jira connector`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-jira-1"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeTruthy();
- });
-
- wrapper
- .find('select[data-test-subj="issueTypeSelect"]')
- .first()
- .simulate('change', {
- target: { value: '10007' },
- });
-
- wrapper
- .find('select[data-test-subj="prioritySelect"]')
- .first()
- .simulate('change', {
- target: { value: '2' },
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
-
- await waitFor(() => {
- expect(postCase).toBeCalledWith({
- ...sampleData,
- connector: {
- id: 'jira-1',
- name: 'Jira',
- type: '.jira',
- fields: { issueType: '10007', parent: null, priority: '2' },
- },
- });
- expect(pushCaseToExternalService).toHaveBeenCalledWith({
- caseId: sampleId,
- connector: {
- id: 'jira-1',
- name: 'Jira',
- type: '.jira',
- fields: { issueType: '10007', parent: null, priority: '2' },
- },
- });
- expect(onFormSubmitSuccess).toHaveBeenCalledWith({
- id: sampleId,
- ...sampleData,
- });
- });
- });
-
- it(`it should submit and push to resilient connector`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-resilient"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-resilient-2"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-resilient"]`).exists()).toBeTruthy();
- });
-
- act(() => {
- ((wrapper.find(EuiComboBox).at(1).props() as unknown) as {
- onChange: (a: EuiComboBoxOptionOption[]) => void;
- }).onChange([{ value: '19', label: 'Denial of Service' }]);
- });
-
- wrapper
- .find('select[data-test-subj="severitySelect"]')
- .first()
- .simulate('change', {
- target: { value: '4' },
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
-
- await waitFor(() => {
- expect(postCase).toBeCalledWith({
- ...sampleData,
- connector: {
- id: 'resilient-2',
- name: 'My Connector 2',
- type: '.resilient',
- fields: { incidentTypes: ['19'], severityCode: '4' },
- },
- });
-
- expect(pushCaseToExternalService).toHaveBeenCalledWith({
- caseId: sampleId,
- connector: {
- id: 'resilient-2',
- name: 'My Connector 2',
- type: '.resilient',
- fields: { incidentTypes: ['19'], severityCode: '4' },
- },
- });
-
- expect(onFormSubmitSuccess).toHaveBeenCalledWith({
- id: sampleId,
- ...sampleData,
- });
- });
- });
-
- it(`it should submit and push to servicenow itsm connector`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-sn-itsm"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-servicenow-1"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-sn-itsm"]`).exists()).toBeTruthy();
- });
-
- ['severitySelect', 'urgencySelect', 'impactSelect'].forEach((subj) => {
- wrapper
- .find(`select[data-test-subj="${subj}"]`)
- .first()
- .simulate('change', {
- target: { value: '2' },
- });
- });
-
- wrapper
- .find('select[data-test-subj="categorySelect"]')
- .first()
- .simulate('change', {
- target: { value: 'software' },
- });
-
- wrapper
- .find('select[data-test-subj="subcategorySelect"]')
- .first()
- .simulate('change', {
- target: { value: 'os' },
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
-
- await waitFor(() => {
- expect(postCase).toBeCalledWith({
- ...sampleData,
- connector: {
- id: 'servicenow-1',
- name: 'My Connector',
- type: '.servicenow',
- fields: {
- impact: '2',
- severity: '2',
- urgency: '2',
- category: 'software',
- subcategory: 'os',
- },
- },
- });
-
- expect(pushCaseToExternalService).toHaveBeenCalledWith({
- caseId: sampleId,
- connector: {
- id: 'servicenow-1',
- name: 'My Connector',
- type: '.servicenow',
- fields: {
- impact: '2',
- severity: '2',
- urgency: '2',
- category: 'software',
- subcategory: 'os',
- },
- },
- });
-
- expect(onFormSubmitSuccess).toHaveBeenCalledWith({
- id: sampleId,
- ...sampleData,
- });
- });
- });
-
- it(`it should submit and push to servicenow sir connector`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-sn-sir"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-servicenow-sir"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-sn-sir"]`).exists()).toBeTruthy();
- });
-
- wrapper
- .find('[data-test-subj="destIpCheckbox"] input')
- .first()
- .simulate('change', { target: { checked: false } });
-
- wrapper
- .find('select[data-test-subj="prioritySelect"]')
- .first()
- .simulate('change', {
- target: { value: '1' },
- });
-
- wrapper
- .find('select[data-test-subj="categorySelect"]')
- .first()
- .simulate('change', {
- target: { value: 'Denial of Service' },
- });
-
- wrapper
- .find('select[data-test-subj="subcategorySelect"]')
- .first()
- .simulate('change', {
- target: { value: '26' },
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
-
- await waitFor(() => {
- expect(postCase).toBeCalledWith({
- ...sampleData,
- connector: {
- id: 'servicenow-sir',
- name: 'My Connector SIR',
- type: '.servicenow-sir',
- fields: {
- destIp: false,
- sourceIp: true,
- malwareHash: true,
- malwareUrl: true,
- priority: '1',
- category: 'Denial of Service',
- subcategory: '26',
- },
- },
- });
-
- expect(pushCaseToExternalService).toHaveBeenCalledWith({
- caseId: sampleId,
- connector: {
- id: 'servicenow-sir',
- name: 'My Connector SIR',
- type: '.servicenow-sir',
- fields: {
- destIp: false,
- sourceIp: true,
- malwareHash: true,
- malwareUrl: true,
- priority: '1',
- category: 'Denial of Service',
- subcategory: '26',
- },
- },
- });
-
- expect(onFormSubmitSuccess).toHaveBeenCalledWith({
- id: sampleId,
- ...sampleData,
- });
- });
- });
- });
-
- it(`it should call afterCaseCreated`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-jira-1"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeTruthy();
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- await waitFor(() => {
- expect(afterCaseCreated).toHaveBeenCalledWith({
- id: sampleId,
- ...sampleData,
- });
- });
- });
-
- it(`it should call callbacks in correct order`, async () => {
- useConnectorsMock.mockReturnValue({
- ...sampleConnectorData,
- connectors: connectorsMock,
- });
-
- const wrapper = mount(
-
-
-
-
-
-
- );
-
- fillForm(wrapper);
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeFalsy();
- wrapper.find('button[data-test-subj="dropdown-connectors"]').simulate('click');
- wrapper.find(`button[data-test-subj="dropdown-connector-jira-1"]`).simulate('click');
-
- await waitFor(() => {
- wrapper.update();
- expect(wrapper.find(`[data-test-subj="connector-fields-jira"]`).exists()).toBeTruthy();
- });
-
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- await waitFor(() => {
- expect(postCase).toHaveBeenCalled();
- expect(afterCaseCreated).toHaveBeenCalled();
- expect(pushCaseToExternalService).toHaveBeenCalled();
- expect(onFormSubmitSuccess).toHaveBeenCalled();
- });
-
- const postCaseOrder = postCase.mock.invocationCallOrder[0];
- const afterCaseOrder = afterCaseCreated.mock.invocationCallOrder[0];
- const pushCaseToExternalServiceOrder = pushCaseToExternalService.mock.invocationCallOrder[0];
- const onFormSubmitSuccessOrder = onFormSubmitSuccess.mock.invocationCallOrder[0];
-
- expect(
- postCaseOrder < afterCaseOrder &&
- postCaseOrder < pushCaseToExternalServiceOrder &&
- postCaseOrder < onFormSubmitSuccessOrder
- ).toBe(true);
-
- expect(
- afterCaseOrder < pushCaseToExternalServiceOrder && afterCaseOrder < onFormSubmitSuccessOrder
- ).toBe(true);
-
- expect(pushCaseToExternalServiceOrder < onFormSubmitSuccessOrder).toBe(true);
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/form_context.tsx b/x-pack/plugins/cases/public/components/create/form_context.tsx
deleted file mode 100644
index e84f451ab4215..0000000000000
--- a/x-pack/plugins/cases/public/components/create/form_context.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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, { useCallback, useEffect, useMemo } from 'react';
-import { schema, FormProps } from './schema';
-import { Form, useForm } from '../../common/shared_imports';
-import {
- getConnectorById,
- getNoneConnector,
- normalizeActionConnector,
-} from '../configure_cases/utils';
-import { usePostCase } from '../../containers/use_post_case';
-import { usePostPushToService } from '../../containers/use_post_push_to_service';
-
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { useCaseConfigure } from '../../containers/configure/use_configure';
-import { Case } from '../../containers/types';
-import { CaseType, ConnectorTypes } from '../../../common';
-
-const initialCaseValue: FormProps = {
- description: '',
- tags: [],
- title: '',
- connectorId: 'none',
- fields: null,
- syncAlerts: true,
-};
-
-interface Props {
- afterCaseCreated?: (theCase: Case) => Promise;
- caseType?: CaseType;
- hideConnectorServiceNowSir?: boolean;
- onSuccess?: (theCase: Case) => Promise;
-}
-
-export const FormContext: React.FC = ({
- afterCaseCreated,
- caseType = CaseType.individual,
- children,
- hideConnectorServiceNowSir,
- onSuccess,
-}) => {
- const { connectors } = useConnectors();
- const { connector: configurationConnector } = useCaseConfigure();
- const { postCase } = usePostCase();
- const { pushCaseToExternalService } = usePostPushToService();
-
- const connectorId = useMemo(() => {
- if (
- hideConnectorServiceNowSir &&
- configurationConnector.type === ConnectorTypes.serviceNowSIR
- ) {
- return 'none';
- }
- return connectors.some((connector) => connector.id === configurationConnector.id)
- ? configurationConnector.id
- : 'none';
- }, [
- configurationConnector.id,
- configurationConnector.type,
- connectors,
- hideConnectorServiceNowSir,
- ]);
-
- const submitCase = useCallback(
- async (
- { connectorId: dataConnectorId, fields, syncAlerts, ...dataWithoutConnectorId },
- isValid
- ) => {
- if (isValid) {
- const caseConnector = getConnectorById(dataConnectorId, connectors);
-
- const connectorToUpdate = caseConnector
- ? normalizeActionConnector(caseConnector, fields)
- : getNoneConnector();
-
- const updatedCase = await postCase({
- ...dataWithoutConnectorId,
- type: caseType,
- connector: connectorToUpdate,
- settings: { syncAlerts },
- });
-
- if (afterCaseCreated && updatedCase) {
- await afterCaseCreated(updatedCase);
- }
-
- if (updatedCase?.id && dataConnectorId !== 'none') {
- await pushCaseToExternalService({
- caseId: updatedCase.id,
- connector: connectorToUpdate,
- });
- }
-
- if (onSuccess && updatedCase) {
- await onSuccess(updatedCase);
- }
- }
- },
- [caseType, connectors, postCase, onSuccess, pushCaseToExternalService, afterCaseCreated]
- );
-
- const { form } = useForm({
- defaultValue: initialCaseValue,
- options: { stripEmptyFields: false },
- schema,
- onSubmit: submitCase,
- });
- const { setFieldValue } = form;
- // Set the selected connector to the configuration connector
- useEffect(() => setFieldValue('connectorId', connectorId), [connectorId, setFieldValue]);
-
- return ;
-};
-
-FormContext.displayName = 'FormContext';
diff --git a/x-pack/plugins/cases/public/components/create/index.test.tsx b/x-pack/plugins/cases/public/components/create/index.test.tsx
deleted file mode 100644
index e82af8edc6337..0000000000000
--- a/x-pack/plugins/cases/public/components/create/index.test.tsx
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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 { mount, ReactWrapper } from 'enzyme';
-import { act, waitFor } from '@testing-library/react';
-import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
-
-import { TestProviders } from '../../common/mock';
-import { useGetTags } from '../../containers/use_get_tags';
-import { useConnectors } from '../../containers/configure/use_connectors';
-import { useCaseConfigure } from '../../containers/configure/use_configure';
-import { useGetIncidentTypes } from '../connectors/resilient/use_get_incident_types';
-import { useGetSeverity } from '../connectors/resilient/use_get_severity';
-import { useGetIssueTypes } from '../connectors/jira/use_get_issue_types';
-import { useGetFieldsByIssueType } from '../connectors/jira/use_get_fields_by_issue_type';
-import { useCaseConfigureResponse } from '../configure_cases/__mock__';
-import {
- sampleConnectorData,
- sampleData,
- sampleTags,
- useGetIncidentTypesResponse,
- useGetSeverityResponse,
- useGetIssueTypesResponse,
- useGetFieldsByIssueTypeResponse,
-} from './mock';
-import { CreateCase } from '.';
-
-jest.mock('../../containers/api');
-jest.mock('../../containers/use_get_tags');
-jest.mock('../../containers/configure/use_connectors');
-jest.mock('../../containers/configure/use_configure');
-jest.mock('../connectors/resilient/use_get_incident_types');
-jest.mock('../connectors/resilient/use_get_severity');
-jest.mock('../connectors/jira/use_get_issue_types');
-jest.mock('../connectors/jira/use_get_fields_by_issue_type');
-jest.mock('../connectors/jira/use_get_single_issue');
-jest.mock('../connectors/jira/use_get_issues');
-
-const useConnectorsMock = useConnectors as jest.Mock;
-const useCaseConfigureMock = useCaseConfigure as jest.Mock;
-const useGetTagsMock = useGetTags as jest.Mock;
-const useGetIncidentTypesMock = useGetIncidentTypes as jest.Mock;
-const useGetSeverityMock = useGetSeverity as jest.Mock;
-const useGetIssueTypesMock = useGetIssueTypes as jest.Mock;
-const useGetFieldsByIssueTypeMock = useGetFieldsByIssueType as jest.Mock;
-const fetchTags = jest.fn();
-
-const fillForm = (wrapper: ReactWrapper) => {
- wrapper
- .find(`[data-test-subj="caseTitle"] input`)
- .first()
- .simulate('change', { target: { value: sampleData.title } });
-
- wrapper
- .find(`[data-test-subj="caseDescription"] textarea`)
- .first()
- .simulate('change', { target: { value: sampleData.description } });
-
- act(() => {
- ((wrapper.find(EuiComboBox).props() as unknown) as {
- onChange: (a: EuiComboBoxOptionOption[]) => void;
- }).onChange(sampleTags.map((tag) => ({ label: tag })));
- });
-};
-
-const defaultProps = {
- onCancel: jest.fn(),
- onSuccess: jest.fn(),
-};
-
-describe('CreateCase case', () => {
- beforeEach(() => {
- jest.resetAllMocks();
- useConnectorsMock.mockReturnValue(sampleConnectorData);
- useCaseConfigureMock.mockImplementation(() => useCaseConfigureResponse);
- useGetIncidentTypesMock.mockReturnValue(useGetIncidentTypesResponse);
- useGetSeverityMock.mockReturnValue(useGetSeverityResponse);
- useGetIssueTypesMock.mockReturnValue(useGetIssueTypesResponse);
- useGetFieldsByIssueTypeMock.mockReturnValue(useGetFieldsByIssueTypeResponse);
- useGetTagsMock.mockImplementation(() => ({
- tags: sampleTags,
- fetchTags,
- }));
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="create-case-submit"]`).exists()).toBeTruthy();
- expect(wrapper.find(`[data-test-subj="create-case-cancel"]`).exists()).toBeTruthy();
- });
-
- it('should call cancel on cancel click', async () => {
- const wrapper = mount(
-
-
-
- );
-
- wrapper.find(`[data-test-subj="create-case-cancel"]`).first().simulate('click');
- expect(defaultProps.onCancel).toHaveBeenCalled();
- });
-
- it('should redirect to new case when posting the case', async () => {
- const wrapper = mount(
-
-
-
- );
-
- fillForm(wrapper);
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- await waitFor(() => {
- expect(defaultProps.onSuccess).toHaveBeenCalled();
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/index.tsx b/x-pack/plugins/cases/public/components/create/index.tsx
deleted file mode 100644
index 192effb6adb24..0000000000000
--- a/x-pack/plugins/cases/public/components/create/index.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
-import styled from 'styled-components';
-
-import { Field, getUseField } from '../../common/shared_imports';
-import * as i18n from './translations';
-import { CreateCaseForm } from './form';
-import { FormContext } from './form_context';
-import { SubmitCaseButton } from './submit_button';
-import { Case } from '../../containers/types';
-
-export const CommonUseField = getUseField({ component: Field });
-
-const Container = styled.div`
- ${({ theme }) => `
- margin-top: ${theme.eui.euiSize};
- `}
-`;
-
-export interface CreateCaseProps {
- afterCaseCreated?: (theCase: Case) => Promise;
- onCancel: () => void;
- onSuccess: (theCase: Case) => Promise;
-}
-
-export const CreateCase = ({ afterCaseCreated, onCancel, onSuccess }: CreateCaseProps) => (
-
-
-
-
-
-
- {i18n.CANCEL}
-
-
-
-
-
-
-
-
-);
-
-// eslint-disable-next-line import/no-default-export
-export { CreateCase as default };
diff --git a/x-pack/plugins/cases/public/components/create/mock.ts b/x-pack/plugins/cases/public/components/create/mock.ts
deleted file mode 100644
index eb40fa097d3cc..0000000000000
--- a/x-pack/plugins/cases/public/components/create/mock.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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 { CasePostRequest, CaseType, ConnectorTypes } from '../../../common';
-import { choices } from '../connectors/mock';
-
-export const sampleTags = ['coke', 'pepsi'];
-export const sampleData: CasePostRequest = {
- description: 'what a great description',
- tags: sampleTags,
- title: 'what a cool title',
- type: CaseType.individual,
- connector: {
- fields: null,
- id: 'none',
- name: 'none',
- type: ConnectorTypes.none,
- },
- settings: {
- syncAlerts: true,
- },
-};
-
-export const sampleConnectorData = { loading: false, connectors: [] };
-
-export const useGetIncidentTypesResponse = {
- isLoading: false,
- incidentTypes: [
- {
- id: 19,
- name: 'Malware',
- },
- {
- id: 21,
- name: 'Denial of Service',
- },
- ],
-};
-
-export const useGetSeverityResponse = {
- isLoading: false,
- severity: [
- {
- id: 4,
- name: 'Low',
- },
- {
- id: 5,
- name: 'Medium',
- },
- {
- id: 6,
- name: 'High',
- },
- ],
-};
-
-export const useGetIssueTypesResponse = {
- isLoading: false,
- issueTypes: [
- {
- id: '10006',
- name: 'Task',
- },
- {
- id: '10007',
- name: 'Bug',
- },
- ],
-};
-
-export const useGetFieldsByIssueTypeResponse = {
- isLoading: false,
- fields: {
- summary: { allowedValues: [], defaultValue: {} },
- labels: { allowedValues: [], defaultValue: {} },
- description: { allowedValues: [], defaultValue: {} },
- priority: {
- allowedValues: [
- {
- name: 'Medium',
- id: '3',
- },
- {
- name: 'Low',
- id: '2',
- },
- ],
- defaultValue: { name: 'Medium', id: '3' },
- },
- },
-};
-
-export const useGetChoicesResponse = {
- isLoading: false,
- choices,
-};
diff --git a/x-pack/plugins/cases/public/components/create/optional_field_label/index.test.tsx b/x-pack/plugins/cases/public/components/create/optional_field_label/index.test.tsx
deleted file mode 100644
index 4b6d5f90513ef..0000000000000
--- a/x-pack/plugins/cases/public/components/create/optional_field_label/index.test.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-
-import { OptionalFieldLabel } from '.';
-
-describe('OptionalFieldLabel', () => {
- it('it renders correctly', async () => {
- const wrapper = mount(OptionalFieldLabel);
- expect(wrapper.find('[data-test-subj="form-optional-field-label"]').first().text()).toBe(
- 'Optional'
- );
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/optional_field_label/index.tsx b/x-pack/plugins/cases/public/components/create/optional_field_label/index.tsx
deleted file mode 100644
index ea994b2219961..0000000000000
--- a/x-pack/plugins/cases/public/components/create/optional_field_label/index.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * 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 { EuiText } from '@elastic/eui';
-import React from 'react';
-
-import * as i18n from '../../../common/translations';
-
-export const OptionalFieldLabel = (
-
- {i18n.OPTIONAL}
-
-);
diff --git a/x-pack/plugins/cases/public/components/create/schema.tsx b/x-pack/plugins/cases/public/components/create/schema.tsx
deleted file mode 100644
index 7ca1e2e061545..0000000000000
--- a/x-pack/plugins/cases/public/components/create/schema.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 { CasePostRequest, ConnectorTypeFields } from '../../../common';
-import { FIELD_TYPES, fieldValidators, FormSchema } from '../../common/shared_imports';
-import * as i18n from './translations';
-
-import { OptionalFieldLabel } from './optional_field_label';
-const { emptyField } = fieldValidators;
-
-export const schemaTags = {
- type: FIELD_TYPES.COMBO_BOX,
- label: i18n.TAGS,
- helpText: i18n.TAGS_HELP,
- labelAppend: OptionalFieldLabel,
-};
-
-export type FormProps = Omit & {
- connectorId: string;
- fields: ConnectorTypeFields['fields'];
- syncAlerts: boolean;
-};
-
-export const schema: FormSchema = {
- title: {
- type: FIELD_TYPES.TEXT,
- label: i18n.NAME,
- validations: [
- {
- validator: emptyField(i18n.TITLE_REQUIRED),
- },
- ],
- },
- description: {
- label: i18n.DESCRIPTION,
- validations: [
- {
- validator: emptyField(i18n.DESCRIPTION_REQUIRED),
- },
- ],
- },
- tags: schemaTags,
- connectorId: {
- type: FIELD_TYPES.SUPER_SELECT,
- label: i18n.CONNECTORS,
- defaultValue: 'none',
- },
- fields: {},
- syncAlerts: {
- helpText: i18n.SYNC_ALERTS_HELP,
- type: FIELD_TYPES.TOGGLE,
- defaultValue: true,
- },
-};
diff --git a/x-pack/plugins/cases/public/components/create/submit_button.test.tsx b/x-pack/plugins/cases/public/components/create/submit_button.test.tsx
deleted file mode 100644
index dd67c8170dc3f..0000000000000
--- a/x-pack/plugins/cases/public/components/create/submit_button.test.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { act, waitFor } from '@testing-library/react';
-
-import { useForm, Form } from '../../common/shared_imports';
-import { SubmitCaseButton } from './submit_button';
-import { schema, FormProps } from './schema';
-
-describe('SubmitCaseButton', () => {
- const onSubmit = jest.fn();
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { title: 'My title' },
- schema: {
- title: schema.title,
- },
- onSubmit,
- });
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="create-case-submit"]`).exists()).toBeTruthy();
- });
-
- it('it submits', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await act(async () => {
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- });
-
- await waitFor(() => expect(onSubmit).toBeCalled());
- });
-
- it('it disables when submitting', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await waitFor(() => {
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- expect(
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().prop('isDisabled')
- ).toBeTruthy();
- });
- });
-
- it('it is loading when submitting', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await waitFor(() => {
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().simulate('click');
- expect(
- wrapper.find(`[data-test-subj="create-case-submit"]`).first().prop('isLoading')
- ).toBeTruthy();
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/submit_button.tsx b/x-pack/plugins/cases/public/components/create/submit_button.tsx
deleted file mode 100644
index b5e58517e6ec1..0000000000000
--- a/x-pack/plugins/cases/public/components/create/submit_button.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 { EuiButton } from '@elastic/eui';
-
-import { useFormContext } from '../../common/shared_imports';
-import * as i18n from './translations';
-
-const SubmitCaseButtonComponent: React.FC = () => {
- const { submit, isSubmitting } = useFormContext();
-
- return (
-
- {i18n.CREATE_CASE}
-
- );
-};
-
-export const SubmitCaseButton = memo(SubmitCaseButtonComponent);
diff --git a/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.test.tsx b/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.test.tsx
deleted file mode 100644
index b4a37f0abb518..0000000000000
--- a/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.test.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { waitFor } from '@testing-library/react';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { SyncAlertsToggle } from './sync_alerts_toggle';
-import { schema, FormProps } from './schema';
-
-describe('SyncAlertsToggle', () => {
- let globalForm: FormHook;
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { syncAlerts: true },
- schema: {
- syncAlerts: schema.syncAlerts,
- },
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseSyncAlerts"]`).exists()).toBeTruthy();
- });
-
- it('it toggles the switch', async () => {
- const wrapper = mount(
-
-
-
- );
-
- wrapper.find('[data-test-subj="caseSyncAlerts"] button').first().simulate('click');
-
- await waitFor(() => {
- expect(globalForm.getFormData()).toEqual({ syncAlerts: false });
- });
- });
-
- it('it shows the correct labels', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseSyncAlerts"] .euiSwitch__label`).first().text()).toBe(
- 'On'
- );
-
- wrapper.find('[data-test-subj="caseSyncAlerts"] button').first().simulate('click');
-
- await waitFor(() => {
- expect(
- wrapper.find(`[data-test-subj="caseSyncAlerts"] .euiSwitch__label`).first().text()
- ).toBe('Off');
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.tsx b/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.tsx
deleted file mode 100644
index bed8e6d18f5e3..0000000000000
--- a/x-pack/plugins/cases/public/components/create/sync_alerts_toggle.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 { Field, getUseField, useFormData } from '../../common/shared_imports';
-import * as i18n from './translations';
-
-const CommonUseField = getUseField({ component: Field });
-
-interface Props {
- isLoading: boolean;
-}
-
-const SyncAlertsToggleComponent: React.FC = ({ isLoading }) => {
- const [{ syncAlerts }] = useFormData({ watch: ['syncAlerts'] });
- return (
-
- );
-};
-
-SyncAlertsToggleComponent.displayName = 'SyncAlertsToggleComponent';
-
-export const SyncAlertsToggle = memo(SyncAlertsToggleComponent);
diff --git a/x-pack/plugins/cases/public/components/create/tags.test.tsx b/x-pack/plugins/cases/public/components/create/tags.test.tsx
deleted file mode 100644
index 2eddb83dcac29..0000000000000
--- a/x-pack/plugins/cases/public/components/create/tags.test.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui';
-import { waitFor } from '@testing-library/react';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { useGetTags } from '../../containers/use_get_tags';
-import { Tags } from './tags';
-import { schema, FormProps } from './schema';
-
-jest.mock('../../containers/use_get_tags');
-const useGetTagsMock = useGetTags as jest.Mock;
-
-describe('Tags', () => {
- let globalForm: FormHook;
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { tags: [] },
- schema: {
- tags: schema.tags,
- },
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- useGetTagsMock.mockReturnValue({ tags: ['test'] });
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await waitFor(() => {
- expect(wrapper.find(`[data-test-subj="caseTags"]`).exists()).toBeTruthy();
- });
- });
-
- it('it disables the input when loading', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(EuiComboBox).prop('disabled')).toBeTruthy();
- });
-
- it('it changes the tags', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await waitFor(() => {
- ((wrapper.find(EuiComboBox).props() as unknown) as {
- onChange: (a: EuiComboBoxOptionOption[]) => void;
- }).onChange(['test', 'case'].map((tag) => ({ label: tag })));
- });
-
- expect(globalForm.getFormData()).toEqual({ tags: ['test', 'case'] });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/tags.tsx b/x-pack/plugins/cases/public/components/create/tags.tsx
deleted file mode 100644
index ac0b67529e15a..0000000000000
--- a/x-pack/plugins/cases/public/components/create/tags.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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, useMemo } from 'react';
-
-import { Field, getUseField } from '../../common/shared_imports';
-import { useGetTags } from '../../containers/use_get_tags';
-
-const CommonUseField = getUseField({ component: Field });
-
-interface Props {
- isLoading: boolean;
-}
-
-const TagsComponent: React.FC = ({ isLoading }) => {
- const { tags: tagOptions, isLoading: isLoadingTags } = useGetTags();
- const options = useMemo(
- () =>
- tagOptions.map((label) => ({
- label,
- })),
- [tagOptions]
- );
-
- return (
-
- );
-};
-
-TagsComponent.displayName = 'TagsComponent';
-
-export const Tags = memo(TagsComponent);
diff --git a/x-pack/plugins/cases/public/components/create/title.test.tsx b/x-pack/plugins/cases/public/components/create/title.test.tsx
deleted file mode 100644
index a41d5afbb4038..0000000000000
--- a/x-pack/plugins/cases/public/components/create/title.test.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-import { act } from '@testing-library/react';
-
-import { useForm, Form, FormHook } from '../../common/shared_imports';
-import { Title } from './title';
-import { schema, FormProps } from './schema';
-
-describe('Title', () => {
- let globalForm: FormHook;
-
- const MockHookWrapperComponent: React.FC = ({ children }) => {
- const { form } = useForm({
- defaultValue: { title: 'My title' },
- schema: {
- title: schema.title,
- },
- });
-
- globalForm = form;
-
- return ;
- };
-
- beforeEach(() => {
- jest.resetAllMocks();
- });
-
- it('it renders', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseTitle"]`).exists()).toBeTruthy();
- });
-
- it('it disables the input when loading', async () => {
- const wrapper = mount(
-
-
-
- );
-
- expect(wrapper.find(`[data-test-subj="caseTitle"] input`).prop('disabled')).toBeTruthy();
- });
-
- it('it changes the title', async () => {
- const wrapper = mount(
-
-
-
- );
-
- await act(async () => {
- wrapper
- .find(`[data-test-subj="caseTitle"] input`)
- .first()
- .simulate('change', { target: { value: 'My new title' } });
- });
-
- expect(globalForm.getFormData()).toEqual({ title: 'My new title' });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/create/title.tsx b/x-pack/plugins/cases/public/components/create/title.tsx
deleted file mode 100644
index cc51a805b5c38..0000000000000
--- a/x-pack/plugins/cases/public/components/create/title.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 { Field, getUseField } from '../../common/shared_imports';
-
-const CommonUseField = getUseField({ component: Field });
-
-interface Props {
- isLoading: boolean;
-}
-
-const TitleComponent: React.FC = ({ isLoading }) => (
-
-);
-
-TitleComponent.displayName = 'TitleComponent';
-
-export const Title = memo(TitleComponent);
diff --git a/x-pack/plugins/cases/public/components/create/translations.ts b/x-pack/plugins/cases/public/components/create/translations.ts
deleted file mode 100644
index 7e0f7e5a6b9d5..0000000000000
--- a/x-pack/plugins/cases/public/components/create/translations.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 { i18n } from '@kbn/i18n';
-
-export * from '../../common/translations';
-
-export const STEP_ONE_TITLE = i18n.translate('xpack.cases.create.stepOneTitle', {
- defaultMessage: 'Case fields',
-});
-
-export const STEP_TWO_TITLE = i18n.translate('xpack.cases.create.stepTwoTitle', {
- defaultMessage: 'Case settings',
-});
-
-export const STEP_THREE_TITLE = i18n.translate('xpack.cases.create.stepThreeTitle', {
- defaultMessage: 'External Connector Fields',
-});
-
-export const SYNC_ALERTS_LABEL = i18n.translate('xpack.cases.create.syncAlertsLabel', {
- defaultMessage: 'Sync alert status with case status',
-});
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx b/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx
deleted file mode 100644
index a7d37fdda3085..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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, useEffect, useState, useCallback } from 'react';
-import {
- EuiMarkdownEditor,
- getDefaultEuiMarkdownParsingPlugins,
- getDefaultEuiMarkdownProcessingPlugins,
- getDefaultEuiMarkdownUiPlugins,
-} from '@elastic/eui';
-
-interface MarkdownEditorProps {
- onChange: (content: string) => void;
- value: string;
- ariaLabel: string;
- editorId?: string;
- dataTestSubj?: string;
- height?: number;
-}
-
-// create plugin stuff here
-export const { uiPlugins, parsingPlugins, processingPlugins } = {
- uiPlugins: getDefaultEuiMarkdownUiPlugins(),
- parsingPlugins: getDefaultEuiMarkdownParsingPlugins(),
- processingPlugins: getDefaultEuiMarkdownProcessingPlugins(),
-};
-const MarkdownEditorComponent: React.FC = ({
- onChange,
- value,
- ariaLabel,
- editorId,
- dataTestSubj,
- height,
-}) => {
- const [markdownErrorMessages, setMarkdownErrorMessages] = useState([]);
- const onParse = useCallback((err, { messages }) => {
- setMarkdownErrorMessages(err ? [err] : messages);
- }, []);
-
- useEffect(
- () => document.querySelector('textarea.euiMarkdownEditorTextArea')?.focus(),
- []
- );
-
- return (
-
- );
-};
-
-export const MarkdownEditor = memo(MarkdownEditorComponent);
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/eui_form.tsx b/x-pack/plugins/cases/public/components/markdown_editor/eui_form.tsx
deleted file mode 100644
index 858e79ff65baf..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/eui_form.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 styled from 'styled-components';
-import { EuiMarkdownEditorProps, EuiFormRow, EuiFlexItem, EuiFlexGroup } from '@elastic/eui';
-import { FieldHook, getFieldValidityAndErrorMessage } from '../../common/shared_imports';
-
-import { MarkdownEditor } from './editor';
-
-type MarkdownEditorFormProps = EuiMarkdownEditorProps & {
- id: string;
- field: FieldHook;
- dataTestSubj: string;
- idAria: string;
- isDisabled?: boolean;
- bottomRightContent?: React.ReactNode;
-};
-
-const BottomContentWrapper = styled(EuiFlexGroup)`
- ${({ theme }) => `
- padding: ${theme.eui.ruleMargins.marginSmall} 0;
- `}
-`;
-
-export const MarkdownEditorForm: React.FC = ({
- id,
- field,
- dataTestSubj,
- idAria,
- bottomRightContent,
-}) => {
- const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field);
-
- return (
-
- <>
-
- {bottomRightContent && (
-
- {bottomRightContent}
-
- )}
- >
-
- );
-};
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/index.tsx b/x-pack/plugins/cases/public/components/markdown_editor/index.tsx
deleted file mode 100644
index e77a36d48f7d9..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/index.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * 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 * from './types';
-export * from './renderer';
-export * from './editor';
-export * from './eui_form';
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/markdown_link.tsx b/x-pack/plugins/cases/public/components/markdown_editor/markdown_link.tsx
deleted file mode 100644
index 7cc8a07c8c04e..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/markdown_link.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 { EuiLink, EuiLinkAnchorProps, EuiToolTip } from '@elastic/eui';
-
-type MarkdownLinkProps = { disableLinks?: boolean } & EuiLinkAnchorProps;
-
-/** prevents search engine manipulation by noting the linked document is not trusted or endorsed by us */
-const REL_NOFOLLOW = 'nofollow';
-
-const MarkdownLinkComponent: React.FC = ({
- disableLinks,
- href,
- target,
- children,
- ...props
-}) => (
-
-
- {children}
-
-
-);
-
-export const MarkdownLink = memo(MarkdownLinkComponent);
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/renderer.test.tsx b/x-pack/plugins/cases/public/components/markdown_editor/renderer.test.tsx
deleted file mode 100644
index 5d299529561ba..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/renderer.test.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-
-import { removeExternalLinkText } from '../../common/test_utils';
-import { MarkdownRenderer } from './renderer';
-
-describe('Markdown', () => {
- describe('markdown links', () => {
- const markdownWithLink = 'A link to an external site [External Site](https://google.com)';
-
- test('it renders the expected link text', () => {
- const wrapper = mount({markdownWithLink});
-
- expect(
- removeExternalLinkText(wrapper.find('[data-test-subj="markdown-link"]').first().text())
- ).toEqual('External Site');
- });
-
- test('it renders the expected href', () => {
- const wrapper = mount({markdownWithLink});
-
- expect(wrapper.find('[data-test-subj="markdown-link"]').first().getDOMNode()).toHaveProperty(
- 'href',
- 'https://google.com/'
- );
- });
-
- test('it does NOT render the href if links are disabled', () => {
- const wrapper = mount(
- {markdownWithLink}
- );
-
- expect(
- wrapper.find('[data-test-subj="markdown-link"]').first().getDOMNode()
- ).not.toHaveProperty('href');
- });
-
- test('it opens links in a new tab via target="_blank"', () => {
- const wrapper = mount({markdownWithLink});
-
- expect(wrapper.find('[data-test-subj="markdown-link"]').first().getDOMNode()).toHaveProperty(
- 'target',
- '_blank'
- );
- });
-
- test('it sets the link `rel` attribute to `noopener` to prevent the new page from accessing `window.opener`, `nofollow` to note the link is not endorsed by us, and noreferrer to prevent the browser from sending the current address', () => {
- const wrapper = mount({markdownWithLink});
-
- expect(wrapper.find('[data-test-subj="markdown-link"]').first().getDOMNode()).toHaveProperty(
- 'rel',
- 'nofollow noopener noreferrer'
- );
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/renderer.tsx b/x-pack/plugins/cases/public/components/markdown_editor/renderer.tsx
deleted file mode 100644
index c321c794c1e77..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/renderer.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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, useMemo } from 'react';
-import { cloneDeep } from 'lodash/fp';
-import { EuiMarkdownFormat, EuiLinkAnchorProps } from '@elastic/eui';
-
-import { parsingPlugins, processingPlugins } from './';
-import { MarkdownLink } from './markdown_link';
-
-interface Props {
- children: string;
- disableLinks?: boolean;
-}
-
-const MarkdownRendererComponent: React.FC = ({ children, disableLinks }) => {
- const MarkdownLinkProcessingComponent: React.FC = useMemo(
- () => (props) => ,
- [disableLinks]
- );
-
- // Deep clone of the processing plugins to prevent affecting the markdown editor.
- const processingPluginList = cloneDeep(processingPlugins);
- // This line of code is TS-compatible and it will break if [1][1] change in the future.
- processingPluginList[1][1].components.a = MarkdownLinkProcessingComponent;
-
- return (
-
- {children}
-
- );
-};
-
-export const MarkdownRenderer = memo(MarkdownRendererComponent);
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/translations.ts b/x-pack/plugins/cases/public/components/markdown_editor/translations.ts
deleted file mode 100644
index 365738f53ef8a..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/translations.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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 { i18n } from '@kbn/i18n';
-
-export const MARKDOWN_SYNTAX_HELP = i18n.translate('xpack.cases.markdownEditor.markdownInputHelp', {
- defaultMessage: 'Markdown syntax help',
-});
-
-export const MARKDOWN = i18n.translate('xpack.cases.markdownEditor.markdown', {
- defaultMessage: 'Markdown',
-});
-export const PREVIEW = i18n.translate('xpack.cases.markdownEditor.preview', {
- defaultMessage: 'Preview',
-});
diff --git a/x-pack/plugins/cases/public/components/markdown_editor/types.ts b/x-pack/plugins/cases/public/components/markdown_editor/types.ts
deleted file mode 100644
index 8a30a4a143f54..0000000000000
--- a/x-pack/plugins/cases/public/components/markdown_editor/types.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * 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 interface CursorPosition {
- start: number;
- end: number;
-}
diff --git a/x-pack/plugins/cases/public/components/status/button.test.tsx b/x-pack/plugins/cases/public/components/status/button.test.tsx
deleted file mode 100644
index a4d4a53ff4a62..0000000000000
--- a/x-pack/plugins/cases/public/components/status/button.test.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-
-import { CaseStatuses } from '../../../common';
-import { StatusActionButton } from './button';
-
-describe('StatusActionButton', () => {
- const onStatusChanged = jest.fn();
- const defaultProps = {
- status: CaseStatuses.open,
- disabled: false,
- isLoading: false,
- onStatusChanged,
- };
-
- it('it renders', async () => {
- const wrapper = mount();
-
- expect(wrapper.find(`[data-test-subj="case-view-status-action-button"]`).exists()).toBeTruthy();
- });
-
- describe('Button icons', () => {
- it('it renders the correct button icon: status open', () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="case-view-status-action-button"]`).first().prop('iconType')
- ).toBe('folderExclamation');
- });
-
- it('it renders the correct button icon: status in-progress', () => {
- const wrapper = mount(
-
- );
-
- expect(
- wrapper.find(`[data-test-subj="case-view-status-action-button"]`).first().prop('iconType')
- ).toBe('folderCheck');
- });
-
- it('it renders the correct button icon: status closed', () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="case-view-status-action-button"]`).first().prop('iconType')
- ).toBe('folderOpen');
- });
- });
-
- describe('Status rotation', () => {
- it('rotates correctly to in-progress when status is open', () => {
- const wrapper = mount();
-
- wrapper
- .find(`button[data-test-subj="case-view-status-action-button"]`)
- .first()
- .simulate('click');
- expect(onStatusChanged).toHaveBeenCalledWith('in-progress');
- });
-
- it('rotates correctly to closed when status is in-progress', () => {
- const wrapper = mount(
-
- );
-
- wrapper
- .find(`button[data-test-subj="case-view-status-action-button"]`)
- .first()
- .simulate('click');
- expect(onStatusChanged).toHaveBeenCalledWith('closed');
- });
-
- it('rotates correctly to open when status is closed', () => {
- const wrapper = mount();
-
- wrapper
- .find(`button[data-test-subj="case-view-status-action-button"]`)
- .first()
- .simulate('click');
- expect(onStatusChanged).toHaveBeenCalledWith('open');
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/status/button.tsx b/x-pack/plugins/cases/public/components/status/button.tsx
deleted file mode 100644
index 623afeb43c596..0000000000000
--- a/x-pack/plugins/cases/public/components/status/button.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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, useCallback, useMemo } from 'react';
-import { EuiButton } from '@elastic/eui';
-
-import { CaseStatuses, caseStatuses } from '../../../common';
-import { statuses } from './config';
-
-interface Props {
- status: CaseStatuses;
- disabled: boolean;
- isLoading: boolean;
- onStatusChanged: (status: CaseStatuses) => void;
-}
-
-// Rotate over the statuses. open -> in-progress -> closes -> open...
-const getNextItem = (item: number) => (item + 1) % caseStatuses.length;
-
-const StatusActionButtonComponent: React.FC = ({
- status,
- onStatusChanged,
- disabled,
- isLoading,
-}) => {
- const indexOfCurrentStatus = useMemo(
- () => caseStatuses.findIndex((caseStatus) => caseStatus === status),
- [status]
- );
- const nextStatusIndex = useMemo(() => getNextItem(indexOfCurrentStatus), [indexOfCurrentStatus]);
-
- const onClick = useCallback(() => {
- onStatusChanged(caseStatuses[nextStatusIndex]);
- }, [nextStatusIndex, onStatusChanged]);
-
- return (
-
- {statuses[caseStatuses[nextStatusIndex]].button.label}
-
- );
-};
-export const StatusActionButton = memo(StatusActionButtonComponent);
diff --git a/x-pack/plugins/cases/public/components/status/config.ts b/x-pack/plugins/cases/public/components/status/config.ts
deleted file mode 100644
index e85d429067724..0000000000000
--- a/x-pack/plugins/cases/public/components/status/config.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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 { CaseStatuses } from '../../../common';
-import * as i18n from './translations';
-import { AllCaseStatus, Statuses, StatusAll } from './types';
-
-export const allCaseStatus: AllCaseStatus = {
- [StatusAll]: { color: 'hollow', label: i18n.ALL },
-};
-
-export const statuses: Statuses = {
- [CaseStatuses.open]: {
- color: 'primary',
- label: i18n.OPEN,
- icon: 'folderOpen' as const,
- actions: {
- bulk: {
- title: i18n.BULK_ACTION_OPEN_SELECTED,
- },
- single: {
- title: i18n.OPEN_CASE,
- },
- },
- actionBar: {
- title: i18n.CASE_OPENED,
- },
- button: {
- label: i18n.REOPEN_CASE,
- },
- stats: {
- title: i18n.OPEN_CASES,
- },
- },
- [CaseStatuses['in-progress']]: {
- color: 'warning',
- label: i18n.IN_PROGRESS,
- icon: 'folderExclamation' as const,
- actions: {
- bulk: {
- title: i18n.BULK_ACTION_MARK_IN_PROGRESS,
- },
- single: {
- title: i18n.MARK_CASE_IN_PROGRESS,
- },
- },
- actionBar: {
- title: i18n.CASE_IN_PROGRESS,
- },
- button: {
- label: i18n.MARK_CASE_IN_PROGRESS,
- },
- stats: {
- title: i18n.IN_PROGRESS_CASES,
- },
- },
- [CaseStatuses.closed]: {
- color: 'default',
- label: i18n.CLOSED,
- icon: 'folderCheck' as const,
- actions: {
- bulk: {
- title: i18n.BULK_ACTION_CLOSE_SELECTED,
- },
- single: {
- title: i18n.CLOSE_CASE,
- },
- },
- actionBar: {
- title: i18n.CASE_CLOSED,
- },
- button: {
- label: i18n.CLOSE_CASE,
- },
- stats: {
- title: i18n.CLOSED_CASES,
- },
- },
-};
diff --git a/x-pack/plugins/cases/public/components/status/index.ts b/x-pack/plugins/cases/public/components/status/index.ts
deleted file mode 100644
index 94d7cb6a31830..0000000000000
--- a/x-pack/plugins/cases/public/components/status/index.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * 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 * from './status';
-export * from './config';
-export * from './stats';
-export * from './types';
diff --git a/x-pack/plugins/cases/public/components/status/stats.test.tsx b/x-pack/plugins/cases/public/components/status/stats.test.tsx
deleted file mode 100644
index b2da828da77b0..0000000000000
--- a/x-pack/plugins/cases/public/components/status/stats.test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-
-import { CaseStatuses } from '../../../common';
-import { Stats } from './stats';
-
-describe('Stats', () => {
- const defaultProps = {
- caseStatus: CaseStatuses.open,
- caseCount: 2,
- isLoading: false,
- dataTestSubj: 'test-stats',
- };
- it('it renders', async () => {
- const wrapper = mount();
-
- expect(wrapper.find(`[data-test-subj="test-stats"]`).exists()).toBeTruthy();
- });
-
- it('shows the count', async () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="test-stats"] .euiDescriptionList__description`).first().text()
- ).toBe('2');
- });
-
- it('shows the loading spinner', async () => {
- const wrapper = mount();
-
- expect(wrapper.find(`[data-test-subj="test-stats-loading-spinner"]`).exists()).toBeTruthy();
- });
-
- describe('Status title', () => {
- it('shows the correct title for status open', async () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="test-stats"] .euiDescriptionList__title`).first().text()
- ).toBe('Open cases');
- });
-
- it('shows the correct title for status in-progress', async () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="test-stats"] .euiDescriptionList__title`).first().text()
- ).toBe('In progress cases');
- });
-
- it('shows the correct title for status closed', async () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="test-stats"] .euiDescriptionList__title`).first().text()
- ).toBe('Closed cases');
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/status/stats.tsx b/x-pack/plugins/cases/public/components/status/stats.tsx
deleted file mode 100644
index 071ea43746fdc..0000000000000
--- a/x-pack/plugins/cases/public/components/status/stats.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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, useMemo } from 'react';
-import { EuiDescriptionList, EuiLoadingSpinner } from '@elastic/eui';
-import { CaseStatuses } from '../../../common';
-import { statuses } from './config';
-
-export interface Props {
- caseCount: number | null;
- caseStatus: CaseStatuses;
- isLoading: boolean;
- dataTestSubj?: string;
-}
-
-const StatsComponent: React.FC = ({ caseCount, caseStatus, isLoading, dataTestSubj }) => {
- const statusStats = useMemo(
- () => [
- {
- title: statuses[caseStatus].stats.title,
- description: isLoading ? (
-
- ) : (
- caseCount ?? 'N/A'
- ),
- },
- ],
- [caseCount, caseStatus, dataTestSubj, isLoading]
- );
- return (
-
- );
-};
-
-StatsComponent.displayName = 'StatsComponent';
-export const Stats = memo(StatsComponent);
diff --git a/x-pack/plugins/cases/public/components/status/status.test.tsx b/x-pack/plugins/cases/public/components/status/status.test.tsx
deleted file mode 100644
index 7cddbf5ca4a1d..0000000000000
--- a/x-pack/plugins/cases/public/components/status/status.test.tsx
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 { mount } from 'enzyme';
-
-import { CaseStatuses } from '../../../common';
-import { Status } from './status';
-
-describe('Stats', () => {
- const onClick = jest.fn();
-
- it('it renders', async () => {
- const wrapper = mount();
-
- expect(wrapper.find(`[data-test-subj="status-badge-open"]`).exists()).toBeTruthy();
- expect(
- wrapper.find(`[data-test-subj="status-badge-open"] .euiBadge__iconButton`).exists()
- ).toBeFalsy();
- });
-
- it('it renders with arrow', async () => {
- const wrapper = mount();
-
- expect(
- wrapper.find(`[data-test-subj="status-badge-open"] .euiBadge__iconButton`).exists()
- ).toBeTruthy();
- });
-
- it('it calls onClick when pressing the badge', async () => {
- const wrapper = mount();
-
- wrapper.find(`[data-test-subj="status-badge-open"] .euiBadge__iconButton`).simulate('click');
- expect(onClick).toHaveBeenCalled();
- });
-
- describe('Colors', () => {
- it('shows the correct color when status is open', async () => {
- const wrapper = mount(
-
- );
-
- expect(wrapper.find(`[data-test-subj="status-badge-open"]`).first().prop('color')).toBe(
- 'primary'
- );
- });
-
- it('shows the correct color when status is in-progress', async () => {
- const wrapper = mount(
-
- );
-
- expect(
- wrapper.find(`[data-test-subj="status-badge-in-progress"]`).first().prop('color')
- ).toBe('warning');
- });
-
- it('shows the correct color when status is closed', async () => {
- const wrapper = mount(
-
- );
-
- expect(wrapper.find(`[data-test-subj="status-badge-closed"]`).first().prop('color')).toBe(
- 'default'
- );
- });
- });
-});
diff --git a/x-pack/plugins/cases/public/components/status/status.tsx b/x-pack/plugins/cases/public/components/status/status.tsx
deleted file mode 100644
index de4c979daf4c1..0000000000000
--- a/x-pack/plugins/cases/public/components/status/status.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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, useMemo } from 'react';
-import { noop } from 'lodash/fp';
-import { EuiBadge } from '@elastic/eui';
-
-import { allCaseStatus, statuses } from './config';
-import { CaseStatusWithAllStatus, StatusAll } from './types';
-import * as i18n from './translations';
-
-interface Props {
- type: CaseStatusWithAllStatus;
- withArrow?: boolean;
- onClick?: () => void;
-}
-
-const StatusComponent: React.FC = ({ type, withArrow = false, onClick = noop }) => {
- const props = useMemo(
- () => ({
- color: type === StatusAll ? allCaseStatus[StatusAll].color : statuses[type].color,
- ...(withArrow ? { iconType: 'arrowDown', iconSide: 'right' as const } : {}),
- }),
- [withArrow, type]
- );
-
- return (
-
- {type === StatusAll ? allCaseStatus[StatusAll].label : statuses[type].label}
-
- );
-};
-
-export const Status = memo(StatusComponent);
diff --git a/x-pack/plugins/cases/public/components/status/translations.ts b/x-pack/plugins/cases/public/components/status/translations.ts
deleted file mode 100644
index b3eadfd681ba5..0000000000000
--- a/x-pack/plugins/cases/public/components/status/translations.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 { i18n } from '@kbn/i18n';
-export * from '../../common/translations';
-
-export const ALL = i18n.translate('xpack.cases.status.all', {
- defaultMessage: 'All',
-});
-
-export const OPEN = i18n.translate('xpack.cases.status.open', {
- defaultMessage: 'Open',
-});
-
-export const IN_PROGRESS = i18n.translate('xpack.cases.status.inProgress', {
- defaultMessage: 'In progress',
-});
-
-export const CLOSED = i18n.translate('xpack.cases.status.closed', {
- defaultMessage: 'Closed',
-});
-
-export const STATUS_ICON_ARIA = i18n.translate('xpack.cases.status.iconAria', {
- defaultMessage: 'Change status',
-});
-
-export const CASE_OPENED = i18n.translate('xpack.cases.caseView.caseOpened', {
- defaultMessage: 'Case opened',
-});
-
-export const CASE_IN_PROGRESS = i18n.translate('xpack.cases.caseView.caseInProgress', {
- defaultMessage: 'Case in progress',
-});
-
-export const CASE_CLOSED = i18n.translate('xpack.cases.caseView.caseClosed', {
- defaultMessage: 'Case closed',
-});
-
-export const BULK_ACTION_CLOSE_SELECTED = i18n.translate(
- 'xpack.cases.caseTable.bulkActions.closeSelectedTitle',
- {
- defaultMessage: 'Close selected',
- }
-);
-
-export const BULK_ACTION_OPEN_SELECTED = i18n.translate(
- 'xpack.cases.caseTable.bulkActions.openSelectedTitle',
- {
- defaultMessage: 'Open selected',
- }
-);
-
-export const BULK_ACTION_DELETE_SELECTED = i18n.translate(
- 'xpack.cases.caseTable.bulkActions.deleteSelectedTitle',
- {
- defaultMessage: 'Delete selected',
- }
-);
-
-export const BULK_ACTION_MARK_IN_PROGRESS = i18n.translate(
- 'xpack.cases.caseTable.bulkActions.markInProgressTitle',
- {
- defaultMessage: 'Mark in progress',
- }
-);
diff --git a/x-pack/plugins/cases/public/components/status/types.ts b/x-pack/plugins/cases/public/components/status/types.ts
deleted file mode 100644
index 674838067b0ac..0000000000000
--- a/x-pack/plugins/cases/public/components/status/types.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 { EuiIconType } from '@elastic/eui/src/components/icon/icon';
-import { CaseStatuses } from '../../../common';
-
-export const StatusAll = 'all' as const;
-type StatusAllType = typeof StatusAll;
-
-export type CaseStatusWithAllStatus = CaseStatuses | StatusAllType;
-
-export type AllCaseStatus = Record;
-
-export type Statuses = Record<
- CaseStatuses,
- {
- color: string;
- label: string;
- icon: EuiIconType;
- actions: {
- bulk: {
- title: string;
- };
- single: {
- title: string;
- description?: string;
- };
- };
- actionBar: {
- title: string;
- };
- button: {
- label: string;
- };
- stats: {
- title: string;
- };
- }
->;
diff --git a/x-pack/plugins/cases/public/components/toasters/__snapshots__/modal_all_errors.test.tsx.snap b/x-pack/plugins/cases/public/components/toasters/__snapshots__/modal_all_errors.test.tsx.snap
deleted file mode 100644
index 5e008e28073de..0000000000000
--- a/x-pack/plugins/cases/public/components/toasters/__snapshots__/modal_all_errors.test.tsx.snap
+++ /dev/null
@@ -1,48 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Modal all errors rendering it renders the default all errors modal when isShowing is positive 1`] = `
-
-
-
- Your visualization has error(s)
-
-
-
-
-
-
-
- Error 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-
-
-
-
-
- Close
-
-
-
-`;
diff --git a/x-pack/plugins/cases/public/components/toasters/errors.ts b/x-pack/plugins/cases/public/components/toasters/errors.ts
deleted file mode 100644
index 0a672aeee8b7c..0000000000000
--- a/x-pack/plugins/cases/public/components/toasters/errors.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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 class ToasterError extends Error {
- public readonly messages: string[];
-
- constructor(messages: string[]) {
- super(messages[0]);
- this.name = 'ToasterError';
- this.messages = messages;
- }
-}
-
-export const isToasterError = (error: unknown): error is ToasterError =>
- error instanceof ToasterError;
diff --git a/x-pack/plugins/cases/public/components/toasters/index.test.tsx b/x-pack/plugins/cases/public/components/toasters/index.test.tsx
deleted file mode 100644
index 1d78570e18a59..0000000000000
--- a/x-pack/plugins/cases/public/components/toasters/index.test.tsx
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * 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 { set } from '@elastic/safer-lodash-set/fp';
-import { cloneDeep } from 'lodash/fp';
-import { mount } from 'enzyme';
-import React, { useEffect } from 'react';
-
-import {
- AppToast,
- useStateToaster,
- ManageGlobalToaster,
- GlobalToaster,
- displayErrorToast,
-} from '.';
-
-jest.mock('uuid', () => {
- return {
- v1: jest.fn(() => '27261ae0-0bbb-11ea-b0ea-db767b07ea47'),
- v4: jest.fn(() => '9e1f72a9-7c73-4b7f-a562-09940f7daf4a'),
- };
-});
-
-const mockToast: AppToast = {
- color: 'danger',
- id: 'id-super-id',
- iconType: 'alert',
- title: 'Test & Test',
- toastLifeTimeMs: 100,
- text:
- 'Error 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
-};
-
-describe('Toaster', () => {
- describe('Manage Global Toaster Reducer', () => {
- test('we can add a toast in the reducer', () => {
- const AddToaster = () => {
- const [{ toasts }, dispatch] = useStateToaster();
- return (
- <>
-