diff --git a/.eslintrc.js b/.eslintrc.js index 22d0270a5b06..c4883feff9b3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -875,6 +875,16 @@ module.exports = { }, }, + /** + * Cases overrides + */ + { + files: ['x-pack/plugins/cases/**/*.{js,mjs,ts,tsx}'], + rules: { + 'no-duplicate-imports': 'error', + }, + }, + /** * Security Solution overrides */ diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 9b4199c81286..9adc075a7983 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -108,6 +108,6 @@ pageLoadAssetSize: banners: 17946 mapsEms: 26072 timelines: 28613 - cases: 162385 screenshotMode: 17856 visTypePie: 35583 + cases: 144442 diff --git a/x-pack/plugins/cases/common/api/cases/sub_case.ts b/x-pack/plugins/cases/common/api/cases/sub_case.ts index 654b74276733..187778f4a4fa 100644 --- a/x-pack/plugins/cases/common/api/cases/sub_case.ts +++ b/x-pack/plugins/cases/common/api/cases/sub_case.ts @@ -10,8 +10,7 @@ import * as rt from 'io-ts'; import { NumberFromString } from '../saved_object'; import { UserRT } from '../user'; import { CommentResponseRt } from './comment'; -import { CasesStatusResponseRt } from './status'; -import { CaseStatusRt } from './status'; +import { CaseStatusRt, CasesStatusResponseRt } from './status'; const SubCaseBasicRt = rt.type({ /** diff --git a/x-pack/plugins/cases/public/common/lib/kibana/hooks.ts b/x-pack/plugins/cases/public/common/lib/kibana/hooks.ts index 5246e09f6b0f..f7138beea70b 100644 --- a/x-pack/plugins/cases/public/common/lib/kibana/hooks.ts +++ b/x-pack/plugins/cases/public/common/lib/kibana/hooks.ts @@ -10,7 +10,7 @@ import moment from 'moment-timezone'; import { useCallback, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; -import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_TZ } from '../../../../common/constants'; +import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_TZ } from '../../../../common'; import { AuthenticatedUser } from '../../../../../security/common/model'; import { convertToCamelCase } from '../../../containers/utils'; import { StartServices } from '../../../types'; diff --git a/x-pack/plugins/cases/public/common/mock/match_media.ts b/x-pack/plugins/cases/public/common/mock/match_media.ts index 722f4c3917ea..88d5cfad812e 100644 --- a/x-pack/plugins/cases/public/common/mock/match_media.ts +++ b/x-pack/plugins/cases/public/common/mock/match_media.ts @@ -5,12 +5,10 @@ * 2.0. */ -window.matchMedia = jest.fn().mockImplementation((query) => { - return { - matches: false, - media: query, - onchange: null, - addListener: jest.fn(), - removeListener: jest.fn(), - }; -}); +window.matchMedia = jest.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), + removeListener: jest.fn(), +})); diff --git a/x-pack/plugins/cases/public/common/mock/test_providers.tsx b/x-pack/plugins/cases/public/common/mock/test_providers.tsx index 9a08918a483a..15a4f6d992da 100644 --- a/x-pack/plugins/cases/public/common/mock/test_providers.tsx +++ b/x-pack/plugins/cases/public/common/mock/test_providers.tsx @@ -40,26 +40,24 @@ const TestProvidersComponent: React.FC = ({ children }) => ( export const TestProviders = React.memo(TestProvidersComponent); -export const useFormFieldMock = (options?: Partial>): FieldHook => { - return { - path: 'path', - type: 'type', - value: ('mockedValue' as unknown) as T, - isPristine: false, - isValidating: false, - isValidated: false, - isChangingValue: false, - errors: [], - isValid: true, - getErrorsMessages: jest.fn(), - onChange: jest.fn(), - setValue: jest.fn(), - setErrors: jest.fn(), - clearErrors: jest.fn(), - validate: jest.fn(), - reset: jest.fn(), - __isIncludedInOutput: true, - __serializeValue: jest.fn(), - ...options, - }; -}; +export const useFormFieldMock = (options?: Partial>): FieldHook => ({ + path: 'path', + type: 'type', + value: ('mockedValue' as unknown) as T, + isPristine: false, + isValidating: false, + isValidated: false, + isChangingValue: false, + errors: [], + isValid: true, + getErrorsMessages: jest.fn(), + onChange: jest.fn(), + setValue: jest.fn(), + setErrors: jest.fn(), + clearErrors: jest.fn(), + validate: jest.fn(), + reset: jest.fn(), + __isIncludedInOutput: true, + __serializeValue: jest.fn(), + ...options, +}); diff --git a/x-pack/plugins/cases/public/common/translations.ts b/x-pack/plugins/cases/public/common/translations.ts index f1bfde4cc448..43f94ecad269 100644 --- a/x-pack/plugins/cases/public/common/translations.ts +++ b/x-pack/plugins/cases/public/common/translations.ts @@ -7,21 +7,6 @@ import { i18n } from '@kbn/i18n'; -export const CASES_FEATURE_NO_PERMISSIONS_TITLE = i18n.translate( - 'xpack.cases.caseFeatureNoPermissionsTitle', - { - defaultMessage: 'Kibana feature privileges required', - } -); - -export const CASES_FEATURE_NO_PERMISSIONS_MSG = i18n.translate( - 'xpack.cases.caseFeatureNoPermissionsMessage', - { - defaultMessage: - 'To view cases, you must have privileges for the Cases feature in the Kibana space. For more information, contact your Kibana administrator.', - } -); - export const BACK_TO_ALL = i18n.translate('xpack.cases.caseView.backLabel', { defaultMessage: 'Back to cases', }); @@ -56,10 +41,6 @@ export const PARTICIPANTS = i18n.translate('xpack.cases.caseView.particpantsLabe defaultMessage: 'Participants', }); -export const CREATE_BC_TITLE = i18n.translate('xpack.cases.caseView.breadcrumb', { - defaultMessage: 'Create', -}); - export const CREATE_TITLE = i18n.translate('xpack.cases.caseView.create', { defaultMessage: 'Create new case', }); @@ -179,18 +160,10 @@ export const SAVE = i18n.translate('xpack.cases.caseView.description.save', { defaultMessage: 'Save', }); -export const GO_TO_DOCUMENTATION = i18n.translate('xpack.cases.caseView.goToDocumentationButton', { - defaultMessage: 'View documentation', -}); - export const CONNECTORS = i18n.translate('xpack.cases.caseView.connectors', { defaultMessage: 'External Incident Management System', }); -export const EDIT_CONNECTOR = i18n.translate('xpack.cases.caseView.editConnector', { - defaultMessage: 'Change external incident management system', -}); - export const NO_CONNECTOR = i18n.translate('xpack.cases.common.noConnector', { defaultMessage: 'No connector selected', }); diff --git a/x-pack/plugins/cases/public/components/add_comment/index.test.tsx b/x-pack/plugins/cases/public/components/add_comment/index.test.tsx index 23a0fca48592..19c303840fc1 100644 --- a/x-pack/plugins/cases/public/components/add_comment/index.test.tsx +++ b/x-pack/plugins/cases/public/components/add_comment/index.test.tsx @@ -11,7 +11,6 @@ import { waitFor, act } from '@testing-library/react'; import { noop } from 'lodash/fp'; import { TestProviders } from '../../common/mock'; -import { Router, routeData, mockHistory, mockLocation } from '../__mock__/router'; import { CommentRequest, CommentType, SECURITY_SOLUTION_OWNER } from '../../../common'; import { usePostComment } from '../../containers/use_post_comment'; @@ -51,15 +50,12 @@ describe('AddComment ', () => { beforeEach(() => { jest.clearAllMocks(); usePostCommentMock.mockImplementation(() => defaultPostComment); - jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); }); it('should post comment on submit click', async () => { const wrapper = mount( - - - + ); @@ -88,9 +84,7 @@ describe('AddComment ', () => { usePostCommentMock.mockImplementation(() => ({ ...defaultPostComment, isLoading: true })); const wrapper = mount( - - - + ); @@ -104,9 +98,7 @@ describe('AddComment ', () => { usePostCommentMock.mockImplementation(() => ({ ...defaultPostComment, isLoading: true })); const wrapper = mount( - - - + ); @@ -120,9 +112,7 @@ describe('AddComment ', () => { const ref = React.createRef(); const wrapper = mount( - - - + ); @@ -153,9 +143,7 @@ describe('AddComment ', () => { const wrapper = mount( - - - + ); diff --git a/x-pack/plugins/cases/public/components/all_cases/helpers.ts b/x-pack/plugins/cases/public/components/all_cases/helpers.ts index 1751d478a5d9..ca5b2e422c15 100644 --- a/x-pack/plugins/cases/public/components/all_cases/helpers.ts +++ b/x-pack/plugins/cases/public/components/all_cases/helpers.ts @@ -26,22 +26,20 @@ export const isIndividual = (theCase: Case | SubCase | null | undefined) => export const getSubCasesStatusCountsBadges = ( subCases: SubCase[] -): Array<{ name: CaseStatuses; color: string; count: number }> => { - return [ - { - name: CaseStatuses.open, - color: statuses[CaseStatuses.open].color, - count: filter({ status: CaseStatuses.open }, subCases).length, - }, - { - name: CaseStatuses['in-progress'], - color: statuses[CaseStatuses['in-progress']].color, - count: filter({ status: CaseStatuses['in-progress'] }, subCases).length, - }, - { - name: CaseStatuses.closed, - color: statuses[CaseStatuses.closed].color, - count: filter({ status: CaseStatuses.closed }, subCases).length, - }, - ]; -}; +): Array<{ name: CaseStatuses; color: string; count: number }> => [ + { + color: statuses[CaseStatuses.open].color, + count: filter({ status: CaseStatuses.open }, subCases).length, + name: CaseStatuses.open, + }, + { + color: statuses[CaseStatuses['in-progress']].color, + count: filter({ status: CaseStatuses['in-progress'] }, subCases).length, + name: CaseStatuses['in-progress'], + }, + { + color: statuses[CaseStatuses.closed].color, + count: filter({ status: CaseStatuses.closed }, subCases).length, + name: CaseStatuses.closed, + }, +]; diff --git a/x-pack/plugins/cases/public/components/all_cases/index.tsx b/x-pack/plugins/cases/public/components/all_cases/index.tsx index 1f836b318dba..78fa1d54a47f 100644 --- a/x-pack/plugins/cases/public/components/all_cases/index.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/index.tsx @@ -19,13 +19,11 @@ export interface AllCasesProps extends Owner { userCanCrud: boolean; } -export const AllCases: React.FC = (props) => { - return ( - - - - ); -}; +export const AllCases: React.FC = (props) => ( + + + +); // eslint-disable-next-line import/no-default-export export { AllCases as default }; diff --git a/x-pack/plugins/cases/public/components/bulk_actions/index.tsx b/x-pack/plugins/cases/public/components/bulk_actions/index.tsx index fae1c4909ffe..751a45a706ef 100644 --- a/x-pack/plugins/cases/public/components/bulk_actions/index.tsx +++ b/x-pack/plugins/cases/public/components/bulk_actions/index.tsx @@ -17,18 +17,18 @@ interface GetBulkItems { caseStatus: CaseStatusWithAllStatus; closePopover: () => void; deleteCasesAction: (cases: Case[]) => void; + includeCollections: boolean; selectedCases: Case[]; updateCaseStatus: (status: string) => void; - includeCollections: boolean; } export const getBulkItems = ({ caseStatus, closePopover, deleteCasesAction, + includeCollections, selectedCases, updateCaseStatus, - includeCollections, }: GetBulkItems) => { let statusMenuItems: JSX.Element[] = []; @@ -36,8 +36,8 @@ export const getBulkItems = ({ { closePopover(); updateCaseStatus(CaseStatuses.open); @@ -51,8 +51,8 @@ export const getBulkItems = ({ { closePopover(); updateCaseStatus(CaseStatuses['in-progress']); @@ -66,8 +66,8 @@ export const getBulkItems = ({ { closePopover(); updateCaseStatus(CaseStatuses.closed); diff --git a/x-pack/plugins/cases/public/components/case_action_bar/status_context_menu.tsx b/x-pack/plugins/cases/public/components/case_action_bar/status_context_menu.tsx index 65a220b65e40..3ee7ab659021 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/status_context_menu.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/status_context_menu.tsx @@ -6,7 +6,6 @@ */ import React, { memo, useCallback, useMemo, useState } from 'react'; -import { memoize } from 'lodash/fp'; import { EuiPopover, EuiContextMenuPanel, EuiContextMenuItem } from '@elastic/eui'; import { caseStatuses, CaseStatuses } from '../../../common'; import { Status } from '../status'; @@ -19,8 +18,8 @@ interface Props { const StatusContextMenuComponent: React.FC = ({ currentStatus, - onStatusChanged, disabled = false, + onStatusChanged, }) => { const [isPopoverOpen, setIsPopoverOpen] = useState(false); const closePopover = useCallback(() => setIsPopoverOpen(false), []); @@ -30,35 +29,38 @@ const StatusContextMenuComponent: React.FC = ({ [disabled, currentStatus, openPopover] ); - const onContextMenuItemClick = useMemo( - () => - memoize<(status: CaseStatuses) => () => void>((status) => () => { - closePopover(); - onStatusChanged(status); - }), + const onContextMenuItemClick = useCallback( + (status: CaseStatuses) => { + closePopover(); + onStatusChanged(status); + }, [closePopover, onStatusChanged] ); - const panelItems = caseStatuses.map((status: CaseStatuses) => ( - - - - )); + const panelItems = useMemo( + () => + caseStatuses.map((status: CaseStatuses) => ( + onContextMenuItemClick(status)} + > + + + )), + [currentStatus, onContextMenuItemClick] + ); return ( <> diff --git a/x-pack/plugins/cases/public/components/case_view/index.test.tsx b/x-pack/plugins/cases/public/components/case_view/index.test.tsx index f89218d5407e..55de4d07b13b 100644 --- a/x-pack/plugins/cases/public/components/case_view/index.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/index.test.tsx @@ -9,7 +9,6 @@ import React from 'react'; import { mount } from 'enzyme'; import '../../common/mock/match_media'; -import { Router, mockHistory } from '../__mock__/router'; import { CaseComponent, CaseComponentProps, CaseView } from '.'; import { basicCase, @@ -30,6 +29,10 @@ import { usePostPushToService } from '../../containers/use_post_push_to_service' import { CaseType, ConnectorTypes } from '../../../common'; import { useKibana } from '../../common/lib/kibana'; +const mockId = basicCase.id; +jest.mock('react-router-dom', () => ({ + useParams: () => ({ detailName: mockId }), +})); jest.mock('../../containers/use_update_case'); jest.mock('../../containers/use_get_case_user_actions'); jest.mock('../../containers/use_get_case'); @@ -172,9 +175,7 @@ describe('CaseView ', () => { it('should render CaseComponent', async () => { const wrapper = mount( - - - + ); @@ -230,9 +231,7 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); @@ -249,9 +248,7 @@ describe('CaseView ', () => { it('should update status', async () => { const wrapper = mount( - - - + ); wrapper.find('[data-test-subj="case-view-status-dropdown"] button').first().simulate('click'); @@ -276,9 +273,7 @@ describe('CaseView ', () => { })); const wrapper = mount( - - - + ); await waitFor(() => { @@ -299,9 +294,7 @@ describe('CaseView ', () => { })); const wrapper = mount( - - - + ); await waitFor(() => { @@ -330,9 +323,7 @@ describe('CaseView ', () => { })); const wrapper = mount( - - - + ); await waitFor(() => { @@ -350,9 +341,7 @@ describe('CaseView ', () => { it('should update title', async () => { const wrapper = mount( - - - + ); const newTitle = 'The new title'; @@ -379,9 +368,7 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); @@ -404,34 +391,32 @@ describe('CaseView ', () => { })); const wrapper = mount( - - - + ); await waitFor(() => { @@ -446,34 +431,32 @@ describe('CaseView ', () => { })); const wrapper = mount( - - - + ); await waitFor(() => { @@ -485,34 +468,32 @@ describe('CaseView ', () => { (useGetCase as jest.Mock).mockImplementation(() => defaultGetCase); const wrapper = mount( - - - + ); await waitFor(() => { @@ -524,34 +505,32 @@ describe('CaseView ', () => { (useGetCase as jest.Mock).mockImplementation(() => defaultGetCase); const wrapper = mount( - - - + ); wrapper.find('[data-test-subj="case-refresh"]').first().simulate('click'); @@ -569,15 +548,13 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); await waitFor(() => { @@ -595,20 +572,18 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); const connectorName = wrapper @@ -636,20 +611,18 @@ describe('CaseView ', () => { it('should update connector', async () => { const wrapper = mount( - - - + ); @@ -681,9 +654,7 @@ describe('CaseView ', () => { const onComponentInitialized = jest.fn(); mount( - - - + ); @@ -705,9 +676,7 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); @@ -723,9 +692,7 @@ describe('CaseView ', () => { const showAlertDetails = jest.fn(); const wrapper = mount( - - - + ); @@ -741,9 +708,7 @@ describe('CaseView ', () => { it('should show the rule name', async () => { const wrapper = mount( - - - + ); @@ -762,9 +727,7 @@ describe('CaseView ', () => { it('should update settings', async () => { const wrapper = mount( - - - + ); @@ -786,9 +749,7 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); @@ -808,9 +769,7 @@ describe('CaseView ', () => { useConnectorsMock.mockImplementation(() => ({ connectors: [], loading: false })); const wrapper = mount( - - - + ); @@ -824,9 +783,7 @@ describe('CaseView ', () => { useConnectorsMock.mockImplementation(() => ({ connectors: [], loading: true })); const wrapper = mount( - - - + ); @@ -841,12 +798,10 @@ describe('CaseView ', () => { it('it does not allow the user to update the status', async () => { const wrapper = mount( - - - + ); @@ -868,12 +823,10 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); @@ -890,12 +843,10 @@ describe('CaseView ', () => { const wrapper = mount( - - - + ); diff --git a/x-pack/plugins/cases/public/components/case_view/translations.ts b/x-pack/plugins/cases/public/components/case_view/translations.ts index 3d4558ac3d4a..0d3ce6787e0f 100644 --- a/x-pack/plugins/cases/public/components/case_view/translations.ts +++ b/x-pack/plugins/cases/public/components/case_view/translations.ts @@ -9,16 +9,6 @@ import { i18n } from '@kbn/i18n'; export * from '../../common/translations'; -export const SHOWING_CASES = (actionDate: string, actionName: string, userName: string) => - i18n.translate('xpack.cases.caseView.actionHeadline', { - values: { - actionDate, - actionName, - userName, - }, - defaultMessage: '{userName} {actionName} on {actionDate}', - }); - export const ADDED_FIELD = i18n.translate('xpack.cases.caseView.actionLabel.addedField', { defaultMessage: 'added', }); @@ -89,10 +79,6 @@ export const ON = i18n.translate('xpack.cases.caseView.actionLabel.on', { defaultMessage: 'on', }); -export const ADDED_COMMENT = i18n.translate('xpack.cases.caseView.actionLabel.addComment', { - defaultMessage: 'added comment', -}); - export const STATUS = i18n.translate('xpack.cases.caseView.statusLabel', { defaultMessage: 'Status', }); diff --git a/x-pack/plugins/cases/public/components/configure_cases/closure_options.tsx b/x-pack/plugins/cases/public/components/configure_cases/closure_options.tsx index ba892116320c..0c76341e9c34 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/closure_options.tsx +++ b/x-pack/plugins/cases/public/components/configure_cases/closure_options.tsx @@ -22,33 +22,31 @@ const ClosureOptionsComponent: React.FC = ({ closureTypeSelected, disabled, onChangeClosureType, -}) => { - return ( - ( + {i18n.CASE_CLOSURE_OPTIONS_TITLE}} + description={ + <> +

{i18n.CASE_CLOSURE_OPTIONS_DESC}

+

{i18n.CASE_CLOSURE_OPTIONS_SUB_CASES}

+ + } + data-test-subj="case-closure-options-form-group" + > + {i18n.CASE_CLOSURE_OPTIONS_TITLE}} - description={ - <> -

{i18n.CASE_CLOSURE_OPTIONS_DESC}

-

{i18n.CASE_COLSURE_OPTIONS_SUB_CASES}

- - } - data-test-subj="case-closure-options-form-group" + label={i18n.CASE_CLOSURE_OPTIONS_LABEL} + data-test-subj="case-closure-options-form-row" > - - - -
- ); -}; + + +
+); export const ClosureOptions = React.memo(ClosureOptionsComponent); diff --git a/x-pack/plugins/cases/public/components/configure_cases/translations.ts b/x-pack/plugins/cases/public/components/configure_cases/translations.ts index a379b03a4f67..1a60521667bb 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/translations.ts +++ b/x-pack/plugins/cases/public/components/configure_cases/translations.ts @@ -50,7 +50,7 @@ export const CASE_CLOSURE_OPTIONS_DESC = i18n.translate( } ); -export const CASE_COLSURE_OPTIONS_SUB_CASES = i18n.translate( +export const CASE_CLOSURE_OPTIONS_SUB_CASES = i18n.translate( 'xpack.cases.configureCases.caseClosureOptionsSubCases', { defaultMessage: 'Automated closures of sub-cases is not currently supported.', @@ -78,39 +78,24 @@ export const CASE_CLOSURE_OPTIONS_NEW_INCIDENT = i18n.translate( } ); -export const CASE_CLOSURE_OPTIONS_CLOSED_INCIDENT = i18n.translate( - 'xpack.cases.configureCases.caseClosureOptionsClosedIncident', - { - defaultMessage: 'Automatically close cases when incident is closed in external system', - } -); -export const FIELD_MAPPING_TITLE = (thirdPartyName: string): string => { - return i18n.translate('xpack.cases.configureCases.fieldMappingTitle', { +export const FIELD_MAPPING_TITLE = (thirdPartyName: string): string => + i18n.translate('xpack.cases.configureCases.fieldMappingTitle', { values: { thirdPartyName }, defaultMessage: '{ thirdPartyName } field mappings', }); -}; -export const FIELD_MAPPING_DESC = (thirdPartyName: string): string => { - return i18n.translate('xpack.cases.configureCases.fieldMappingDesc', { +export const FIELD_MAPPING_DESC = (thirdPartyName: string): string => + i18n.translate('xpack.cases.configureCases.fieldMappingDesc', { values: { thirdPartyName }, defaultMessage: 'Map Case fields to { thirdPartyName } fields when pushing data to { thirdPartyName }. Field mappings require an established connection to { thirdPartyName }.', }); -}; -export const FIELD_MAPPING_DESC_ERR = (thirdPartyName: string): string => { - return i18n.translate('xpack.cases.configureCases.fieldMappingDescErr', { +export const FIELD_MAPPING_DESC_ERR = (thirdPartyName: string): string => + i18n.translate('xpack.cases.configureCases.fieldMappingDescErr', { values: { thirdPartyName }, defaultMessage: 'Failed to retrieve mappings for { thirdPartyName }.', }); -}; -export const EDIT_FIELD_MAPPING_TITLE = (thirdPartyName: string): string => { - return i18n.translate('xpack.cases.configureCases.editFieldMappingTitle', { - values: { thirdPartyName }, - defaultMessage: 'Edit { thirdPartyName } field mappings', - }); -}; export const FIELD_MAPPING_FIRST_COL = i18n.translate( 'xpack.cases.configureCases.fieldMappingFirstCol', @@ -119,12 +104,11 @@ export const FIELD_MAPPING_FIRST_COL = i18n.translate( } ); -export const FIELD_MAPPING_SECOND_COL = (thirdPartyName: string): string => { - return i18n.translate('xpack.cases.configureCases.fieldMappingSecondCol', { +export const FIELD_MAPPING_SECOND_COL = (thirdPartyName: string): string => + i18n.translate('xpack.cases.configureCases.fieldMappingSecondCol', { values: { thirdPartyName }, defaultMessage: '{ thirdPartyName } field', }); -}; export const FIELD_MAPPING_THIRD_COL = i18n.translate( 'xpack.cases.configureCases.fieldMappingThirdCol', @@ -133,20 +117,6 @@ export const FIELD_MAPPING_THIRD_COL = i18n.translate( } ); -export const FIELD_MAPPING_EDIT_NOTHING = i18n.translate( - 'xpack.cases.configureCases.fieldMappingEditNothing', - { - defaultMessage: 'Nothing', - } -); - -export const FIELD_MAPPING_EDIT_OVERWRITE = i18n.translate( - 'xpack.cases.configureCases.fieldMappingEditOverwrite', - { - defaultMessage: 'Overwrite', - } -); - export const FIELD_MAPPING_EDIT_APPEND = i18n.translate( 'xpack.cases.configureCases.fieldMappingEditAppend', { @@ -181,46 +151,22 @@ export const WARNING_NO_CONNECTOR_MESSAGE = i18n.translate( } ); -export const MAPPING_FIELD_NOT_MAPPED = i18n.translate( - 'xpack.cases.configureCases.mappingFieldNotMapped', - { - defaultMessage: 'Not mapped', - } -); - export const COMMENT = i18n.translate('xpack.cases.configureCases.commentMapping', { defaultMessage: 'Comments', }); - -export const NO_FIELDS_ERROR = (connectorName: string): string => { - return i18n.translate('xpack.cases.configureCases.noFieldsError', { - values: { connectorName }, - defaultMessage: - 'No { connectorName } fields found. Please check your { connectorName } connector settings or your { connectorName } instance settings to resolve.', - }); -}; - -export const BLANK_MAPPINGS = (connectorName: string): string => { - return i18n.translate('xpack.cases.configureCases.blankMappings', { - values: { connectorName }, - defaultMessage: 'At least one field needs to be mapped to { connectorName }', - }); -}; - -export const REQUIRED_MAPPINGS = (connectorName: string, fields: string): string => { - return i18n.translate('xpack.cases.configureCases.requiredMappings', { +export const REQUIRED_MAPPINGS = (connectorName: string, fields: string): string => + i18n.translate('xpack.cases.configureCases.requiredMappings', { values: { connectorName, fields }, defaultMessage: 'At least one Case field needs to be mapped to the following required { connectorName } fields: { fields }', }); -}; + export const UPDATE_FIELD_MAPPINGS = i18n.translate('xpack.cases.configureCases.updateConnector', { defaultMessage: 'Update field mappings', }); -export const UPDATE_SELECTED_CONNECTOR = (connectorName: string): string => { - return i18n.translate('xpack.cases.configureCases.updateSelectedConnector', { +export const UPDATE_SELECTED_CONNECTOR = (connectorName: string): string => + i18n.translate('xpack.cases.configureCases.updateSelectedConnector', { values: { connectorName }, defaultMessage: 'Update { connectorName }', }); -}; diff --git a/x-pack/plugins/cases/public/components/connectors/case/translations.ts b/x-pack/plugins/cases/public/components/connectors/case/translations.ts index 8304aaef5765..0d4e1d2f0bd6 100644 --- a/x-pack/plugins/cases/public/components/connectors/case/translations.ts +++ b/x-pack/plugins/cases/public/components/connectors/case/translations.ts @@ -22,21 +22,6 @@ export const CASE_CONNECTOR_TITLE = i18n.translate( defaultMessage: 'Cases', } ); - -export const CASE_CONNECTOR_COMMENT_LABEL = i18n.translate( - 'xpack.cases.components.connectors.cases.commentLabel', - { - defaultMessage: 'Comment', - } -); - -export const CASE_CONNECTOR_COMMENT_REQUIRED = i18n.translate( - 'xpack.cases.components.connectors.cases.commentRequired', - { - defaultMessage: 'Comment is required.', - } -); - export const CASE_CONNECTOR_CASES_DROPDOWN_ROW_LABEL = i18n.translate( 'xpack.cases.components.connectors.cases.casesDropdownRowLabel', { @@ -44,20 +29,6 @@ export const CASE_CONNECTOR_CASES_DROPDOWN_ROW_LABEL = i18n.translate( } ); -export const CASE_CONNECTOR_CASES_DROPDOWN_PLACEHOLDER = i18n.translate( - 'xpack.cases.components.connectors.cases.casesDropdownPlaceholder', - { - defaultMessage: 'Select case', - } -); - -export const CASE_CONNECTOR_CASES_OPTION_NEW_CASE = i18n.translate( - 'xpack.cases.components.connectors.cases.optionAddNewCase', - { - defaultMessage: 'Add to a new case', - } -); - export const CASE_CONNECTOR_CASES_OPTION_EXISTING_CASE = i18n.translate( 'xpack.cases.components.connectors.cases.optionAddToExistingCase', { @@ -100,10 +71,3 @@ export const CREATE_CASE = i18n.translate( defaultMessage: 'Create case', } ); - -export const CONNECTED_CASE = i18n.translate( - 'xpack.cases.components.connectors.cases.connectedCaseLabel', - { - defaultMessage: 'Connected case', - } -); diff --git a/x-pack/plugins/cases/public/components/connectors/index.ts b/x-pack/plugins/cases/public/components/connectors/index.ts index 2a7d59ca7b04..ad202365ae96 100644 --- a/x-pack/plugins/cases/public/components/connectors/index.ts +++ b/x-pack/plugins/cases/public/components/connectors/index.ts @@ -49,8 +49,6 @@ class CaseConnectors { const caseConnectors = new CaseConnectors(); -export const getCaseConnectors = (): GetCaseConnectorsReturn => { - return { - caseConnectorsRegistry: caseConnectors.registry(), - }; -}; +export const getCaseConnectors = (): GetCaseConnectorsReturn => ({ + caseConnectorsRegistry: caseConnectors.registry(), +}); diff --git a/x-pack/plugins/cases/public/components/connectors/jira/index.ts b/x-pack/plugins/cases/public/components/connectors/jira/index.ts index ea408a1bd666..f987d9823af8 100644 --- a/x-pack/plugins/cases/public/components/connectors/jira/index.ts +++ b/x-pack/plugins/cases/public/components/connectors/jira/index.ts @@ -13,13 +13,10 @@ import * as i18n from './translations'; export * from './types'; -export const getCaseConnector = (): CaseConnector => { - return { - id: '.jira', - fieldsComponent: lazy(() => import('./case_fields')), - }; -}; - +export const getCaseConnector = (): CaseConnector => ({ + id: '.jira', + fieldsComponent: lazy(() => import('./case_fields')), +}); export const fieldLabels = { issueType: i18n.ISSUE_TYPE, priority: i18n.PRIORITY, diff --git a/x-pack/plugins/cases/public/components/connectors/resilient/index.ts b/x-pack/plugins/cases/public/components/connectors/resilient/index.ts index c8e7ad9a063c..9bf96b16f358 100644 --- a/x-pack/plugins/cases/public/components/connectors/resilient/index.ts +++ b/x-pack/plugins/cases/public/components/connectors/resilient/index.ts @@ -13,12 +13,10 @@ import * as i18n from './translations'; export * from './types'; -export const getCaseConnector = (): CaseConnector => { - return { - id: '.resilient', - fieldsComponent: lazy(() => import('./case_fields')), - }; -}; +export const getCaseConnector = (): CaseConnector => ({ + id: '.resilient', + fieldsComponent: lazy(() => import('./case_fields')), +}); export const fieldLabels = { incidentTypes: i18n.INCIDENT_TYPES_LABEL, diff --git a/x-pack/plugins/cases/public/components/connectors/servicenow/index.ts b/x-pack/plugins/cases/public/components/connectors/servicenow/index.ts index a6f0795fe4d8..9df5f87b416e 100644 --- a/x-pack/plugins/cases/public/components/connectors/servicenow/index.ts +++ b/x-pack/plugins/cases/public/components/connectors/servicenow/index.ts @@ -11,19 +11,15 @@ import { CaseConnector } from '../types'; import { ServiceNowITSMFieldsType, ServiceNowSIRFieldsType } from '../../../../common'; import * as i18n from './translations'; -export const getServiceNowITSMCaseConnector = (): CaseConnector => { - return { - id: '.servicenow', - fieldsComponent: lazy(() => import('./servicenow_itsm_case_fields')), - }; -}; +export const getServiceNowITSMCaseConnector = (): CaseConnector => ({ + id: '.servicenow', + fieldsComponent: lazy(() => import('./servicenow_itsm_case_fields')), +}); -export const getServiceNowSIRCaseConnector = (): CaseConnector => { - return { - id: '.servicenow-sir', - fieldsComponent: lazy(() => import('./servicenow_sir_case_fields')), - }; -}; +export const getServiceNowSIRCaseConnector = (): CaseConnector => ({ + id: '.servicenow-sir', + fieldsComponent: lazy(() => import('./servicenow_sir_case_fields')), +}); export const serviceNowITSMFieldLabels = { impact: i18n.IMPACT, diff --git a/x-pack/plugins/cases/public/components/create/connector.test.tsx b/x-pack/plugins/cases/public/components/create/connector.test.tsx index b2a8838774b0..c453838f6cd7 100644 --- a/x-pack/plugins/cases/public/components/create/connector.test.tsx +++ b/x-pack/plugins/cases/public/components/create/connector.test.tsx @@ -19,24 +19,22 @@ 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: {}, - triggersActionsUi: { - actionTypeRegistry: { - get: jest.fn().mockReturnValue({ - actionTypeTitle: 'test', - iconClass: 'logoSecurity', - }), - }, +jest.mock('../../common/lib/kibana', () => ({ + useKibana: () => ({ + services: { + notifications: {}, + http: {}, + triggersActionsUi: { + actionTypeRegistry: { + get: jest.fn().mockReturnValue({ + actionTypeTitle: 'test', + iconClass: 'logoSecurity', + }), }, }, - }), - }; -}); + }, + }), +})); jest.mock('../connectors/resilient/use_get_incident_types'); jest.mock('../connectors/resilient/use_get_severity'); diff --git a/x-pack/plugins/cases/public/components/create/connector.tsx b/x-pack/plugins/cases/public/components/create/connector.tsx index 959193380694..2049f2a083a6 100644 --- a/x-pack/plugins/cases/public/components/create/connector.tsx +++ b/x-pack/plugins/cases/public/components/create/connector.tsx @@ -8,11 +8,10 @@ import React, { memo, useCallback } from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { ConnectorTypes } from '../../../common'; +import { ActionConnector, ConnectorTypes } from '../../../common'; import { UseField, useFormData, FieldHook, useFormContext } from '../../common/shared_imports'; import { ConnectorSelector } from '../connector_selector/form'; import { ConnectorFieldsForm } from '../connectors/fields_form'; -import { ActionConnector } from '../../../common'; import { getConnectorById } from '../configure_cases/utils'; import { FormProps } from './schema'; diff --git a/x-pack/plugins/cases/public/components/create/index.tsx b/x-pack/plugins/cases/public/components/create/index.tsx index 139a2103f604..7f8b8f664529 100644 --- a/x-pack/plugins/cases/public/components/create/index.tsx +++ b/x-pack/plugins/cases/public/components/create/index.tsx @@ -15,7 +15,7 @@ import { CreateCaseForm } from './form'; import { FormContext } from './form_context'; import { SubmitCaseButton } from './submit_button'; import { Case } from '../../containers/types'; -import { CaseType } from '../../../common/api/cases'; +import { CaseType } from '../../../common'; import { CasesTimelineIntegration, CasesTimelineIntegrationProvider } from '../timeline_context'; import { fieldName as descriptionFieldName } from './description'; import { InsertTimeline } from '../insert_timeline'; @@ -91,12 +91,10 @@ const CreateCaseComponent = ({ ); -export const CreateCase: React.FC = React.memo((props) => { - return ( - - - - ); -}); +export const CreateCase: React.FC = React.memo((props) => ( + + + +)); // eslint-disable-next-line import/no-default-export export { CreateCase as default }; diff --git a/x-pack/plugins/cases/public/components/header_page/index.tsx b/x-pack/plugins/cases/public/components/header_page/index.tsx index dc9f73e37b02..d6daf1b57d33 100644 --- a/x-pack/plugins/cases/public/components/header_page/index.tsx +++ b/x-pack/plugins/cases/public/components/header_page/index.tsx @@ -88,41 +88,39 @@ const HeaderPageComponent: React.FC = ({ title, titleNode, ...rest -}) => { - return ( -
- - - {backOptions && ( - - - {backOptions.text} - - - )} - - {!backOptions && backComponent && <>{backComponent}} - - {titleNode || } - - {subtitle && <Subtitle data-test-subj="header-page-subtitle" items={subtitle} />} - {subtitle2 && <Subtitle data-test-subj="header-page-subtitle-2" items={subtitle2} />} - {border && isLoading && <EuiProgress size="xs" color="accent" />} - </FlexItem> - - {children && ( - <FlexItem data-test-subj="header-page-supplements" grow={false}> - {children} - </FlexItem> +}) => ( + <Header border={border} {...rest}> + <EuiFlexGroup alignItems="center"> + <FlexItem> + {backOptions && ( + <LinkBack> + <LinkIcon + dataTestSubj={backOptions.dataTestSubj} + onClick={backOptions.onClick} + href={backOptions.href} + iconType="arrowLeft" + > + {backOptions.text} + </LinkIcon> + </LinkBack> )} - </EuiFlexGroup> - </Header> - ); -}; + + {!backOptions && backComponent && <>{backComponent}</>} + + {titleNode || <Title title={title} badgeOptions={badgeOptions} />} + + {subtitle && <Subtitle data-test-subj="header-page-subtitle" items={subtitle} />} + {subtitle2 && <Subtitle data-test-subj="header-page-subtitle-2" items={subtitle2} />} + {border && isLoading && <EuiProgress size="xs" color="accent" />} + </FlexItem> + + {children && ( + <FlexItem data-test-subj="header-page-supplements" grow={false}> + {children} + </FlexItem> + )} + </EuiFlexGroup> + </Header> +); export const HeaderPage = React.memo(HeaderPageComponent); diff --git a/x-pack/plugins/cases/public/components/links/index.tsx b/x-pack/plugins/cases/public/components/links/index.tsx index 23eedc7c090b..d53d5c973e7d 100644 --- a/x-pack/plugins/cases/public/components/links/index.tsx +++ b/x-pack/plugins/cases/public/components/links/index.tsx @@ -18,7 +18,9 @@ import * as i18n from './translations'; export interface CasesNavigation<T = React.MouseEvent | MouseEvent | null, K = null> { href: K extends 'configurable' ? (arg: T) => string : string; - onClick: (arg: T) => void; + onClick: K extends 'configurable' + ? (arg: T, arg2: React.MouseEvent | MouseEvent) => Promise<void> | void + : (arg: T) => Promise<void> | void; } export const LinkButton: React.FC< @@ -47,7 +49,7 @@ const CaseDetailsLinkComponent: React.FC<{ (ev) => { if (onClick) { ev.preventDefault(); - onClick({ detailName, subCaseId }); + onClick({ detailName, subCaseId }, ev); } }, [detailName, onClick, subCaseId] diff --git a/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx b/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx index f80e66a8c3e9..3d9e75c6450d 100644 --- a/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx +++ b/x-pack/plugins/cases/public/components/markdown_editor/editor.tsx @@ -7,8 +7,7 @@ import React, { memo, useEffect, useState, useCallback } from 'react'; import { PluggableList } from 'unified'; -import { EuiMarkdownEditor } from '@elastic/eui'; -import { EuiMarkdownEditorUiPlugin } from '@elastic/eui'; +import { EuiMarkdownEditor, EuiMarkdownEditorUiPlugin } from '@elastic/eui'; import { usePlugins } from './use_plugins'; interface MarkdownEditorProps { diff --git a/x-pack/plugins/cases/public/components/markdown_editor/translations.ts b/x-pack/plugins/cases/public/components/markdown_editor/translations.ts index 365738f53ef8..ad8c51f96617 100644 --- a/x-pack/plugins/cases/public/components/markdown_editor/translations.ts +++ b/x-pack/plugins/cases/public/components/markdown_editor/translations.ts @@ -7,10 +7,6 @@ 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', }); diff --git a/x-pack/plugins/cases/public/components/subtitle/index.tsx b/x-pack/plugins/cases/public/components/subtitle/index.tsx index 267c564fc498..51e0f829100c 100644 --- a/x-pack/plugins/cases/public/components/subtitle/index.tsx +++ b/x-pack/plugins/cases/public/components/subtitle/index.tsx @@ -61,15 +61,13 @@ export interface SubtitleProps { items: string | React.ReactNode | Array<string | React.ReactNode>; } -export const Subtitle = React.memo<SubtitleProps>(({ items }) => { - return ( - <Wrapper className="casesSubtitle"> - {Array.isArray(items) ? ( - items.map((item, i) => <SubtitleItem key={i}>{item}</SubtitleItem>) - ) : ( - <SubtitleItem>{items}</SubtitleItem> - )} - </Wrapper> - ); -}); +export const Subtitle = React.memo<SubtitleProps>(({ items }) => ( + <Wrapper className="casesSubtitle"> + {Array.isArray(items) ? ( + items.map((item, i) => <SubtitleItem key={i}>{item}</SubtitleItem>) + ) : ( + <SubtitleItem>{items}</SubtitleItem> + )} + </Wrapper> +)); Subtitle.displayName = 'Subtitle'; diff --git a/x-pack/plugins/cases/public/components/tag_list/tags.tsx b/x-pack/plugins/cases/public/components/tag_list/tags.tsx index b38cf1745307..c91953c3077c 100644 --- a/x-pack/plugins/cases/public/components/tag_list/tags.tsx +++ b/x-pack/plugins/cases/public/components/tag_list/tags.tsx @@ -14,20 +14,18 @@ interface TagsProps { gutterSize?: EuiBadgeGroupProps['gutterSize']; } -const TagsComponent: React.FC<TagsProps> = ({ tags, color = 'default', gutterSize }) => { - return ( - <> - {tags.length > 0 && ( - <EuiBadgeGroup gutterSize={gutterSize}> - {tags.map((tag) => ( - <EuiBadge data-test-subj={`tag-${tag}`} color={color} key={tag}> - {tag} - </EuiBadge> - ))} - </EuiBadgeGroup> - )} - </> - ); -}; +const TagsComponent: React.FC<TagsProps> = ({ tags, color = 'default', gutterSize }) => ( + <> + {tags.length > 0 && ( + <EuiBadgeGroup gutterSize={gutterSize}> + {tags.map((tag) => ( + <EuiBadge data-test-subj={`tag-${tag}`} color={color} key={tag}> + {tag} + </EuiBadge> + ))} + </EuiBadgeGroup> + )} + </> +); export const Tags = memo(TagsComponent); diff --git a/x-pack/plugins/cases/public/components/timeline_context/use_timeline_context.ts b/x-pack/plugins/cases/public/components/timeline_context/use_timeline_context.ts index d0f9417c20ab..0f7d27b4c3e5 100644 --- a/x-pack/plugins/cases/public/components/timeline_context/use_timeline_context.ts +++ b/x-pack/plugins/cases/public/components/timeline_context/use_timeline_context.ts @@ -8,6 +8,4 @@ import { useContext } from 'react'; import { CasesTimelineIntegrationContext } from '.'; -export const useTimelineContext = () => { - return useContext(CasesTimelineIntegrationContext); -}; +export const useTimelineContext = () => useContext(CasesTimelineIntegrationContext); diff --git a/x-pack/plugins/cases/public/components/use_create_case_modal/create_case_modal.tsx b/x-pack/plugins/cases/public/components/use_create_case_modal/create_case_modal.tsx index a4278e53ea34..677aabd593ad 100644 --- a/x-pack/plugins/cases/public/components/use_create_case_modal/create_case_modal.tsx +++ b/x-pack/plugins/cases/public/components/use_create_case_modal/create_case_modal.tsx @@ -29,8 +29,8 @@ const CreateModalComponent: React.FC<CreateCaseModalProps> = ({ onCloseCaseModal, onSuccess, owner, -}) => { - return isModalOpen ? ( +}) => + isModalOpen ? ( <EuiModal onClose={onCloseCaseModal} data-test-subj="create-case-modal"> <EuiModalHeader> <EuiModalHeaderTitle>{i18n.CREATE_TITLE}</EuiModalHeaderTitle> @@ -47,7 +47,6 @@ const CreateModalComponent: React.FC<CreateCaseModalProps> = ({ </EuiModalBody> </EuiModal> ) : null; -}; export const CreateCaseModal = memo(CreateModalComponent); diff --git a/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx b/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx index 1b8e01b15db8..00b88d372584 100644 --- a/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx +++ b/x-pack/plugins/cases/public/components/use_push_to_service/index.tsx @@ -143,8 +143,8 @@ export const usePushToService = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [actionLicense, caseStatus, connectors.length, connector, loadingLicense]); - const pushToServiceButton = useMemo(() => { - return ( + const pushToServiceButton = useMemo( + () => ( <EuiButton data-test-subj="push-to-external-service" fill @@ -159,21 +159,22 @@ export const usePushToService = ({ ? i18n.UPDATE_THIRD(connector.name) : i18n.PUSH_THIRD(connector.name)} </EuiButton> - ); + ), // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ - connector, - connectors, - errorsMsg, - handlePushToService, - isLoading, - loadingLicense, - userCanCrud, - isValidConnector, - ]); + [ + connector, + connectors, + errorsMsg, + handlePushToService, + isLoading, + loadingLicense, + userCanCrud, + isValidConnector, + ] + ); - const objToReturn = useMemo(() => { - return { + const objToReturn = useMemo( + () => ({ pushButton: errorsMsg.length > 0 ? ( <EuiToolTip @@ -190,8 +191,9 @@ export const usePushToService = ({ errorsMsg.length > 0 ? ( <CaseCallOut title={i18n.ERROR_PUSH_SERVICE_CALLOUT_TITLE} messages={errorsMsg} /> ) : null, - }; - }, [errorsMsg, pushToServiceButton]); + }), + [errorsMsg, pushToServiceButton] + ); return objToReturn; }; diff --git a/x-pack/plugins/cases/public/components/user_action_tree/helpers.tsx b/x-pack/plugins/cases/public/components/user_action_tree/helpers.tsx index 024fa4d49490..5424ad8238a2 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/helpers.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/helpers.tsx @@ -26,26 +26,26 @@ import { Status, statuses } from '../status'; import { UserActionShowAlert } from './user_action_show_alert'; import * as i18n from './translations'; import { AlertCommentEvent } from './user_action_alert_comment_event'; +import { CasesNavigation } from '../links'; interface LabelTitle { action: CaseUserActions; field: string; } +export type RuleDetailsNavigation = CasesNavigation<string | null | undefined, 'configurable'>; -const getStatusTitle = (id: string, status: CaseStatuses) => { - return ( - <EuiFlexGroup - gutterSize="s" - alignItems={'center'} - data-test-subj={`${id}-user-action-status-title`} - > - <EuiFlexItem grow={false}>{i18n.MARKED_CASE_AS}</EuiFlexItem> - <EuiFlexItem grow={false}> - <Status type={status} /> - </EuiFlexItem> - </EuiFlexGroup> - ); -}; +const getStatusTitle = (id: string, status: CaseStatuses) => ( + <EuiFlexGroup + gutterSize="s" + alignItems={'center'} + data-test-subj={`${id}-user-action-status-title`} + > + <EuiFlexItem grow={false}>{i18n.MARKED_CASE_AS}</EuiFlexItem> + <EuiFlexItem grow={false}> + <Status type={status} /> + </EuiFlexItem> + </EuiFlexGroup> +); const isStatusValid = (status: string): status is CaseStatuses => Object.prototype.hasOwnProperty.call(statuses, status); @@ -204,67 +204,65 @@ export const getAlertAttachment = ({ alertId, getCaseDetailHrefWithCommentId, getRuleDetailsHref, - onRuleDetailsClick, index, loadingAlertData, + onRuleDetailsClick, + onShowAlertDetails, ruleId, ruleName, - onShowAlertDetails, }: { action: CaseUserActions; - getCaseDetailHrefWithCommentId: (commentId: string) => string; - getRuleDetailsHref: (ruleId: string | null | undefined) => string; - onRuleDetailsClick?: (ruleId: string | null | undefined) => void; - onShowAlertDetails: (alertId: string, index: string) => void; alertId: string; + getCaseDetailHrefWithCommentId: (commentId: string) => string; + getRuleDetailsHref: RuleDetailsNavigation['href']; index: string; loadingAlertData: boolean; + onRuleDetailsClick?: RuleDetailsNavigation['onClick']; + onShowAlertDetails: (alertId: string, index: string) => void; ruleId?: string | null; ruleName?: string | null; -}): EuiCommentProps => { - return { - username: ( - <UserActionUsernameWithAvatar - username={action.actionBy.username} - fullName={action.actionBy.fullName} - /> - ), - className: 'comment-alert', - type: 'update', - event: ( - <AlertCommentEvent - alertId={alertId} - getRuleDetailsHref={getRuleDetailsHref} - loadingAlertData={loadingAlertData} - onRuleDetailsClick={onRuleDetailsClick} - ruleId={ruleId} - ruleName={ruleName} - commentType={CommentType.alert} - /> - ), - 'data-test-subj': `${action.actionField[0]}-${action.action}-action-${action.actionId}`, - timestamp: <UserActionTimestamp createdAt={action.actionAt} />, - timelineIcon: 'bell', - actions: ( - <EuiFlexGroup> - <EuiFlexItem> - <UserActionCopyLink - id={action.actionId} - getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} - /> - </EuiFlexItem> - <EuiFlexItem> - <UserActionShowAlert - id={action.actionId} - alertId={alertId} - index={index} - onShowAlertDetails={onShowAlertDetails} - /> - </EuiFlexItem> - </EuiFlexGroup> - ), - }; -}; +}): EuiCommentProps => ({ + username: ( + <UserActionUsernameWithAvatar + username={action.actionBy.username} + fullName={action.actionBy.fullName} + /> + ), + className: 'comment-alert', + type: 'update', + event: ( + <AlertCommentEvent + alertId={alertId} + getRuleDetailsHref={getRuleDetailsHref} + loadingAlertData={loadingAlertData} + onRuleDetailsClick={onRuleDetailsClick} + ruleId={ruleId} + ruleName={ruleName} + commentType={CommentType.alert} + /> + ), + 'data-test-subj': `${action.actionField[0]}-${action.action}-action-${action.actionId}`, + timestamp: <UserActionTimestamp createdAt={action.actionAt} />, + timelineIcon: 'bell', + actions: ( + <EuiFlexGroup> + <EuiFlexItem> + <UserActionCopyLink + id={action.actionId} + getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} + /> + </EuiFlexItem> + <EuiFlexItem> + <UserActionShowAlert + id={action.actionId} + alertId={alertId} + index={index} + onShowAlertDetails={onShowAlertDetails} + /> + </EuiFlexItem> + </EuiFlexGroup> + ), +}); export const toStringArray = (value: unknown): string[] => { if (Array.isArray(value)) { @@ -314,45 +312,43 @@ export const getGeneratedAlertsAttachment = ({ action: CaseUserActions; alertIds: string[]; getCaseDetailHrefWithCommentId: (commentId: string) => string; - getRuleDetailsHref: (ruleId: string | null | undefined) => string; - onRuleDetailsClick?: (ruleId: string | null | undefined) => void; + getRuleDetailsHref: RuleDetailsNavigation['href']; + onRuleDetailsClick?: RuleDetailsNavigation['onClick']; renderInvestigateInTimelineActionComponent?: (alertIds: string[]) => JSX.Element; ruleId: string; ruleName: string; -}): EuiCommentProps => { - return { - username: <EuiIcon type="logoSecurity" size="m" />, - className: 'comment-alert', - type: 'update', - event: ( - <AlertCommentEvent - alertId={alertIds[0]} - getRuleDetailsHref={getRuleDetailsHref} - onRuleDetailsClick={onRuleDetailsClick} - ruleId={ruleId} - ruleName={ruleName} - alertsCount={alertIds.length} - commentType={CommentType.generatedAlert} - /> - ), - 'data-test-subj': `${action.actionField[0]}-${action.action}-action-${action.actionId}`, - timestamp: <UserActionTimestamp createdAt={action.actionAt} />, - timelineIcon: 'bell', - actions: ( - <EuiFlexGroup> - <EuiFlexItem> - <UserActionCopyLink - getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} - id={action.actionId} - /> - </EuiFlexItem> - {renderInvestigateInTimelineActionComponent ? ( - <EuiFlexItem>{renderInvestigateInTimelineActionComponent(alertIds)}</EuiFlexItem> - ) : null} - </EuiFlexGroup> - ), - }; -}; +}): EuiCommentProps => ({ + username: <EuiIcon type="logoSecurity" size="m" />, + className: 'comment-alert', + type: 'update', + event: ( + <AlertCommentEvent + alertId={alertIds[0]} + getRuleDetailsHref={getRuleDetailsHref} + onRuleDetailsClick={onRuleDetailsClick} + ruleId={ruleId} + ruleName={ruleName} + alertsCount={alertIds.length} + commentType={CommentType.generatedAlert} + /> + ), + 'data-test-subj': `${action.actionField[0]}-${action.action}-action-${action.actionId}`, + timestamp: <UserActionTimestamp createdAt={action.actionAt} />, + timelineIcon: 'bell', + actions: ( + <EuiFlexGroup> + <EuiFlexItem> + <UserActionCopyLink + getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} + id={action.actionId} + /> + </EuiFlexItem> + {renderInvestigateInTimelineActionComponent ? ( + <EuiFlexItem>{renderInvestigateInTimelineActionComponent(alertIds)}</EuiFlexItem> + ) : null} + </EuiFlexGroup> + ), +}); interface Signal { rule: { diff --git a/x-pack/plugins/cases/public/components/user_action_tree/index.test.tsx b/x-pack/plugins/cases/public/components/user_action_tree/index.test.tsx index b30726bf23b2..c58f5e53c9fd 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/index.test.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/index.test.tsx @@ -8,8 +8,9 @@ import React from 'react'; import { mount } from 'enzyme'; import { waitFor } from '@testing-library/react'; +// eslint-disable-next-line @kbn/eslint/module_migration +import routeData from 'react-router'; -import { Router, routeData, mockHistory, mockLocation } from '../__mock__/router'; import { getFormMock, useFormMock, useFormDataMock } from '../__mock__/form'; import { useUpdateComment } from '../../containers/use_update_comment'; import { basicCase, basicPush, getUserAction } from '../../containers/mock'; @@ -63,7 +64,7 @@ describe(`UserActionTree`, () => { const formHookMock = getFormMock(sampleData); useFormMock.mockImplementation(() => ({ form: formHookMock })); useFormDataMock.mockImplementation(() => [{ content: sampleData.content, comment: '' }]); - jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); + jest .spyOn(routeData, 'useParams') .mockReturnValue({ detailName: 'case-id', subCaseId: 'sub-case-id' }); @@ -72,9 +73,7 @@ describe(`UserActionTree`, () => { it('Loading spinner when user actions loading and displays fullName/username', () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...{ ...defaultProps, isLoadingUserActions: true }} /> - </Router> + <UserActionTree {...{ ...defaultProps, isLoadingUserActions: true }} /> </TestProviders> ); expect(wrapper.find(`[data-test-subj="user-actions-loading"]`).exists()).toEqual(true); @@ -109,13 +108,13 @@ describe(`UserActionTree`, () => { }; const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); - expect(wrapper.find(`[data-test-subj="top-footer"]`).exists()).toEqual(true); - expect(wrapper.find(`[data-test-subj="bottom-footer"]`).exists()).toEqual(true); + await waitFor(() => { + expect(wrapper.find(`[data-test-subj="top-footer"]`).exists()).toEqual(true); + expect(wrapper.find(`[data-test-subj="bottom-footer"]`).exists()).toEqual(true); + }); }); it('Renders service now update line with top only when push is up to date', async () => { @@ -136,13 +135,13 @@ describe(`UserActionTree`, () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); - expect(wrapper.find(`[data-test-subj="top-footer"]`).exists()).toEqual(true); - expect(wrapper.find(`[data-test-subj="bottom-footer"]`).exists()).toEqual(false); + await waitFor(() => { + expect(wrapper.find(`[data-test-subj="top-footer"]`).exists()).toEqual(true); + expect(wrapper.find(`[data-test-subj="bottom-footer"]`).exists()).toEqual(false); + }); }); it('Outlines comment when update move to link is clicked', async () => { const ourActions = [getUserAction(['comment'], 'create'), getUserAction(['comment'], 'update')]; @@ -153,9 +152,7 @@ describe(`UserActionTree`, () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); expect( @@ -190,9 +187,7 @@ describe(`UserActionTree`, () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); @@ -236,9 +231,7 @@ describe(`UserActionTree`, () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); @@ -287,9 +280,7 @@ describe(`UserActionTree`, () => { it('calls update description when description markdown is saved', async () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...defaultProps} /> - </Router> + <UserActionTree {...defaultProps} /> </TestProviders> ); @@ -333,9 +324,7 @@ describe(`UserActionTree`, () => { const props = defaultProps; const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); @@ -365,17 +354,16 @@ describe(`UserActionTree`, () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionTree {...props} /> - </Router> + <UserActionTree {...props} /> </TestProviders> ); - - expect( - wrapper - .find(`[data-test-subj="comment-create-action-${commentId}"]`) - .first() - .hasClass('outlined') - ).toEqual(true); + await waitFor(() => { + expect( + wrapper + .find(`[data-test-subj="comment-create-action-${commentId}"]`) + .first() + .hasClass('outlined') + ).toEqual(true); + }); }); }); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/index.tsx b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx index 156e011a18d8..f9bd94154707 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/index.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/index.tsx @@ -21,15 +21,17 @@ import { isRight } from 'fp-ts/Either'; import * as i18n from './translations'; -import { Case, CaseUserActions } from '../../../common'; import { useUpdateComment } from '../../containers/use_update_comment'; import { useCurrentUser } from '../../common/lib/kibana'; import { AddComment, AddCommentRefObject } from '../add_comment'; import { ActionConnector, AlertCommentRequestRt, + Case, + CaseUserActions, CommentType, ContextTypeUserRt, + Ecs, } from '../../../common'; import { CaseServices } from '../../containers/use_get_case_user_actions'; import { parseString } from '../../containers/utils'; @@ -42,6 +44,7 @@ import { getUpdateAction, getAlertAttachment, getGeneratedAlertsAttachment, + RuleDetailsNavigation, } from './helpers'; import { UserActionAvatar } from './user_action_avatar'; import { UserActionMarkdown } from './user_action_markdown'; @@ -49,24 +52,24 @@ import { UserActionTimestamp } from './user_action_timestamp'; import { UserActionUsername } from './user_action_username'; import { UserActionContentToolbar } from './user_action_content_toolbar'; import { getManualAlertIdsWithNoRuleId } from '../case_view/helpers'; -import { Ecs } from '../../../common'; + export interface UserActionTreeProps { - getCaseDetailHrefWithCommentId: (commentId: string) => string; caseServices: CaseServices; caseUserActions: CaseUserActions[]; connectors: ActionConnector[]; data: Case; - getRuleDetailsHref?: (ruleId: string | null | undefined) => string; fetchUserActions: () => void; + getCaseDetailHrefWithCommentId: (commentId: string) => string; + getRuleDetailsHref?: RuleDetailsNavigation['href']; isLoadingDescription: boolean; isLoadingUserActions: boolean; - onRuleDetailsClick?: (ruleId: string | null | undefined) => void; + onRuleDetailsClick?: RuleDetailsNavigation['onClick']; + onShowAlertDetails: (alertId: string, index: string) => void; onUpdateField: ({ key, value, onSuccess, onError }: OnUpdateFields) => void; renderInvestigateInTimelineActionComponent?: (alertIds: string[]) => JSX.Element; updateCase: (newCase: Case) => void; useFetchAlertData: (alertIds: string[]) => [boolean, Record<string, Ecs>]; userCanCrud: boolean; - onShowAlertDetails: (alertId: string, index: string) => void; } const MyEuiFlexGroup = styled(EuiFlexGroup)` @@ -114,22 +117,22 @@ const NEW_ID = 'newComment'; export const UserActionTree = React.memo( ({ - data: caseData, - getCaseDetailHrefWithCommentId, caseServices, caseUserActions, connectors, - getRuleDetailsHref, + data: caseData, fetchUserActions, + getCaseDetailHrefWithCommentId, + getRuleDetailsHref, isLoadingDescription, isLoadingUserActions, onRuleDetailsClick, + onShowAlertDetails, onUpdateField, renderInvestigateInTimelineActionComponent, updateCase, useFetchAlertData, userCanCrud, - onShowAlertDetails, }: UserActionTreeProps) => { const { detailName: caseId, commentId, subCaseId } = useParams<{ detailName: string; diff --git a/x-pack/plugins/cases/public/components/user_action_tree/translations.ts b/x-pack/plugins/cases/public/components/user_action_tree/translations.ts index 256e7ad66eeb..27d1554ed255 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/translations.ts +++ b/x-pack/plugins/cases/public/components/user_action_tree/translations.ts @@ -49,24 +49,10 @@ export const GENERATED_ALERT_COUNT_COMMENT_LABEL_TITLE = (totalCount: number) => defaultMessage: `{totalCount} {totalCount, plural, =1 {alert} other {alerts}}`, }); -export const ALERT_RULE_DELETED_COMMENT_LABEL = i18n.translate( - 'xpack.cases.caseView.alertRuleDeletedLabelTitle', - { - defaultMessage: 'added an alert', - } -); - export const SHOW_ALERT_TOOLTIP = i18n.translate('xpack.cases.caseView.showAlertTooltip', { defaultMessage: 'Show alert details', }); -export const SEND_ALERT_TO_TIMELINE = i18n.translate( - 'xpack.cases.caseView.sendAlertToTimelineTooltip', - { - defaultMessage: 'Investigate in timeline', - } -); - export const UNKNOWN_RULE = i18n.translate('xpack.cases.caseView.unknownRule.label', { defaultMessage: 'Unknown rule', }); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_alert_comment_event.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_alert_comment_event.tsx index ee962f1407d7..8f405caa153f 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_alert_comment_event.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_alert_comment_event.tsx @@ -12,12 +12,13 @@ import { EuiText, EuiLoadingSpinner } from '@elastic/eui'; import * as i18n from './translations'; import { CommentType } from '../../../common'; import { LinkAnchor } from '../links'; +import { RuleDetailsNavigation } from './helpers'; interface Props { alertId: string; commentType: CommentType; - getRuleDetailsHref: (ruleId: string | null | undefined) => string; - onRuleDetailsClick?: (ruleId: string | null | undefined) => void; + getRuleDetailsHref: RuleDetailsNavigation['href']; + onRuleDetailsClick?: RuleDetailsNavigation['onClick']; ruleId?: string | null; ruleName?: string | null; alertsCount?: number; @@ -35,9 +36,9 @@ const AlertCommentEventComponent: React.FC<Props> = ({ commentType, }) => { const onLinkClick = useCallback( - (ev: { preventDefault: () => void }) => { + (ev) => { ev.preventDefault(); - if (onRuleDetailsClick) onRuleDetailsClick(ruleId); + if (onRuleDetailsClick) onRuleDetailsClick(ruleId, ev); }, [ruleId, onRuleDetailsClick] ); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.test.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.test.tsx index dc14011087a8..a5244e14ad24 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.test.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.test.tsx @@ -18,17 +18,15 @@ jest.mock('react-router-dom', () => { }; }); -jest.mock('../../common/lib/kibana', () => { - return { - useKibana: () => ({ - services: { - application: { - getUrlForApp: jest.fn(), - }, +jest.mock('../../common/lib/kibana', () => ({ + useKibana: () => ({ + services: { + application: { + getUrlForApp: jest.fn(), }, - }), - }; -}); + }, + }), +})); const props = { getCaseDetailHrefWithCommentId: jest.fn().mockReturnValue('case-detail-url-with-comment-id-1'), diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.tsx index f1f0a0148b9c..7adaffce22c5 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_content_toolbar.tsx @@ -31,28 +31,23 @@ const UserActionContentToolbarComponent = ({ isLoading, onEdit, onQuote, -}: UserActionContentToolbarProps) => { - return ( - <EuiFlexGroup> - <EuiFlexItem> - <UserActionCopyLink - id={id} - getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} - /> - </EuiFlexItem> - <EuiFlexItem> - <UserActionPropertyActions - id={id} - editLabel={editLabel} - quoteLabel={quoteLabel} - disabled={disabled} - isLoading={isLoading} - onEdit={onEdit} - onQuote={onQuote} - /> - </EuiFlexItem> - </EuiFlexGroup> - ); -}; +}: UserActionContentToolbarProps) => ( + <EuiFlexGroup> + <EuiFlexItem> + <UserActionCopyLink id={id} getCaseDetailHrefWithCommentId={getCaseDetailHrefWithCommentId} /> + </EuiFlexItem> + <EuiFlexItem> + <UserActionPropertyActions + id={id} + editLabel={editLabel} + quoteLabel={quoteLabel} + disabled={disabled} + isLoading={isLoading} + onEdit={onEdit} + onQuote={onQuote} + /> + </EuiFlexItem> + </EuiFlexGroup> +); export const UserActionContentToolbar = memo(UserActionContentToolbarComponent); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_copy_link.test.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_copy_link.test.tsx index 51381bee9897..91184d49479b 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_copy_link.test.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_copy_link.test.tsx @@ -24,26 +24,22 @@ jest.mock('react-router-dom', () => { }; }); -jest.mock('copy-to-clipboard', () => { - return jest.fn(); -}); +jest.mock('copy-to-clipboard', () => jest.fn()); const mockGetUrlForApp = jest.fn( (appId: string, options?: { path?: string; absolute?: boolean }) => `${appId}${options?.path ?? ''}` ); -jest.mock('../../common/lib/kibana', () => { - return { - useKibana: () => ({ - services: { - application: { - getUrlForApp: mockGetUrlForApp, - }, +jest.mock('../../common/lib/kibana', () => ({ + useKibana: () => ({ + services: { + application: { + getUrlForApp: mockGetUrlForApp, }, - }), - }; -}); + }, + }), +})); const props = { id: 'comment-id', diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_markdown.test.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_markdown.test.tsx index 6fff3c8f9abe..43c51e9e394d 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_markdown.test.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_markdown.test.tsx @@ -7,7 +7,6 @@ import React from 'react'; import { mount } from 'enzyme'; -import { Router, mockHistory } from '../__mock__/router'; import { UserActionMarkdown } from './user_action_markdown'; import { TestProviders } from '../../common/mock'; import { waitFor } from '@testing-library/react'; @@ -31,9 +30,7 @@ describe('UserActionMarkdown ', () => { it('Renders markdown correctly when not in edit mode', async () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionMarkdown {...{ ...defaultProps, isEditable: false }} /> - </Router> + <UserActionMarkdown {...{ ...defaultProps, isEditable: false }} /> </TestProviders> ); @@ -43,9 +40,7 @@ describe('UserActionMarkdown ', () => { it('Save button click calls onSaveContent and onChangeEditable', async () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionMarkdown {...defaultProps} /> - </Router> + <UserActionMarkdown {...defaultProps} /> </TestProviders> ); wrapper.find(`[data-test-subj="user-action-save-markdown"]`).first().simulate('click'); @@ -58,9 +53,7 @@ describe('UserActionMarkdown ', () => { it('Cancel button click calls only onChangeEditable', async () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <UserActionMarkdown {...defaultProps} /> - </Router> + <UserActionMarkdown {...defaultProps} /> </TestProviders> ); wrapper.find(`[data-test-subj="user-action-cancel-markdown"]`).first().simulate('click'); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_property_actions.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_property_actions.tsx index c0d2075a278b..44b5baf3246c 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_property_actions.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_property_actions.tsx @@ -32,8 +32,8 @@ const UserActionPropertyActionsComponent = ({ const onEditClick = useCallback(() => onEdit(id), [id, onEdit]); const onQuoteClick = useCallback(() => onQuote(id), [id, onQuote]); - const propertyActions = useMemo(() => { - return [ + const propertyActions = useMemo( + () => [ { disabled, iconType: 'pencil', @@ -46,8 +46,9 @@ const UserActionPropertyActionsComponent = ({ label: quoteLabel, onClick: onQuoteClick, }, - ]; - }, [disabled, editLabel, quoteLabel, onEditClick, onQuoteClick]); + ], + [disabled, editLabel, quoteLabel, onEditClick, onQuoteClick] + ); return ( <> {isLoading && <EuiLoadingSpinner data-test-subj="user-action-title-loading" />} diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_timestamp.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_timestamp.tsx index 2e3973458c24..51b60dae4984 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_timestamp.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_timestamp.tsx @@ -17,31 +17,29 @@ interface UserActionAvatarProps { updatedAt?: string | null; } -const UserActionTimestampComponent = ({ createdAt, updatedAt }: UserActionAvatarProps) => { - return ( - <> - <LocalizedDateTooltip date={new Date(createdAt)}> - <FormattedRelative - data-test-subj="user-action-title-creation-relative-time" - value={createdAt} - /> - </LocalizedDateTooltip> - {updatedAt && ( - <EuiTextColor color="subdued"> - {/* be careful of the extra space at the beginning of the parenthesis */} - {' ('} - {i18n.EDITED_FIELD}{' '} - <LocalizedDateTooltip date={new Date(updatedAt)}> - <FormattedRelative - data-test-subj="user-action-title-edited-relative-time" - value={updatedAt} - /> - </LocalizedDateTooltip> - {')'} - </EuiTextColor> - )} - </> - ); -}; +const UserActionTimestampComponent = ({ createdAt, updatedAt }: UserActionAvatarProps) => ( + <> + <LocalizedDateTooltip date={new Date(createdAt)}> + <FormattedRelative + data-test-subj="user-action-title-creation-relative-time" + value={createdAt} + /> + </LocalizedDateTooltip> + {updatedAt && ( + <EuiTextColor color="subdued"> + {/* be careful of the extra space at the beginning of the parenthesis */} + {' ('} + {i18n.EDITED_FIELD}{' '} + <LocalizedDateTooltip date={new Date(updatedAt)}> + <FormattedRelative + data-test-subj="user-action-title-edited-relative-time" + value={updatedAt} + /> + </LocalizedDateTooltip> + {')'} + </EuiTextColor> + )} + </> +); export const UserActionTimestamp = memo(UserActionTimestampComponent); diff --git a/x-pack/plugins/cases/public/components/user_action_tree/user_action_username_with_avatar.tsx b/x-pack/plugins/cases/public/components/user_action_tree/user_action_username_with_avatar.tsx index c538403e8b63..685adc8724e8 100644 --- a/x-pack/plugins/cases/public/components/user_action_tree/user_action_username_with_avatar.tsx +++ b/x-pack/plugins/cases/public/components/user_action_tree/user_action_username_with_avatar.tsx @@ -20,26 +20,24 @@ interface UserActionUsernameWithAvatarProps { const UserActionUsernameWithAvatarComponent = ({ username, fullName, -}: UserActionUsernameWithAvatarProps) => { - return ( - <EuiFlexGroup - responsive={false} - alignItems="center" - gutterSize="s" - data-test-subj="user-action-username-with-avatar" - > - <EuiFlexItem grow={false}> - <EuiAvatar - size="s" - name={(isEmpty(fullName) ? username : fullName) ?? i18n.UNKNOWN} - data-test-subj="user-action-username-avatar" - /> - </EuiFlexItem> - <EuiFlexItem grow={false}> - <UserActionUsername username={username} fullName={fullName} /> - </EuiFlexItem> - </EuiFlexGroup> - ); -}; +}: UserActionUsernameWithAvatarProps) => ( + <EuiFlexGroup + responsive={false} + alignItems="center" + gutterSize="s" + data-test-subj="user-action-username-with-avatar" + > + <EuiFlexItem grow={false}> + <EuiAvatar + size="s" + name={(isEmpty(fullName) ? username : fullName) ?? i18n.UNKNOWN} + data-test-subj="user-action-username-avatar" + /> + </EuiFlexItem> + <EuiFlexItem grow={false}> + <UserActionUsername username={username} fullName={fullName} /> + </EuiFlexItem> + </EuiFlexGroup> +); export const UserActionUsernameWithAvatar = memo(UserActionUsernameWithAvatarComponent); diff --git a/x-pack/plugins/cases/public/containers/__mocks__/api.ts b/x-pack/plugins/cases/public/containers/__mocks__/api.ts index 006ad3f7afe6..6db92829bb8d 100644 --- a/x-pack/plugins/cases/public/containers/__mocks__/api.ts +++ b/x-pack/plugins/cases/public/containers/__mocks__/api.ts @@ -39,9 +39,7 @@ export const getCase = async ( caseId: string, includeComments: boolean = true, signal: AbortSignal -): Promise<Case> => { - return Promise.resolve(basicCase); -}; +): Promise<Case> => Promise.resolve(basicCase); export const getCasesStatus = async (signal: AbortSignal): Promise<CasesStatus> => Promise.resolve(casesStatus); diff --git a/x-pack/plugins/cases/public/containers/api.test.tsx b/x-pack/plugins/cases/public/containers/api.test.tsx index f9e128e7f713..abdee387a2c4 100644 --- a/x-pack/plugins/cases/public/containers/api.test.tsx +++ b/x-pack/plugins/cases/public/containers/api.test.tsx @@ -7,8 +7,13 @@ import { KibanaServices } from '../common/lib/kibana'; -import { ConnectorTypes, CommentType, CaseStatuses, SECURITY_SOLUTION_OWNER } from '../../common'; -import { CASES_URL } from '../../common'; +import { + CASES_URL, + ConnectorTypes, + CommentType, + CaseStatuses, + SECURITY_SOLUTION_OWNER, +} from '../../common'; import { deleteCases, diff --git a/x-pack/plugins/cases/public/containers/api.ts b/x-pack/plugins/cases/public/containers/api.ts index fc1dc34b4e1a..1a2a92850a4a 100644 --- a/x-pack/plugins/cases/public/containers/api.ts +++ b/x-pack/plugins/cases/public/containers/api.ts @@ -8,9 +8,14 @@ import { assign, omit } from 'lodash'; import { + ACTION_TYPES_URL, + CASE_REPORTERS_URL, + CASE_STATUS_URL, + CASE_TAGS_URL, CasePatchRequest, CasePostRequest, CaseResponse, + CASES_URL, CasesFindResponse, CasesResponse, CasesStatusResponse, @@ -18,32 +23,21 @@ import { CaseUserActionsResponse, CommentRequest, CommentType, + getCaseCommentsUrl, + getCaseDetailsUrl, + getCasePushUrl, + getCaseUserActionUrl, + getSubCaseDetailsUrl, + getSubCaseUserActionUrl, StatusAll, + SUB_CASE_DETAILS_URL, + SUB_CASES_PATCH_DEL_URL, SubCasePatchRequest, SubCaseResponse, SubCasesResponse, User, } from '../../common'; -import { - ACTION_TYPES_URL, - CASE_REPORTERS_URL, - CASE_STATUS_URL, - CASE_TAGS_URL, - CASES_URL, - SUB_CASE_DETAILS_URL, - SUB_CASES_PATCH_DEL_URL, -} from '../../common'; - -import { - getCaseCommentsUrl, - getCasePushUrl, - getCaseDetailsUrl, - getCaseUserActionUrl, - getSubCaseDetailsUrl, - getSubCaseUserActionUrl, -} from '../../common'; - import { KibanaServices } from '../common/lib/kibana'; import { diff --git a/x-pack/plugins/cases/public/containers/translations.ts b/x-pack/plugins/cases/public/containers/translations.ts index 966a5e158923..eb7e5ff99e51 100644 --- a/x-pack/plugins/cases/public/containers/translations.ts +++ b/x-pack/plugins/cases/public/containers/translations.ts @@ -72,10 +72,6 @@ export const SUCCESS_SEND_TO_EXTERNAL_SERVICE = (serviceName: string) => defaultMessage: 'Successfully sent to { serviceName }', }); -export const ERROR_GET_FIELDS = i18n.translate('xpack.cases.configure.errorGetFields', { - defaultMessage: 'Error getting fields from service', -}); - export const SYNC_CASE = (caseTitle: string) => i18n.translate('xpack.cases.containers.syncCase', { values: { caseTitle }, diff --git a/x-pack/plugins/cases/public/containers/use_bulk_update_case.tsx b/x-pack/plugins/cases/public/containers/use_bulk_update_case.tsx index ae2d09deafb0..449ca0ab77f1 100644 --- a/x-pack/plugins/cases/public/containers/use_bulk_update_case.tsx +++ b/x-pack/plugins/cases/public/containers/use_bulk_update_case.tsx @@ -141,12 +141,13 @@ export const useUpdateCases = (): UseUpdateCases => { [] ); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, updateBulkStatus, dispatchResetIsUpdated }; }; diff --git a/x-pack/plugins/cases/public/containers/use_delete_cases.tsx b/x-pack/plugins/cases/public/containers/use_delete_cases.tsx index 81a44004b244..153be6126f96 100644 --- a/x-pack/plugins/cases/public/containers/use_delete_cases.tsx +++ b/x-pack/plugins/cases/public/containers/use_delete_cases.tsx @@ -134,12 +134,13 @@ export const useDeleteCases = (): UseDeleteCase => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [state.isDisplayConfirmDeleteModal]); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, dispatchResetIsDeleted, handleOnDeleteConfirm, handleToggleModal }; }; diff --git a/x-pack/plugins/cases/public/containers/use_post_case.tsx b/x-pack/plugins/cases/public/containers/use_post_case.tsx index f3c92fc1ab33..f13c250b96a3 100644 --- a/x-pack/plugins/cases/public/containers/use_post_case.tsx +++ b/x-pack/plugins/cases/public/containers/use_post_case.tsx @@ -80,11 +80,12 @@ export const usePostCase = (): UsePostCase => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, postCase: postMyCase }; }; diff --git a/x-pack/plugins/cases/public/containers/use_post_comment.tsx b/x-pack/plugins/cases/public/containers/use_post_comment.tsx index 15cf398a2fdb..8677787fd9af 100644 --- a/x-pack/plugins/cases/public/containers/use_post_comment.tsx +++ b/x-pack/plugins/cases/public/containers/use_post_comment.tsx @@ -91,12 +91,13 @@ export const usePostComment = (): UsePostComment => { [toasts] ); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, postComment: postMyComment }; }; diff --git a/x-pack/plugins/cases/public/containers/use_post_push_to_service.tsx b/x-pack/plugins/cases/public/containers/use_post_push_to_service.tsx index bee89e21b428..f4cf5b012e84 100644 --- a/x-pack/plugins/cases/public/containers/use_post_push_to_service.tsx +++ b/x-pack/plugins/cases/public/containers/use_post_push_to_service.tsx @@ -97,12 +97,13 @@ export const usePostPushToService = (): UsePostPushToService => { [] ); - useEffect(() => { - return () => { + useEffect( + () => () => { abortCtrlRef.current.abort(); cancel.current = true; - }; - }, []); + }, + [] + ); return { ...state, pushCaseToExternalService }; }; diff --git a/x-pack/plugins/cases/public/containers/use_update_case.tsx b/x-pack/plugins/cases/public/containers/use_update_case.tsx index b6ea580cf542..afdc33bcc25e 100644 --- a/x-pack/plugins/cases/public/containers/use_update_case.tsx +++ b/x-pack/plugins/cases/public/containers/use_update_case.tsx @@ -138,12 +138,13 @@ export const useUpdateCase = ({ [caseId, subCaseId] ); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, updateCaseProperty: dispatchUpdateCaseProperty }; }; diff --git a/x-pack/plugins/cases/public/containers/use_update_comment.tsx b/x-pack/plugins/cases/public/containers/use_update_comment.tsx index 512b5b50a22b..478d7ebf1fc3 100644 --- a/x-pack/plugins/cases/public/containers/use_update_comment.tsx +++ b/x-pack/plugins/cases/public/containers/use_update_comment.tsx @@ -119,12 +119,13 @@ export const useUpdateComment = (): UseUpdateComment => { [] ); - useEffect(() => { - return () => { + useEffect( + () => () => { isCancelledRef.current = true; abortCtrlRef.current.abort(); - }; - }, []); + }, + [] + ); return { ...state, patchComment: dispatchUpdateComment }; }; diff --git a/x-pack/plugins/cases/public/plugin.ts b/x-pack/plugins/cases/public/plugin.ts index 8c9105961c13..5bfdf9b8b950 100644 --- a/x-pack/plugins/cases/public/plugin.ts +++ b/x-pack/plugins/cases/public/plugin.ts @@ -43,49 +43,37 @@ export class CasesUiPlugin implements Plugin<void, CasesUiStart, SetupPlugins, S * @param props AllCasesProps * @return {ReactElement<AllCasesProps>} */ - getAllCases: (props) => { - return getAllCasesLazy(props); - }, + getAllCases: getAllCasesLazy, /** * Get the case view component * @param props CaseViewProps * @return {ReactElement<CaseViewProps>} */ - getCaseView: (props) => { - return getCaseViewLazy(props); - }, + getCaseView: getCaseViewLazy, /** * Get the configure case component * @param props ConfigureCasesProps * @return {ReactElement<ConfigureCasesProps>} */ - getConfigureCases: (props) => { - return getConfigureCasesLazy(props); - }, + getConfigureCases: getConfigureCasesLazy, /** * Get the create case form * @param props CreateCaseProps * @return {ReactElement<CreateCaseProps>} */ - getCreateCase: (props) => { - return getCreateCaseLazy(props); - }, + getCreateCase: getCreateCaseLazy, /** * Get the recent cases component * @param props RecentCasesProps * @return {ReactElement<RecentCasesProps>} */ - getRecentCases: (props) => { - return getRecentCasesLazy(props); - }, + getRecentCases: getRecentCasesLazy, /** * use Modal hook for all cases selector * @param props UseAllCasesSelectorModalProps * @return UseAllCasesSelectorModalReturnedValues */ - getAllCasesSelectorModal: (props) => { - return getAllCasesSelectorModalLazy(props); - }, + getAllCasesSelectorModal: getAllCasesSelectorModalLazy, }; } diff --git a/x-pack/plugins/cases/server/authorization/authorization.ts b/x-pack/plugins/cases/server/authorization/authorization.ts index a363874857d5..71cd38363778 100644 --- a/x-pack/plugins/cases/server/authorization/authorization.ts +++ b/x-pack/plugins/cases/server/authorization/authorization.ts @@ -9,11 +9,10 @@ import { KibanaRequest, Logger } from 'kibana/server'; import Boom from '@hapi/boom'; import { SecurityPluginStart } from '../../../security/server'; import { PluginStartContract as FeaturesPluginStart } from '../../../features/server'; -import { AuthFilterHelpers, GetSpaceFn } from './types'; +import { AuthFilterHelpers, GetSpaceFn, OwnerEntity } from './types'; import { getOwnersFilter } from './utils'; import { AuthorizationAuditLogger, OperationDetails } from '.'; import { createCaseError } from '../common'; -import { OwnerEntity } from './types'; /** * This class handles ensuring that the user making a request has the correct permissions diff --git a/x-pack/plugins/cases/server/authorization/index.ts b/x-pack/plugins/cases/server/authorization/index.ts index 9a8b44a4a4f5..87683c55f5da 100644 --- a/x-pack/plugins/cases/server/authorization/index.ts +++ b/x-pack/plugins/cases/server/authorization/index.ts @@ -11,7 +11,7 @@ import { CASE_CONFIGURE_SAVED_OBJECT, CASE_SAVED_OBJECT, CASE_USER_ACTION_SAVED_OBJECT, -} from '../../common/constants'; +} from '../../common'; import { Verbs, ReadOperations, WriteOperations, OperationDetails } from './types'; export * from './authorization'; diff --git a/x-pack/plugins/cases/server/authorization/utils.ts b/x-pack/plugins/cases/server/authorization/utils.ts index 19dc37d0c3fd..92293d281447 100644 --- a/x-pack/plugins/cases/server/authorization/utils.ts +++ b/x-pack/plugins/cases/server/authorization/utils.ts @@ -7,7 +7,7 @@ import { remove, uniq } from 'lodash'; import { nodeBuilder, KueryNode } from '../../../../../src/plugins/data/common'; -import { OWNER_FIELD } from '../../common/api'; +import { OWNER_FIELD } from '../../common'; export const getOwnersFilter = ( savedObjectType: string, diff --git a/x-pack/plugins/cases/server/client/alerts/client.ts b/x-pack/plugins/cases/server/client/alerts/client.ts index 19dc95982613..6b25474bf0e7 100644 --- a/x-pack/plugins/cases/server/client/alerts/client.ts +++ b/x-pack/plugins/cases/server/client/alerts/client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CaseStatuses } from '../../../common/api'; +import { CaseStatuses } from '../../../common'; import { AlertInfo } from '../../common'; import { CasesClientGetAlertsResponse } from './types'; import { get } from './get'; diff --git a/x-pack/plugins/cases/server/client/attachments/add.ts b/x-pack/plugins/cases/server/client/attachments/add.ts index 9008e0fc28de..dd1f09da5cb4 100644 --- a/x-pack/plugins/cases/server/client/attachments/add.ts +++ b/x-pack/plugins/cases/server/client/attachments/add.ts @@ -19,16 +19,19 @@ import { import { nodeBuilder } from '../../../../../../src/plugins/data/common'; import { - throwErrors, - CommentRequestRt, - CommentType, + AlertCommentRequestRt, + CASE_COMMENT_SAVED_OBJECT, + CaseResponse, CaseStatuses, CaseType, - SubCaseAttributes, - CaseResponse, - User, - AlertCommentRequestRt, CommentRequest, + CommentRequestRt, + CommentType, + ENABLE_CASE_CONNECTOR, + MAX_GENERATED_ALERTS_PER_SUB_CASE, + SubCaseAttributes, + throwErrors, + User, } from '../../../common'; import { buildCaseUserActionItem, @@ -37,17 +40,12 @@ import { import { AttachmentService, CasesService, CaseUserActionService } from '../../services'; import { + createCaseError, CommentableCase, createAlertUpdateRequest, isCommentRequestTypeGenAlert, } from '../../common'; import { CasesClientArgs, CasesClientInternal } from '..'; -import { createCaseError } from '../../common/error'; -import { - ENABLE_CASE_CONNECTOR, - MAX_GENERATED_ALERTS_PER_SUB_CASE, - CASE_COMMENT_SAVED_OBJECT, -} from '../../../common'; import { decodeCommentRequest } from '../utils'; import { Operations } from '../../authorization'; diff --git a/x-pack/plugins/cases/server/client/attachments/client.ts b/x-pack/plugins/cases/server/client/attachments/client.ts index 1f6945a9d058..6a0f2c71ddd9 100644 --- a/x-pack/plugins/cases/server/client/attachments/client.ts +++ b/x-pack/plugins/cases/server/client/attachments/client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CommentResponse } from '../../../common/api'; +import { CommentResponse } from '../../../common'; import { CasesClientInternal } from '../client_internal'; import { IAllCommentsResponse, ICaseResponse, ICommentsResponse } from '../typedoc_interfaces'; diff --git a/x-pack/plugins/cases/server/client/attachments/delete.ts b/x-pack/plugins/cases/server/client/attachments/delete.ts index 89e12d7f7ea3..89d097c5334b 100644 --- a/x-pack/plugins/cases/server/client/attachments/delete.ts +++ b/x-pack/plugins/cases/server/client/attachments/delete.ts @@ -10,15 +10,15 @@ import pMap from 'p-map'; import { SavedObject } from 'kibana/public'; import { + AssociationType, CASE_SAVED_OBJECT, + CommentAttributes, MAX_CONCURRENT_SEARCHES, SUB_CASE_SAVED_OBJECT, -} from '../../../common/constants'; -import { AssociationType, CommentAttributes } from '../../../common/api'; +} from '../../../common'; import { CasesClientArgs } from '../types'; import { buildCommentUserActionItem } from '../../services/user_actions/helpers'; -import { createCaseError } from '../../common/error'; -import { checkEnabledCaseConnectorOrThrow } from '../../common'; +import { createCaseError, checkEnabledCaseConnectorOrThrow } from '../../common'; import { Operations } from '../../authorization'; /** diff --git a/x-pack/plugins/cases/server/client/attachments/get.ts b/x-pack/plugins/cases/server/client/attachments/get.ts index e15bdcc7c8c2..590038a200e4 100644 --- a/x-pack/plugins/cases/server/client/attachments/get.ts +++ b/x-pack/plugins/cases/server/client/attachments/get.ts @@ -6,7 +6,6 @@ */ import Boom from '@hapi/boom'; import { SavedObjectsFindResponse } from 'kibana/server'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; import { AllCommentsResponse, @@ -17,16 +16,17 @@ import { CommentResponseRt, CommentsResponse, CommentsResponseRt, + ENABLE_CASE_CONNECTOR, FindQueryParams, -} from '../../../common/api'; +} from '../../../common'; import { + createCaseError, checkEnabledCaseConnectorOrThrow, defaultSortField, transformComments, flattenCommentSavedObject, flattenCommentSavedObjects, } from '../../common'; -import { createCaseError } from '../../common/error'; import { defaultPage, defaultPerPage } from '../../routes/api'; import { CasesClientArgs } from '../types'; import { combineFilters, stringToKueryNode } from '../utils'; diff --git a/x-pack/plugins/cases/server/client/attachments/update.ts b/x-pack/plugins/cases/server/client/attachments/update.ts index c0566ff64681..157dd0b41089 100644 --- a/x-pack/plugins/cases/server/client/attachments/update.ts +++ b/x-pack/plugins/cases/server/client/attachments/update.ts @@ -9,14 +9,17 @@ import { pick } from 'lodash/fp'; import Boom from '@hapi/boom'; import { SavedObjectsClientContract, Logger } from 'kibana/server'; -import { checkEnabledCaseConnectorOrThrow, CommentableCase } from '../../common'; +import { checkEnabledCaseConnectorOrThrow, CommentableCase, createCaseError } from '../../common'; import { buildCommentUserActionItem } from '../../services/user_actions/helpers'; -import { CASE_SAVED_OBJECT, SUB_CASE_SAVED_OBJECT } from '../../../common/constants'; +import { + CASE_SAVED_OBJECT, + SUB_CASE_SAVED_OBJECT, + CaseResponse, + CommentPatchRequest, +} from '../../../common'; import { AttachmentService, CasesService } from '../../services'; -import { CaseResponse, CommentPatchRequest } from '../../../common/api'; import { CasesClientArgs } from '..'; import { decodeCommentRequest } from '../utils'; -import { createCaseError } from '../../common/error'; import { Operations } from '../../authorization'; /** diff --git a/x-pack/plugins/cases/server/client/cases/client.ts b/x-pack/plugins/cases/server/client/cases/client.ts index 20670f331443..8a17ff9bd0ec 100644 --- a/x-pack/plugins/cases/server/client/cases/client.ts +++ b/x-pack/plugins/cases/server/client/cases/client.ts @@ -12,7 +12,7 @@ import { User, AllTagsFindRequest, AllReportersFindRequest, -} from '../../../common/api'; +} from '../../../common'; import { CasesClient } from '../client'; import { CasesClientInternal } from '../client_internal'; import { diff --git a/x-pack/plugins/cases/server/client/cases/create.ts b/x-pack/plugins/cases/server/client/cases/create.ts index 879edd5eb1b5..0eebeb343e81 100644 --- a/x-pack/plugins/cases/server/client/cases/create.ts +++ b/x-pack/plugins/cases/server/client/cases/create.ts @@ -21,14 +21,14 @@ import { CasePostRequest, CaseType, OWNER_FIELD, + ENABLE_CASE_CONNECTOR, } from '../../../common'; import { buildCaseUserActionItem } from '../../services/user_actions/helpers'; import { getConnectorFromConfiguration } from '../utils'; -import { createCaseError } from '../../common/error'; import { Operations } from '../../authorization'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; import { + createCaseError, flattenCaseSavedObject, transformCaseConnectorToEsConnector, transformNewCase, diff --git a/x-pack/plugins/cases/server/client/cases/delete.ts b/x-pack/plugins/cases/server/client/cases/delete.ts index 8e99e39ec473..80a687a0e72f 100644 --- a/x-pack/plugins/cases/server/client/cases/delete.ts +++ b/x-pack/plugins/cases/server/client/cases/delete.ts @@ -8,13 +8,18 @@ import pMap from 'p-map'; import { Boom } from '@hapi/boom'; import { SavedObject, SavedObjectsClientContract, SavedObjectsFindResponse } from 'kibana/server'; -import { ENABLE_CASE_CONNECTOR, MAX_CONCURRENT_SEARCHES } from '../../../common/constants'; +import { + CommentAttributes, + ENABLE_CASE_CONNECTOR, + MAX_CONCURRENT_SEARCHES, + OWNER_FIELD, + SubCaseAttributes, +} from '../../../common'; import { CasesClientArgs } from '..'; -import { createCaseError } from '../../common/error'; +import { createCaseError } from '../../common'; import { AttachmentService, CasesService } from '../../services'; import { buildCaseUserActionItem } from '../../services/user_actions/helpers'; import { Operations, OwnerEntity } from '../../authorization'; -import { OWNER_FIELD, SubCaseAttributes, CommentAttributes } from '../../../common/api'; async function deleteSubCases({ attachmentService, diff --git a/x-pack/plugins/cases/server/client/cases/find.ts b/x-pack/plugins/cases/server/client/cases/find.ts index 73eca5e7abb9..4b8f82b939a4 100644 --- a/x-pack/plugins/cases/server/client/cases/find.ts +++ b/x-pack/plugins/cases/server/client/cases/find.ts @@ -18,13 +18,12 @@ import { caseStatuses, CasesFindResponseRt, excess, -} from '../../../common/api'; +} from '../../../common'; -import { createCaseError } from '../../common/error'; +import { createCaseError, transformCases } from '../../common'; import { constructQueryOptions } from '../utils'; import { includeFieldsRequiredForAuthentication } from '../../authorization/utils'; import { Operations } from '../../authorization'; -import { transformCases } from '../../common'; import { CasesClientArgs } from '..'; /** diff --git a/x-pack/plugins/cases/server/client/cases/get.ts b/x-pack/plugins/cases/server/client/cases/get.ts index 7a8100ad60ff..f908a8f091ef 100644 --- a/x-pack/plugins/cases/server/client/cases/get.ts +++ b/x-pack/plugins/cases/server/client/cases/get.ts @@ -24,10 +24,9 @@ import { AllReportersFindRequest, CasesByAlertIDRequest, CasesByAlertIDRequestRt, -} from '../../../common/api'; -import { countAlertsForID, flattenCaseSavedObject } from '../../common'; -import { createCaseError } from '../../common/error'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; + ENABLE_CASE_CONNECTOR, +} from '../../../common'; +import { countAlertsForID, createCaseError, flattenCaseSavedObject } from '../../common'; import { CasesClientArgs } from '..'; import { Operations } from '../../authorization'; import { combineAuthorizedAndOwnerFilter } from '../utils'; diff --git a/x-pack/plugins/cases/server/client/cases/push.ts b/x-pack/plugins/cases/server/client/cases/push.ts index c232f73c2a23..6b4f03887162 100644 --- a/x-pack/plugins/cases/server/client/cases/push.ts +++ b/x-pack/plugins/cases/server/client/cases/push.ts @@ -17,12 +17,12 @@ import { ESCaseAttributes, ESCasesConfigureAttributes, CaseType, + ENABLE_CASE_CONNECTOR, } from '../../../common'; import { buildCaseUserActionItem } from '../../services/user_actions/helpers'; import { createIncident, getCommentContextFromAttributes } from './utils'; import { createCaseError, flattenCaseSavedObject, getAlertInfoFromComments } from '../../common'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; import { CasesClient, CasesClientArgs, CasesClientInternal } from '..'; import { Operations } from '../../authorization'; import { casesConnectors } from '../../connectors'; diff --git a/x-pack/plugins/cases/server/client/cases/update.ts b/x-pack/plugins/cases/server/client/cases/update.ts index 608c726f1853..5726cfe44f69 100644 --- a/x-pack/plugins/cases/server/client/cases/update.ts +++ b/x-pack/plugins/cases/server/client/cases/update.ts @@ -21,39 +21,37 @@ import { import { nodeBuilder } from '../../../../../../src/plugins/data/common'; import { - throwErrors, - excess, - CasesResponseRt, - ESCasePatchRequest, - CasePatchRequest, - CasesResponse, - CaseStatuses, - CasesPatchRequestRt, - CommentType, - ESCaseAttributes, - CaseType, - CasesPatchRequest, AssociationType, + CASE_COMMENT_SAVED_OBJECT, + CASE_SAVED_OBJECT, + CasePatchRequest, + CasesPatchRequest, + CasesPatchRequestRt, + CasesResponse, + CasesResponseRt, + CaseStatuses, + CaseType, CommentAttributes, -} from '../../../common/api'; + CommentType, + ENABLE_CASE_CONNECTOR, + ESCaseAttributes, + ESCasePatchRequest, + excess, + MAX_CONCURRENT_SEARCHES, + SUB_CASE_SAVED_OBJECT, + throwErrors, +} from '../../../common'; import { buildCaseUserActions } from '../../services/user_actions/helpers'; import { getCaseToUpdate } from '../utils'; import { CasesService } from '../../services'; -import { - CASE_COMMENT_SAVED_OBJECT, - CASE_SAVED_OBJECT, - MAX_CONCURRENT_SEARCHES, - SUB_CASE_SAVED_OBJECT, -} from '../../../common/constants'; import { createAlertUpdateRequest, - transformCaseConnectorToEsConnector, + createCaseError, flattenCaseSavedObject, isCommentRequestTypeAlertOrGenAlert, + transformCaseConnectorToEsConnector, } from '../../common'; -import { createCaseError } from '../../common/error'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; import { UpdateAlertRequest } from '../alerts/client'; import { CasesClientInternal } from '../client_internal'; import { CasesClientArgs } from '..'; diff --git a/x-pack/plugins/cases/server/client/client.ts b/x-pack/plugins/cases/server/client/client.ts index 4b21b401f5b7..b7b1dd46d003 100644 --- a/x-pack/plugins/cases/server/client/client.ts +++ b/x-pack/plugins/cases/server/client/client.ts @@ -11,7 +11,7 @@ import { AttachmentsSubClient, createAttachmentsSubClient } from './attachments/ import { UserActionsSubClient, createUserActionsSubClient } from './user_actions/client'; import { CasesClientInternal, createCasesClientInternal } from './client_internal'; import { createSubCasesClient, SubCasesClient } from './sub_cases/client'; -import { ENABLE_CASE_CONNECTOR } from '../../common/constants'; +import { ENABLE_CASE_CONNECTOR } from '../../common'; import { ConfigureSubClient, createConfigurationSubClient } from './configure/client'; import { createStatsSubClient, StatsSubClient } from './stats/client'; diff --git a/x-pack/plugins/cases/server/client/configure/client.ts b/x-pack/plugins/cases/server/client/configure/client.ts index 2f486556e4ae..e8ff984fef99 100644 --- a/x-pack/plugins/cases/server/client/configure/client.ts +++ b/x-pack/plugins/cases/server/client/configure/client.ts @@ -16,25 +16,26 @@ import { SavedObjectsFindResponse, SavedObjectsUtils, } from '../../../../../../src/core/server'; -import { MAX_CONCURRENT_SEARCHES, SUPPORTED_CONNECTORS } from '../../../common/constants'; import { + CaseConfigurationsResponseRt, CaseConfigureResponseRt, + CasesConfigurationsResponse, CasesConfigurePatch, + CasesConfigurePatchRt, CasesConfigureRequest, CasesConfigureResponse, + ConnectorMappings, ConnectorMappingsAttributes, + ESCasesConfigureAttributes, excess, GetConfigureFindRequest, GetConfigureFindRequestRt, + MAX_CONCURRENT_SEARCHES, + SUPPORTED_CONNECTORS, throwErrors, - CasesConfigurationsResponse, - CaseConfigurationsResponseRt, - CasesConfigurePatchRt, - ConnectorMappings, - ESCasesConfigureAttributes, -} from '../../../common/api'; -import { createCaseError } from '../../common/error'; +} from '../../../common'; import { + createCaseError, transformCaseConnectorToEsConnector, transformESConnectorToCaseConnector, } from '../../common'; diff --git a/x-pack/plugins/cases/server/client/configure/create_mappings.ts b/x-pack/plugins/cases/server/client/configure/create_mappings.ts index bb4c32ae5707..2e9280b968d2 100644 --- a/x-pack/plugins/cases/server/client/configure/create_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/create_mappings.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { ConnectorMappingsAttributes } from '../../../common/api'; +import { ConnectorMappingsAttributes } from '../../../common'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; -import { createCaseError } from '../../common/error'; +import { createCaseError } from '../../common'; import { CasesClientArgs } from '..'; import { CreateMappingsArgs } from './types'; import { casesConnectors } from '../../connectors'; diff --git a/x-pack/plugins/cases/server/client/configure/get_mappings.ts b/x-pack/plugins/cases/server/client/configure/get_mappings.ts index 2fa0e8454bac..c080159488cf 100644 --- a/x-pack/plugins/cases/server/client/configure/get_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/get_mappings.ts @@ -6,9 +6,9 @@ */ import { SavedObjectsFindResponse } from 'kibana/server'; -import { ConnectorMappings } from '../../../common/api'; +import { ConnectorMappings } from '../../../common'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; -import { createCaseError } from '../../common/error'; +import { createCaseError } from '../../common'; import { CasesClientArgs } from '..'; import { MappingsArgs } from './types'; diff --git a/x-pack/plugins/cases/server/client/configure/update_mappings.ts b/x-pack/plugins/cases/server/client/configure/update_mappings.ts index 3d529e51e756..43fe527facd5 100644 --- a/x-pack/plugins/cases/server/client/configure/update_mappings.ts +++ b/x-pack/plugins/cases/server/client/configure/update_mappings.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { ConnectorMappingsAttributes } from '../../../common/api'; +import { ConnectorMappingsAttributes } from '../../../common'; import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server'; -import { createCaseError } from '../../common/error'; +import { createCaseError } from '../../common'; import { CasesClientArgs } from '..'; import { UpdateMappingsArgs } from './types'; import { casesConnectors } from '../../connectors'; diff --git a/x-pack/plugins/cases/server/client/factory.ts b/x-pack/plugins/cases/server/client/factory.ts index 4644efb61916..8fcfbe934c3a 100644 --- a/x-pack/plugins/cases/server/client/factory.ts +++ b/x-pack/plugins/cases/server/client/factory.ts @@ -12,7 +12,7 @@ import { ElasticsearchClient, } from 'kibana/server'; import { SecurityPluginSetup, SecurityPluginStart } from '../../../security/server'; -import { SAVED_OBJECT_TYPES } from '../../common/constants'; +import { SAVED_OBJECT_TYPES } from '../../common'; import { Authorization } from '../authorization/authorization'; import { GetSpaceFn } from '../authorization/types'; import { diff --git a/x-pack/plugins/cases/server/client/stats/client.ts b/x-pack/plugins/cases/server/client/stats/client.ts index 4fc8be4ccbfb..4cdb11ad15e5 100644 --- a/x-pack/plugins/cases/server/client/stats/client.ts +++ b/x-pack/plugins/cases/server/client/stats/client.ts @@ -19,9 +19,9 @@ import { throwErrors, excess, CasesStatusRequestRt, -} from '../../../common/api'; +} from '../../../common'; import { Operations } from '../../authorization'; -import { createCaseError } from '../../common/error'; +import { createCaseError } from '../../common'; import { constructQueryOptions } from '../utils'; /** diff --git a/x-pack/plugins/cases/server/client/sub_cases/client.ts b/x-pack/plugins/cases/server/client/sub_cases/client.ts index 9a7dad77909e..6ca5a80565a7 100644 --- a/x-pack/plugins/cases/server/client/sub_cases/client.ts +++ b/x-pack/plugins/cases/server/client/sub_cases/client.ts @@ -10,19 +10,24 @@ import Boom from '@hapi/boom'; import { SavedObject } from 'kibana/server'; import { + CASE_SAVED_OBJECT, caseStatuses, CommentAttributes, + MAX_CONCURRENT_SEARCHES, SubCaseResponse, SubCaseResponseRt, SubCasesFindRequest, SubCasesFindResponse, SubCasesFindResponseRt, SubCasesPatchRequest, -} from '../../../common/api'; +} from '../../../common'; import { CasesClientArgs, CasesClientInternal } from '..'; -import { countAlertsForID, flattenSubCaseSavedObject, transformSubCases } from '../../common'; -import { createCaseError } from '../../common/error'; -import { CASE_SAVED_OBJECT, MAX_CONCURRENT_SEARCHES } from '../../../common/constants'; +import { + countAlertsForID, + createCaseError, + flattenSubCaseSavedObject, + transformSubCases, +} from '../../common'; import { buildCaseUserActionItem } from '../../services/user_actions/helpers'; import { constructQueryOptions } from '../utils'; import { defaultPage, defaultPerPage } from '../../routes/api'; diff --git a/x-pack/plugins/cases/server/client/sub_cases/update.ts b/x-pack/plugins/cases/server/client/sub_cases/update.ts index b49d36d7a27d..c2c5f8719e64 100644 --- a/x-pack/plugins/cases/server/client/sub_cases/update.ts +++ b/x-pack/plugins/cases/server/client/sub_cases/update.ts @@ -19,30 +19,31 @@ import { import { nodeBuilder } from '../../../../../../src/plugins/data/common'; import { CasesService } from '../../services'; import { + CASE_COMMENT_SAVED_OBJECT, CaseStatuses, + CommentAttributes, + CommentType, + ESCaseAttributes, + excess, + SUB_CASE_SAVED_OBJECT, + SubCaseAttributes, + SubCasePatchRequest, + SubCaseResponse, SubCasesPatchRequest, SubCasesPatchRequestRt, - CommentType, - excess, - throwErrors, SubCasesResponse, - SubCasePatchRequest, - SubCaseAttributes, - ESCaseAttributes, - SubCaseResponse, SubCasesResponseRt, + throwErrors, User, - CommentAttributes, -} from '../../../common/api'; -import { CASE_COMMENT_SAVED_OBJECT, SUB_CASE_SAVED_OBJECT } from '../../../common/constants'; +} from '../../../common'; import { getCaseToUpdate } from '../utils'; import { buildSubCaseUserActions } from '../../services/user_actions/helpers'; import { createAlertUpdateRequest, + createCaseError, isCommentRequestTypeAlertOrGenAlert, flattenSubCaseSavedObject, } from '../../common'; -import { createCaseError } from '../../common/error'; import { UpdateAlertRequest } from '../../client/alerts/client'; import { CasesClientArgs } from '../types'; import { CasesClientInternal } from '../client_internal'; diff --git a/x-pack/plugins/cases/server/client/types.ts b/x-pack/plugins/cases/server/client/types.ts index f6b229b94800..ebf79519da59 100644 --- a/x-pack/plugins/cases/server/client/types.ts +++ b/x-pack/plugins/cases/server/client/types.ts @@ -7,7 +7,7 @@ import type { PublicMethodsOf } from '@kbn/utility-types'; import { ElasticsearchClient, SavedObjectsClientContract, Logger } from 'kibana/server'; -import { User } from '../../common/api'; +import { User } from '../../common'; import { Authorization } from '../authorization/authorization'; import { AlertServiceContract, diff --git a/x-pack/plugins/cases/server/client/user_actions/get.ts b/x-pack/plugins/cases/server/client/user_actions/get.ts index a0dddc79ef4b..2a6608014c80 100644 --- a/x-pack/plugins/cases/server/client/user_actions/get.ts +++ b/x-pack/plugins/cases/server/client/user_actions/get.ts @@ -6,13 +6,13 @@ */ import { - SUB_CASE_SAVED_OBJECT, - CASE_SAVED_OBJECT, CASE_COMMENT_SAVED_OBJECT, -} from '../../../common/constants'; -import { CaseUserActionsResponseRt, CaseUserActionsResponse } from '../../../common/api'; -import { createCaseError } from '../../common/error'; -import { checkEnabledCaseConnectorOrThrow } from '../../common'; + CASE_SAVED_OBJECT, + CaseUserActionsResponse, + CaseUserActionsResponseRt, + SUB_CASE_SAVED_OBJECT, +} from '../../../common'; +import { createCaseError, checkEnabledCaseConnectorOrThrow } from '../../common'; import { CasesClientArgs } from '..'; import { Operations } from '../../authorization'; import { UserActionGet } from './client'; diff --git a/x-pack/plugins/cases/server/client/utils.ts b/x-pack/plugins/cases/server/client/utils.ts index 7ceb9cec60c3..3240ec06803c 100644 --- a/x-pack/plugins/cases/server/client/utils.ts +++ b/x-pack/plugins/cases/server/client/utils.ts @@ -16,19 +16,20 @@ import { SavedObjectsFindResponse } from 'kibana/server'; import { nodeBuilder, KueryNode } from '../../../../../src/plugins/data/common'; import { esKuery } from '../../../../../src/plugins/data/server'; import { + AlertCommentRequestRt, + CASE_SAVED_OBJECT, CaseConnector, - ESCasesConfigureAttributes, - ConnectorTypes, CaseStatuses, CaseType, CommentRequest, - throwErrors, - excess, + ConnectorTypes, ContextTypeUserRt, - AlertCommentRequestRt, + ESCasesConfigureAttributes, + excess, OWNER_FIELD, -} from '../../common/api'; -import { CASE_SAVED_OBJECT, SUB_CASE_SAVED_OBJECT } from '../../common/constants'; + SUB_CASE_SAVED_OBJECT, + throwErrors, +} from '../../common'; import { combineFilterWithAuthorizationFilter } from '../authorization/utils'; import { getIDsAndIndicesAsArrays, diff --git a/x-pack/plugins/cases/server/common/models/commentable_case.ts b/x-pack/plugins/cases/server/common/models/commentable_case.ts index 241278c77ab4..e082a0b290f1 100644 --- a/x-pack/plugins/cases/server/common/models/commentable_case.ts +++ b/x-pack/plugins/cases/server/common/models/commentable_case.ts @@ -15,30 +15,28 @@ import { } from 'src/core/server'; import { AssociationType, + CASE_SAVED_OBJECT, + CaseResponse, + CaseResponseRt, CaseSettings, CaseStatuses, CaseType, - CaseResponse, - CaseResponseRt, CommentAttributes, CommentPatchRequest, CommentRequest, CommentType, ESCaseAttributes, + MAX_DOCS_PER_PAGE, + SUB_CASE_SAVED_OBJECT, SubCaseAttributes, User, -} from '../../../common/api'; +} from '../../../common'; import { transformESConnectorToCaseConnector, flattenCommentSavedObjects, flattenSubCaseSavedObject, transformNewComment, } from '..'; -import { - CASE_SAVED_OBJECT, - MAX_DOCS_PER_PAGE, - SUB_CASE_SAVED_OBJECT, -} from '../../../common/constants'; import { AttachmentService, CasesService } from '../../services'; import { createCaseError } from '../error'; import { countAlertsForID } from '../index'; diff --git a/x-pack/plugins/cases/server/common/types.ts b/x-pack/plugins/cases/server/common/types.ts index b99612f1b1cf..067f2fc7c311 100644 --- a/x-pack/plugins/cases/server/common/types.ts +++ b/x-pack/plugins/cases/server/common/types.ts @@ -6,7 +6,7 @@ */ import { KueryNode } from '../../../../../src/plugins/data/server'; -import { SavedObjectFindOptions } from '../../common/api'; +import { SavedObjectFindOptions } from '../../common'; /** * This structure holds the alert ID and index from an alert comment diff --git a/x-pack/plugins/cases/server/common/utils.ts b/x-pack/plugins/cases/server/common/utils.ts index 7f38be2ba806..54124260ae5d 100644 --- a/x-pack/plugins/cases/server/common/utils.ts +++ b/x-pack/plugins/cases/server/common/utils.ts @@ -25,6 +25,7 @@ import { CommentsResponse, CommentType, ConnectorTypeFields, + ENABLE_CASE_CONNECTOR, ESCaseAttributes, ESCaseConnector, ESConnectorFields, @@ -32,8 +33,7 @@ import { SubCaseResponse, SubCasesFindResponse, User, -} from '../../common/api'; -import { ENABLE_CASE_CONNECTOR } from '../../common/constants'; +} from '../../common'; import { UpdateAlertRequest } from '../client/alerts/client'; /** diff --git a/x-pack/plugins/cases/server/connectors/case/index.ts b/x-pack/plugins/cases/server/connectors/case/index.ts index 4a706d8fcb52..e566ab7cacc3 100644 --- a/x-pack/plugins/cases/server/connectors/case/index.ts +++ b/x-pack/plugins/cases/server/connectors/case/index.ts @@ -13,7 +13,8 @@ import { CasePostRequest, CommentRequest, CommentType, -} from '../../../common/api'; + ENABLE_CASE_CONNECTOR, +} from '../../../common'; import { CaseExecutorParamsSchema, CaseConfigurationSchema, CommentSchemaType } from './schema'; import { CaseExecutorResponse, @@ -24,8 +25,7 @@ import { import * as i18n from './translations'; import { GetActionTypeParams, isCommentGeneratedAlert, separator } from '..'; -import { createCaseError } from '../../common/error'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; +import { createCaseError } from '../../common'; import { CasesClient } from '../../client'; const supportedSubActions: string[] = ['create', 'update', 'addComment']; diff --git a/x-pack/plugins/cases/server/connectors/factory.ts b/x-pack/plugins/cases/server/connectors/factory.ts index 64e3e6f3eb22..5ed7eb4ade4c 100644 --- a/x-pack/plugins/cases/server/connectors/factory.ts +++ b/x-pack/plugins/cases/server/connectors/factory.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ConnectorTypes } from '../../common/api'; +import { ConnectorTypes } from '../../common'; import { getCaseConnector as getJiraCaseConnector } from './jira'; import { getCaseConnector as getResilientCaseConnector } from './resilient'; import { getServiceNowITSMCaseConnector, getServiceNowSIRCaseConnector } from './servicenow'; diff --git a/x-pack/plugins/cases/server/connectors/index.ts b/x-pack/plugins/cases/server/connectors/index.ts index b5dc1cc4a8ff..ee7c692c1525 100644 --- a/x-pack/plugins/cases/server/connectors/index.ts +++ b/x-pack/plugins/cases/server/connectors/index.ts @@ -12,7 +12,7 @@ import { ContextTypeAlertSchemaType, } from './types'; import { getActionType as getCaseConnector } from './case'; -import { CommentRequest, CommentType } from '../../common/api'; +import { CommentRequest, CommentType } from '../../common'; export * from './types'; export { transformConnectorComment } from './case'; diff --git a/x-pack/plugins/cases/server/connectors/jira/format.ts b/x-pack/plugins/cases/server/connectors/jira/format.ts index 4caa23634d88..3dadd9a107d5 100644 --- a/x-pack/plugins/cases/server/connectors/jira/format.ts +++ b/x-pack/plugins/cases/server/connectors/jira/format.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ConnectorJiraTypeFields } from '../../../common/api'; +import { ConnectorJiraTypeFields } from '../../../common'; import { Format } from './types'; export const format: Format = (theCase, alerts) => { diff --git a/x-pack/plugins/cases/server/connectors/jira/types.ts b/x-pack/plugins/cases/server/connectors/jira/types.ts index 59d5741d381b..1941485ccece 100644 --- a/x-pack/plugins/cases/server/connectors/jira/types.ts +++ b/x-pack/plugins/cases/server/connectors/jira/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { JiraFieldsType } from '../../../common/api'; +import { JiraFieldsType } from '../../../common'; import { ICasesConnector } from '../types'; interface ExternalServiceFormatterParams extends JiraFieldsType { diff --git a/x-pack/plugins/cases/server/connectors/resilient/format.ts b/x-pack/plugins/cases/server/connectors/resilient/format.ts index 3e966d87686d..821c9b214a26 100644 --- a/x-pack/plugins/cases/server/connectors/resilient/format.ts +++ b/x-pack/plugins/cases/server/connectors/resilient/format.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ConnectorResillientTypeFields } from '../../../common/api'; +import { ConnectorResillientTypeFields } from '../../../common'; import { Format } from './types'; export const format: Format = (theCase, alerts) => { diff --git a/x-pack/plugins/cases/server/connectors/resilient/types.ts b/x-pack/plugins/cases/server/connectors/resilient/types.ts index f895dccf6521..40cde0500280 100644 --- a/x-pack/plugins/cases/server/connectors/resilient/types.ts +++ b/x-pack/plugins/cases/server/connectors/resilient/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ResilientFieldsType } from '../../../common/api'; +import { ResilientFieldsType } from '../../../common'; import { ICasesConnector } from '../types'; export type ResilientCaseConnector = ICasesConnector<ResilientFieldsType>; diff --git a/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts index 9bf8c3e7e8b2..22bd84df6630 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/itsm_format.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ConnectorServiceNowITSMTypeFields } from '../../../common/api'; +import { ConnectorServiceNowITSMTypeFields } from '../../../common'; import { ServiceNowITSMFormat } from './types'; export const format: ServiceNowITSMFormat = (theCase, alerts) => { diff --git a/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts index 1c6e993d3956..b48a1b7f734c 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/sir_format.ts @@ -5,7 +5,7 @@ * 2.0. */ import { get } from 'lodash/fp'; -import { ConnectorServiceNowSIRTypeFields } from '../../../common/api'; +import { ConnectorServiceNowSIRTypeFields } from '../../../common'; import { ServiceNowSIRFormat, SirFieldKey, AlertFieldMappingAndValues } from './types'; export const format: ServiceNowSIRFormat = (theCase, alerts) => { diff --git a/x-pack/plugins/cases/server/connectors/servicenow/types.ts b/x-pack/plugins/cases/server/connectors/servicenow/types.ts index 500d1d22e3dc..2caebc3dab31 100644 --- a/x-pack/plugins/cases/server/connectors/servicenow/types.ts +++ b/x-pack/plugins/cases/server/connectors/servicenow/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ServiceNowITSMFieldsType } from '../../../common/api'; +import { ServiceNowITSMFieldsType } from '../../../common'; import { ICasesConnector } from '../types'; export interface ServiceNowSIRFieldsType { diff --git a/x-pack/plugins/cases/server/connectors/types.ts b/x-pack/plugins/cases/server/connectors/types.ts index 2fab59037b1b..a8673c126258 100644 --- a/x-pack/plugins/cases/server/connectors/types.ts +++ b/x-pack/plugins/cases/server/connectors/types.ts @@ -6,7 +6,7 @@ */ import { Logger } from 'kibana/server'; -import { CaseResponse, ConnectorMappingsAttributes } from '../../common/api'; +import { CaseResponse, ConnectorMappingsAttributes } from '../../common'; import { CasesClientGetAlertsResponse } from '../client/alerts/types'; import { CasesClientFactory } from '../client/factory'; import { RegisterActionType } from '../types'; diff --git a/x-pack/plugins/cases/server/plugin.ts b/x-pack/plugins/cases/server/plugin.ts index 34cf71aff58b..28b9cf9e4e03 100644 --- a/x-pack/plugins/cases/server/plugin.ts +++ b/x-pack/plugins/cases/server/plugin.ts @@ -13,7 +13,7 @@ import { PluginSetupContract as ActionsPluginSetup, PluginStartContract as ActionsPluginStart, } from '../../actions/server'; -import { APP_ID, ENABLE_CASE_CONNECTOR } from '../common/constants'; +import { APP_ID, ENABLE_CASE_CONNECTOR } from '../common'; import { ConfigType } from './config'; import { initCaseApi } from './routes/api'; diff --git a/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts b/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts index ef5e0ebb5bbc..625324312e6b 100644 --- a/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts +++ b/x-pack/plugins/cases/server/routes/api/__fixtures__/mock_saved_objects.ts @@ -15,8 +15,8 @@ import { ConnectorTypes, ESCaseAttributes, ESCasesConfigureAttributes, + SECURITY_SOLUTION_OWNER, } from '../../../../common'; -import { SECURITY_SOLUTION_OWNER } from '../../../../common/constants'; export const mockCases: Array<SavedObject<ESCaseAttributes>> = [ { diff --git a/x-pack/plugins/cases/server/routes/api/cases/alerts/get_cases.ts b/x-pack/plugins/cases/server/routes/api/cases/alerts/get_cases.ts index 7a65229a2a07..f4b53a921ef8 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/alerts/get_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/alerts/get_cases.ts @@ -10,8 +10,7 @@ import Boom from '@hapi/boom'; import { RouteDeps } from '../../types'; import { escapeHatch, wrapError } from '../../utils'; -import { CASE_ALERTS_URL } from '../../../../../common/constants'; -import { CasesByAlertIDRequest } from '../../../../../common'; +import { CASE_ALERTS_URL, CasesByAlertIDRequest } from '../../../../../common'; export function initGetCaseIdsByAlertIdApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/cases/delete_cases.ts b/x-pack/plugins/cases/server/routes/api/cases/delete_cases.ts index 1784a434292c..383f9b82706a 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/delete_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/delete_cases.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASES_URL } from '../../../../common/constants'; +import { CASES_URL } from '../../../../common'; export function initDeleteCasesApi({ router, logger }: RouteDeps) { router.delete( diff --git a/x-pack/plugins/cases/server/routes/api/cases/find_cases.ts b/x-pack/plugins/cases/server/routes/api/cases/find_cases.ts index 1ded265a8b17..9b3d186ca0ad 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/find_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/find_cases.ts @@ -5,10 +5,9 @@ * 2.0. */ -import { CasesFindRequest } from '../../../../common/api'; +import { CASES_URL, CasesFindRequest } from '../../../../common'; import { wrapError, escapeHatch } from '../utils'; import { RouteDeps } from '../types'; -import { CASES_URL } from '../../../../common/constants'; export function initFindCasesApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/cases/get_case.ts b/x-pack/plugins/cases/server/routes/api/cases/get_case.ts index 9d26fbb90328..2313c3cad900 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/get_case.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/get_case.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_DETAILS_URL } from '../../../../common/constants'; +import { CASE_DETAILS_URL } from '../../../../common'; export function initGetCaseApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/cases/patch_cases.ts b/x-pack/plugins/cases/server/routes/api/cases/patch_cases.ts index 8c72dee719d0..e518d3717fcd 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/patch_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/patch_cases.ts @@ -7,8 +7,7 @@ import { escapeHatch, wrapError } from '../utils'; import { RouteDeps } from '../types'; -import { CASES_URL } from '../../../../common'; -import { CasesPatchRequest } from '../../../../common'; +import { CASES_URL, CasesPatchRequest } from '../../../../common'; export function initPatchCasesApi({ router, logger }: RouteDeps) { router.patch( diff --git a/x-pack/plugins/cases/server/routes/api/cases/post_case.ts b/x-pack/plugins/cases/server/routes/api/cases/post_case.ts index cc5d2c98333c..6ee94df007d6 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/post_case.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/post_case.ts @@ -8,8 +8,7 @@ import { wrapError, escapeHatch } from '../utils'; import { RouteDeps } from '../types'; -import { CASES_URL } from '../../../../common'; -import { CasePostRequest } from '../../../../common'; +import { CASES_URL, CasePostRequest } from '../../../../common'; export function initPostCaseApi({ router, logger }: RouteDeps) { router.post( diff --git a/x-pack/plugins/cases/server/routes/api/cases/push_case.ts b/x-pack/plugins/cases/server/routes/api/cases/push_case.ts index a49e1a99c418..4c467c3840c2 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/push_case.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/push_case.ts @@ -12,9 +12,8 @@ import { identity } from 'fp-ts/lib/function'; import { wrapError, escapeHatch } from '../utils'; -import { throwErrors, CasePushRequestParamsRt } from '../../../../common'; +import { throwErrors, CasePushRequestParamsRt, CASE_PUSH_URL } from '../../../../common'; import { RouteDeps } from '../types'; -import { CASE_PUSH_URL } from '../../../../common'; export function initPushCaseApi({ router, logger }: RouteDeps) { router.post( diff --git a/x-pack/plugins/cases/server/routes/api/cases/reporters/get_reporters.ts b/x-pack/plugins/cases/server/routes/api/cases/reporters/get_reporters.ts index a7a0e4f8bb14..109cac0d977c 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/reporters/get_reporters.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/reporters/get_reporters.ts @@ -7,8 +7,7 @@ import { RouteDeps } from '../../types'; import { wrapError, escapeHatch } from '../../utils'; -import { CASE_REPORTERS_URL } from '../../../../../common/constants'; -import { AllReportersFindRequest } from '../../../../../common/api'; +import { CASE_REPORTERS_URL, AllReportersFindRequest } from '../../../../../common'; export function initGetReportersApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/cases/tags/get_tags.ts b/x-pack/plugins/cases/server/routes/api/cases/tags/get_tags.ts index a62c3247b01d..778261c048bf 100644 --- a/x-pack/plugins/cases/server/routes/api/cases/tags/get_tags.ts +++ b/x-pack/plugins/cases/server/routes/api/cases/tags/get_tags.ts @@ -7,8 +7,7 @@ import { RouteDeps } from '../../types'; import { wrapError, escapeHatch } from '../../utils'; -import { CASE_TAGS_URL } from '../../../../../common/constants'; -import { AllTagsFindRequest } from '../../../../../common/api'; +import { CASE_TAGS_URL, AllTagsFindRequest } from '../../../../../common'; export function initGetTagsApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/comments/delete_all_comments.ts b/x-pack/plugins/cases/server/routes/api/comments/delete_all_comments.ts index a41d4683af2d..9c77b1814376 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/delete_all_comments.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/delete_all_comments.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_COMMENTS_URL } from '../../../../common/constants'; +import { CASE_COMMENTS_URL } from '../../../../common'; export function initDeleteAllCommentsApi({ router, logger }: RouteDeps) { router.delete( diff --git a/x-pack/plugins/cases/server/routes/api/comments/delete_comment.ts b/x-pack/plugins/cases/server/routes/api/comments/delete_comment.ts index f145fc62efc8..6dfb188763aa 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/delete_comment.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/delete_comment.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_COMMENT_DETAILS_URL } from '../../../../common/constants'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../common'; export function initDeleteCommentApi({ router, logger }: RouteDeps) { router.delete( diff --git a/x-pack/plugins/cases/server/routes/api/comments/find_comments.ts b/x-pack/plugins/cases/server/routes/api/comments/find_comments.ts index a758805deb6e..c0e4d8901eec 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/find_comments.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/find_comments.ts @@ -12,10 +12,9 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { FindQueryParamsRt, throwErrors, excess } from '../../../../common/api'; +import { CASE_COMMENTS_URL, FindQueryParamsRt, throwErrors, excess } from '../../../../common'; import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; -import { CASE_COMMENTS_URL } from '../../../../common/constants'; export function initFindCaseCommentsApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/comments/get_all_comment.ts b/x-pack/plugins/cases/server/routes/api/comments/get_all_comment.ts index b916e22c6b0e..41a4b6f79665 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/get_all_comment.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/get_all_comment.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_COMMENTS_URL } from '../../../../common/constants'; +import { CASE_COMMENTS_URL } from '../../../../common'; export function initGetAllCommentsApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/comments/get_comment.ts b/x-pack/plugins/cases/server/routes/api/comments/get_comment.ts index 09805c00cb10..a3ba0d3f23c3 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/get_comment.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/get_comment.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_COMMENT_DETAILS_URL } from '../../../../common/constants'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../common'; export function initGetCommentApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/comments/patch_comment.ts b/x-pack/plugins/cases/server/routes/api/comments/patch_comment.ts index aecdeb46756c..687b568e67d7 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/patch_comment.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/patch_comment.ts @@ -13,8 +13,7 @@ import Boom from '@hapi/boom'; import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; -import { CASE_COMMENTS_URL } from '../../../../common/constants'; -import { CommentPatchRequestRt, throwErrors } from '../../../../common/api'; +import { CASE_COMMENTS_URL, CommentPatchRequestRt, throwErrors } from '../../../../common'; export function initPatchCommentApi({ router, logger }: RouteDeps) { router.patch( diff --git a/x-pack/plugins/cases/server/routes/api/comments/post_comment.ts b/x-pack/plugins/cases/server/routes/api/comments/post_comment.ts index 1919aef7b72b..44871f7f0c81 100644 --- a/x-pack/plugins/cases/server/routes/api/comments/post_comment.ts +++ b/x-pack/plugins/cases/server/routes/api/comments/post_comment.ts @@ -9,8 +9,7 @@ import Boom from '@hapi/boom'; import { schema } from '@kbn/config-schema'; import { escapeHatch, wrapError } from '../utils'; import { RouteDeps } from '../types'; -import { CASE_COMMENTS_URL, ENABLE_CASE_CONNECTOR } from '../../../../common/constants'; -import { CommentRequest } from '../../../../common/api'; +import { CASE_COMMENTS_URL, ENABLE_CASE_CONNECTOR, CommentRequest } from '../../../../common'; export function initPostCommentApi({ router, logger }: RouteDeps) { router.post( diff --git a/x-pack/plugins/cases/server/routes/api/configure/get_configure.ts b/x-pack/plugins/cases/server/routes/api/configure/get_configure.ts index 8222ac8fe569..59f136b971da 100644 --- a/x-pack/plugins/cases/server/routes/api/configure/get_configure.ts +++ b/x-pack/plugins/cases/server/routes/api/configure/get_configure.ts @@ -7,8 +7,7 @@ import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; -import { CASE_CONFIGURE_URL } from '../../../../common/constants'; -import { GetConfigureFindRequest } from '../../../../common/api'; +import { CASE_CONFIGURE_URL, GetConfigureFindRequest } from '../../../../common'; export function initGetCaseConfigure({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/configure/get_connectors.ts b/x-pack/plugins/cases/server/routes/api/configure/get_connectors.ts index 46c110bbb8ba..220481e8ff07 100644 --- a/x-pack/plugins/cases/server/routes/api/configure/get_connectors.ts +++ b/x-pack/plugins/cases/server/routes/api/configure/get_connectors.ts @@ -8,7 +8,7 @@ import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../common/constants'; +import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../common'; /* * Be aware that this api will only return 20 connectors diff --git a/x-pack/plugins/cases/server/routes/api/configure/patch_configure.ts b/x-pack/plugins/cases/server/routes/api/configure/patch_configure.ts index 49288c72eade..a50753413585 100644 --- a/x-pack/plugins/cases/server/routes/api/configure/patch_configure.ts +++ b/x-pack/plugins/cases/server/routes/api/configure/patch_configure.ts @@ -11,14 +11,14 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { + CASE_CONFIGURE_DETAILS_URL, CaseConfigureRequestParamsRt, throwErrors, CasesConfigurePatch, excess, -} from '../../../../common/api'; +} from '../../../../common'; import { RouteDeps } from '../types'; import { wrapError, escapeHatch } from '../utils'; -import { CASE_CONFIGURE_DETAILS_URL } from '../../../../common/constants'; export function initPatchCaseConfigure({ router, logger }: RouteDeps) { router.patch( diff --git a/x-pack/plugins/cases/server/routes/api/configure/post_configure.ts b/x-pack/plugins/cases/server/routes/api/configure/post_configure.ts index fe8ffedbc85f..b444ed119318 100644 --- a/x-pack/plugins/cases/server/routes/api/configure/post_configure.ts +++ b/x-pack/plugins/cases/server/routes/api/configure/post_configure.ts @@ -10,10 +10,9 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { CasesConfigureRequestRt, throwErrors } from '../../../../common/api'; +import { CASE_CONFIGURE_URL, CasesConfigureRequestRt, throwErrors } from '../../../../common'; import { RouteDeps } from '../types'; import { wrapError, escapeHatch } from '../utils'; -import { CASE_CONFIGURE_URL } from '../../../../common/constants'; export function initPostCaseConfigure({ router, logger }: RouteDeps) { router.post( diff --git a/x-pack/plugins/cases/server/routes/api/index.ts b/x-pack/plugins/cases/server/routes/api/index.ts index 51652408d583..4f6db0c1081b 100644 --- a/x-pack/plugins/cases/server/routes/api/index.ts +++ b/x-pack/plugins/cases/server/routes/api/index.ts @@ -37,7 +37,7 @@ import { initGetSubCaseApi } from './sub_case/get_sub_case'; import { initPatchSubCasesApi } from './sub_case/patch_sub_cases'; import { initFindSubCasesApi } from './sub_case/find_sub_cases'; import { initDeleteSubCasesApi } from './sub_case/delete_sub_cases'; -import { ENABLE_CASE_CONNECTOR } from '../../../common/constants'; +import { ENABLE_CASE_CONNECTOR } from '../../../common'; import { initGetCaseIdsByAlertIdApi } from './cases/alerts/get_cases'; /** diff --git a/x-pack/plugins/cases/server/routes/api/stats/get_status.ts b/x-pack/plugins/cases/server/routes/api/stats/get_status.ts index 7fef5f59e245..469e32b46622 100644 --- a/x-pack/plugins/cases/server/routes/api/stats/get_status.ts +++ b/x-pack/plugins/cases/server/routes/api/stats/get_status.ts @@ -8,8 +8,7 @@ import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; -import { CASE_STATUS_URL } from '../../../../common/constants'; -import { CasesStatusRequest } from '../../../../common'; +import { CASE_STATUS_URL, CasesStatusRequest } from '../../../../common'; export function initGetCasesStatusApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/sub_case/delete_sub_cases.ts b/x-pack/plugins/cases/server/routes/api/sub_case/delete_sub_cases.ts index 11b68b70390f..0fe436f2269b 100644 --- a/x-pack/plugins/cases/server/routes/api/sub_case/delete_sub_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/sub_case/delete_sub_cases.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { SUB_CASES_PATCH_DEL_URL } from '../../../../common/constants'; +import { SUB_CASES_PATCH_DEL_URL } from '../../../../common'; export function initDeleteSubCasesApi({ router, logger }: RouteDeps) { router.delete( diff --git a/x-pack/plugins/cases/server/routes/api/sub_case/find_sub_cases.ts b/x-pack/plugins/cases/server/routes/api/sub_case/find_sub_cases.ts index e062f2238439..3049f05337b4 100644 --- a/x-pack/plugins/cases/server/routes/api/sub_case/find_sub_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/sub_case/find_sub_cases.ts @@ -12,10 +12,9 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { SubCasesFindRequestRt, throwErrors } from '../../../../common/api'; +import { SubCasesFindRequestRt, SUB_CASES_URL, throwErrors } from '../../../../common'; import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; -import { SUB_CASES_URL } from '../../../../common/constants'; export function initFindSubCasesApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/sub_case/get_sub_case.ts b/x-pack/plugins/cases/server/routes/api/sub_case/get_sub_case.ts index db3e29f5ed96..fea81524b526 100644 --- a/x-pack/plugins/cases/server/routes/api/sub_case/get_sub_case.ts +++ b/x-pack/plugins/cases/server/routes/api/sub_case/get_sub_case.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { SUB_CASE_DETAILS_URL } from '../../../../common/constants'; +import { SUB_CASE_DETAILS_URL } from '../../../../common'; export function initGetSubCaseApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/sub_case/patch_sub_cases.ts b/x-pack/plugins/cases/server/routes/api/sub_case/patch_sub_cases.ts index 1fb260453d18..d3b24a1e3c06 100644 --- a/x-pack/plugins/cases/server/routes/api/sub_case/patch_sub_cases.ts +++ b/x-pack/plugins/cases/server/routes/api/sub_case/patch_sub_cases.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { SubCasesPatchRequest } from '../../../../common/api'; -import { SUB_CASES_PATCH_DEL_URL } from '../../../../common/constants'; +import { SubCasesPatchRequest, SUB_CASES_PATCH_DEL_URL } from '../../../../common'; import { RouteDeps } from '../types'; import { escapeHatch, wrapError } from '../utils'; diff --git a/x-pack/plugins/cases/server/routes/api/user_actions/get_all_user_actions.ts b/x-pack/plugins/cases/server/routes/api/user_actions/get_all_user_actions.ts index 5944ff6176d7..39b277e2239a 100644 --- a/x-pack/plugins/cases/server/routes/api/user_actions/get_all_user_actions.ts +++ b/x-pack/plugins/cases/server/routes/api/user_actions/get_all_user_actions.ts @@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; -import { CASE_USER_ACTIONS_URL, SUB_CASE_USER_ACTIONS_URL } from '../../../../common/constants'; +import { CASE_USER_ACTIONS_URL, SUB_CASE_USER_ACTIONS_URL } from '../../../../common'; export function initGetAllCaseUserActionsApi({ router, logger }: RouteDeps) { router.get( diff --git a/x-pack/plugins/cases/server/routes/api/utils.ts b/x-pack/plugins/cases/server/routes/api/utils.ts index f7a77a5dbf39..b2b5417ecae0 100644 --- a/x-pack/plugins/cases/server/routes/api/utils.ts +++ b/x-pack/plugins/cases/server/routes/api/utils.ts @@ -9,7 +9,7 @@ import { Boom, boomify, isBoom } from '@hapi/boom'; import { schema } from '@kbn/config-schema'; import { CustomHttpResponseOptions, ResponseError } from 'kibana/server'; -import { isCaseError } from '../../common/error'; +import { isCaseError } from '../../common'; /** * Transforms an error into the correct format for a kibana response. diff --git a/x-pack/plugins/cases/server/saved_object_types/cases.ts b/x-pack/plugins/cases/server/saved_object_types/cases.ts index 2a260a9bcf2a..869437f125ca 100644 --- a/x-pack/plugins/cases/server/saved_object_types/cases.ts +++ b/x-pack/plugins/cases/server/saved_object_types/cases.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { CASE_SAVED_OBJECT } from '../../common/constants'; +import { CASE_SAVED_OBJECT } from '../../common'; import { caseMigrations } from './migrations'; export const caseSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/saved_object_types/comments.ts b/x-pack/plugins/cases/server/saved_object_types/comments.ts index 2ba6e2562a54..cd2dec7260fa 100644 --- a/x-pack/plugins/cases/server/saved_object_types/comments.ts +++ b/x-pack/plugins/cases/server/saved_object_types/comments.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { CASE_COMMENT_SAVED_OBJECT } from '../../common/constants'; +import { CASE_COMMENT_SAVED_OBJECT } from '../../common'; import { commentsMigrations } from './migrations'; export const caseCommentSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/saved_object_types/configure.ts b/x-pack/plugins/cases/server/saved_object_types/configure.ts index 98a60ac39598..e88ecb93d9d6 100644 --- a/x-pack/plugins/cases/server/saved_object_types/configure.ts +++ b/x-pack/plugins/cases/server/saved_object_types/configure.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { CASE_CONFIGURE_SAVED_OBJECT } from '../../common/constants'; +import { CASE_CONFIGURE_SAVED_OBJECT } from '../../common'; import { configureMigrations } from './migrations'; export const caseConfigureSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/saved_object_types/connector_mappings.ts b/x-pack/plugins/cases/server/saved_object_types/connector_mappings.ts index 16aba01616c3..ea7c10cedc82 100644 --- a/x-pack/plugins/cases/server/saved_object_types/connector_mappings.ts +++ b/x-pack/plugins/cases/server/saved_object_types/connector_mappings.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT } from '../../common/constants'; +import { CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT } from '../../common'; import { connectorMappingsMigrations } from './migrations'; export const caseConnectorMappingsSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/saved_object_types/migrations.ts b/x-pack/plugins/cases/server/saved_object_types/migrations.ts index 3d0bab68cf45..e4b201b21b75 100644 --- a/x-pack/plugins/cases/server/saved_object_types/migrations.ts +++ b/x-pack/plugins/cases/server/saved_object_types/migrations.ts @@ -14,8 +14,8 @@ import { CaseType, AssociationType, ESConnectorFields, -} from '../../common/api'; -import { SECURITY_SOLUTION_OWNER } from '../../common/constants'; + SECURITY_SOLUTION_OWNER, +} from '../../common'; interface UnsanitizedCaseConnector { connector_id: string; diff --git a/x-pack/plugins/cases/server/saved_object_types/sub_case.ts b/x-pack/plugins/cases/server/saved_object_types/sub_case.ts index 471dfebe74ae..65a8db02d747 100644 --- a/x-pack/plugins/cases/server/saved_object_types/sub_case.ts +++ b/x-pack/plugins/cases/server/saved_object_types/sub_case.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { SUB_CASE_SAVED_OBJECT } from '../../common/constants'; +import { SUB_CASE_SAVED_OBJECT } from '../../common'; import { subCasesMigrations } from './migrations'; export const subCaseSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/saved_object_types/user_actions.ts b/x-pack/plugins/cases/server/saved_object_types/user_actions.ts index 55a79f56f84d..16bb7ac09a6e 100644 --- a/x-pack/plugins/cases/server/saved_object_types/user_actions.ts +++ b/x-pack/plugins/cases/server/saved_object_types/user_actions.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsType } from 'src/core/server'; -import { CASE_USER_ACTION_SAVED_OBJECT } from '../../common/constants'; +import { CASE_USER_ACTION_SAVED_OBJECT } from '../../common'; import { userActionsMigrations } from './migrations'; export const caseUserActionSavedObjectType: SavedObjectsType = { diff --git a/x-pack/plugins/cases/server/services/alerts/index.ts b/x-pack/plugins/cases/server/services/alerts/index.ts index e7b331138d73..4b2460d4b68c 100644 --- a/x-pack/plugins/cases/server/services/alerts/index.ts +++ b/x-pack/plugins/cases/server/services/alerts/index.ts @@ -10,9 +10,8 @@ import { isEmpty } from 'lodash'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { ElasticsearchClient, Logger } from 'kibana/server'; -import { MAX_ALERTS_PER_SUB_CASE } from '../../../common/constants'; -import { AlertInfo } from '../../common'; -import { createCaseError } from '../../common/error'; +import { MAX_ALERTS_PER_SUB_CASE } from '../../../common'; +import { AlertInfo, createCaseError } from '../../common'; import { UpdateAlertRequest } from '../../client/alerts/client'; export type AlertServiceContract = PublicMethodsOf<AlertService>; diff --git a/x-pack/plugins/cases/server/services/attachments/index.ts b/x-pack/plugins/cases/server/services/attachments/index.ts index 077f00a571fa..685b088701f6 100644 --- a/x-pack/plugins/cases/server/services/attachments/index.ts +++ b/x-pack/plugins/cases/server/services/attachments/index.ts @@ -8,10 +8,10 @@ import { Logger, SavedObject, SavedObjectReference } from 'kibana/server'; import { + CASE_COMMENT_SAVED_OBJECT, CommentAttributes as AttachmentAttributes, CommentPatchAttributes as AttachmentPatchAttributes, -} from '../../../common/api'; -import { CASE_COMMENT_SAVED_OBJECT } from '../../../common/constants'; +} from '../../../common'; import { ClientArgs } from '..'; interface GetAttachmentArgs extends ClientArgs { diff --git a/x-pack/plugins/cases/server/services/cases/index.ts b/x-pack/plugins/cases/server/services/cases/index.ts index fd0a5e878bfb..a0e4380f9564 100644 --- a/x-pack/plugins/cases/server/services/cases/index.ts +++ b/x-pack/plugins/cases/server/services/cases/index.ts @@ -21,21 +21,27 @@ import { nodeBuilder, KueryNode } from '../../../../../../src/plugins/data/commo import { SecurityPluginSetup } from '../../../../security/server'; import { - ESCaseAttributes, - CommentAttributes, - User, - SubCaseAttributes, AssociationType, - SubCaseResponse, - CommentType, - CaseType, + CASE_COMMENT_SAVED_OBJECT, + CASE_SAVED_OBJECT, CaseResponse, - caseTypeField, CasesFindRequest, CaseStatuses, - OWNER_FIELD, + CaseType, + caseTypeField, + CommentAttributes, + CommentType, + ENABLE_CASE_CONNECTOR, + ESCaseAttributes, GetCaseIdsByAlertIdAggs, -} from '../../../common/api'; + MAX_CONCURRENT_SEARCHES, + MAX_DOCS_PER_PAGE, + OWNER_FIELD, + SUB_CASE_SAVED_OBJECT, + SubCaseAttributes, + SubCaseResponse, + User, +} from '../../../common'; import { defaultSortField, flattenCaseSavedObject, @@ -43,17 +49,7 @@ import { groupTotalAlertsByID, SavedObjectFindOptionsKueryNode, } from '../../common'; -import { - ENABLE_CASE_CONNECTOR, - MAX_CONCURRENT_SEARCHES, - MAX_DOCS_PER_PAGE, -} from '../../../common/constants'; import { defaultPage, defaultPerPage } from '../../routes/api'; -import { - CASE_SAVED_OBJECT, - CASE_COMMENT_SAVED_OBJECT, - SUB_CASE_SAVED_OBJECT, -} from '../../../common/constants'; import { ClientArgs } from '..'; import { combineFilters } from '../../client/utils'; import { includeFieldsRequiredForAuthentication } from '../../authorization/utils'; diff --git a/x-pack/plugins/cases/server/services/configure/index.ts b/x-pack/plugins/cases/server/services/configure/index.ts index 745e64d9016f..348bff954b73 100644 --- a/x-pack/plugins/cases/server/services/configure/index.ts +++ b/x-pack/plugins/cases/server/services/configure/index.ts @@ -8,8 +8,7 @@ import { Logger, SavedObjectsClientContract } from 'kibana/server'; import { SavedObjectFindOptionsKueryNode } from '../../common'; -import { ESCasesConfigureAttributes } from '../../../common/api'; -import { CASE_CONFIGURE_SAVED_OBJECT } from '../../../common/constants'; +import { ESCasesConfigureAttributes, CASE_CONFIGURE_SAVED_OBJECT } from '../../../common'; interface ClientArgs { unsecuredSavedObjectsClient: SavedObjectsClientContract; diff --git a/x-pack/plugins/cases/server/services/connector_mappings/index.ts b/x-pack/plugins/cases/server/services/connector_mappings/index.ts index e3ac5b4c55cf..0798b35a78a4 100644 --- a/x-pack/plugins/cases/server/services/connector_mappings/index.ts +++ b/x-pack/plugins/cases/server/services/connector_mappings/index.ts @@ -7,8 +7,7 @@ import { Logger, SavedObjectReference, SavedObjectsClientContract } from 'kibana/server'; -import { ConnectorMappings } from '../../../common/api'; -import { CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT } from '../../../common/constants'; +import { ConnectorMappings, CASE_CONNECTOR_MAPPINGS_SAVED_OBJECT } from '../../../common'; import { SavedObjectFindOptionsKueryNode } from '../../common'; interface ClientArgs { diff --git a/x-pack/plugins/cases/server/services/user_actions/helpers.ts b/x-pack/plugins/cases/server/services/user_actions/helpers.ts index 664a9041491a..4d0f899d4078 100644 --- a/x-pack/plugins/cases/server/services/user_actions/helpers.ts +++ b/x-pack/plugins/cases/server/services/user_actions/helpers.ts @@ -10,22 +10,20 @@ import { get, isPlainObject, isString } from 'lodash'; import deepEqual from 'fast-deep-equal'; import { + CASE_COMMENT_SAVED_OBJECT, + CASE_SAVED_OBJECT, CaseUserActionAttributes, + ESCaseAttributes, + OWNER_FIELD, + SUB_CASE_SAVED_OBJECT, + SubCaseAttributes, + User, UserAction, UserActionField, - ESCaseAttributes, - User, UserActionFieldType, - SubCaseAttributes, - OWNER_FIELD, -} from '../../../common/api'; +} from '../../../common'; import { isTwoArraysDifference } from '../../client/utils'; import { UserActionItem } from '.'; -import { - CASE_SAVED_OBJECT, - CASE_COMMENT_SAVED_OBJECT, - SUB_CASE_SAVED_OBJECT, -} from '../../../common/constants'; import { transformESConnectorToCaseConnector } from '../../common'; export const transformNewUserAction = ({ diff --git a/x-pack/plugins/cases/server/services/user_actions/index.ts b/x-pack/plugins/cases/server/services/user_actions/index.ts index 2c20bf808ad4..5fdf4680f5ca 100644 --- a/x-pack/plugins/cases/server/services/user_actions/index.ts +++ b/x-pack/plugins/cases/server/services/user_actions/index.ts @@ -7,13 +7,13 @@ import { Logger, SavedObjectReference } from 'kibana/server'; -import { CaseUserActionAttributes } from '../../../common'; import { - CASE_USER_ACTION_SAVED_OBJECT, CASE_SAVED_OBJECT, - SUB_CASE_SAVED_OBJECT, + CASE_USER_ACTION_SAVED_OBJECT, + CaseUserActionAttributes, MAX_DOCS_PER_PAGE, -} from '../../../common/constants'; + SUB_CASE_SAVED_OBJECT, +} from '../../../common'; import { ClientArgs } from '..'; interface GetCaseUserActionArgs extends ClientArgs { diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index 87e99a4b472e..4ce20af28b1d 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -70,6 +70,8 @@ export enum SecurityPageName { administration = 'administration', } +export const CASES_APP_ID = `${APP_ID}:${SecurityPageName.case}`; + export const APP_OVERVIEW_PATH = `${APP_PATH}/overview`; export const APP_DETECTIONS_PATH = `${APP_PATH}/detections`; export const APP_HOSTS_PATH = `${APP_PATH}/hosts`; diff --git a/x-pack/plugins/security_solution/public/cases/components/__mock__/router.ts b/x-pack/plugins/security_solution/public/cases/components/__mock__/router.ts deleted file mode 100644 index 58b7bb0ac268..000000000000 --- a/x-pack/plugins/security_solution/public/cases/components/__mock__/router.ts +++ /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 { Router } from 'react-router-dom'; -// eslint-disable-next-line @kbn/eslint/module_migration -import routeData from 'react-router'; -type Action = 'PUSH' | 'POP' | 'REPLACE'; -const pop: Action = 'POP'; -const location = { - pathname: '/network', - search: '', - state: '', - hash: '', -}; -export const mockHistory = { - length: 2, - location, - action: pop, - push: jest.fn(), - replace: jest.fn(), - go: jest.fn(), - goBack: jest.fn(), - goForward: jest.fn(), - block: jest.fn(), - createHref: jest.fn(), - listen: jest.fn(), -}; - -export const mockLocation = { - pathname: '/welcome', - hash: '', - search: '', - state: '', -}; - -export { Router, routeData }; diff --git a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx index 337c07fa93ea..aa84f639c457 100644 --- a/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/all_cases/index.tsx @@ -6,7 +6,6 @@ */ import React, { useCallback } from 'react'; -import { useHistory } from 'react-router-dom'; import { getCaseDetailsUrl, @@ -16,7 +15,7 @@ import { } from '../../../common/components/link_to'; import { SecurityPageName } from '../../../app/types'; import { useKibana } from '../../../common/lib/kibana'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../common/constants'; export interface AllCasesNavProps { detailName: string; @@ -32,13 +31,12 @@ export const AllCases = React.memo<AllCasesProps>(({ userCanCrud }) => { cases: casesUi, application: { navigateToApp }, } = useKibana().services; - const history = useHistory(); const { formatUrl, search: urlSearch } = useFormatUrl(SecurityPageName.case); const goToCreateCase = useCallback( - (ev) => { + async (ev) => { ev.preventDefault(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + return navigateToApp(CASES_APP_ID, { path: getCreateCaseUrl(urlSearch), }); }, @@ -46,11 +44,13 @@ export const AllCases = React.memo<AllCasesProps>(({ userCanCrud }) => { ); const goToCaseConfigure = useCallback( - (ev) => { + async (ev) => { ev.preventDefault(); - history.push(getConfigureCasesUrl(urlSearch)); + return navigateToApp(CASES_APP_ID, { + path: getConfigureCasesUrl(urlSearch), + }); }, - [history, urlSearch] + [navigateToApp, urlSearch] ); return casesUi.getAllCases({ @@ -58,8 +58,8 @@ export const AllCases = React.memo<AllCasesProps>(({ userCanCrud }) => { href: ({ detailName, subCaseId }: AllCasesNavProps) => { return formatUrl(getCaseDetailsUrl({ id: detailName, subCaseId })); }, - onClick: ({ detailName, subCaseId, search }: AllCasesNavProps) => { - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + onClick: async ({ detailName, subCaseId, search }: AllCasesNavProps) => { + return navigateToApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id: detailName, search, subCaseId }), }); }, diff --git a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx index b0f3ccb8c21a..71bc241f65e1 100644 --- a/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/case_view/index.tsx @@ -7,7 +7,6 @@ import React, { useCallback, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { useHistory } from 'react-router-dom'; import { SearchResponse } from 'elasticsearch'; import { isEmpty } from 'lodash'; @@ -21,11 +20,14 @@ import { } from '../../../common/components/link_to'; import { Ecs } from '../../../../common/ecs'; import { Case } from '../../../../../cases/common'; -import { TimelineNonEcsData } from '../../../../common/search_strategy'; import { TimelineId } from '../../../../common/types/timeline'; import { SecurityPageName } from '../../../app/types'; import { KibanaServices, useKibana } from '../../../common/lib/kibana'; -import { APP_ID, DETECTION_ENGINE_QUERY_SIGNALS_URL } from '../../../../common/constants'; +import { + APP_ID, + CASES_APP_ID, + DETECTION_ENGINE_QUERY_SIGNALS_URL, +} from '../../../../common/constants'; import { timelineActions } from '../../../timelines/store/timeline'; import { useSourcererScope } from '../../../common/containers/sourcerer'; import { SourcererScopeName } from '../../../common/store/sourcerer/model'; @@ -70,7 +72,6 @@ const TimelineDetailsPanel = () => { }; const InvestigateInTimelineActionComponent = (alertIds: string[]) => { - const EMPTY_ARRAY: TimelineNonEcsData[] = []; const fetchEcsAlertsData = async (fetchAlertIds?: string[]): Promise<Ecs[]> => { if (isEmpty(fetchAlertIds)) { return []; @@ -104,7 +105,7 @@ const InvestigateInTimelineActionComponent = (alertIds: string[]) => { key="investigate-in-timeline" ecsRowData={null} fetchEcsAlertsData={fetchEcsAlertsData} - nonEcsRowData={EMPTY_ARRAY} + nonEcsRowData={[]} /> ); }; @@ -127,7 +128,6 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = cases: casesUi, application: { navigateToApp }, } = useKibana().services; - const history = useHistory(); const dispatch = useDispatch(); const { formatUrl, search } = useFormatUrl(SecurityPageName.case); const { formatUrl: detectionsFormatUrl, search: detectionsUrlSearch } = useFormatUrl( @@ -136,42 +136,16 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = const allCasesLink = getCaseUrl(search); const formattedAllCasesLink = formatUrl(allCasesLink); - const backToAllCasesOnClick = useCallback( - (ev) => { - ev.preventDefault(); - history.push(allCasesLink); - }, - [allCasesLink, history] - ); + const configureCasesHref = formatUrl(getConfigureCasesUrl()); + const caseDetailsLink = formatUrl(getCaseDetailsUrl({ id: caseId }), { absolute: true }); - const getCaseDetailHrefWithCommentId = (commentId: string) => { - return formatUrl(getCaseDetailsUrlWithCommentId({ id: caseId, commentId, subCaseId }), { + const getCaseDetailHrefWithCommentId = (commentId: string) => + formatUrl(getCaseDetailsUrlWithCommentId({ id: caseId, commentId, subCaseId }), { absolute: true, }); - }; - - const configureCasesHref = formatUrl(getConfigureCasesUrl()); - const onConfigureCasesNavClick = useCallback( - (ev) => { - ev.preventDefault(); - history.push(getConfigureCasesUrl(search)); - }, - [history, search] - ); - - const onDetectionsRuleDetailsClick = useCallback( - (ruleId: string | null | undefined) => { - navigateToApp(`${APP_ID}:${SecurityPageName.detections}`, { - path: getRuleDetailsUrl(ruleId ?? ''), - }); - }, - [navigateToApp] - ); const getDetectionsRuleDetailsHref = useCallback( - (ruleId) => { - return detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)); - }, + (ruleId) => detectionsFormatUrl(getRuleDetailsUrl(ruleId ?? '', detectionsUrlSearch)), [detectionsFormatUrl, detectionsUrlSearch] ); @@ -207,12 +181,22 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = {casesUi.getCaseView({ allCasesNavigation: { href: formattedAllCasesLink, - onClick: backToAllCasesOnClick, + onClick: async (e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID, { + path: allCasesLink, + }); + }, }, caseDetailsNavigation: { href: caseDetailsLink, - onClick: () => { - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + onClick: async (e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id: caseId }), }); }, @@ -220,14 +204,28 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) = caseId, configureCasesNavigation: { href: configureCasesHref, - onClick: onConfigureCasesNavClick, + onClick: async (e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID, { + path: getConfigureCasesUrl(search), + }); + }, }, getCaseDetailHrefWithCommentId, onCaseDataSuccess, onComponentInitialized, ruleDetailsNavigation: { href: getDetectionsRuleDetailsHref, - onClick: onDetectionsRuleDetailsClick, + onClick: async (ruleId: string | null | undefined, e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(`${APP_ID}:${SecurityPageName.detections}`, { + path: getRuleDetailsUrl(ruleId ?? ''), + }); + }, }, showAlertDetails, subCaseId, diff --git a/x-pack/plugins/security_solution/public/cases/components/create/flyout.test.tsx b/x-pack/plugins/security_solution/public/cases/components/create/flyout.test.tsx index d413a2d5e001..caa88a8fd1c2 100644 --- a/x-pack/plugins/security_solution/public/cases/components/create/flyout.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/create/flyout.test.tsx @@ -16,7 +16,7 @@ jest.mock('../../../common/lib/kibana', () => ({ useKibana: () => ({ services: { cases: { - getCreateCase: jest.fn(), + getCreateCase: () => {}, }, }, }), diff --git a/x-pack/plugins/security_solution/public/cases/components/create/index.test.tsx b/x-pack/plugins/security_solution/public/cases/components/create/index.test.tsx index 1a6015d1bbd4..0b6e98e1badc 100644 --- a/x-pack/plugins/security_solution/public/cases/components/create/index.test.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/create/index.test.tsx @@ -11,29 +11,33 @@ import { act, waitFor } from '@testing-library/react'; import { noop } from 'lodash/fp'; import { TestProviders } from '../../../common/mock'; -import { Router, routeData, mockHistory, mockLocation } from '../__mock__/router'; import { useInsertTimeline } from '../use_insert_timeline'; import { Create } from '.'; import { useKibana } from '../../../common/lib/kibana'; import { Case } from '../../../../../cases/public/containers/types'; import { basicCase } from '../../../../../cases/public/containers/mock'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../common/constants'; +import { useGetUrlSearch } from '../../../common/components/navigation/use_get_url_search'; jest.mock('../use_insert_timeline'); jest.mock('../../../common/lib/kibana'); +jest.mock('../../../common/components/navigation/use_get_url_search'); const useInsertTimelineMock = useInsertTimeline as jest.Mock; describe('Create case', () => { const mockCreateCase = jest.fn(); + const mockNavigateToApp = jest.fn(); + const mockRes = 'coolstring'; beforeEach(() => { jest.resetAllMocks(); - jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); + (useGetUrlSearch as jest.Mock).mockReturnValue(mockRes); (useKibana as jest.Mock).mockReturnValue({ services: { cases: { getCreateCase: mockCreateCase, }, + application: { navigateToApp: mockNavigateToApp }, }, }); }); @@ -41,9 +45,7 @@ describe('Create case', () => { it('it renders', () => { mount( <TestProviders> - <Router history={mockHistory}> - <Create /> - </Router> + <Create /> </TestProviders> ); @@ -59,17 +61,20 @@ describe('Create case', () => { onCancel(); }, }, + application: { navigateToApp: mockNavigateToApp }, }, }); mount( <TestProviders> - <Router history={mockHistory}> - <Create /> - </Router> + <Create /> </TestProviders> ); - await waitFor(() => expect(mockHistory.push).toHaveBeenCalledWith('/')); + await waitFor(() => + expect(mockNavigateToApp).toHaveBeenCalledWith(CASES_APP_ID, { + path: `?${mockRes}`, + }) + ); }); it('should redirect to new case when posting the case', async () => { @@ -80,17 +85,20 @@ describe('Create case', () => { onSuccess(basicCase); }, }, + application: { navigateToApp: mockNavigateToApp }, }, }); mount( <TestProviders> - <Router history={mockHistory}> - <Create /> - </Router> + <Create /> </TestProviders> ); - await waitFor(() => expect(mockHistory.push).toHaveBeenNthCalledWith(1, '/basic-case-id')); + await waitFor(() => + expect(mockNavigateToApp).toHaveBeenNthCalledWith(1, CASES_APP_ID, { + path: `/basic-case-id?${mockRes}`, + }) + ); }); it.skip('it should insert a timeline', async () => { @@ -101,9 +109,7 @@ describe('Create case', () => { const wrapper = mount( <TestProviders> - <Router history={mockHistory}> - <Create /> - </Router> + <Create /> </TestProviders> ); diff --git a/x-pack/plugins/security_solution/public/cases/components/create/index.tsx b/x-pack/plugins/security_solution/public/cases/components/create/index.tsx index f946cefd3494..91fb45de0432 100644 --- a/x-pack/plugins/security_solution/public/cases/components/create/index.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/create/index.tsx @@ -7,27 +7,35 @@ import React, { useCallback } from 'react'; import { EuiPanel } from '@elastic/eui'; -import { useHistory } from 'react-router-dom'; -import { getCaseDetailsUrl } from '../../../common/components/link_to'; +import { getCaseDetailsUrl, getCaseUrl } from '../../../common/components/link_to'; import { useKibana } from '../../../common/lib/kibana'; import * as timelineMarkdownPlugin from '../../../common/components/markdown_editor/plugins/timeline'; import { useInsertTimeline } from '../use_insert_timeline'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../common/constants'; +import { useGetUrlSearch } from '../../../common/components/navigation/use_get_url_search'; +import { navTabs } from '../../../app/home/home_navigations'; export const Create = React.memo(() => { - const { cases } = useKibana().services; - const history = useHistory(); + const { + cases, + application: { navigateToApp }, + } = useKibana().services; + const search = useGetUrlSearch(navTabs.case); const onSuccess = useCallback( - async ({ id }) => { - history.push(getCaseDetailsUrl({ id })); - }, - [history] + async ({ id }) => + navigateToApp(CASES_APP_ID, { + path: getCaseDetailsUrl({ id, search }), + }), + [navigateToApp, search] + ); + const handleSetIsCancel = useCallback( + async () => + navigateToApp(CASES_APP_ID, { + path: getCaseUrl(search), + }), + [navigateToApp, search] ); - - const handleSetIsCancel = useCallback(() => { - history.push('/'); - }, [history]); return ( <EuiPanel> diff --git a/x-pack/plugins/security_solution/public/cases/components/timeline_actions/add_to_case_action.tsx b/x-pack/plugins/security_solution/public/cases/components/timeline_actions/add_to_case_action.tsx index 4435b32e07cc..eaad912a4dc5 100644 --- a/x-pack/plugins/security_solution/public/cases/components/timeline_actions/add_to_case_action.tsx +++ b/x-pack/plugins/security_solution/public/cases/components/timeline_actions/add_to_case_action.tsx @@ -17,7 +17,7 @@ import { } from '@elastic/eui'; import { Case, CaseStatuses, StatusAll } from '../../../../../cases/common'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../common/constants'; import { Ecs } from '../../../../common/ecs'; import { SecurityPageName } from '../../../app/types'; import { @@ -80,7 +80,7 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({ const onViewCaseClick = useCallback( (id) => { - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + navigateToApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id }), }); }, @@ -132,9 +132,9 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({ const { formatUrl, search: urlSearch } = useFormatUrl(SecurityPageName.case); const goToCreateCase = useCallback( - (ev) => { + async (ev) => { ev.preventDefault(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + return navigateToApp(CASES_APP_ID, { path: getCreateCaseUrl(urlSearch), }); }, diff --git a/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx b/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx index bbc29828731c..730773342686 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/case_details.tsx @@ -6,20 +6,23 @@ */ import React from 'react'; -import { useParams, useHistory } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import { SecurityPageName } from '../../app/types'; import { SpyRoute } from '../../common/utils/route/spy_routes'; import { WrapperPage } from '../../common/components/wrapper_page'; import { useGetUrlSearch } from '../../common/components/navigation/use_get_url_search'; -import { useGetUserCasesPermissions } from '../../common/lib/kibana'; +import { useGetUserCasesPermissions, useKibana } from '../../common/lib/kibana'; import { getCaseUrl } from '../../common/components/link_to'; import { navTabs } from '../../app/home/home_navigations'; import { CaseView } from '../components/case_view'; import { permissionsReadOnlyErrorMessage, CaseCallOut } from '../components/callout'; +import { CASES_APP_ID } from '../../../common/constants'; export const CaseDetailsPage = React.memo(() => { - const history = useHistory(); + const { + application: { navigateToApp }, + } = useKibana().services; const userPermissions = useGetUserCasesPermissions(); const { detailName: caseId, subCaseId } = useParams<{ detailName?: string; @@ -28,7 +31,7 @@ export const CaseDetailsPage = React.memo(() => { const search = useGetUrlSearch(navTabs.case); if (userPermissions != null && !userPermissions.read) { - history.replace(getCaseUrl(search)); + navigateToApp(CASES_APP_ID, { path: getCaseUrl(search) }); return null; } diff --git a/x-pack/plugins/security_solution/public/cases/pages/configure_cases.tsx b/x-pack/plugins/security_solution/public/cases/pages/configure_cases.tsx index 905167c232c7..a3fce0823ce7 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/configure_cases.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/configure_cases.tsx @@ -6,7 +6,6 @@ */ import React, { useMemo } from 'react'; -import { useHistory } from 'react-router-dom'; import styled from 'styled-components'; import { SecurityPageName } from '../../app/types'; @@ -19,11 +18,13 @@ import { navTabs } from '../../app/home/home_navigations'; import { CaseHeaderPage } from '../components/case_header_page'; import { WhitePageWrapper, SectionWrapper } from '../components/wrappers'; import * as i18n from './translations'; -import { APP_ID } from '../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../common/constants'; const ConfigureCasesPageComponent: React.FC = () => { - const { cases } = useKibana().services; - const history = useHistory(); + const { + application: { navigateToApp }, + cases, + } = useKibana().services; const userPermissions = useGetUserCasesPermissions(); const search = useGetUrlSearch(navTabs.case); @@ -37,7 +38,7 @@ const ConfigureCasesPageComponent: React.FC = () => { ); if (userPermissions != null && !userPermissions.read) { - history.push(getCaseUrl(search)); + navigateToApp(CASES_APP_ID, { path: getCaseUrl(search) }); return null; } diff --git a/x-pack/plugins/security_solution/public/cases/pages/create_case.tsx b/x-pack/plugins/security_solution/public/cases/pages/create_case.tsx index 41344a8deb3b..19f97bae60eb 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/create_case.tsx +++ b/x-pack/plugins/security_solution/public/cases/pages/create_case.tsx @@ -6,24 +6,25 @@ */ import React, { useMemo } from 'react'; -import { useHistory } from 'react-router-dom'; import { SecurityPageName } from '../../app/types'; import { getCaseUrl } from '../../common/components/link_to'; import { useGetUrlSearch } from '../../common/components/navigation/use_get_url_search'; import { WrapperPage } from '../../common/components/wrapper_page'; -import { useGetUserCasesPermissions } from '../../common/lib/kibana'; +import { useGetUserCasesPermissions, useKibana } from '../../common/lib/kibana'; import { SpyRoute } from '../../common/utils/route/spy_routes'; import { navTabs } from '../../app/home/home_navigations'; import { CaseHeaderPage } from '../components/case_header_page'; import { Create } from '../components/create'; import * as i18n from './translations'; +import { CASES_APP_ID } from '../../../common/constants'; export const CreateCasePage = React.memo(() => { - const history = useHistory(); const userPermissions = useGetUserCasesPermissions(); const search = useGetUrlSearch(navTabs.case); - + const { + application: { navigateToApp }, + } = useKibana().services; const backOptions = useMemo( () => ({ href: getCaseUrl(search), @@ -34,7 +35,9 @@ export const CreateCasePage = React.memo(() => { ); if (userPermissions != null && !userPermissions.crud) { - history.replace(getCaseUrl(search)); + navigateToApp(CASES_APP_ID, { + path: getCaseUrl(search), + }); return null; } diff --git a/x-pack/plugins/security_solution/public/cases/pages/translations.ts b/x-pack/plugins/security_solution/public/cases/pages/translations.ts index e45aca87ff1f..1a811a3fd7bb 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/translations.ts +++ b/x-pack/plugins/security_solution/public/cases/pages/translations.ts @@ -48,14 +48,6 @@ export const NAME = i18n.translate('xpack.securitySolution.cases.caseView.name', defaultMessage: 'Name', }); -export const OPENED_ON = i18n.translate('xpack.securitySolution.cases.caseView.openedOn', { - defaultMessage: 'Opened on', -}); - -export const CLOSED_ON = i18n.translate('xpack.securitySolution.cases.caseView.closedOn', { - defaultMessage: 'Closed on', -}); - export const REPORTER = i18n.translate('xpack.securitySolution.cases.caseView.reporterLabel', { defaultMessage: 'Reporter', }); @@ -86,20 +78,6 @@ export const DESCRIPTION_REQUIRED = i18n.translate( } ); -export const COMMENT_REQUIRED = i18n.translate( - 'xpack.securitySolution.cases.caseView.commentFieldRequiredError', - { - defaultMessage: 'A comment is required.', - } -); - -export const REQUIRED_FIELD = i18n.translate( - 'xpack.securitySolution.cases.caseView.fieldRequiredError', - { - defaultMessage: 'Required field', - } -); - export const EDIT = i18n.translate('xpack.securitySolution.cases.caseView.edit', { defaultMessage: 'Edit', }); @@ -120,10 +98,6 @@ export const CLOSE_CASE = i18n.translate('xpack.securitySolution.cases.caseView. defaultMessage: 'Close case', }); -export const REOPEN_CASE = i18n.translate('xpack.securitySolution.cases.caseView.reopenCase', { - defaultMessage: 'Reopen case', -}); - export const CASE_NAME = i18n.translate('xpack.securitySolution.cases.caseView.caseName', { defaultMessage: 'Case name', }); @@ -140,13 +114,6 @@ export const ACTIONS = i18n.translate('xpack.securitySolution.cases.allCases.act defaultMessage: 'Actions', }); -export const NO_TAGS_AVAILABLE = i18n.translate( - 'xpack.securitySolution.cases.allCases.noTagsAvailable', - { - defaultMessage: 'No tags available', - } -); - export const NO_REPORTERS_AVAILABLE = i18n.translate( 'xpack.securitySolution.cases.caseView.noReportersAvailable', { @@ -158,14 +125,6 @@ export const COMMENTS = i18n.translate('xpack.securitySolution.cases.allCases.co defaultMessage: 'Comments', }); -export const TAGS_HELP = i18n.translate( - 'xpack.securitySolution.cases.createCase.fieldTagsHelpText', - { - defaultMessage: - 'Type one or more custom identifying tags for this case. Press enter after each tag to begin a new one.', - } -); - export const NO_TAGS = i18n.translate('xpack.securitySolution.cases.caseView.noTags', { defaultMessage: 'No tags are currently assigned to this case.', }); @@ -184,27 +143,6 @@ export const CONFIGURE_CASES_PAGE_TITLE = i18n.translate( } ); -export const CONFIGURE_CASES_BUTTON = i18n.translate( - 'xpack.securitySolution.cases.configureCasesButton', - { - defaultMessage: 'Edit external connection', - } -); - -export const ADD_COMMENT = i18n.translate( - 'xpack.securitySolution.cases.caseView.comment.addComment', - { - defaultMessage: 'Add comment', - } -); - -export const ADD_COMMENT_HELP_TEXT = i18n.translate( - 'xpack.securitySolution.cases.caseView.comment.addCommentHelpText', - { - defaultMessage: 'Add a new comment...', - } -); - export const SAVE = i18n.translate('xpack.securitySolution.cases.caseView.description.save', { defaultMessage: 'Save', }); @@ -219,10 +157,3 @@ export const GO_TO_DOCUMENTATION = i18n.translate( export const CONNECTORS = i18n.translate('xpack.securitySolution.cases.caseView.connectors', { defaultMessage: 'External Incident Management System', }); - -export const EDIT_CONNECTOR = i18n.translate( - 'xpack.securitySolution.cases.caseView.editConnector', - { - defaultMessage: 'Change external incident management system', - } -); diff --git a/x-pack/plugins/security_solution/public/cases/pages/utils.ts b/x-pack/plugins/security_solution/public/cases/pages/utils.ts index 5454c6db6750..1c848190cbef 100644 --- a/x-pack/plugins/security_solution/public/cases/pages/utils.ts +++ b/x-pack/plugins/security_solution/public/cases/pages/utils.ts @@ -13,8 +13,7 @@ import { getCaseDetailsUrl, getCreateCaseUrl } from '../../common/components/lin import { RouteSpyState } from '../../common/utils/route/types'; import * as i18n from './translations'; import { GetUrlForApp } from '../../common/components/navigation/types'; -import { APP_ID } from '../../../common/constants'; -import { SecurityPageName } from '../../app/types'; +import { CASES_APP_ID } from '../../../common/constants'; export const getBreadcrumbs = ( params: RouteSpyState, @@ -26,17 +25,17 @@ export const getBreadcrumbs = ( let breadcrumb = [ { text: i18n.PAGE_TITLE, - href: getUrlForApp(`${APP_ID}:${SecurityPageName.case}`, { + href: getUrlForApp(CASES_APP_ID, { path: queryParameters, }), }, ]; - if (params.detailName === 'create') { + if (params.pathName === '/create') { breadcrumb = [ ...breadcrumb, { text: i18n.CREATE_BC_TITLE, - href: getUrlForApp(`${APP_ID}:${SecurityPageName.case}`, { + href: getUrlForApp(CASES_APP_ID, { path: getCreateCaseUrl(queryParameters), }), }, @@ -46,7 +45,7 @@ export const getBreadcrumbs = ( ...breadcrumb, { text: params.state?.caseTitle ?? '', - href: getUrlForApp(`${APP_ID}:${SecurityPageName.case}`, { + href: getUrlForApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id: params.detailName, search: queryParameters }), }), }, diff --git a/x-pack/plugins/security_solution/public/cases/translations.ts b/x-pack/plugins/security_solution/public/cases/translations.ts index 63fc5695ebab..1405a8baa171 100644 --- a/x-pack/plugins/security_solution/public/cases/translations.ts +++ b/x-pack/plugins/security_solution/public/cases/translations.ts @@ -66,11 +66,6 @@ export const PARTICIPANTS = i18n.translate( defaultMessage: 'Participants', } ); - -export const CREATE_BC_TITLE = i18n.translate('xpack.securitySolution.cases.caseView.breadcrumb', { - defaultMessage: 'Create', -}); - export const CREATE_TITLE = i18n.translate('xpack.securitySolution.cases.caseView.create', { defaultMessage: 'Create new case', }); @@ -86,20 +81,6 @@ export const DESCRIPTION_REQUIRED = i18n.translate( } ); -export const COMMENT_REQUIRED = i18n.translate( - 'xpack.securitySolution.cases.caseView.commentFieldRequiredError', - { - defaultMessage: 'A comment is required.', - } -); - -export const REQUIRED_FIELD = i18n.translate( - 'xpack.securitySolution.cases.caseView.fieldRequiredError', - { - defaultMessage: 'Required field', - } -); - export const EDIT = i18n.translate('xpack.securitySolution.cases.caseView.edit', { defaultMessage: 'Edit', }); @@ -119,18 +100,6 @@ export const CREATE_CASE = i18n.translate('xpack.securitySolution.cases.caseView export const CLOSE_CASE = i18n.translate('xpack.securitySolution.cases.caseView.closeCase', { defaultMessage: 'Close case', }); - -export const MARK_CASE_IN_PROGRESS = i18n.translate( - 'xpack.securitySolution.cases.caseView.markInProgress', - { - defaultMessage: 'Mark in progress', - } -); - -export const REOPEN_CASE = i18n.translate('xpack.securitySolution.cases.caseView.reopenCase', { - defaultMessage: 'Reopen case', -}); - export const OPEN_CASE = i18n.translate('xpack.securitySolution.cases.caseView.openCase', { defaultMessage: 'Open case', }); @@ -151,13 +120,6 @@ export const ACTIONS = i18n.translate('xpack.securitySolution.cases.allCases.act defaultMessage: 'Actions', }); -export const NO_TAGS_AVAILABLE = i18n.translate( - 'xpack.securitySolution.cases.allCases.noTagsAvailable', - { - defaultMessage: 'No tags available', - } -); - export const NO_REPORTERS_AVAILABLE = i18n.translate( 'xpack.securitySolution.cases.caseView.noReportersAvailable', { @@ -168,15 +130,6 @@ export const NO_REPORTERS_AVAILABLE = i18n.translate( export const COMMENTS = i18n.translate('xpack.securitySolution.cases.allCases.comments', { defaultMessage: 'Comments', }); - -export const TAGS_HELP = i18n.translate( - 'xpack.securitySolution.cases.createCase.fieldTagsHelpText', - { - defaultMessage: - 'Type one or more custom identifying tags for this case. Press enter after each tag to begin a new one.', - } -); - export const NO_TAGS = i18n.translate('xpack.securitySolution.cases.caseView.noTags', { defaultMessage: 'No tags are currently assigned to this case.', }); @@ -188,105 +141,19 @@ export const TITLE_REQUIRED = i18n.translate( } ); -export const CONFIGURE_CASES_PAGE_TITLE = i18n.translate( - 'xpack.securitySolution.cases.configureCases.headerTitle', - { - defaultMessage: 'Configure cases', - } -); - -export const CONFIGURE_CASES_BUTTON = i18n.translate( - 'xpack.securitySolution.cases.configureCasesButton', - { - defaultMessage: 'Edit external connection', - } -); - -export const ADD_COMMENT = i18n.translate( - 'xpack.securitySolution.cases.caseView.comment.addComment', - { - defaultMessage: 'Add comment', - } -); - -export const ADD_COMMENT_HELP_TEXT = i18n.translate( - 'xpack.securitySolution.cases.caseView.comment.addCommentHelpText', - { - defaultMessage: 'Add a new comment...', - } -); - export const SAVE = i18n.translate('xpack.securitySolution.cases.caseView.description.save', { defaultMessage: 'Save', }); -export const GO_TO_DOCUMENTATION = i18n.translate( - 'xpack.securitySolution.cases.caseView.goToDocumentationButton', - { - defaultMessage: 'View documentation', - } -); - export const CONNECTORS = i18n.translate('xpack.securitySolution.cases.caseView.connectors', { defaultMessage: 'External Incident Management System', }); - -export const EDIT_CONNECTOR = i18n.translate( - 'xpack.securitySolution.cases.caseView.editConnector', - { - defaultMessage: 'Change external incident management system', - } -); - -export const NO_CONNECTOR = i18n.translate('xpack.securitySolution.cases.common.noConnector', { - defaultMessage: 'No connector selected', -}); - export const UNKNOWN = i18n.translate('xpack.securitySolution.cases.caseView.unknown', { defaultMessage: 'Unknown', }); - -export const MARKED_CASE_AS = i18n.translate('xpack.securitySolution.cases.caseView.markedCaseAs', { - defaultMessage: 'marked case as', -}); - export const OPEN_CASES = i18n.translate('xpack.securitySolution.cases.caseTable.openCases', { defaultMessage: 'Open cases', }); - -export const CLOSED_CASES = i18n.translate('xpack.securitySolution.cases.caseTable.closedCases', { - defaultMessage: 'Closed cases', -}); - -export const IN_PROGRESS_CASES = i18n.translate( - 'xpack.securitySolution.cases.caseTable.inProgressCases', - { - defaultMessage: 'In progress cases', - } -); - -export const SYNC_ALERTS_SWITCH_LABEL_ON = i18n.translate( - 'xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOn', - { - defaultMessage: 'On', - } -); - -export const SYNC_ALERTS_SWITCH_LABEL_OFF = i18n.translate( - 'xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOff', - { - defaultMessage: 'Off', - } -); - -export const SYNC_ALERTS_HELP = i18n.translate( - 'xpack.securitySolution.components.create.syncAlertHelpText', - { - defaultMessage: - 'Enabling this option will sync the status of alerts in this case with the case status.', - } -); - export const ALERT = i18n.translate('xpack.securitySolution.common.alertLabel', { defaultMessage: 'Alert', }); diff --git a/x-pack/plugins/security_solution/public/common/components/links/index.tsx b/x-pack/plugins/security_solution/public/common/components/links/index.tsx index a02cc8bf76bc..13888c98c424 100644 --- a/x-pack/plugins/security_solution/public/common/components/links/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/links/index.tsx @@ -20,7 +20,7 @@ import React, { useMemo, useCallback } from 'react'; import { isNil } from 'lodash/fp'; import styled from 'styled-components'; -import { IP_REPUTATION_LINKS_SETTING, APP_ID } from '../../../../common/constants'; +import { IP_REPUTATION_LINKS_SETTING, APP_ID, CASES_APP_ID } from '../../../../common/constants'; import { DefaultFieldRendererOverflow, DEFAULT_MORE_MAX_HEIGHT, @@ -177,9 +177,9 @@ const CaseDetailsLinkComponent: React.FC<{ const { formatUrl, search } = useFormatUrl(SecurityPageName.case); const { navigateToApp } = useKibana().services.application; const goToCaseDetails = useCallback( - (ev) => { + async (ev) => { ev.preventDefault(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + return navigateToApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id: detailName, search, subCaseId }), }); }, @@ -204,9 +204,9 @@ export const CreateCaseLink = React.memo<{ children: React.ReactNode }>(({ child const { formatUrl, search } = useFormatUrl(SecurityPageName.case); const { navigateToApp } = useKibana().services.application; const goToCreateCase = useCallback( - (ev) => { + async (ev) => { ev.preventDefault(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + return navigateToApp(CASES_APP_ID, { path: getCreateCaseUrl(search), }); }, diff --git a/x-pack/plugins/cases/public/components/__mock__/router.ts b/x-pack/plugins/security_solution/public/common/mock/router.tsx similarity index 100% rename from x-pack/plugins/cases/public/components/__mock__/router.ts rename to x-pack/plugins/security_solution/public/common/mock/router.tsx diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.test.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.test.tsx index 1e8525f0519e..8c6f74a01e49 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/query_bar/index.test.tsx @@ -14,8 +14,8 @@ import { useFormFieldMock, mockOpenTimelineQueryResults, } from '../../../../common/mock'; -import { mockHistory, Router } from '../../../../cases/components/__mock__/router'; import { useGetAllTimeline, getAllTimeline } from '../../../../timelines/containers/all'; +import { mockHistory, Router } from '../../../../common/mock/router'; jest.mock('../../../../common/lib/kibana'); diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx index 6bca9bf2756b..0695275f4cd7 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.test.tsx @@ -21,7 +21,7 @@ import { DetectionEnginePage } from './detection_engine'; import { useUserData } from '../../components/user_info'; import { useSourcererScope } from '../../../common/containers/sourcerer'; import { createStore, State } from '../../../common/store'; -import { mockHistory, Router } from '../../../cases/components/__mock__/router'; +import { mockHistory, Router } from '../../../common/mock/router'; // Test will fail because we will to need to mock some core services to make the test work // For now let's forget about SiemSearchBar and QueryBar diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.test.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.test.tsx index b1c7bf8aa41e..14c791adcf98 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/details/index.test.tsx @@ -22,7 +22,7 @@ import { createStore, State } from '../../../../../common/store'; import { useUserData } from '../../../../components/user_info'; import { useSourcererScope } from '../../../../../common/containers/sourcerer'; import { useParams } from 'react-router-dom'; -import { mockHistory, Router } from '../../../../../cases/components/__mock__/router'; +import { mockHistory, Router } from '../../../../../common/mock/router'; // Test will fail because we will to need to mock some core services to make the test work // For now let's forget about SiemSearchBar and QueryBar diff --git a/x-pack/plugins/security_solution/public/overview/components/recent_cases/index.tsx b/x-pack/plugins/security_solution/public/overview/components/recent_cases/index.tsx index fc2e2e87ffc5..996835296fcc 100644 --- a/x-pack/plugins/security_solution/public/overview/components/recent_cases/index.tsx +++ b/x-pack/plugins/security_solution/public/overview/components/recent_cases/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useCallback } from 'react'; +import React from 'react'; import { getCaseDetailsUrl, @@ -14,7 +14,7 @@ import { } from '../../../common/components/link_to/redirect_to_case'; import { useFormatUrl } from '../../../common/components/link_to'; import { useKibana } from '../../../common/lib/kibana'; -import { APP_ID } from '../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../common/constants'; import { SecurityPageName } from '../../../app/types'; import { AllCasesNavProps } from '../../../cases/components/all_cases'; @@ -26,33 +26,36 @@ const RecentCasesComponent = () => { application: { navigateToApp }, } = useKibana().services; - const goToCases = useCallback( - (ev) => { - ev.preventDefault(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`); - }, - [navigateToApp] - ); - return casesUi.getRecentCases({ allCasesNavigation: { href: formatUrl(getCaseUrl()), - onClick: goToCases, + onClick: async (e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID); + }, }, caseDetailsNavigation: { href: ({ detailName, subCaseId }: AllCasesNavProps) => { return formatUrl(getCaseDetailsUrl({ id: detailName, subCaseId })); }, - onClick: ({ detailName, subCaseId, search }: AllCasesNavProps) => { - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + onClick: async ({ detailName, subCaseId, search }, e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID, { path: getCaseDetailsUrl({ id: detailName, search, subCaseId }), }); }, }, createCaseNavigation: { href: formatUrl(getCreateCaseUrl()), - onClick: () => { - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + onClick: async (e) => { + if (e) { + e.preventDefault(); + } + return navigateToApp(CASES_APP_ID, { path: getCreateCaseUrl(), }); }, diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index 2e41e291156a..781ed8ffdaa5 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -42,6 +42,7 @@ import { APP_MANAGEMENT_PATH, APP_CASES_PATH, APP_PATH, + CASES_APP_ID, DEFAULT_INDEX_KEY, DETECTION_ENGINE_INDEX_URL, DEFAULT_ALERTS_INDEX, @@ -274,7 +275,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S }); core.application.register({ - id: `${APP_ID}:${SecurityPageName.case}`, + id: CASES_APP_ID, title: CASE, order: 9002, euiIconType: APP_ICON_SOLUTION, diff --git a/x-pack/plugins/security_solution/public/resolver/view/index.tsx b/x-pack/plugins/security_solution/public/resolver/view/index.tsx index db79f820bdca..449ca8deb564 100644 --- a/x-pack/plugins/security_solution/public/resolver/view/index.tsx +++ b/x-pack/plugins/security_solution/public/resolver/view/index.tsx @@ -25,9 +25,7 @@ export const Resolver = React.memo((props: ResolverProps) => { context, ]); - const store = useMemo(() => { - return resolverStoreFactory(dataAccessLayer); - }, [dataAccessLayer]); + const store = useMemo(() => resolverStoreFactory(dataAccessLayer), [dataAccessLayer]); const [activeStore, updateActiveStore] = useState(store); diff --git a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_timeline_button/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_timeline_button/index.test.tsx index 1375f6fb4bcb..2035b1b4be7b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_timeline_button/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_timeline_button/index.test.tsx @@ -13,8 +13,8 @@ import { AddTimelineButton } from './'; import { useKibana } from '../../../../common/lib/kibana'; import { TimelineId } from '../../../../../common/types/timeline'; import { mockOpenTimelineQueryResults, TestProviders } from '../../../../common/mock'; -import { mockHistory, Router } from '../../../../cases/components/__mock__/router'; import { getAllTimeline, useGetAllTimeline } from '../../../containers/all'; +import { mockHistory, Router } from '../../../../common/mock/router'; jest.mock('../../open_timeline/use_timeline_status', () => { const originalModule = jest.requireActual('../../open_timeline/use_timeline_status'); diff --git a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx index dd21b33afa5b..47935347b96a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/flyout/add_to_case_button/index.tsx @@ -11,7 +11,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import { useDispatch } from 'react-redux'; import { Case, SubCase } from '../../../../../../cases/common'; -import { APP_ID } from '../../../../../common/constants'; +import { APP_ID, CASES_APP_ID } from '../../../../../common/constants'; import { timelineSelectors } from '../../../../timelines/store/timeline'; import { setInsertTimeline, showTimeline } from '../../../store/timeline/actions'; import { useDeepEqualSelector } from '../../../../common/hooks/use_selector'; @@ -55,7 +55,7 @@ const AddToCaseButtonComponent: React.FC<Props> = ({ timelineId }) => { const onRowClick = useCallback( async (theCase?: Case | SubCase) => { openCaseModal(false); - await navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + await navigateToApp(CASES_APP_ID, { path: theCase != null ? getCaseDetailsUrl({ id: theCase.id }) : getCreateCaseUrl(), }); dispatch( @@ -88,7 +88,7 @@ const AddToCaseButtonComponent: React.FC<Props> = ({ timelineId }) => { const handleNewCaseClick = useCallback(() => { handlePopoverClose(); - navigateToApp(`${APP_ID}:${SecurityPageName.case}`, { + navigateToApp(CASES_APP_ID, { path: getCreateCaseUrl(), }).then(() => { dispatch( diff --git a/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx index 4ba6fa8b22cd..16c300298e4e 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/all/index.tsx @@ -196,11 +196,12 @@ export const useGetAllTimeline = (): AllTimelinesArgs => { [dispatch, dispatchToaster] ); - useEffect(() => { - return () => { + useEffect( + () => () => { dispatch(inputsActions.deleteOneQuery({ inputId: 'global', id: ALL_TIMELINE_QUERY_ID })); - }; - }, [dispatch]); + }, + [dispatch] + ); return { ...allTimelines, diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 70504076a55f..534a8ad8a084 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -18913,10 +18913,7 @@ "xpack.securitySolution.callouts.dismissButton": "閉じる", "xpack.securitySolution.cases.allCases.actions": "アクション", "xpack.securitySolution.cases.allCases.comments": "コメント", - "xpack.securitySolution.cases.allCases.noTagsAvailable": "利用可能なタグがありません", "xpack.securitySolution.cases.caseTable.caseDetailsLinkAria": "クリックすると、タイトル{detailName}のケースを表示します", - "xpack.securitySolution.cases.caseTable.closedCases": "終了したケース", - "xpack.securitySolution.cases.caseTable.inProgressCases": "進行中のケース", "xpack.securitySolution.cases.caseTable.openCases": "ケースを開く", "xpack.securitySolution.cases.caseView.backLabel": "ケースに戻る", "xpack.securitySolution.cases.caseView.breadcrumb": "作成", @@ -18924,20 +18921,13 @@ "xpack.securitySolution.cases.caseView.caseName": "ケース名", "xpack.securitySolution.cases.caseView.closeCase": "ケースを閉じる", "xpack.securitySolution.cases.caseView.closedOn": "終了日", - "xpack.securitySolution.cases.caseView.comment.addComment": "コメントを追加", - "xpack.securitySolution.cases.caseView.comment.addCommentHelpText": "新しいコメントを追加...", - "xpack.securitySolution.cases.caseView.commentFieldRequiredError": "コメントが必要です。", "xpack.securitySolution.cases.caseView.connectors": "外部インシデント管理システム", "xpack.securitySolution.cases.caseView.create": "新規ケースを作成", "xpack.securitySolution.cases.caseView.createCase": "ケースを作成", "xpack.securitySolution.cases.caseView.description": "説明", "xpack.securitySolution.cases.caseView.description.save": "保存", "xpack.securitySolution.cases.caseView.edit": "編集", - "xpack.securitySolution.cases.caseView.editConnector": "外部インシデント管理システムを変更", - "xpack.securitySolution.cases.caseView.fieldRequiredError": "必須フィールド", "xpack.securitySolution.cases.caseView.goToDocumentationButton": "ドキュメンテーションを表示", - "xpack.securitySolution.cases.caseView.markedCaseAs": "ケースを設定", - "xpack.securitySolution.cases.caseView.markInProgress": "実行中に設定", "xpack.securitySolution.cases.caseView.name": "名前", "xpack.securitySolution.cases.caseView.noReportersAvailable": "利用可能なレポートがありません。", "xpack.securitySolution.cases.caseView.noTags": "現在、このケースにタグは割り当てられていません。", @@ -18945,24 +18935,18 @@ "xpack.securitySolution.cases.caseView.openedOn": "開始日", "xpack.securitySolution.cases.caseView.optional": "オプション", "xpack.securitySolution.cases.caseView.particpantsLabel": "参加者", - "xpack.securitySolution.cases.caseView.reopenCase": "ケースを再開", "xpack.securitySolution.cases.caseView.reporterLabel": "報告者", "xpack.securitySolution.cases.caseView.sendAlertToTimelineTooltip": "タイムラインで調査", "xpack.securitySolution.cases.caseView.tags": "タグ", "xpack.securitySolution.cases.caseView.to": "に", "xpack.securitySolution.cases.caseView.unknown": "不明", - "xpack.securitySolution.cases.common.noConnector": "コネクターを選択していません", "xpack.securitySolution.cases.configureCases.headerTitle": "ケースを構成", - "xpack.securitySolution.cases.configureCasesButton": "外部接続を編集", "xpack.securitySolution.cases.confirmDeleteCase.deleteCase": "ケースを削除", "xpack.securitySolution.cases.confirmDeleteCase.deleteCases": "ケースを削除", "xpack.securitySolution.cases.createCase.descriptionFieldRequiredError": "説明が必要です。", - "xpack.securitySolution.cases.createCase.fieldTagsHelpText": "このケースの1つ以上のカスタム識別タグを入力します。新しいタグを開始するには、各タグの後でEnterを押します。", "xpack.securitySolution.cases.createCase.titleFieldRequiredError": "タイトルが必要です。", "xpack.securitySolution.cases.dismissErrorsPushServiceCallOutTitle": "閉じる", "xpack.securitySolution.cases.pageTitle": "ケース", - "xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOff": "オフ", - "xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOn": "オン", "xpack.securitySolution.cases.timeline.actions.addCase": "ケースに追加", "xpack.securitySolution.cases.timeline.actions.addExistingCase": "既存のケースに追加", "xpack.securitySolution.cases.timeline.actions.addNewCase": "新しいケースに追加", @@ -18988,7 +18972,6 @@ "xpack.securitySolution.common.alertAddedToCase": "ケースに追加しました", "xpack.securitySolution.common.alertLabel": "アラート", "xpack.securitySolution.common.allCases.table.selectableMessageCollections": "ケースとサブケースを選択することはできません", - "xpack.securitySolution.components.create.syncAlertHelpText": "このオプションを有効にすると、このケースのアラートのステータスをケースステータスと同期します。", "xpack.securitySolution.components.embeddables.embeddedMap.clientLayerLabel": "クライアントポイント", "xpack.securitySolution.components.embeddables.embeddedMap.destinationLayerLabel": "デスティネーションポイント", "xpack.securitySolution.components.embeddables.embeddedMap.embeddableHeaderHelp": "マップ構成ヘルプ", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 1ab121479a01..40f10abddebb 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -19181,10 +19181,7 @@ "xpack.securitySolution.callouts.dismissButton": "关闭", "xpack.securitySolution.cases.allCases.actions": "操作", "xpack.securitySolution.cases.allCases.comments": "注释", - "xpack.securitySolution.cases.allCases.noTagsAvailable": "没有可用标签", "xpack.securitySolution.cases.caseTable.caseDetailsLinkAria": "单击以访问标题为 {detailName} 的案例", - "xpack.securitySolution.cases.caseTable.closedCases": "已关闭案例", - "xpack.securitySolution.cases.caseTable.inProgressCases": "进行中的案例", "xpack.securitySolution.cases.caseTable.openCases": "未结案例", "xpack.securitySolution.cases.caseView.backLabel": "返回到案例", "xpack.securitySolution.cases.caseView.breadcrumb": "创建", @@ -19192,20 +19189,13 @@ "xpack.securitySolution.cases.caseView.caseName": "案例名称", "xpack.securitySolution.cases.caseView.closeCase": "关闭案例", "xpack.securitySolution.cases.caseView.closedOn": "关闭日期", - "xpack.securitySolution.cases.caseView.comment.addComment": "添加注释", - "xpack.securitySolution.cases.caseView.comment.addCommentHelpText": "添加新注释......", - "xpack.securitySolution.cases.caseView.commentFieldRequiredError": "注释必填。", "xpack.securitySolution.cases.caseView.connectors": "外部事件管理系统", "xpack.securitySolution.cases.caseView.create": "创建新案例", "xpack.securitySolution.cases.caseView.createCase": "创建案例", "xpack.securitySolution.cases.caseView.description": "描述", "xpack.securitySolution.cases.caseView.description.save": "保存", "xpack.securitySolution.cases.caseView.edit": "编辑", - "xpack.securitySolution.cases.caseView.editConnector": "更改外部事件管理系统", - "xpack.securitySolution.cases.caseView.fieldRequiredError": "必填字段", "xpack.securitySolution.cases.caseView.goToDocumentationButton": "查看文档", - "xpack.securitySolution.cases.caseView.markedCaseAs": "将案例标记为", - "xpack.securitySolution.cases.caseView.markInProgress": "标记为进行中", "xpack.securitySolution.cases.caseView.name": "名称", "xpack.securitySolution.cases.caseView.noReportersAvailable": "没有报告者。", "xpack.securitySolution.cases.caseView.noTags": "当前没有为此案例分配标签。", @@ -19213,24 +19203,18 @@ "xpack.securitySolution.cases.caseView.openedOn": "打开时间", "xpack.securitySolution.cases.caseView.optional": "可选", "xpack.securitySolution.cases.caseView.particpantsLabel": "参与者", - "xpack.securitySolution.cases.caseView.reopenCase": "重新打开案例", "xpack.securitySolution.cases.caseView.reporterLabel": "报告者", "xpack.securitySolution.cases.caseView.sendAlertToTimelineTooltip": "在时间线中调查", "xpack.securitySolution.cases.caseView.tags": "标签", "xpack.securitySolution.cases.caseView.to": "到", "xpack.securitySolution.cases.caseView.unknown": "未知", - "xpack.securitySolution.cases.common.noConnector": "未选择任何连接器", "xpack.securitySolution.cases.configureCases.headerTitle": "配置案例", - "xpack.securitySolution.cases.configureCasesButton": "编辑外部连接", "xpack.securitySolution.cases.confirmDeleteCase.deleteCase": "删除案例", "xpack.securitySolution.cases.confirmDeleteCase.deleteCases": "删除案例", "xpack.securitySolution.cases.createCase.descriptionFieldRequiredError": "描述必填。", - "xpack.securitySolution.cases.createCase.fieldTagsHelpText": "为此案例键入一个或多个定制识别标签。在每个标签后按 Enter 键可开始新的标签。", "xpack.securitySolution.cases.createCase.titleFieldRequiredError": "标题必填。", "xpack.securitySolution.cases.dismissErrorsPushServiceCallOutTitle": "关闭", "xpack.securitySolution.cases.pageTitle": "案例", - "xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOff": "关闭", - "xpack.securitySolution.cases.settings.syncAlertsSwitchLabelOn": "开启", "xpack.securitySolution.cases.timeline.actions.addCase": "添加到案例", "xpack.securitySolution.cases.timeline.actions.addExistingCase": "添加到现有案例", "xpack.securitySolution.cases.timeline.actions.addNewCase": "添加到新案例", @@ -19256,7 +19240,6 @@ "xpack.securitySolution.common.alertAddedToCase": "已添加到案例", "xpack.securitySolution.common.alertLabel": "告警", "xpack.securitySolution.common.allCases.table.selectableMessageCollections": "无法选择具有子案例的案例", - "xpack.securitySolution.components.create.syncAlertHelpText": "启用此选项将使本案例中的告警状态与案例状态同步。", "xpack.securitySolution.components.embeddables.embeddedMap.clientLayerLabel": "客户端点", "xpack.securitySolution.components.embeddables.embeddedMap.destinationLayerLabel": "目标点", "xpack.securitySolution.components.embeddables.embeddedMap.embeddableHeaderHelp": "地图配置帮助",