diff --git a/x-pack/plugins/cases/common/api/saved_object.ts b/x-pack/plugins/cases/common/api/saved_object.ts index 2ed6ec2acdfe46..44af143284bce0 100644 --- a/x-pack/plugins/cases/common/api/saved_object.ts +++ b/x-pack/plugins/cases/common/api/saved_object.ts @@ -68,5 +68,3 @@ export const SavedObjectFindOptionsRt = rt.partial({ */ sortOrder: rt.union([rt.literal('desc'), rt.literal('asc')]), }); - -export type SavedObjectFindOptions = rt.TypeOf; diff --git a/x-pack/plugins/cases/common/index.ts b/x-pack/plugins/cases/common/index.ts index 16ccaaf5602fac..6483bba8ce4f26 100644 --- a/x-pack/plugins/cases/common/index.ts +++ b/x-pack/plugins/cases/common/index.ts @@ -39,12 +39,14 @@ export { export type { Case, + Cases, CasesBulkGetRequestCertainFields, CasesBulkGetResponseCertainFields, } from './api'; export type { - Case, + CaseUI, + CasesUI, Ecs, CasesFeatures, CaseViewRefreshPropInterface, diff --git a/x-pack/plugins/cases/common/ui/types.ts b/x-pack/plugins/cases/common/ui/types.ts index c7808e3c0a1adf..c513f5a8e23377 100644 --- a/x-pack/plugins/cases/common/ui/types.ts +++ b/x-pack/plugins/cases/common/ui/types.ts @@ -20,7 +20,7 @@ import type { CaseUserActionResponse, SingleCaseMetricsResponse, CommentResponse, - Case, + Case as CaseSnakeCase, UserActionFindResponse, FindTypeField as UserActionFindTypeField, CommentResponseAlertsType, @@ -92,8 +92,8 @@ export type FindCaseUserActions = Omit, userActions: CaseUserActions[]; }; export type CaseUserActionsStats = SnakeToCamelCase; -export type Case = Omit, 'comments'> & { comments: Comment[] }; -export type Cases = Omit, 'cases'> & { cases: Case[] }; +export type CaseUI = Omit, 'comments'> & { comments: Comment[] }; +export type CasesUI = Omit, 'cases'> & { cases: CaseUI[] }; export type CasesStatus = SnakeToCamelCase; export type CasesMetrics = SnakeToCamelCase; export type CaseUpdateRequest = SnakeToCamelCase; @@ -101,7 +101,7 @@ export type CaseConnectors = SnakeToCamelCase; export type CaseUsers = GetCaseUsersResponse; export interface ResolvedCase { - case: Case; + case: CaseUI; outcome: ResolvedSimpleSavedObject['outcome']; aliasTargetId?: ResolvedSimpleSavedObject['alias_target_id']; aliasPurpose?: ResolvedSimpleSavedObject['alias_purpose']; @@ -191,7 +191,7 @@ export type UpdateKey = keyof Pick< export interface UpdateByKey { updateKey: UpdateKey; updateValue: CasePatchRequest[UpdateKey]; - caseData: Case; + caseData: CaseUI; onSuccess?: () => void; onError?: () => void; } diff --git a/x-pack/plugins/cases/public/api/index.ts b/x-pack/plugins/cases/public/api/index.ts index 0e4e93370f3884..9d30cd0b585570 100644 --- a/x-pack/plugins/cases/public/api/index.ts +++ b/x-pack/plugins/cases/public/api/index.ts @@ -6,7 +6,7 @@ */ import type { HttpStart } from '@kbn/core/public'; -import type { Cases, CasesStatus, CasesMetrics } from '../../common/ui'; +import type { CasesUI, CasesStatus, CasesMetrics } from '../../common/ui'; import { CASE_FIND_URL, CASE_METRICS_URL, @@ -41,7 +41,7 @@ export const getCases = async ({ http, signal, query, -}: HTTPService & { query: CasesFindRequest }): Promise => { +}: HTTPService & { query: CasesFindRequest }): Promise => { const res = await http.get(CASE_FIND_URL, { query, signal }); return convertAllCasesToCamel(decodeCasesFindResponse(res)); }; diff --git a/x-pack/plugins/cases/public/api/utils.ts b/x-pack/plugins/cases/public/api/utils.ts index 9437581ece8b31..d463fb43042492 100644 --- a/x-pack/plugins/cases/public/api/utils.ts +++ b/x-pack/plugins/cases/public/api/utils.ts @@ -21,7 +21,7 @@ import type { Cases, } from '../../common/api'; import { isCommentUserAction } from '../../common/utils/user_actions'; -import type { Cases, Case, Comment, ResolvedCase } from '../containers/types'; +import type { CasesUI, CaseUI, Comment, ResolvedCase } from '../containers/types'; export const convertArrayToCamelCase = (arrayOfSnakes: unknown[]): unknown[] => arrayOfSnakes.reduce((acc: unknown[], value) => { @@ -46,15 +46,16 @@ export const convertToCamelCase = (obj: T): U => return acc; }, {} as U); -export const convertCaseToCamelCase = (theCase: Case): Case => { +export const convertCaseToCamelCase = (theCase: Case): CaseUI => { const { comments, ...restCase } = theCase; return { - ...convertToCamelCase(restCase), + ...convertToCamelCase(restCase), ...(comments != null ? { comments: convertAttachmentsToCamelCase(comments) } : {}), }; }; -export const convertCasesToCamelCase = (cases: Cases): Case[] => cases.map(convertCaseToCamelCase); +export const convertCasesToCamelCase = (cases: Cases): CaseUI[] => + cases.map(convertCaseToCamelCase); export const convertCaseResolveToCamelCase = (res: CaseResolveResponse): ResolvedCase => { const { case: theCase, ...rest } = res; @@ -112,7 +113,7 @@ const convertAttachmentToCamelExceptProperty = ( } as Comment; }; -export const convertAllCasesToCamel = (snakeCases: CasesFindResponse): Cases => ({ +export const convertAllCasesToCamel = (snakeCases: CasesFindResponse): CasesUI => ({ cases: convertCasesToCamelCase(snakeCases.cases), countOpenCases: snakeCases.count_open_cases, countInProgressCases: snakeCases.count_in_progress_cases, diff --git a/x-pack/plugins/cases/public/client/api/index.ts b/x-pack/plugins/cases/public/client/api/index.ts index 09a172121d08cf..d040c3a8e7fb9e 100644 --- a/x-pack/plugins/cases/public/client/api/index.ts +++ b/x-pack/plugins/cases/public/client/api/index.ts @@ -14,7 +14,7 @@ import type { CasesMetricsRequest, } from '../../../common/api'; import { getCasesFromAlertsUrl } from '../../../common/api'; -import type { Cases, CasesStatus, CasesMetrics } from '../../../common/ui'; +import type { CasesUI, CasesStatus, CasesMetrics } from '../../../common/ui'; import { bulkGetCases, getCases, getCasesMetrics, getCasesStatus } from '../../api'; import type { CasesUiStart } from '../../types'; @@ -26,7 +26,7 @@ export const createClientAPI = ({ http }: { http: HttpStart }): CasesUiStart['ap ): Promise => http.get(getCasesFromAlertsUrl(alertId), { query }), cases: { - find: (query: CasesFindRequest, signal?: AbortSignal): Promise => + find: (query: CasesFindRequest, signal?: AbortSignal): Promise => getCases({ http, query, signal }), getCasesStatus: (query: CasesStatusRequest, signal?: AbortSignal): Promise => getCasesStatus({ http, query, signal }), diff --git a/x-pack/plugins/cases/public/client/attachment_framework/types.ts b/x-pack/plugins/cases/public/client/attachment_framework/types.ts index 95a453b9d0a12b..793bcca8d15eb4 100644 --- a/x-pack/plugins/cases/public/client/attachment_framework/types.ts +++ b/x-pack/plugins/cases/public/client/attachment_framework/types.ts @@ -11,7 +11,7 @@ import type { CommentRequestExternalReferenceType, CommentRequestPersistableStateType, } from '../../../common/api'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; export enum AttachmentActionType { BUTTON = 'button', @@ -48,7 +48,7 @@ export interface AttachmentViewObject { } export interface CommonAttachmentViewProps { - caseData: Pick; + caseData: Pick; } export interface ExternalReferenceAttachmentViewProps extends CommonAttachmentViewProps { diff --git a/x-pack/plugins/cases/public/client/helpers/can_use_cases.ts b/x-pack/plugins/cases/public/client/helpers/can_use_cases.ts index 34af1c3865da55..954edeac81713f 100644 --- a/x-pack/plugins/cases/public/client/helpers/can_use_cases.ts +++ b/x-pack/plugins/cases/public/client/helpers/can_use_cases.ts @@ -65,5 +65,5 @@ const getFeatureID = (owner: CasesOwners) => { return FEATURE_ID; } - return `${owner}Cases`; + return `${owner}CasesUI`; }; diff --git a/x-pack/plugins/cases/public/common/apm/use_cases_transactions.test.ts b/x-pack/plugins/cases/public/common/apm/use_cases_transactions.test.ts index 5438258187a2f1..a7ae41f218603f 100644 --- a/x-pack/plugins/cases/public/common/apm/use_cases_transactions.test.ts +++ b/x-pack/plugins/cases/public/common/apm/use_cases_transactions.test.ts @@ -57,7 +57,7 @@ describe('cases transactions', () => { result.current.startTransaction({ appId }); - expect(mockStartTransaction).toHaveBeenCalledWith(`Cases [${appId}] createCase`); + expect(mockStartTransaction).toHaveBeenCalledWith(`CasesUI [${appId}] createCase`); expect(mockAddLabels).not.toHaveBeenCalled(); }); @@ -66,7 +66,9 @@ describe('cases transactions', () => { result.current.startTransaction({ appId, attachments: singleAttachments }); - expect(mockStartTransaction).toHaveBeenCalledWith(`Cases [${appId}] addAttachmentToNewCase`); + expect(mockStartTransaction).toHaveBeenCalledWith( + `CasesUI [${appId}] addAttachmentToNewCase` + ); expect(mockAddLabels).not.toHaveBeenCalled(); }); @@ -76,7 +78,7 @@ describe('cases transactions', () => { result.current.startTransaction({ appId, attachments: bulkAttachments }); expect(mockStartTransaction).toHaveBeenCalledWith( - `Cases [${appId}] bulkAddAttachmentsToNewCase` + `CasesUI [${appId}] bulkAddAttachmentsToNewCase` ); expect(mockAddLabels).toHaveBeenCalledWith({ alert_count: 3 }); }); @@ -89,7 +91,7 @@ describe('cases transactions', () => { result.current.startTransaction({ appId, attachments: singleAttachments }); expect(mockStartTransaction).toHaveBeenCalledWith( - `Cases [${appId}] addAttachmentToExistingCase` + `CasesUI [${appId}] addAttachmentToExistingCase` ); expect(mockAddLabels).not.toHaveBeenCalled(); }); @@ -100,7 +102,7 @@ describe('cases transactions', () => { result.current.startTransaction({ appId, attachments: bulkAttachments }); expect(mockStartTransaction).toHaveBeenCalledWith( - `Cases [${appId}] bulkAddAttachmentsToExistingCase` + `CasesUI [${appId}] bulkAddAttachmentsToExistingCase` ); expect(mockAddLabels).toHaveBeenCalledWith({ alert_count: 3 }); }); diff --git a/x-pack/plugins/cases/public/common/apm/use_cases_transactions.ts b/x-pack/plugins/cases/public/common/apm/use_cases_transactions.ts index 1a4be4053b7ef0..0b8d4f529662e0 100644 --- a/x-pack/plugins/cases/public/common/apm/use_cases_transactions.ts +++ b/x-pack/plugins/cases/public/common/apm/use_cases_transactions.ts @@ -30,14 +30,16 @@ export const useCreateCaseWithAttachmentsTransaction = () => { useCallback( ({ appId, attachments }) => { if (!attachments) { - return startTransaction(`Cases [${appId}] ${CREATE_CASE}`); + return startTransaction(`CasesUI [${appId}] ${CREATE_CASE}`); } const alertCount = getAlertCount(attachments); if (alertCount <= 1) { - return startTransaction(`Cases [${appId}] ${ADD_ATTACHMENT_TO_NEW_CASE}`); + return startTransaction(`CasesUI [${appId}] ${ADD_ATTACHMENT_TO_NEW_CASE}`); } - const transaction = startTransaction(`Cases [${appId}] ${BULK_ADD_ATTACHMENT_TO_NEW_CASE}`); + const transaction = startTransaction( + `CasesUI [${appId}] ${BULK_ADD_ATTACHMENT_TO_NEW_CASE}` + ); transaction?.addLabels({ alert_count: alertCount }); return transaction; }, @@ -61,10 +63,10 @@ export const useAddAttachmentToExistingCaseTransaction = () => { ({ appId, attachments }) => { const alertCount = getAlertCount(attachments); if (alertCount <= 1) { - return startTransaction(`Cases [${appId}] ${ADD_ATTACHMENT_TO_EXISTING_CASE}`); + return startTransaction(`CasesUI [${appId}] ${ADD_ATTACHMENT_TO_EXISTING_CASE}`); } const transaction = startTransaction( - `Cases [${appId}] ${BULK_ADD_ATTACHMENT_TO_EXISTING_CASE}` + `CasesUI [${appId}] ${BULK_ADD_ATTACHMENT_TO_EXISTING_CASE}` ); transaction?.addLabels({ alert_count: alertCount }); return transaction; diff --git a/x-pack/plugins/cases/public/common/apm/use_start_transaction.ts b/x-pack/plugins/cases/public/common/apm/use_start_transaction.ts index 5951b6454cb42d..69a1325a01b869 100644 --- a/x-pack/plugins/cases/public/common/apm/use_start_transaction.ts +++ b/x-pack/plugins/cases/public/common/apm/use_start_transaction.ts @@ -15,7 +15,7 @@ import { useCallback } from 'react'; import type { TransactionOptions } from '@elastic/apm-rum'; import { useKibana } from '../lib/kibana'; -export type CasesApmTransactionName = `Cases [${string}] ${string}`; +export type CasesApmTransactionName = `CasesUI [${string}] ${string}`; interface StartTransactionOptions { type?: string; diff --git a/x-pack/plugins/cases/public/common/lib/kibana/services.ts b/x-pack/plugins/cases/public/common/lib/kibana/services.ts index ab06c1be0bf022..2a238f0fb7a3bb 100644 --- a/x-pack/plugins/cases/public/common/lib/kibana/services.ts +++ b/x-pack/plugins/cases/public/common/lib/kibana/services.ts @@ -50,7 +50,7 @@ export class KibanaServices { private static throwUninitializedError(): never { throw new Error( - 'Kibana services not initialized - are you trying to import this module from outside of the Cases app?' + 'Kibana services not initialized - are you trying to import this module from outside of the CasesUI app?' ); } } diff --git a/x-pack/plugins/cases/public/common/navigation/deep_links.test.ts b/x-pack/plugins/cases/public/common/navigation/deep_links.test.ts index af8685cd16fb64..6c3fb5de3c78a1 100644 --- a/x-pack/plugins/cases/public/common/navigation/deep_links.test.ts +++ b/x-pack/plugins/cases/public/common/navigation/deep_links.test.ts @@ -14,17 +14,17 @@ describe('getCasesDeepLinks', () => { expect(deepLinks).toEqual({ id: 'cases', path: '/cases', - title: 'Cases', + title: 'CasesUI', deepLinks: [ { id: 'cases_create', path: '/cases/create', - title: 'Create New Case', + title: 'Create New CaseUI', }, { id: 'cases_configure', path: '/cases/configure', - title: 'Configure Cases', + title: 'Configure CasesUI', }, ], }); @@ -35,17 +35,17 @@ describe('getCasesDeepLinks', () => { expect(deepLinks).toEqual({ id: 'cases', path: '/test', - title: 'Cases', + title: 'CasesUI', deepLinks: [ { id: 'cases_create', path: '/test/create', - title: 'Create New Case', + title: 'Create New CaseUI', }, { id: 'cases_configure', path: '/test/configure', - title: 'Configure Cases', + title: 'Configure CasesUI', }, ], }); @@ -69,19 +69,19 @@ describe('getCasesDeepLinks', () => { expect(deepLinks).toEqual({ id: 'cases', path: '/cases', - title: 'Cases', + title: 'CasesUI', searchable: false, deepLinks: [ { id: 'cases_create', path: '/cases/create', - title: 'Create New Case', + title: 'Create New CaseUI', navLinkStatus: AppNavLinkStatus.hidden, }, { id: 'cases_configure', path: '/cases/configure', - title: 'Configure Cases', + title: 'Configure CasesUI', order: 8002, }, ], @@ -110,17 +110,17 @@ describe('getCasesDeepLinks', () => { expect(deepLinks).toEqual({ id: 'cases', path: '/cases', - title: 'Cases', + title: 'CasesUI', deepLinks: [ { id: 'cases_create', path: '/cases/create', - title: 'Create New Case', + title: 'Create New CaseUI', }, { id: 'cases_configure', path: '/cases/configure', - title: 'Configure Cases', + title: 'Configure CasesUI', }, ], }); diff --git a/x-pack/plugins/cases/public/common/navigation/deep_links.ts b/x-pack/plugins/cases/public/common/navigation/deep_links.ts index 6743d22e74dac4..abab696d066b1b 100644 --- a/x-pack/plugins/cases/public/common/navigation/deep_links.ts +++ b/x-pack/plugins/cases/public/common/navigation/deep_links.ts @@ -25,7 +25,7 @@ export const getCasesDeepLinks = ({ extend?: Partial>>; }) => ({ title: i18n.translate('xpack.cases.navigation.cases', { - defaultMessage: 'Cases', + defaultMessage: 'CasesUI', }), ...(extend[CasesDeepLinkId.cases] ?? {}), id: CasesDeepLinkId.cases, @@ -33,7 +33,7 @@ export const getCasesDeepLinks = ({ deepLinks: [ { title: i18n.translate('xpack.cases.navigation.create', { - defaultMessage: 'Create New Case', + defaultMessage: 'Create New CaseUI', }), ...(extend[CasesDeepLinkId.casesCreate] ?? {}), id: CasesDeepLinkId.casesCreate, @@ -41,7 +41,7 @@ export const getCasesDeepLinks = ({ }, { title: i18n.translate('xpack.cases.navigation.configure', { - defaultMessage: 'Configure Cases', + defaultMessage: 'Configure CasesUI', }), ...(extend[CasesDeepLinkId.casesConfigure] ?? {}), id: CasesDeepLinkId.casesConfigure, diff --git a/x-pack/plugins/cases/public/common/navigation/hooks.ts b/x-pack/plugins/cases/public/common/navigation/hooks.ts index 81b59c9b426370..86bd9a8f6af178 100644 --- a/x-pack/plugins/cases/public/common/navigation/hooks.ts +++ b/x-pack/plugins/cases/public/common/navigation/hooks.ts @@ -59,7 +59,7 @@ export const useCasesNavigation = ({ }; /** - * Cases can be either be part of a solution or a standalone application + * CasesUI can be either be part of a solution or a standalone application * The standalone application is registered from the cases plugin and is called * the main application. The main application uses paths and the solutions * deep links. diff --git a/x-pack/plugins/cases/public/common/translations.ts b/x-pack/plugins/cases/public/common/translations.ts index e691e712becd9c..ac99f2c26d36a2 100644 --- a/x-pack/plugins/cases/public/common/translations.ts +++ b/x-pack/plugins/cases/public/common/translations.ts @@ -22,11 +22,11 @@ export const DELETE_CASE = (quantity: number = 1) => }); export const COPY_ID_ACTION_LABEL = i18n.translate('xpack.cases.caseView.copyID', { - defaultMessage: 'Copy Case ID', + defaultMessage: 'Copy CaseUI ID', }); export const COPY_ID_ACTION_SUCCESS = i18n.translate('xpack.cases.caseView.copyIDSuccess', { - defaultMessage: 'Copied Case ID to clipboard', + defaultMessage: 'Copied CaseUI ID to clipboard', }); export const NAME = i18n.translate('xpack.cases.caseView.name', { @@ -102,7 +102,7 @@ export const OPTIONAL = i18n.translate('xpack.cases.caseView.optional', { }); export const PAGE_TITLE = i18n.translate('xpack.cases.pageTitle', { - defaultMessage: 'Cases', + defaultMessage: 'CasesUI', }); export const CREATE_CASE = i18n.translate('xpack.cases.caseView.createCase', { @@ -126,7 +126,7 @@ export const OPEN_CASE = i18n.translate('xpack.cases.caseView.openCase', { }); export const CASE_NAME = i18n.translate('xpack.cases.caseView.caseName', { - defaultMessage: 'Case name', + defaultMessage: 'CaseUI name', }); export const TO = i18n.translate('xpack.cases.caseView.to', { @@ -296,7 +296,7 @@ export const VIEW_CASE = i18n.translate('xpack.cases.actions.viewCase', { }); export const APP_TITLE = i18n.translate('xpack.cases.common.appTitle', { - defaultMessage: 'Cases', + defaultMessage: 'CasesUI', }); export const APP_DESC = i18n.translate('xpack.cases.common.appDescription', { diff --git a/x-pack/plugins/cases/public/common/use_cases_toast.tsx b/x-pack/plugins/cases/public/common/use_cases_toast.tsx index 26027905f8f0ea..d123cc1bdd5e8b 100644 --- a/x-pack/plugins/cases/public/common/use_cases_toast.tsx +++ b/x-pack/plugins/cases/public/common/use_cases_toast.tsx @@ -11,7 +11,7 @@ import React from 'react'; import styled from 'styled-components'; import { toMountPoint } from '@kbn/kibana-react-plugin/public'; import { isValidOwner } from '../../common/utils/owner'; -import type { Case } from '../../common'; +import type { CaseUI } from '../../common'; import { CommentType } from '../../common'; import { useKibana, useToasts } from './lib/kibana'; import { generateCaseViewPath } from './navigation'; @@ -61,7 +61,7 @@ function getToastTitle({ title, attachments, }: { - theCase: Case; + theCase: CaseUI; title?: string; attachments?: CaseAttachmentsWithoutOwner; }): string { @@ -82,7 +82,7 @@ function getToastContent({ content, attachments, }: { - theCase: Case; + theCase: CaseUI; content?: string; attachments?: CaseAttachmentsWithoutOwner; }): string | undefined { @@ -131,7 +131,7 @@ export const useCasesToast = () => { title, content, }: { - theCase: Case; + theCase: CaseUI; attachments?: CaseAttachmentsWithoutOwner; title?: string; content?: string; diff --git a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.test.tsx b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.test.tsx index d6f65ff09b694e..5a8a4a7d88934d 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.test.tsx @@ -20,8 +20,8 @@ describe('EditAssigneesFlyout', () => { let appMock: AppMockRenderer; /** - * Case one has the following assignees: coke, pepsi, one - * Case two has the following assignees: one, three + * CaseUI one has the following assignees: coke, pepsi, one + * CaseUI two has the following assignees: one, three * All available assignees are: one, two, three, coke, pepsi */ const props = { diff --git a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.tsx b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.tsx index 42f4ef30ec5941..2d9ee31171e420 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_flyout.tsx @@ -21,13 +21,13 @@ import { EuiTitle, } from '@elastic/eui'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { EditAssigneesSelectable } from './edit_assignees_selectable'; import * as i18n from './translations'; import type { ItemsSelectionState } from '../types'; interface Props { - selectedCases: Case[]; + selectedCases: CaseUI[]; onClose: () => void; onSaveAssignees: (args: ItemsSelectionState) => void; } diff --git a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.test.tsx b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.test.tsx index 60a19df11b04a4..d613e3cf2fc23d 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.test.tsx @@ -21,7 +21,7 @@ describe('EditAssigneesSelectable', () => { let appMock: AppMockRenderer; /** - * Case has the following tags: Damaged Raccoon + * CaseUI has the following tags: Damaged Raccoon * All available tags are: Damaged Raccoon, Physical Dinosaur, Wet Dingo */ const props = { @@ -31,8 +31,8 @@ describe('EditAssigneesSelectable', () => { }; /** - * Case one has the following assignees: Damaged Raccoon - * Case two has the following assignees: Damaged Raccoon, Physical Dinosaur + * CaseUI one has the following assignees: Damaged Raccoon + * CaseUI two has the following assignees: Damaged Raccoon, Physical Dinosaur * All available assignees are: Damaged Raccoon, Physical Dinosaur, Wet Dingo, Silly Hare, Convenient Orca */ const propsMultipleCases = { diff --git a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx index afcbbd4e165f57..3630c7114c0095 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/edit_assignees_selectable.tsx @@ -27,7 +27,7 @@ import { getUserDisplayName } from '@kbn/user-profile-components'; import { useBulkGetUserProfiles } from '../../../containers/user_profiles/use_bulk_get_user_profiles'; import { useIsUserTyping } from '../../../common/use_is_user_typing'; import { useSuggestUserProfiles } from '../../../containers/user_profiles/use_suggest_user_profiles'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import * as i18n from './translations'; import { useItemsState } from '../use_items_state'; import type { ItemSelectableOption, ItemsSelectionState } from '../types'; @@ -38,7 +38,7 @@ import { SmallUserAvatar } from '../../user_profiles/small_user_avatar'; import { NoSelectedAssignees } from './no_selected_assignees'; interface Props { - selectedCases: Case[]; + selectedCases: CaseUI[]; onChangeAssignees: (args: ItemsSelectionState) => void; } diff --git a/x-pack/plugins/cases/public/components/actions/assignees/use_assignees_action.tsx b/x-pack/plugins/cases/public/components/actions/assignees/use_assignees_action.tsx index f2b1cb6947c9b3..76e5d2239135e7 100644 --- a/x-pack/plugins/cases/public/components/actions/assignees/use_assignees_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/assignees/use_assignees_action.tsx @@ -7,14 +7,14 @@ import { EuiIcon } from '@elastic/eui'; import React from 'react'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import type { UseActionProps } from '../types'; import { useItemsAction } from '../use_items_action'; import * as i18n from './translations'; export const useAssigneesAction = ({ onAction, onActionSuccess, isDisabled }: UseActionProps) => { const { isFlyoutOpen, onFlyoutClosed, onSaveItems, openFlyout, isActionDisabled } = - useItemsAction({ + useItemsAction({ fieldKey: 'assignees', isDisabled, onAction, @@ -27,7 +27,7 @@ export const useAssigneesAction = ({ onAction, onActionSuccess, isDisabled }: Us })), }); - const getAction = (selectedCases: Case[]) => { + const getAction = (selectedCases: CaseUI[]) => { return { name: i18n.EDIT_ASSIGNEES, onClick: () => openFlyout(selectedCases), diff --git a/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.test.tsx b/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.test.tsx index 0c33980b3ab63d..fb2d48f8e122ee 100644 --- a/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.test.tsx @@ -50,7 +50,7 @@ describe('useCopyIDAction', () => { />, "key": "cases-action-copy-id", "name": - Copy Case ID + Copy CaseUI ID , "onClick": [Function], } @@ -84,7 +84,7 @@ describe('useCopyIDAction', () => { await waitFor(() => { expect(onActionSuccess).toHaveBeenCalled(); expect(appMockRender.coreStart.notifications.toasts.addSuccess).toHaveBeenCalledWith({ - title: 'Copied Case ID to clipboard', + title: 'Copied CaseUI ID to clipboard', className: 'eui-textBreakWord', }); }); diff --git a/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.tsx b/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.tsx index be2166ba5b2504..260726daa59502 100644 --- a/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/copy_id/use_copy_id_action.tsx @@ -10,13 +10,13 @@ import { EuiIcon, EuiTextColor } from '@elastic/eui'; import * as i18n from '../../../common/translations'; import { useCasesToast } from '../../../common/use_cases_toast'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import type { UseCopyIDActionProps } from '../types'; export const useCopyIDAction = ({ onActionSuccess }: UseCopyIDActionProps) => { const { showSuccessToast } = useCasesToast(); - const getAction = (selectedCase: Case) => { + const getAction = (selectedCase: CaseUI) => { return { name: {i18n.COPY_ID_ACTION_LABEL}, onClick: () => { diff --git a/x-pack/plugins/cases/public/components/actions/delete/use_delete_action.tsx b/x-pack/plugins/cases/public/components/actions/delete/use_delete_action.tsx index 608af0e66444b6..52370742a66853 100644 --- a/x-pack/plugins/cases/public/components/actions/delete/use_delete_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/delete/use_delete_action.tsx @@ -7,7 +7,7 @@ import React, { useCallback, useState } from 'react'; import { EuiIcon, EuiTextColor, useEuiTheme } from '@elastic/eui'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { useDeleteCases } from '../../../containers/use_delete_cases'; import * as i18n from './translations'; @@ -21,13 +21,13 @@ export const useDeleteAction = ({ onAction, onActionSuccess, isDisabled }: UseAc const euiTheme = useEuiTheme(); const { permissions } = useCasesContext(); const [isModalVisible, setIsModalVisible] = useState(false); - const [caseToBeDeleted, setCaseToBeDeleted] = useState([]); + const [caseToBeDeleted, setCaseToBeDeleted] = useState([]); const canDelete = permissions.delete; const isActionDisabled = isDisabled || !canDelete; const onCloseModal = useCallback(() => setIsModalVisible(false), []); const openModal = useCallback( - (selectedCases: Case[]) => { + (selectedCases: CaseUI[]) => { onAction(); setIsModalVisible(true); setCaseToBeDeleted(selectedCases); @@ -50,7 +50,7 @@ export const useDeleteAction = ({ onAction, onActionSuccess, isDisabled }: UseAc const color = isActionDisabled ? euiTheme.euiTheme.colors.disabled : 'danger'; - const getAction = (selectedCases: Case[]) => { + const getAction = (selectedCases: CaseUI[]) => { return { name: {getDeleteActionTitle(selectedCases.length)}, onClick: () => openModal(selectedCases), diff --git a/x-pack/plugins/cases/public/components/actions/severity/translations.ts b/x-pack/plugins/cases/public/components/actions/severity/translations.ts index 81e0caf848d153..e9c0de566691b7 100644 --- a/x-pack/plugins/cases/public/components/actions/severity/translations.ts +++ b/x-pack/plugins/cases/public/components/actions/severity/translations.ts @@ -21,7 +21,7 @@ const SET_SEVERITY = ({ i18n.translate('xpack.cases.actions.severity', { values: { caseTitle, totalCases, severity }, defaultMessage: - '{totalCases, plural, =1 {Case "{caseTitle}" was} other {{totalCases} cases were}} set to {severity}', + '{totalCases, plural, =1 {CaseUI "{caseTitle}" was} other {{totalCases} cases were}} set to {severity}', }); export const SET_SEVERITY_LOW = ({ diff --git a/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.test.tsx b/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.test.tsx index 695b90624fdd6b..21368e84ad3c68 100644 --- a/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.test.tsx @@ -112,10 +112,10 @@ describe('useSeverityAction', () => { }); const singleCaseTests = [ - [CaseSeverity.LOW, 0, 'Case "Another horrible breach!!" was set to Low'], - [CaseSeverity.MEDIUM, 1, 'Case "Another horrible breach!!" was set to Medium'], - [CaseSeverity.HIGH, 2, 'Case "Another horrible breach!!" was set to High'], - [CaseSeverity.CRITICAL, 3, 'Case "Another horrible breach!!" was set to Critical'], + [CaseSeverity.LOW, 0, 'CaseUI "Another horrible breach!!" was set to Low'], + [CaseSeverity.MEDIUM, 1, 'CaseUI "Another horrible breach!!" was set to Medium'], + [CaseSeverity.HIGH, 2, 'CaseUI "Another horrible breach!!" was set to High'], + [CaseSeverity.CRITICAL, 3, 'CaseUI "Another horrible breach!!" was set to Critical'], ]; it.each(singleCaseTests)( diff --git a/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.tsx b/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.tsx index 614bb0cbef77ca..d271f8891bfeb4 100644 --- a/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/severity/use_severity_action.tsx @@ -9,14 +9,14 @@ import { useCallback } from 'react'; import type { EuiContextMenuPanelItemDescriptor } from '@elastic/eui'; import { CaseSeverity } from '../../../../common/api'; import { useUpdateCases } from '../../../containers/use_bulk_update_case'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import * as i18n from './translations'; import type { UseActionProps } from '../types'; import { useCasesContext } from '../../cases_context/use_cases_context'; import { severities } from '../../severity/config'; -const getSeverityToasterMessage = (severity: CaseSeverity, cases: Case[]): string => { +const getSeverityToasterMessage = (severity: CaseSeverity, cases: CaseUI[]): string => { const totalCases = cases.length; const caseTitle = totalCases === 1 ? cases[0].title : ''; @@ -39,7 +39,7 @@ interface UseSeverityActionProps extends UseActionProps { selectedSeverity?: CaseSeverity; } -const shouldDisableSeverity = (cases: Case[], severity: CaseSeverity) => +const shouldDisableSeverity = (cases: CaseUI[], severity: CaseSeverity) => cases.every((theCase) => theCase.severity === severity); export const useSeverityAction = ({ @@ -54,7 +54,7 @@ export const useSeverityAction = ({ const isActionDisabled = isDisabled || !canUpdateSeverity; const handleUpdateCaseSeverity = useCallback( - (selectedCases: Case[], severity: CaseSeverity) => { + (selectedCases: CaseUI[], severity: CaseSeverity) => { onAction(); const casesToUpdate = selectedCases.map((theCase) => ({ severity, @@ -76,7 +76,7 @@ export const useSeverityAction = ({ const getSeverityIcon = (severity: CaseSeverity): string => selectedSeverity && selectedSeverity === severity ? 'check' : 'empty'; - const getActions = (selectedCases: Case[]): EuiContextMenuPanelItemDescriptor[] => { + const getActions = (selectedCases: CaseUI[]): EuiContextMenuPanelItemDescriptor[] => { return [ { name: severities[CaseSeverity.LOW].label, diff --git a/x-pack/plugins/cases/public/components/actions/status/use_status_action.tsx b/x-pack/plugins/cases/public/components/actions/status/use_status_action.tsx index 6b9fe58c15105a..6c32d2cdbd8658 100644 --- a/x-pack/plugins/cases/public/components/actions/status/use_status_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/status/use_status_action.tsx @@ -8,7 +8,7 @@ import { useCallback } from 'react'; import type { EuiContextMenuPanelItemDescriptor } from '@elastic/eui'; import { useUpdateCases } from '../../../containers/use_bulk_update_case'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { CaseStatuses } from '../../../../common'; import * as i18n from './translations'; @@ -16,7 +16,7 @@ import type { UseActionProps } from '../types'; import { statuses } from '../../status'; import { useCasesContext } from '../../cases_context/use_cases_context'; -const getStatusToasterMessage = (status: CaseStatuses, cases: Case[]): string => { +const getStatusToasterMessage = (status: CaseStatuses, cases: CaseUI[]): string => { const totalCases = cases.length; const caseTitle = totalCases === 1 ? cases[0].title : ''; @@ -35,7 +35,7 @@ interface UseStatusActionProps extends UseActionProps { selectedStatus?: CaseStatuses; } -const shouldDisableStatus = (cases: Case[], status: CaseStatuses) => +const shouldDisableStatus = (cases: CaseUI[], status: CaseStatuses) => cases.every((theCase) => theCase.status === status); export const useStatusAction = ({ @@ -50,7 +50,7 @@ export const useStatusAction = ({ const isActionDisabled = isDisabled || !canUpdateStatus; const handleUpdateCaseStatus = useCallback( - (selectedCases: Case[], status: CaseStatuses) => { + (selectedCases: CaseUI[], status: CaseStatuses) => { onAction(); const casesToUpdate = selectedCases.map((theCase) => ({ status, @@ -72,7 +72,7 @@ export const useStatusAction = ({ const getStatusIcon = (status: CaseStatuses): string => selectedStatus && selectedStatus === status ? 'check' : 'empty'; - const getActions = (selectedCases: Case[]): EuiContextMenuPanelItemDescriptor[] => { + const getActions = (selectedCases: CaseUI[]): EuiContextMenuPanelItemDescriptor[] => { return [ { name: statuses[CaseStatuses.open].label, diff --git a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.test.tsx b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.test.tsx index b6ebaa03be06c5..80dea285f00503 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.test.tsx @@ -20,8 +20,8 @@ describe('EditTagsFlyout', () => { let appMock: AppMockRenderer; /** - * Case one has the following tags: coke, pepsi, one - * Case two has the following tags: one, three + * CaseUI one has the following tags: coke, pepsi, one + * CaseUI two has the following tags: one, three * All available tags are: one, two, three, coke, pepsi */ const props = { diff --git a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.tsx b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.tsx index babedee38611c8..6bf5853d5e6719 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_flyout.tsx @@ -22,14 +22,14 @@ import { EuiTitle, } from '@elastic/eui'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { useGetTags } from '../../../containers/use_get_tags'; import { EditTagsSelectable } from './edit_tags_selectable'; import * as i18n from './translations'; import type { ItemsSelectionState } from '../types'; interface Props { - selectedCases: Case[]; + selectedCases: CaseUI[]; onClose: () => void; onSaveTags: (args: ItemsSelectionState) => void; } diff --git a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.test.tsx b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.test.tsx index 953fabf31d788a..b0f0815c579fae 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.test.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.test.tsx @@ -17,7 +17,7 @@ describe('EditTagsSelectable', () => { let appMock: AppMockRenderer; /** - * Case has the following tags: coke, pepsi + * CaseUI has the following tags: coke, pepsi * All available tags are: one, two, coke, pepsi */ const props = { @@ -28,8 +28,8 @@ describe('EditTagsSelectable', () => { }; /** - * Case one has the following tags: coke, pepsi, one - * Case two has the following tags: one, three + * CaseUI one has the following tags: coke, pepsi, one + * CaseUI two has the following tags: one, three * All available tags are: one, two, three, coke, pepsi */ const propsMultipleCases = { diff --git a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx index 3bdbb60cac8e87..437c3c94b1915d 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/edit_tags_selectable.tsx @@ -20,13 +20,13 @@ import { } from '@elastic/eui'; import { isEmpty } from 'lodash'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import * as i18n from './translations'; import { useItemsState } from '../use_items_state'; import type { ItemSelectableOption, ItemsSelectionState } from '../types'; interface Props { - selectedCases: Case[]; + selectedCases: CaseUI[]; tags: string[]; isLoading: boolean; onChangeTags: (args: ItemsSelectionState) => void; diff --git a/x-pack/plugins/cases/public/components/actions/tags/use_tags_action.tsx b/x-pack/plugins/cases/public/components/actions/tags/use_tags_action.tsx index 2e4acd618b34f2..ff7d9dc078f39f 100644 --- a/x-pack/plugins/cases/public/components/actions/tags/use_tags_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/tags/use_tags_action.tsx @@ -7,14 +7,14 @@ import { EuiIcon } from '@elastic/eui'; import React from 'react'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import type { UseActionProps } from '../types'; import { useItemsAction } from '../use_items_action'; import * as i18n from './translations'; export const useTagsAction = ({ onAction, onActionSuccess, isDisabled }: UseActionProps) => { const { isFlyoutOpen, onFlyoutClosed, onSaveItems, openFlyout, isActionDisabled } = - useItemsAction({ + useItemsAction({ fieldKey: 'tags', isDisabled, onAction, @@ -24,7 +24,7 @@ export const useTagsAction = ({ onAction, onActionSuccess, isDisabled }: UseActi itemsTransformer: (items) => items, }); - const getAction = (selectedCases: Case[]) => { + const getAction = (selectedCases: CaseUI[]) => { return { name: i18n.EDIT_TAGS, onClick: () => openFlyout(selectedCases), diff --git a/x-pack/plugins/cases/public/components/actions/use_items_action.tsx b/x-pack/plugins/cases/public/components/actions/use_items_action.tsx index 6ab5dce5f48ef4..464f14bbee11b1 100644 --- a/x-pack/plugins/cases/public/components/actions/use_items_action.tsx +++ b/x-pack/plugins/cases/public/components/actions/use_items_action.tsx @@ -9,14 +9,14 @@ import { useCallback, useState } from 'react'; import { difference, isEqual } from 'lodash'; import type { CaseUpdateRequest } from '../../../common/ui'; import { useUpdateCases } from '../../containers/use_bulk_update_case'; -import type { Case } from '../../../common'; +import type { CaseUI } from '../../../common'; import { useCasesContext } from '../cases_context/use_cases_context'; import type { UseActionProps, ItemsSelectionState } from './types'; type UseItemsActionProps = UseActionProps & { fieldKey: 'tags' | 'assignees'; successToasterTitle: (totalCases: number) => string; - fieldSelector: (theCase: Case) => string[]; + fieldSelector: (theCase: CaseUI) => string[]; itemsTransformer: (items: string[]) => T; }; @@ -32,13 +32,13 @@ export const useItemsAction = ({ const { mutate: updateCases } = useUpdateCases(); const { permissions } = useCasesContext(); const [isFlyoutOpen, setIsFlyoutOpen] = useState(false); - const [selectedCasesToEdit, setSelectedCasesToEdit] = useState([]); + const [selectedCasesToEdit, setSelectedCasesToEdit] = useState([]); const canUpdateStatus = permissions.update; const isActionDisabled = isDisabled || !canUpdateStatus; const onFlyoutClosed = useCallback(() => setIsFlyoutOpen(false), []); const openFlyout = useCallback( - (selectedCases: Case[]) => { + (selectedCases: CaseUI[]) => { onAction(); setIsFlyoutOpen(true); setSelectedCasesToEdit(selectedCases); diff --git a/x-pack/plugins/cases/public/components/actions/use_items_state.tsx b/x-pack/plugins/cases/public/components/actions/use_items_state.tsx index bd5db49336b5ae..99ccf9b9e20555 100644 --- a/x-pack/plugins/cases/public/components/actions/use_items_state.tsx +++ b/x-pack/plugins/cases/public/components/actions/use_items_state.tsx @@ -8,14 +8,14 @@ import type { EuiSelectableOption, IconType } from '@elastic/eui'; import { assertNever } from '@elastic/eui'; import { useCallback, useReducer, useMemo } from 'react'; -import type { Case } from '../../../common'; +import type { CaseUI } from '../../../common'; import type { ItemSelectableOption, ItemsSelectionState } from './types'; interface UseItemsStateProps { items: string[]; - selectedCases: Case[]; + selectedCases: CaseUI[]; itemToSelectableOption: (item: Payload[number]) => EuiSelectableOption; - fieldSelector: (theCase: Case) => string[]; + fieldSelector: (theCase: CaseUI) => string[]; onChangeItems: (args: ItemsSelectionState) => void; } @@ -153,7 +153,7 @@ const getInitialItemsState = ({ fieldSelector, }: { items: string[]; - selectedCases: Case[]; + selectedCases: CaseUI[]; fieldSelector: UseItemsStateProps['fieldSelector']; }): State => { const itemCounterMap = createItemsCounterMapping({ selectedCases, fieldSelector }); @@ -183,7 +183,7 @@ const createItemsCounterMapping = ({ selectedCases, fieldSelector, }: { - selectedCases: Case[]; + selectedCases: CaseUI[]; fieldSelector: UseItemsStateProps['fieldSelector']; }) => { const counterMap = new Map(); diff --git a/x-pack/plugins/cases/public/components/add_comment/index.tsx b/x-pack/plugins/cases/public/components/add_comment/index.tsx index d75401841b6f5c..fceeef2d314120 100644 --- a/x-pack/plugins/cases/public/components/add_comment/index.tsx +++ b/x-pack/plugins/cases/public/components/add_comment/index.tsx @@ -25,7 +25,7 @@ import { } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; import { CommentType } from '../../../common/api'; import { useCreateAttachments } from '../../containers/use_create_attachments'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import type { EuiMarkdownEditorRef } from '../markdown_editor'; import { MarkdownEditorForm } from '../markdown_editor'; import { getMarkdownEditorStorageKey } from '../markdown_editor/utils'; @@ -57,7 +57,7 @@ export interface AddCommentProps { id: string; caseId: string; onCommentSaving?: () => void; - onCommentPosted: (newCase: Case) => void; + onCommentPosted: (newCase: CaseUI) => void; showLoading?: boolean; statusActionButton: JSX.Element | null; } diff --git a/x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx b/x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx index 7666d518fe9b4c..f30fd33fd09959 100644 --- a/x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/all_cases_list.tsx @@ -11,7 +11,7 @@ import { EuiProgress } from '@elastic/eui'; import { difference, head, isEmpty } from 'lodash/fp'; import styled, { css } from 'styled-components'; -import type { Case, CaseStatusWithAllStatus, FilterOptions } from '../../../common/ui/types'; +import type { CaseUI, CaseStatusWithAllStatus, FilterOptions } from '../../../common/ui/types'; import { SortFieldCase, StatusAll } from '../../../common/ui/types'; import { CaseStatuses, caseStatuses } from '../../../common/api'; import { OWNER_INFO } from '../../../common/constants'; @@ -64,7 +64,7 @@ const mapToReadableSolutionName = (solution: string): Solution => { export interface AllCasesListProps { hiddenStatuses?: CaseStatusWithAllStatus[]; isSelectorView?: boolean; - onRowClick?: (theCase?: Case) => void; + onRowClick?: (theCase?: CaseUI) => void; } export const AllCasesList = React.memo( @@ -84,7 +84,7 @@ export const AllCasesList = React.memo( isSelectorView, initialFilterOptions ); - const [selectedCases, setSelectedCases] = useState([]); + const [selectedCases, setSelectedCases] = useState([]); const { data = initialData, isFetching: isLoadingCases } = useGetCases({ filterOptions, @@ -224,7 +224,7 @@ export const AllCasesList = React.memo( [data, queryParams] ); - const euiBasicTableSelectionProps = useMemo>( + const euiBasicTableSelectionProps = useMemo>( () => ({ onSelectionChange: setSelectedCases, initialSelected: selectedCases, @@ -235,7 +235,7 @@ export const AllCasesList = React.memo( const isDataEmpty = useMemo(() => data.total === 0, [data]); const tableRowProps = useCallback( - (theCase: Case) => ({ + (theCase: CaseUI) => ({ 'data-test-subj': `cases-table-row-${theCase.id}`, }), [] diff --git a/x-pack/plugins/cases/public/components/all_cases/assignees_column.tsx b/x-pack/plugins/cases/public/components/all_cases/assignees_column.tsx index 8b5444f9a9d911..41e936a7021c0c 100644 --- a/x-pack/plugins/cases/public/components/all_cases/assignees_column.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/assignees_column.tsx @@ -8,7 +8,7 @@ import React, { useCallback, useMemo, useState } from 'react'; import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import type { UserProfileWithAvatar } from '@kbn/user-profile-components'; -import type { Case } from '../../../common/ui/types'; +import type { CaseUI } from '../../../common/ui/types'; import { getEmptyTagValue } from '../empty_value'; import { UserToolTip } from '../user_profiles/user_tooltip'; import { useAssignees } from '../../containers/user_profiles/use_assignees'; @@ -19,7 +19,7 @@ import * as i18n from './translations'; const COMPRESSED_AVATAR_LIMIT = 3; export interface AssigneesColumnProps { - assignees: Case['assignees']; + assignees: CaseUI['assignees']; userProfiles: Map; compressedDisplayLimit?: number; } diff --git a/x-pack/plugins/cases/public/components/all_cases/cases_metrics.test.tsx b/x-pack/plugins/cases/public/components/all_cases/cases_metrics.test.tsx index 4a10df984c07d9..7e9057075e1379 100644 --- a/x-pack/plugins/cases/public/components/all_cases/cases_metrics.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/cases_metrics.test.tsx @@ -13,7 +13,7 @@ import { CasesMetrics } from './cases_metrics'; jest.mock('../../api'); -describe('Cases metrics', () => { +describe('CasesUI metrics', () => { let appMockRenderer: AppMockRenderer; beforeEach(() => { diff --git a/x-pack/plugins/cases/public/components/all_cases/selector_modal/all_cases_selector_modal.tsx b/x-pack/plugins/cases/public/components/all_cases/selector_modal/all_cases_selector_modal.tsx index 6a9629699734b5..1aaf9c87cf2459 100644 --- a/x-pack/plugins/cases/public/components/all_cases/selector_modal/all_cases_selector_modal.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/selector_modal/all_cases_selector_modal.tsx @@ -17,14 +17,14 @@ import { import styled from 'styled-components'; import { QueryClientProvider } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; -import type { Case, CaseStatusWithAllStatus } from '../../../../common/ui/types'; +import type { CaseUI, CaseStatusWithAllStatus } from '../../../../common/ui/types'; import * as i18n from '../../../common/translations'; import { AllCasesList } from '../all_cases_list'; import { casesQueryClient } from '../../cases_context/query_client'; export interface AllCasesSelectorModalProps { hiddenStatuses?: CaseStatusWithAllStatus[]; - onRowClick?: (theCase?: Case) => void; + onRowClick?: (theCase?: CaseUI) => void; onClose?: () => void; } @@ -46,7 +46,7 @@ export const AllCasesSelectorModal = React.memo( }, [onClose]); const onClick = useCallback( - (theCase?: Case) => { + (theCase?: CaseUI) => { closeModal(); if (onRowClick) { onRowClick(theCase); diff --git a/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.test.tsx b/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.test.tsx index e98397d8bb37eb..a63fd6ceaef105 100644 --- a/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.test.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.test.tsx @@ -10,7 +10,7 @@ import { act, renderHook } from '@testing-library/react-hooks'; import userEvent from '@testing-library/user-event'; import React from 'react'; import AllCasesSelectorModal from '.'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { CaseStatuses, StatusAll } from '../../../../common'; import type { AppMockRenderer } from '../../../common/mock'; import { allCasesPermissions, createAppMockRenderer } from '../../../common/mock'; @@ -144,7 +144,7 @@ describe('use cases add to existing case modal hook', () => { it('should call getAttachments with the case info', async () => { AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); @@ -159,7 +159,7 @@ describe('use cases add to existing case modal hook', () => { it('should show a toaster info when no attachments are defined and noAttachmentsToaster is defined', async () => { AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); @@ -182,7 +182,7 @@ describe('use cases add to existing case modal hook', () => { it('should show a toaster info when no attachments are defined and noAttachmentsToaster is not defined', async () => { AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); @@ -213,7 +213,7 @@ describe('use cases add to existing case modal hook', () => { }); AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); @@ -244,7 +244,7 @@ describe('use cases add to existing case modal hook', () => { }); AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); @@ -295,7 +295,7 @@ describe('use cases add to existing case modal hook', () => { // simulate a case selected AllCasesSelectorModalMock.mockImplementation(({ onRowClick }) => { - onRowClick({ id: 'test' } as Case); + onRowClick({ id: 'test' } as CaseUI); return null; }); diff --git a/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.tsx b/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.tsx index ea2e0f200433e1..fb7a40d5725df1 100644 --- a/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/selector_modal/use_cases_add_to_existing_case_modal.tsx @@ -9,7 +9,7 @@ import { useCallback } from 'react'; import { CaseStatuses, StatusAll } from '../../../../common'; import type { AllCasesSelectorModalProps } from '.'; import { useCasesToast } from '../../../common/use_cases_toast'; -import type { Case } from '../../../containers/types'; +import type { CaseUI } from '../../../containers/types'; import { CasesContextStoreActionsList } from '../../cases_context/cases_context_reducer'; import { useCasesContext } from '../../cases_context/use_cases_context'; import { useCasesAddToNewCaseFlyout } from '../../create/flyout/use_cases_add_to_new_case_flyout'; @@ -27,13 +27,13 @@ export type AddToExistingCaseModalProps = Omit void; + onSuccess?: (theCase: CaseUI) => void; }; export const useCasesAddToExistingCaseModal = (props: AddToExistingCaseModalProps = {}) => { const createNewCaseFlyout = useCasesAddToNewCaseFlyout({ onClose: props.onClose, - onSuccess: (theCase?: Case) => { + onSuccess: (theCase?: CaseUI) => { if (props.onSuccess && theCase) { return props.onSuccess(theCase); } @@ -60,8 +60,8 @@ export const useCasesAddToExistingCaseModal = (props: AddToExistingCaseModalProp const handleOnRowClick = useCallback( async ( - theCase: Case | undefined, - getAttachments?: ({ theCase }: { theCase?: Case }) => CaseAttachmentsWithoutOwner + theCase: CaseUI | undefined, + getAttachments?: ({ theCase }: { theCase?: CaseUI }) => CaseAttachmentsWithoutOwner ) => { const attachments = getAttachments?.({ theCase }) ?? []; // when the case is undefined in the modal @@ -121,14 +121,14 @@ export const useCasesAddToExistingCaseModal = (props: AddToExistingCaseModalProp ({ getAttachments, }: { - getAttachments?: ({ theCase }: { theCase?: Case }) => CaseAttachmentsWithoutOwner; + getAttachments?: ({ theCase }: { theCase?: CaseUI }) => CaseAttachmentsWithoutOwner; } = {}) => { dispatch({ type: CasesContextStoreActionsList.OPEN_ADD_TO_CASE_MODAL, payload: { ...props, hiddenStatuses: [CaseStatuses.closed, StatusAll], - onRowClick: (theCase?: Case) => { + onRowClick: (theCase?: CaseUI) => { handleOnRowClick(theCase, getAttachments); }, onClose: () => { diff --git a/x-pack/plugins/cases/public/components/all_cases/table.tsx b/x-pack/plugins/cases/public/components/all_cases/table.tsx index 61fb081a0dd9a5..0aa9f78c5d0bf5 100644 --- a/x-pack/plugins/cases/public/components/all_cases/table.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/table.tsx @@ -14,26 +14,26 @@ import styled from 'styled-components'; import { CasesTableUtilityBar } from './utility_bar'; import { LinkButton } from '../links'; -import type { Cases, Case } from '../../../common/ui/types'; +import type { CasesUI, CaseUI } from '../../../common/ui/types'; import * as i18n from './translations'; import { useCreateCaseNavigation } from '../../common/navigation'; import { useCasesContext } from '../cases_context/use_cases_context'; interface CasesTableProps { - columns: EuiBasicTableProps['columns']; - data: Cases; + columns: EuiBasicTableProps['columns']; + data: CasesUI; goToCreateCase?: () => void; isCasesLoading: boolean; isCommentUpdating: boolean; isDataEmpty: boolean; isSelectorView?: boolean; - onChange: EuiBasicTableProps['onChange']; + onChange: EuiBasicTableProps['onChange']; pagination: Pagination; - selectedCases: Case[]; - selection: EuiTableSelectionType; - sorting: EuiBasicTableProps['sorting']; + selectedCases: CaseUI[]; + selection: EuiTableSelectionType; + sorting: EuiBasicTableProps['sorting']; tableRef: MutableRefObject; - tableRowProps: EuiBasicTableProps['rowProps']; + tableRowProps: EuiBasicTableProps['rowProps']; deselectCases: () => void; } diff --git a/x-pack/plugins/cases/public/components/all_cases/use_actions.tsx b/x-pack/plugins/cases/public/components/all_cases/use_actions.tsx index 88d94f65f900c1..ea43f79b4954ea 100644 --- a/x-pack/plugins/cases/public/components/all_cases/use_actions.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/use_actions.tsx @@ -13,7 +13,7 @@ import type { } from '@elastic/eui'; import { EuiButtonIcon, EuiContextMenu, EuiPopover } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import { useDeleteAction } from '../actions/delete/use_delete_action'; import { ConfirmDeleteCaseModal } from '../confirm_delete_case'; import { useStatusAction } from '../actions/status/use_status_action'; @@ -29,7 +29,7 @@ import { useAssigneesAction } from '../actions/assignees/use_assignees_action'; import { EditAssigneesFlyout } from '../actions/assignees/edit_assignees_flyout'; import { useCopyIDAction } from '../actions/copy_id/use_copy_id_action'; -const ActionColumnComponent: React.FC<{ theCase: Case; disableActions: boolean }> = ({ +const ActionColumnComponent: React.FC<{ theCase: CaseUI; disableActions: boolean }> = ({ theCase, disableActions, }) => { @@ -223,7 +223,7 @@ ActionColumnComponent.displayName = 'ActionColumnComponent'; const ActionColumn = React.memo(ActionColumnComponent); interface UseBulkActionsReturnValue { - actions: EuiTableComputedColumnType | null; + actions: EuiTableComputedColumnType | null; } interface UseBulkActionsProps { @@ -239,7 +239,7 @@ export const useActions = ({ disableActions }: UseBulkActionsProps): UseBulkActi ? { name: i18n.ACTIONS, align: 'right', - render: (theCase: Case) => { + render: (theCase: CaseUI) => { return ( ); diff --git a/x-pack/plugins/cases/public/components/all_cases/use_bulk_actions.tsx b/x-pack/plugins/cases/public/components/all_cases/use_bulk_actions.tsx index 1d7efd62736fb0..eadd3eb8840810 100644 --- a/x-pack/plugins/cases/public/components/all_cases/use_bulk_actions.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/use_bulk_actions.tsx @@ -11,7 +11,7 @@ import type { } from '@elastic/eui'; import React, { useMemo } from 'react'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import { useDeleteAction } from '../actions/delete/use_delete_action'; import { useSeverityAction } from '../actions/severity/use_severity_action'; import { useStatusAction } from '../actions/status/use_status_action'; @@ -23,7 +23,7 @@ import { EditAssigneesFlyout } from '../actions/assignees/edit_assignees_flyout' import * as i18n from './translations'; interface UseBulkActionsProps { - selectedCases: Case[]; + selectedCases: CaseUI[]; onAction: () => void; onActionSuccess: () => void; } diff --git a/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx b/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx index 1f267eca40a843..b2048893b1895a 100644 --- a/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx @@ -28,7 +28,7 @@ import { Status } from '@kbn/cases-components'; import type { UserProfileWithAvatar } from '@kbn/user-profile-components'; import { euiStyled } from '@kbn/kibana-react-plugin/common'; -import type { Case } from '../../../common/ui/types'; +import type { CaseUI } from '../../../common/ui/types'; import type { ActionConnector } from '../../../common/api'; import { CaseStatuses, CaseSeverity } from '../../../common/api'; import { OWNER_INFO } from '../../../common/constants'; @@ -47,9 +47,9 @@ import { useCasesFeatures } from '../../common/use_cases_features'; import { AssigneesColumn } from './assignees_column'; type CasesColumns = - | EuiTableActionsColumnType - | EuiTableComputedColumnType - | EuiTableFieldDataColumnType; + | EuiTableActionsColumnType + | EuiTableComputedColumnType + | EuiTableFieldDataColumnType; const MediumShadeText = styled.p` color: ${({ theme }) => theme.eui.euiColorMediumShade}; @@ -80,7 +80,7 @@ export interface GetCasesColumn { userProfiles: Map; isSelectorView: boolean; connectors?: ActionConnector[]; - onRowClick?: (theCase: Case) => void; + onRowClick?: (theCase: CaseUI) => void; showSolutionColumn?: boolean; disableActions?: boolean; } @@ -102,7 +102,7 @@ export const useCasesColumns = ({ const { actions } = useActions({ disableActions }); const assignCaseAction = useCallback( - async (theCase: Case) => { + async (theCase: CaseUI) => { if (onRowClick) { onRowClick(theCase); } @@ -115,7 +115,7 @@ export const useCasesColumns = ({ field: 'title', name: i18n.NAME, sortable: true, - render: (title: string, theCase: Case) => { + render: (title: string, theCase: CaseUI) => { if (theCase.id != null && theCase.title != null) { const caseDetailsLinkComponent = isSelectorView ? ( theCase.title @@ -145,7 +145,7 @@ export const useCasesColumns = ({ columns.push({ field: 'assignees', name: i18n.ASSIGNEES, - render: (assignees: Case['assignees']) => ( + render: (assignees: CaseUI['assignees']) => ( ), width: '180px', @@ -156,7 +156,7 @@ export const useCasesColumns = ({ columns.push({ field: 'tags', name: i18n.TAGS, - render: (tags: Case['tags']) => { + render: (tags: CaseUI['tags']) => { if (tags != null && tags.length > 0) { const clampedBadges = ( @@ -207,7 +207,7 @@ export const useCasesColumns = ({ align: RIGHT_ALIGNMENT, field: 'totalAlerts', name: ALERTS, - render: (totalAlerts: Case['totalAlerts']) => + render: (totalAlerts: CaseUI['totalAlerts']) => totalAlerts != null ? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`) : getEmptyTagValue(), @@ -241,7 +241,7 @@ export const useCasesColumns = ({ align: RIGHT_ALIGNMENT, field: 'totalComment', name: i18n.COMMENTS, - render: (totalComment: Case['totalComment']) => + render: (totalComment: CaseUI['totalComment']) => totalComment != null ? renderStringField(`${totalComment}`, `case-table-column-commentCount`) : getEmptyTagValue(), @@ -253,7 +253,7 @@ export const useCasesColumns = ({ field: 'closedAt', name: i18n.CLOSED_ON, sortable: true, - render: (closedAt: Case['closedAt']) => { + render: (closedAt: CaseUI['closedAt']) => { if (closedAt != null) { return ( @@ -269,7 +269,7 @@ export const useCasesColumns = ({ field: 'createdAt', name: i18n.CREATED_ON, sortable: true, - render: (createdAt: Case['createdAt']) => { + render: (createdAt: CaseUI['createdAt']) => { if (createdAt != null) { return ( @@ -287,7 +287,7 @@ export const useCasesColumns = ({ field: 'updatedAt', name: i18n.UPDATED_ON, sortable: true, - render: (updatedAt: Case['updatedAt']) => { + render: (updatedAt: CaseUI['updatedAt']) => { if (updatedAt != null) { return ( @@ -304,7 +304,7 @@ export const useCasesColumns = ({ columns.push( { name: i18n.EXTERNAL_INCIDENT, - render: (theCase: Case) => { + render: (theCase: CaseUI) => { if (theCase.id != null) { return ; } @@ -316,7 +316,7 @@ export const useCasesColumns = ({ field: 'status', name: i18n.STATUS, sortable: true, - render: (status: Case['status']) => { + render: (status: CaseUI['status']) => { if (status != null) { return ; } @@ -330,7 +330,7 @@ export const useCasesColumns = ({ field: 'severity', name: i18n.SEVERITY, sortable: true, - render: (severity: Case['severity']) => { + render: (severity: CaseUI['severity']) => { if (severity != null) { const severityData = severities[severity ?? CaseSeverity.LOW]; return ( @@ -349,7 +349,7 @@ export const useCasesColumns = ({ if (isSelectorView) { columns.push({ align: RIGHT_ALIGNMENT, - render: (theCase: Case) => { + render: (theCase: CaseUI) => { if (theCase.id != null) { return ( void; } diff --git a/x-pack/plugins/cases/public/components/app/routes.test.tsx b/x-pack/plugins/cases/public/components/app/routes.test.tsx index e905c831e398b3..a96978c709a5a3 100644 --- a/x-pack/plugins/cases/public/components/app/routes.test.tsx +++ b/x-pack/plugins/cases/public/components/app/routes.test.tsx @@ -46,7 +46,7 @@ const renderWithRouter = ( ); }; -describe('Cases routes', () => { +describe('CasesUI routes', () => { describe('All cases', () => { it('navigates to the all cases page', () => { renderWithRouter(); @@ -60,7 +60,7 @@ describe('Cases routes', () => { }); }); - describe('Case view', () => { + describe('CaseUI view', () => { it.each(getCaseViewPaths())( 'navigates to the cases view page for path: %s', async (path: string) => { diff --git a/x-pack/plugins/cases/public/components/app/translations.ts b/x-pack/plugins/cases/public/components/app/translations.ts index 4958ce4358c1c5..5ea616ac6656a4 100644 --- a/x-pack/plugins/cases/public/components/app/translations.ts +++ b/x-pack/plugins/cases/public/components/app/translations.ts @@ -8,11 +8,11 @@ import { i18n } from '@kbn/i18n'; export const CREATE_CASE_PAGE_NAME = i18n.translate('xpack.cases.createCase', { - defaultMessage: 'Create Case', + defaultMessage: 'Create CaseUI', }); export const CONFIGURE_CASES_PAGE_NAME = i18n.translate('xpack.cases.configureCases', { - defaultMessage: 'Configure Cases', + defaultMessage: 'Configure CasesUI', }); export const READ_ONLY_BADGE_TEXT = i18n.translate('xpack.cases.badge.readOnly.text', { diff --git a/x-pack/plugins/cases/public/components/app/use_available_owners.ts b/x-pack/plugins/cases/public/components/app/use_available_owners.ts index c829b9c590d011..8450477308584c 100644 --- a/x-pack/plugins/cases/public/components/app/use_available_owners.ts +++ b/x-pack/plugins/cases/public/components/app/use_available_owners.ts @@ -25,7 +25,7 @@ export const useAvailableCasesOwners = ( return Object.entries(kibanaCapabilities).reduce( (availableOwners: string[], [featureId, kibanaCapability]) => { - if (!featureId.endsWith('Cases')) { + if (!featureId.endsWith('CasesUI')) { return availableOwners; } for (const cap of capabilities) { @@ -46,5 +46,5 @@ const getOwnerFromFeatureID = (featureID: string) => { return APP_ID; } - return featureID.replace('Cases', ''); + return featureID.replace('CasesUI', ''); }; diff --git a/x-pack/plugins/cases/public/components/case_action_bar/actions.tsx b/x-pack/plugins/cases/public/components/case_action_bar/actions.tsx index b80cd5c2dbe749..b6d9248839f3ca 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/actions.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/actions.tsx @@ -12,15 +12,15 @@ import * as i18n from '../case_view/translations'; import { useDeleteCases } from '../../containers/use_delete_cases'; import { ConfirmDeleteCaseModal } from '../confirm_delete_case'; import { PropertyActions } from '../property_actions'; -import type { Case } from '../../../common/ui/types'; +import type { CaseUI } from '../../../common/ui/types'; import { useAllCasesNavigation } from '../../common/navigation'; import { useCasesContext } from '../cases_context/use_cases_context'; import { useCasesToast } from '../../common/use_cases_toast'; import { AttachmentActionType } from '../../client/attachment_framework/types'; interface CaseViewActions { - caseData: Case; - currentExternalIncident: Case['externalService']; + caseData: CaseUI; + currentExternalIncident: CaseUI['externalService']; } const ActionsComponent: React.FC = ({ caseData, currentExternalIncident }) => { diff --git a/x-pack/plugins/cases/public/components/case_action_bar/helpers.test.ts b/x-pack/plugins/cases/public/components/case_action_bar/helpers.test.ts index f04ef94405db87..58982502ab6e19 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/helpers.test.ts +++ b/x-pack/plugins/cases/public/components/case_action_bar/helpers.test.ts @@ -36,15 +36,15 @@ describe('helpers', () => { describe('getStatusTitle', () => { it('it return the correct title for open status', () => { - expect(getStatusTitle(CaseStatuses.open)).toBe('Case opened'); + expect(getStatusTitle(CaseStatuses.open)).toBe('CaseUI opened'); }); it('it return the correct title for in-progress status', () => { - expect(getStatusTitle(CaseStatuses['in-progress'])).toBe('Case in progress'); + expect(getStatusTitle(CaseStatuses['in-progress'])).toBe('CaseUI in progress'); }); it('it return the correct title for closed status', () => { - expect(getStatusTitle(CaseStatuses.closed)).toBe('Case closed'); + expect(getStatusTitle(CaseStatuses.closed)).toBe('CaseUI closed'); }); }); }); diff --git a/x-pack/plugins/cases/public/components/case_action_bar/helpers.ts b/x-pack/plugins/cases/public/components/case_action_bar/helpers.ts index 772bedd266dd83..2e1e176ff850a1 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/helpers.ts +++ b/x-pack/plugins/cases/public/components/case_action_bar/helpers.ts @@ -6,10 +6,10 @@ */ import { CaseStatuses } from '../../../common/api'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import { statuses } from '../status'; -export const getStatusDate = (theCase: Case): string | null => { +export const getStatusDate = (theCase: CaseUI): string | null => { if (theCase.status === CaseStatuses.open) { return theCase.createdAt; } else if (theCase.status === CaseStatuses['in-progress']) { diff --git a/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx b/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx index 909bcc317b505b..11543a8df6c434 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/index.test.tsx @@ -149,7 +149,7 @@ describe('CaseActionBar', () => { expect(queryByText('Sync alerts')).toBeInTheDocument(); }); - it('should not show the Case open text when the lifespan feature is enabled', () => { + it('should not show the CaseUI open text when the lifespan feature is enabled', () => { const props: CaseActionBarProps = { ...defaultProps }; const { queryByText } = render( @@ -157,17 +157,17 @@ describe('CaseActionBar', () => { ); - expect(queryByText('Case opened')).not.toBeInTheDocument(); + expect(queryByText('CaseUI opened')).not.toBeInTheDocument(); }); - it('should show the Case open text when the lifespan feature is disabled', () => { + it('should show the CaseUI open text when the lifespan feature is disabled', () => { const { getByText } = render( ); - expect(getByText('Case opened')).toBeInTheDocument(); + expect(getByText('CaseUI opened')).toBeInTheDocument(); }); it('should show the change status text when the user has update privileges', () => { diff --git a/x-pack/plugins/cases/public/components/case_action_bar/index.tsx b/x-pack/plugins/cases/public/components/case_action_bar/index.tsx index b8be843e8c659e..f412dd73715619 100644 --- a/x-pack/plugins/cases/public/components/case_action_bar/index.tsx +++ b/x-pack/plugins/cases/public/components/case_action_bar/index.tsx @@ -16,7 +16,7 @@ import { EuiFlexItem, EuiIconTip, } from '@elastic/eui'; -import type { Case } from '../../../common/ui/types'; +import type { CaseUI } from '../../../common/ui/types'; import type { CaseStatuses } from '../../../common/api'; import * as i18n from '../case_view/translations'; import { Actions } from './actions'; @@ -44,7 +44,7 @@ const MyDescriptionList = styled(EuiDescriptionList)` `; export interface CaseActionBarProps { - caseData: Case; + caseData: CaseUI; isLoading: boolean; onUpdateField: (args: OnUpdateFields) => void; } diff --git a/x-pack/plugins/cases/public/components/case_view/case_view_page.test.tsx b/x-pack/plugins/cases/public/components/case_view/case_view_page.test.tsx index f247945c7c7003..f4be92d36a7042 100644 --- a/x-pack/plugins/cases/public/components/case_view/case_view_page.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/case_view_page.test.tsx @@ -652,7 +652,7 @@ describe('CaseViewPage', () => { it('should set the cases title', () => { appMockRenderer.render(); - expect(mockSetTitle).toHaveBeenCalledWith([caseProps.caseData.title, 'Cases', 'Test']); + expect(mockSetTitle).toHaveBeenCalledWith([caseProps.caseData.title, 'CasesUI', 'Test']); }); }); }); diff --git a/x-pack/plugins/cases/public/components/case_view/case_view_tabs.tsx b/x-pack/plugins/cases/public/components/case_view/case_view_tabs.tsx index 630248bf79d523..b1e41d7c38b30d 100644 --- a/x-pack/plugins/cases/public/components/case_view/case_view_tabs.tsx +++ b/x-pack/plugins/cases/public/components/case_view/case_view_tabs.tsx @@ -13,7 +13,7 @@ import { useCaseViewNavigation } from '../../common/navigation'; import { useCasesContext } from '../cases_context/use_cases_context'; import { EXPERIMENTAL_DESC, EXPERIMENTAL_LABEL } from '../header_page/translations'; import { ACTIVITY_TAB, ALERTS_TAB, FILES_TAB } from './translations'; -import type { Case } from '../../../common'; +import type { CaseUI } from '../../../common'; import { useGetCaseFileStats } from '../../containers/use_get_case_file_stats'; const ExperimentalBadge = styled(EuiBetaBadge)` @@ -49,7 +49,7 @@ const FilesTab = ({ FilesTab.displayName = 'FilesTab'; export interface CaseViewTabsProps { - caseData: Case; + caseData: CaseUI; activeTab: CASE_VIEW_PAGE_TABS; } diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.test.tsx index aa28340c55308c..3484acfaab6161 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.test.tsx @@ -21,7 +21,7 @@ import type { AppMockRenderer } from '../../../common/mock'; import { createAppMockRenderer, noUpdateCasesPermissions } from '../../../common/mock'; import { CaseViewActivity } from './case_view_activity'; import { ConnectorTypes } from '../../../../common/api/connectors'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { CASE_VIEW_PAGE_TABS } from '../../../../common/types'; import type { CaseViewProps } from '../types'; import { useFindCaseUserActions } from '../../../containers/use_find_case_user_actions'; @@ -54,7 +54,7 @@ jest.mock('../../../containers/use_get_case_users'); (useGetTags as jest.Mock).mockReturnValue({ data: ['coke', 'pepsi'], refetch: jest.fn() }); -const caseData: Case = { +const caseData: CaseUI = { ...basicCase, comments: [...basicCase.comments, alertComment], connector: { @@ -122,7 +122,7 @@ const useGetCaseUsersMock = useGetCaseUsers as jest.Mock; // FLAKY: https://github.com/elastic/kibana/issues/151979 // FLAKY: https://github.com/elastic/kibana/issues/151980 // FLAKY: https://github.com/elastic/kibana/issues/151981 -describe.skip('Case View Page activity tab', () => { +describe.skip('CaseUI View Page activity tab', () => { const caseConnectors = getCaseConnectorsMockResponse(); beforeAll(() => { @@ -372,7 +372,7 @@ describe.skip('Case View Page activity tab', () => { }); }); - describe('Case users', () => { + describe('CaseUI users', () => { describe('Participants', () => { it('should render the participants correctly', async () => { appMockRender = createAppMockRenderer(); diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx index b178fe37bb4506..0075b08f5a7978 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_activity.tsx @@ -18,7 +18,7 @@ import { useGetCurrentUserProfile } from '../../../containers/user_profiles/use_ import { useGetSupportedActionConnectors } from '../../../containers/configure/use_get_supported_action_connectors'; import type { CaseSeverity } from '../../../../common/api'; import type { CaseUsers, UseFetchAlertData } from '../../../../common/ui/types'; -import type { Case, CaseStatuses } from '../../../../common'; +import type { CaseUI, CaseStatuses } from '../../../../common'; import { EditConnector } from '../../edit_connector'; import type { CasesNavigation } from '../../links'; import { StatusActionButton } from '../../status/button'; @@ -81,7 +81,7 @@ export const CaseViewActivity = ({ useFetchAlertData, }: { ruleDetailsNavigation?: CasesNavigation; - caseData: Case; + caseData: CaseUI; actionsNavigation?: CasesNavigation; showAlertDetails?: (alertId: string, index: string) => void; useFetchAlertData: UseFetchAlertData; diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.test.tsx index 54e5a0bc2febbc..6833df28046306 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.test.tsx @@ -11,18 +11,18 @@ import { OBSERVABILITY_OWNER } from '../../../../common/constants'; import { alertCommentWithIndices, basicCase } from '../../../containers/mock'; import type { AppMockRenderer } from '../../../common/mock'; import { createAppMockRenderer } from '../../../common/mock'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { CaseViewAlerts } from './case_view_alerts'; import * as api from '../../../containers/api'; jest.mock('../../../containers/api'); -const caseData: Case = { +const caseData: CaseUI = { ...basicCase, comments: [...basicCase.comments, alertCommentWithIndices], }; -describe('Case View Page activity tab', () => { +describe('CaseUI View Page activity tab', () => { const getAlertsStateTableMock = jest.fn(); let appMockRender: AppMockRenderer; diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.tsx index 6b884325d3f730..e3393bf7f35446 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_alerts.tsx @@ -10,7 +10,7 @@ import React, { useMemo } from 'react'; import type { EuiFlyoutSize } from '@elastic/eui'; import { EuiFlexItem, EuiFlexGroup, EuiProgress } from '@elastic/eui'; import { SECURITY_SOLUTION_OWNER } from '../../../../common/constants'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import { useKibana } from '../../../common/lib/kibana'; import { getManualAlertIds, getRegistrationContextFromAlerts } from './helpers'; import { useGetFeatureIds } from '../../../containers/use_get_feature_ids'; @@ -18,7 +18,7 @@ import { CaseViewAlertsEmpty } from './case_view_alerts_empty'; import { CaseViewTabs } from '../case_view_tabs'; import { CASE_VIEW_PAGE_TABS } from '../../../../common/types'; interface CaseViewAlertsProps { - caseData: Case; + caseData: CaseUI; } export const CaseViewAlerts = ({ caseData }: CaseViewAlertsProps) => { const { triggersActionsUi } = useKibana().services; diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx index dc5b937bd87814..1d4a028c2aede0 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import type { Case } from '../../../../common'; +import type { CaseUI } from '../../../../common'; import type { AppMockRenderer } from '../../../common/mock'; import { createAppMockRenderer } from '../../../common/mock'; @@ -21,12 +21,12 @@ jest.mock('../../../containers/use_get_case_files'); const useGetCaseFilesMock = useGetCaseFiles as jest.Mock; -const caseData: Case = { +const caseData: CaseUI = { ...basicCase, comments: [...basicCase.comments, alertCommentWithIndices], }; -describe('Case View Page files tab', () => { +describe('CaseUI View Page files tab', () => { let appMockRender: AppMockRenderer; useGetCaseFilesMock.mockReturnValue({ diff --git a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx index 54693acfa2390e..85cd4685a41fb1 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/case_view_files.tsx @@ -12,7 +12,7 @@ import type { FileJSON } from '@kbn/shared-ux-file-types'; import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; -import type { Case } from '../../../../common/ui/types'; +import type { CaseUI } from '../../../../common/ui/types'; import type { CaseFilesFilteringOptions } from '../../../containers/use_get_case_files'; import { CASE_VIEW_PAGE_TABS } from '../../../../common/types'; @@ -22,7 +22,7 @@ import { CaseViewTabs } from '../case_view_tabs'; import { FilesUtilityBar } from '../../files/files_utility_bar'; interface CaseViewFilesProps { - caseData: Case; + caseData: CaseUI; } export const DEFAULT_CASE_FILES_FILTERING_OPTIONS = { diff --git a/x-pack/plugins/cases/public/components/case_view/components/helpers.test.ts b/x-pack/plugins/cases/public/components/case_view/components/helpers.test.ts index fba878ef1061a0..f7732e939808b9 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/helpers.test.ts +++ b/x-pack/plugins/cases/public/components/case_view/components/helpers.test.ts @@ -49,7 +49,7 @@ const multipleIndices = { ], }; -describe('Case view helpers', () => { +describe('CaseUI view helpers', () => { describe('getRegistrationContextFromAlerts', () => { it('returns the correct registration context', () => { const result = getRegistrationContextFromAlerts([comment, comment2, multipleIndices]); diff --git a/x-pack/plugins/cases/public/components/case_view/components/user_list.test.tsx b/x-pack/plugins/cases/public/components/case_view/components/user_list.test.tsx index 3176dbc1cdcc02..b8ce882262b70c 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/user_list.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/user_list.test.tsx @@ -23,7 +23,7 @@ describe('UserList ', () => { const caseLink = 'https://example.com/cases/test'; const user = { email: 'case_all@elastic.co', - fullName: 'Cases', + fullName: 'CasesUI', username: 'cases_all', }; @@ -66,7 +66,7 @@ describe('UserList ', () => { headline={i18n.REPORTER} users={[ { - user: { ...user, full_name: 'Cases' }, + user: { ...user, full_name: 'CasesUI' }, }, { user: { ...user, username: 'elastic', email: 'elastic@elastic.co', full_name: null }, @@ -80,7 +80,7 @@ describe('UserList ', () => { const userProfiles = result.getAllByTestId('user-profile-username'); - expect(userProfiles[0].textContent).toBe('Cases'); + expect(userProfiles[0].textContent).toBe('CasesUI'); expect(userProfiles[1].textContent).toBe('elastic@elastic.co'); expect(userProfiles[2].textContent).toBe('test'); }); diff --git a/x-pack/plugins/cases/public/components/case_view/components/user_list.tsx b/x-pack/plugins/cases/public/components/case_view/components/user_list.tsx index 47bd0ac3750a96..96b4c80c723f93 100644 --- a/x-pack/plugins/cases/public/components/case_view/components/user_list.tsx +++ b/x-pack/plugins/cases/public/components/case_view/components/user_list.tsx @@ -22,7 +22,7 @@ import styled, { css } from 'styled-components'; import type { UserProfileWithAvatar } from '@kbn/user-profile-components'; import { useCaseViewNavigation } from '../../../common/navigation'; -import type { Case } from '../../../containers/types'; +import type { CaseUI } from '../../../containers/types'; import * as i18n from '../translations'; import type { CaseUserWithProfileInfo, UserInfoWithAvatar } from '../../user_profiles/types'; import { HoverableUserWithAvatar } from '../../user_profiles/hoverable_user_with_avatar'; @@ -30,7 +30,7 @@ import { convertToUserInfo } from '../../user_profiles/user_converter'; import { getSortField } from '../../user_profiles/sort'; interface UserListProps { - theCase: Case; + theCase: CaseUI; headline: string; loading?: boolean; users: CaseUserWithProfileInfo[]; diff --git a/x-pack/plugins/cases/public/components/case_view/metrics/index.test.tsx b/x-pack/plugins/cases/public/components/case_view/metrics/index.test.tsx index 166ec92d5798c1..2633cc79f5de1c 100644 --- a/x-pack/plugins/cases/public/components/case_view/metrics/index.test.tsx +++ b/x-pack/plugins/cases/public/components/case_view/metrics/index.test.tsx @@ -86,7 +86,7 @@ const metricsFeaturesTests: FeatureTest[] = [ feature: 'lifespan', items: [ { - title: 'Case created', + title: 'CaseUI created', value: '2020-02-19T23:06:33Z', }, { diff --git a/x-pack/plugins/cases/public/components/case_view/metrics/translations.ts b/x-pack/plugins/cases/public/components/case_view/metrics/translations.ts index 0ca0ec7ae7380e..3a9562ed3b0945 100644 --- a/x-pack/plugins/cases/public/components/case_view/metrics/translations.ts +++ b/x-pack/plugins/cases/public/components/case_view/metrics/translations.ts @@ -37,7 +37,7 @@ export const TOTAL_CONNECTORS_METRIC = i18n.translate( ); export const CASE_CREATED = i18n.translate('xpack.cases.caseView.metrics.lifespan.caseCreated', { - defaultMessage: 'Case created', + defaultMessage: 'CaseUI created', }); export const CASE_IN_PROGRESS_DURATION = i18n.translate( diff --git a/x-pack/plugins/cases/public/components/case_view/mocks.ts b/x-pack/plugins/cases/public/components/case_view/mocks.ts index 1f656ea42aa8c0..af335653a9a510 100644 --- a/x-pack/plugins/cases/public/components/case_view/mocks.ts +++ b/x-pack/plugins/cases/public/components/case_view/mocks.ts @@ -13,7 +13,7 @@ import { caseUserActions, getAlertUserAction, } from '../../containers/mock'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import type { CaseViewProps } from './types'; export const alertsHit = [ @@ -63,7 +63,7 @@ export const caseViewProps: CaseViewProps = { ], }; -export const caseData: Case = { +export const caseData: CaseUI = { ...basicCase, comments: [...basicCase.comments, alertComment], connector: { 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 8fc80c1a0aba39..69b3a8f820fd3c 100644 --- a/x-pack/plugins/cases/public/components/case_view/translations.ts +++ b/x-pack/plugins/cases/public/components/case_view/translations.ts @@ -119,13 +119,13 @@ export const ACTIVITY = i18n.translate('xpack.cases.caseView.activity', { export const EMAIL_SUBJECT = (caseTitle: string) => i18n.translate('xpack.cases.caseView.emailSubject', { values: { caseTitle }, - defaultMessage: 'Security Case - {caseTitle}', + defaultMessage: 'Security CaseUI - {caseTitle}', }); export const EMAIL_BODY = (caseUrl: string) => i18n.translate('xpack.cases.caseView.emailBody', { values: { caseUrl }, - defaultMessage: 'Case reference: {caseUrl}', + defaultMessage: 'CaseUI reference: {caseUrl}', }); export const CHANGED_CONNECTOR_FIELD = i18n.translate('xpack.cases.caseView.fieldChanged', { @@ -154,7 +154,7 @@ export const DOES_NOT_EXIST_DESCRIPTION = (caseId: string) => }); export const DOES_NOT_EXIST_BUTTON = i18n.translate('xpack.cases.caseView.doesNotExist.button', { - defaultMessage: 'Back to Cases', + defaultMessage: 'Back to CasesUI', }); export const ACTIVITY_TAB = i18n.translate('xpack.cases.caseView.tabs.activity', { diff --git a/x-pack/plugins/cases/public/components/case_view/types.ts b/x-pack/plugins/cases/public/components/case_view/types.ts index 0e6bf82c5fef95..0dba765f0d5cb9 100644 --- a/x-pack/plugins/cases/public/components/case_view/types.ts +++ b/x-pack/plugins/cases/public/components/case_view/types.ts @@ -7,7 +7,7 @@ import type { MutableRefObject } from 'react'; import type { CasesTimelineIntegration } from '../timeline_context'; import type { CasesNavigation } from '../links'; -import type { CaseViewRefreshPropInterface, Case } from '../../../common'; +import type { CaseViewRefreshPropInterface, CaseUI } from '../../../common'; import type { UseFetchAlertData } from '../../../common/ui'; export interface CaseViewBaseProps { @@ -30,12 +30,12 @@ export interface CaseViewProps extends CaseViewBaseProps { export interface CaseViewPageProps extends CaseViewBaseProps { caseId: string; fetchCase: () => void; - caseData: Case; + caseData: CaseUI; } export interface OnUpdateFields { - key: keyof Case; - value: Case[keyof Case]; + key: keyof CaseUI; + value: CaseUI[keyof CaseUI]; onSuccess?: () => void; onError?: () => void; } diff --git a/x-pack/plugins/cases/public/components/case_view/use_on_update_field.ts b/x-pack/plugins/cases/public/components/case_view/use_on_update_field.ts index d0fc6f98f0ce67..713c73d9b830c6 100644 --- a/x-pack/plugins/cases/public/components/case_view/use_on_update_field.ts +++ b/x-pack/plugins/cases/public/components/case_view/use_on_update_field.ts @@ -11,12 +11,12 @@ import deepEqual from 'fast-deep-equal'; import type { CaseConnector } from '../../../common/api'; import type { CaseAttributes } from '../../../common/api/cases/case'; import type { CaseStatuses } from '../../../common/api/cases/status'; -import type { Case, UpdateByKey, UpdateKey } from '../../containers/types'; +import type { CaseUI, UpdateByKey, UpdateKey } from '../../containers/types'; import { useUpdateCase } from '../../containers/use_update_case'; import { getTypedPayload } from '../../containers/utils'; import type { OnUpdateFields } from './types'; -export const useOnUpdateField = ({ caseData }: { caseData: Case }) => { +export const useOnUpdateField = ({ caseData }: { caseData: CaseUI }) => { const { isLoading, updateKey: loadingKey, updateCaseProperty } = useUpdateCase(); const onUpdateField = useCallback( diff --git a/x-pack/plugins/cases/public/components/cases_context/cases_global_components.test.tsx b/x-pack/plugins/cases/public/components/cases_context/cases_global_components.test.tsx index 40793010c789fb..5a54a49e1e1c90 100644 --- a/x-pack/plugins/cases/public/components/cases_context/cases_global_components.test.tsx +++ b/x-pack/plugins/cases/public/components/cases_context/cases_global_components.test.tsx @@ -20,7 +20,7 @@ const getCreateCaseFlyoutLazyNoProviderMock = getCreateCaseFlyoutLazyNoProvider const getAllCasesSelectorModalNoProviderLazyMock = getAllCasesSelectorModalNoProviderLazy as jest.Mock; -describe('Cases context UI', () => { +describe('CasesUI context UI', () => { let appMock: AppMockRenderer; beforeEach(() => { diff --git a/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx b/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx index b97602beda906b..0441a4cfd3fe83 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx +++ b/x-pack/plugins/cases/public/components/configure_cases/mapping.test.tsx @@ -47,7 +47,7 @@ describe('Mapping', () => { test('displays the description correctly', () => { const wrapper = mount(, { wrappingComponent: TestProviders }); expect(wrapper.find('[data-test-subj="field-mapping-desc"]').first().text()).toBe( - 'Map Case fields to ServiceNow ITSM fields when pushing data to ServiceNow ITSM. Field mappings require an established connection to ServiceNow ITSM.' + 'Map CaseUI fields to ServiceNow ITSM fields when pushing data to ServiceNow ITSM. Field mappings require an established connection to ServiceNow ITSM.' ); }); 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 ada2690ab7b038..68e60a67fff24a 100644 --- a/x-pack/plugins/cases/public/components/configure_cases/translations.ts +++ b/x-pack/plugins/cases/public/components/configure_cases/translations.ts @@ -38,7 +38,7 @@ export const ADD_NEW_CONNECTOR = i18n.translate('xpack.cases.configureCases.addN export const CASE_CLOSURE_OPTIONS_TITLE = i18n.translate( 'xpack.cases.configureCases.caseClosureOptionsTitle', { - defaultMessage: 'Case closures', + defaultMessage: 'CaseUI closures', } ); @@ -53,7 +53,7 @@ export const CASE_CLOSURE_OPTIONS_DESC = i18n.translate( export const CASE_CLOSURE_OPTIONS_LABEL = i18n.translate( 'xpack.cases.configureCases.caseClosureOptionsLabel', { - defaultMessage: 'Case closure options', + defaultMessage: 'CaseUI closure options', } ); @@ -81,7 +81,7 @@ 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 }.', + 'Map CaseUI 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 => @@ -157,6 +157,6 @@ export const CASES_WEBHOOK_MAPPINGS = i18n.translate( 'xpack.cases.configureCases.casesWebhookMappings', { defaultMessage: - 'Webhook - Case Management field mappings are configured in the connector settings in the third-party REST API JSON.', + 'Webhook - CaseUI Management field mappings are configured in the connector settings in the third-party REST API JSON.', } ); diff --git a/x-pack/plugins/cases/public/components/connectors/swimlane/case_fields.test.tsx b/x-pack/plugins/cases/public/components/connectors/swimlane/case_fields.test.tsx index cca74b83ddb800..2ad85d33409956 100644 --- a/x-pack/plugins/cases/public/components/connectors/swimlane/case_fields.test.tsx +++ b/x-pack/plugins/cases/public/components/connectors/swimlane/case_fields.test.tsx @@ -19,7 +19,7 @@ const fields = { const onChange = jest.fn(); -describe('Swimlane Cases Fields', () => { +describe('Swimlane CasesUI Fields', () => { test('it does not shows the mapping error callout', () => { render(); expect(screen.queryByText(i18n.EMPTY_MAPPING_WARNING_TITLE)).toBeFalsy(); diff --git a/x-pack/plugins/cases/public/components/connectors/swimlane/translations.ts b/x-pack/plugins/cases/public/components/connectors/swimlane/translations.ts index eb6cd168fab991..67ce5ef64616cf 100644 --- a/x-pack/plugins/cases/public/components/connectors/swimlane/translations.ts +++ b/x-pack/plugins/cases/public/components/connectors/swimlane/translations.ts @@ -15,11 +15,11 @@ export const ALERT_SOURCE_LABEL = i18n.translate( ); export const CASE_ID_LABEL = i18n.translate('xpack.cases.connectors.swimlane.caseIdLabel', { - defaultMessage: 'Case Id', + defaultMessage: 'CaseUI Id', }); export const CASE_NAME_LABEL = i18n.translate('xpack.cases.connectors.swimlane.caseNameLabel', { - defaultMessage: 'Case Name', + defaultMessage: 'CaseUI Name', }); export const SEVERITY_LABEL = i18n.translate('xpack.cases.connectors.swimlane.severityLabel', { @@ -37,6 +37,6 @@ export const EMPTY_MAPPING_WARNING_DESC = i18n.translate( 'xpack.cases.connectors.swimlane.emptyMappingWarningDesc', { defaultMessage: - 'This connector cannot be selected because it is missing the required case field mappings. You can edit this connector to add required field mappings or select a connector of type Cases.', + 'This connector cannot be selected because it is missing the required case field mappings. You can edit this connector to add required field mappings or select a connector of type CasesUI.', } ); diff --git a/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.tsx b/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.tsx index 216d80a702dec7..66c83d5b968cbf 100644 --- a/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.tsx +++ b/x-pack/plugins/cases/public/components/create/flyout/create_case_flyout.tsx @@ -14,7 +14,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { noop } from 'lodash'; import type { CasePostRequest } from '../../../../common/api'; import * as i18n from '../translations'; -import type { Case } from '../../../../common/ui/types'; +import type { CaseUI } from '../../../../common/ui/types'; import { CreateCaseForm } from '../form'; import type { UseCreateAttachments } from '../../../containers/use_create_attachments'; import type { CaseAttachmentsWithoutOwner } from '../../../types'; @@ -22,11 +22,11 @@ import { casesQueryClient } from '../../cases_context/query_client'; export interface CreateCaseFlyoutProps { afterCaseCreated?: ( - theCase: Case, + theCase: CaseUI, createAttachments: UseCreateAttachments['createAttachments'] ) => Promise; onClose?: () => void; - onSuccess?: (theCase: Case) => void; + onSuccess?: (theCase: CaseUI) => void; attachments?: CaseAttachmentsWithoutOwner; headerContent?: React.ReactNode; initialValue?: Pick; diff --git a/x-pack/plugins/cases/public/components/create/flyout/use_cases_add_to_new_case_flyout.tsx b/x-pack/plugins/cases/public/components/create/flyout/use_cases_add_to_new_case_flyout.tsx index a92046e8c99281..a8e234f9bb96aa 100644 --- a/x-pack/plugins/cases/public/components/create/flyout/use_cases_add_to_new_case_flyout.tsx +++ b/x-pack/plugins/cases/public/components/create/flyout/use_cases_add_to_new_case_flyout.tsx @@ -9,7 +9,7 @@ import type React from 'react'; import { useCallback } from 'react'; import type { CaseAttachmentsWithoutOwner } from '../../../types'; import { useCasesToast } from '../../../common/use_cases_toast'; -import type { Case } from '../../../containers/types'; +import type { CaseUI } from '../../../containers/types'; import { CasesContextStoreActionsList } from '../../cases_context/cases_context_reducer'; import { useCasesContext } from '../../cases_context/use_cases_context'; import type { CreateCaseFlyoutProps } from './create_case_flyout'; @@ -46,7 +46,7 @@ export const useCasesAddToNewCaseFlyout = (props: AddToNewCaseFlyoutProps = {}) return props.onClose(); } }, - onSuccess: async (theCase: Case) => { + onSuccess: async (theCase: CaseUI) => { if (theCase) { casesToasts.showSuccessAttach({ theCase, diff --git a/x-pack/plugins/cases/public/components/create/form.tsx b/x-pack/plugins/cases/public/components/create/form.tsx index 05dfef20636301..76344989ac0b2d 100644 --- a/x-pack/plugins/cases/public/components/create/form.tsx +++ b/x-pack/plugins/cases/public/components/create/form.tsx @@ -24,7 +24,7 @@ import { Connector } from './connector'; import * as i18n from './translations'; import { SyncAlertsToggle } from './sync_alerts_toggle'; import type { ActionConnector, CasePostRequest } from '../../../common/api'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import type { CasesTimelineIntegration } from '../timeline_context'; import { CasesTimelineIntegrationProvider } from '../timeline_context'; import { InsertTimeline } from '../insert_timeline'; @@ -69,9 +69,9 @@ export interface CreateCaseFormFieldsProps { } export interface CreateCaseFormProps extends Pick, 'withSteps'> { onCancel: () => void; - onSuccess: (theCase: Case) => void; + onSuccess: (theCase: CaseUI) => void; afterCaseCreated?: ( - theCase: Case, + theCase: CaseUI, createAttachments: UseCreateAttachments['createAttachments'] ) => Promise; timelineIntegration?: CasesTimelineIntegration; @@ -208,7 +208,7 @@ export const CreateCaseForm: React.FC = React.memo( onConfirmationCallback: handleOnConfirmationCallback, }); - const handleOnSuccess = (theCase: Case): void => { + const handleOnSuccess = (theCase: CaseUI): void => { removeItemFromSessionStorage(draftStorageKey); return onSuccess(theCase); }; diff --git a/x-pack/plugins/cases/public/components/create/form_context.test.tsx b/x-pack/plugins/cases/public/components/create/form_context.test.tsx index 1330f5b7532222..a161b7aee55f65 100644 --- a/x-pack/plugins/cases/public/components/create/form_context.test.tsx +++ b/x-pack/plugins/cases/public/components/create/form_context.test.tsx @@ -184,7 +184,7 @@ describe('Create case', () => { sessionStorage.removeItem(defaultCreateCaseForm.draftStorageKey); }); - describe('Step 1 - Case Fields', () => { + describe('Step 1 - CaseUI Fields', () => { it('renders correctly', async () => { mockedContext.render( diff --git a/x-pack/plugins/cases/public/components/create/form_context.tsx b/x-pack/plugins/cases/public/components/create/form_context.tsx index f3a78e8a1b9ca4..d62f8e155badf5 100644 --- a/x-pack/plugins/cases/public/components/create/form_context.tsx +++ b/x-pack/plugins/cases/public/components/create/form_context.tsx @@ -13,7 +13,7 @@ import { getNoneConnector, normalizeActionConnector } from '../configure_cases/u import { usePostCase } from '../../containers/use_post_case'; import { usePostPushToService } from '../../containers/use_post_push_to_service'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import type { CasePostRequest } from '../../../common/api'; import { CaseSeverity, NONE_CONNECTOR_ID } from '../../../common/api'; import type { UseCreateAttachments } from '../../containers/use_create_attachments'; @@ -39,11 +39,11 @@ const initialCaseValue: FormProps = { interface Props { afterCaseCreated?: ( - theCase: Case, + theCase: CaseUI, createAttachments: UseCreateAttachments['createAttachments'] ) => Promise; children?: JSX.Element | JSX.Element[]; - onSuccess?: (theCase: Case) => void; + onSuccess?: (theCase: CaseUI) => void; attachments?: CaseAttachmentsWithoutOwner; initialValue?: Pick; } diff --git a/x-pack/plugins/cases/public/components/create/owner_selector.test.tsx b/x-pack/plugins/cases/public/components/create/owner_selector.test.tsx index cd9515edbd28c3..460c39c67764bc 100644 --- a/x-pack/plugins/cases/public/components/create/owner_selector.test.tsx +++ b/x-pack/plugins/cases/public/components/create/owner_selector.test.tsx @@ -18,7 +18,7 @@ import type { FormProps } from './schema'; import { schema } from './schema'; import { waitForComponentToPaint } from '../../common/test_utils'; -describe('Case Owner Selection', () => { +describe('CaseUI Owner Selection', () => { let globalForm: FormHook; const MockHookWrapperComponent: React.FC = ({ children }) => { diff --git a/x-pack/plugins/cases/public/components/create/translations.ts b/x-pack/plugins/cases/public/components/create/translations.ts index 4bb7471e1c648e..534a532997ef41 100644 --- a/x-pack/plugins/cases/public/components/create/translations.ts +++ b/x-pack/plugins/cases/public/components/create/translations.ts @@ -11,11 +11,11 @@ export * from '../../common/translations'; export * from '../user_profiles/translations'; export const STEP_ONE_TITLE = i18n.translate('xpack.cases.create.stepOneTitle', { - defaultMessage: 'Case fields', + defaultMessage: 'CaseUI fields', }); export const STEP_TWO_TITLE = i18n.translate('xpack.cases.create.stepTwoTitle', { - defaultMessage: 'Case settings', + defaultMessage: 'CaseUI settings', }); export const STEP_THREE_TITLE = i18n.translate('xpack.cases.create.stepThreeTitle', { diff --git a/x-pack/plugins/cases/public/components/description/description_wrapper.tsx b/x-pack/plugins/cases/public/components/description/description_wrapper.tsx index 77b29abfa0c0d5..a7fd42d128716a 100644 --- a/x-pack/plugins/cases/public/components/description/description_wrapper.tsx +++ b/x-pack/plugins/cases/public/components/description/description_wrapper.tsx @@ -12,14 +12,14 @@ import { EuiCommentList, EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@e import React, { useMemo } from 'react'; import styled from 'styled-components'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import type { OnUpdateFields } from '../case_view/types'; import { getDescriptionUserAction } from '../user_actions/description'; import { useUserActionsHandler } from '../user_actions/use_user_actions_handler'; import { useCasesContext } from '../cases_context/use_cases_context'; interface DescriptionWrapperProps { - data: Case; + data: CaseUI; isLoadingDescription: boolean; userProfiles: Map; onUpdateField: ({ key, value, onSuccess, onError }: OnUpdateFields) => void; diff --git a/x-pack/plugins/cases/public/components/edit_connector/index.tsx b/x-pack/plugins/cases/public/components/edit_connector/index.tsx index 8a63c9d02ad266..fd2ca685b8854c 100644 --- a/x-pack/plugins/cases/public/components/edit_connector/index.tsx +++ b/x-pack/plugins/cases/public/components/edit_connector/index.tsx @@ -22,7 +22,7 @@ import { isEmpty, noop } from 'lodash/fp'; import type { FieldConfig } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; import { Form, UseField, useForm } from '@kbn/es-ui-shared-plugin/static/forms/hook_form_lib'; -import type { Case, CaseConnectors } from '../../../common/ui/types'; +import type { CaseUI, CaseConnectors } from '../../../common/ui/types'; import type { ActionConnector, CaseConnector, ConnectorTypeFields } from '../../../common/api'; import { NONE_CONNECTOR_ID } from '../../../common/api'; import { ConnectorSelector } from '../connector_selector/form'; @@ -37,7 +37,7 @@ import { PushCallouts } from './push_callouts'; import { normalizeActionConnector, getNoneConnector } from '../configure_cases/utils'; export interface EditConnectorProps { - caseData: Case; + caseData: CaseUI; caseConnectors: CaseConnectors; supportedActionConnectors: ActionConnector[]; isLoading: boolean; diff --git a/x-pack/plugins/cases/public/components/no_privileges/translations.ts b/x-pack/plugins/cases/public/components/no_privileges/translations.ts index b10b9eb4b6a7ca..e6f1bff747d6c8 100644 --- a/x-pack/plugins/cases/public/components/no_privileges/translations.ts +++ b/x-pack/plugins/cases/public/components/no_privileges/translations.ts @@ -19,5 +19,5 @@ export const NO_PRIVILEGES_TITLE = i18n.translate('xpack.cases.noPrivileges.titl }); export const NO_PRIVILEGES_BUTTON = i18n.translate('xpack.cases.noPrivileges.button', { - defaultMessage: 'Back to Cases', + defaultMessage: 'Back to CasesUI', }); diff --git a/x-pack/plugins/cases/public/components/recent_cases/translations.ts b/x-pack/plugins/cases/public/components/recent_cases/translations.ts index e0b9f8438df4b9..1aefd1bf04ba43 100644 --- a/x-pack/plugins/cases/public/components/recent_cases/translations.ts +++ b/x-pack/plugins/cases/public/components/recent_cases/translations.ts @@ -60,5 +60,5 @@ export const VIEW_ALL_CASES = i18n.translate('xpack.cases.recentCases.viewAllCas }); export const CASES_FILTER_CONTROL = i18n.translate('xpack.cases.recentCases.controlLegend', { - defaultMessage: 'Cases filter', + defaultMessage: 'CasesUI filter', }); diff --git a/x-pack/plugins/cases/public/components/status/translations.ts b/x-pack/plugins/cases/public/components/status/translations.ts index 3806074f3be11e..a5384f959e08dd 100644 --- a/x-pack/plugins/cases/public/components/status/translations.ts +++ b/x-pack/plugins/cases/public/components/status/translations.ts @@ -17,13 +17,13 @@ export const STATUS_ICON_ARIA = i18n.translate('xpack.cases.status.iconAria', { }); export const CASE_OPENED = i18n.translate('xpack.cases.caseView.caseOpened', { - defaultMessage: 'Case opened', + defaultMessage: 'CaseUI opened', }); export const CASE_IN_PROGRESS = i18n.translate('xpack.cases.caseView.caseInProgress', { - defaultMessage: 'Case in progress', + defaultMessage: 'CaseUI in progress', }); export const CASE_CLOSED = i18n.translate('xpack.cases.caseView.caseClosed', { - defaultMessage: 'Case closed', + defaultMessage: 'CaseUI closed', }); diff --git a/x-pack/plugins/cases/public/components/use_breadcrumbs/index.test.tsx b/x-pack/plugins/cases/public/components/use_breadcrumbs/index.test.tsx index 7a52686e64378c..486eedfb5c0a3f 100644 --- a/x-pack/plugins/cases/public/components/use_breadcrumbs/index.test.tsx +++ b/x-pack/plugins/cases/public/components/use_breadcrumbs/index.test.tsx @@ -48,13 +48,13 @@ describe('useCasesBreadcrumbs', () => { renderHook(() => useCasesBreadcrumbs(CasesDeepLinkId.cases), { wrapper }); expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ { href: '/test', onClick: expect.any(Function), text: 'Test' }, - { text: 'Cases' }, + { text: 'CasesUI' }, ]); }); it('should sets the cases title', () => { renderHook(() => useCasesBreadcrumbs(CasesDeepLinkId.cases), { wrapper }); - expect(mockSetTitle).toHaveBeenCalledWith(['Cases', 'Test']); + expect(mockSetTitle).toHaveBeenCalledWith(['CasesUI', 'Test']); }); }); @@ -63,14 +63,14 @@ describe('useCasesBreadcrumbs', () => { renderHook(() => useCasesBreadcrumbs(CasesDeepLinkId.casesCreate), { wrapper }); expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ { href: '/test', onClick: expect.any(Function), text: 'Test' }, - { href: CasesDeepLinkId.cases, onClick: expect.any(Function), text: 'Cases' }, + { href: CasesDeepLinkId.cases, onClick: expect.any(Function), text: 'CasesUI' }, { text: 'Create' }, ]); }); it('should sets the cases title', () => { renderHook(() => useCasesBreadcrumbs(CasesDeepLinkId.casesCreate), { wrapper }); - expect(mockSetTitle).toHaveBeenCalledWith(['Create', 'Cases', 'Test']); + expect(mockSetTitle).toHaveBeenCalledWith(['Create', 'CasesUI', 'Test']); }); }); @@ -80,14 +80,14 @@ describe('useCasesBreadcrumbs', () => { renderHook(() => useCasesTitleBreadcrumbs(title), { wrapper }); expect(mockSetBreadcrumbs).toHaveBeenCalledWith([ { href: '/test', onClick: expect.any(Function), text: 'Test' }, - { href: CasesDeepLinkId.cases, onClick: expect.any(Function), text: 'Cases' }, + { href: CasesDeepLinkId.cases, onClick: expect.any(Function), text: 'CasesUI' }, { text: title }, ]); }); it('should sets the cases title', () => { renderHook(() => useCasesTitleBreadcrumbs(title), { wrapper }); - expect(mockSetTitle).toHaveBeenCalledWith([title, 'Cases', 'Test']); + expect(mockSetTitle).toHaveBeenCalledWith([title, 'CasesUI', 'Test']); }); }); }); diff --git a/x-pack/plugins/cases/public/components/use_breadcrumbs/index.ts b/x-pack/plugins/cases/public/components/use_breadcrumbs/index.ts index 68a37f8252f050..fae4043abd7af8 100644 --- a/x-pack/plugins/cases/public/components/use_breadcrumbs/index.ts +++ b/x-pack/plugins/cases/public/components/use_breadcrumbs/index.ts @@ -15,7 +15,7 @@ import { useCasesContext } from '../cases_context/use_cases_context'; const casesBreadcrumbTitle: Record = { [CasesDeepLinkId.cases]: i18n.translate('xpack.cases.breadcrumbs.all_cases', { - defaultMessage: 'Cases', + defaultMessage: 'CasesUI', }), [CasesDeepLinkId.casesCreate]: i18n.translate('xpack.cases.breadcrumbs.create_case', { defaultMessage: 'Create', 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 0418746eff912f..482c198d15d633 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 @@ -8,14 +8,14 @@ import React, { memo } from 'react'; import { EuiModal, EuiModalBody, EuiModalHeader, EuiModalHeaderTitle } from '@elastic/eui'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import * as i18n from '../../common/translations'; import { CreateCase } from '../create'; export interface CreateCaseModalProps { isModalOpen: boolean; onCloseCaseModal: () => void; - onSuccess: (theCase: Case) => Promise; + onSuccess: (theCase: CaseUI) => Promise; } const CreateModalComponent: React.FC = ({ diff --git a/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx b/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx index f640fd2b3df7ca..92a24b615e3830 100644 --- a/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx +++ b/x-pack/plugins/cases/public/components/use_create_case_modal/index.tsx @@ -6,11 +6,11 @@ */ import React, { useState, useCallback, useMemo } from 'react'; -import type { Case } from '../../../common/ui/types'; +import type { CaseUI } from '../../../common/ui/types'; import { CreateCaseModal } from './create_case_modal'; export interface UseCreateCaseModalProps { - onCaseCreated: (theCase: Case) => void; + onCaseCreated: (theCase: CaseUI) => void; } export interface UseCreateCaseModalReturnedValues { modal: JSX.Element; diff --git a/x-pack/plugins/cases/public/components/user_actions/helpers.test.ts b/x-pack/plugins/cases/public/components/user_actions/helpers.test.ts index bd1873a591beeb..e4f97bb2bec3d3 100644 --- a/x-pack/plugins/cases/public/components/user_actions/helpers.test.ts +++ b/x-pack/plugins/cases/public/components/user_actions/helpers.test.ts @@ -49,7 +49,7 @@ const comments: Comment[] = [ }, ]; -describe('Case view helpers', () => {}); +describe('CaseUI view helpers', () => {}); describe('helpers', () => { describe('isUserActionTypeSupported', () => { diff --git a/x-pack/plugins/cases/public/components/user_actions/markdown_form.tsx b/x-pack/plugins/cases/public/components/user_actions/markdown_form.tsx index 3ddb62eb4fb7aa..67451c4a7183d5 100644 --- a/x-pack/plugins/cases/public/components/user_actions/markdown_form.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/markdown_form.tsx @@ -89,7 +89,7 @@ const UserActionMarkdownComponent = forwardRef< component={MarkdownEditorForm} componentProps={{ ref: editorRef, - 'aria-label': 'Cases markdown editor', + 'aria-label': 'CasesUI markdown editor', value: content, id, draftStorageKey, diff --git a/x-pack/plugins/cases/public/components/user_actions/types.ts b/x-pack/plugins/cases/public/components/user_actions/types.ts index 5146a97aba65bc..f8ff85e05bf182 100644 --- a/x-pack/plugins/cases/public/components/user_actions/types.ts +++ b/x-pack/plugins/cases/public/components/user_actions/types.ts @@ -10,7 +10,7 @@ import type { UserProfileWithAvatar } from '@kbn/user-profile-components'; import type { SnakeToCamelCase } from '../../../common/types'; import type { ActionTypes, UserActionWithResponse } from '../../../common/api'; import type { - Case, + CaseUI, CaseConnectors, CaseUserActions, Comment, @@ -31,7 +31,7 @@ export interface UserActionTreeProps { caseConnectors: CaseConnectors; userProfiles: Map; currentUserProfile: CurrentUserProfile; - data: Case; + data: CaseUI; getRuleDetailsHref?: RuleDetailsNavigation['href']; actionsNavigation?: ActionsNavigation; onRuleDetailsClick?: RuleDetailsNavigation['onClick']; @@ -48,7 +48,7 @@ export type SupportedUserActionTypes = keyof Omit; currentUserProfile: CurrentUserProfile; externalReferenceAttachmentTypeRegistry: ExternalReferenceAttachmentTypeRegistry; diff --git a/x-pack/plugins/cases/public/components/user_actions/use_user_actions_handler.tsx b/x-pack/plugins/cases/public/components/user_actions/use_user_actions_handler.tsx index e19dbea584fc8e..5c9bb98ccb2a2e 100644 --- a/x-pack/plugins/cases/public/components/user_actions/use_user_actions_handler.tsx +++ b/x-pack/plugins/cases/public/components/user_actions/use_user_actions_handler.tsx @@ -7,7 +7,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { useCaseViewParams } from '../../common/navigation'; -import type { Case } from '../../containers/types'; +import type { CaseUI } from '../../containers/types'; import { useLensDraftComment } from '../markdown_editor/plugins/lens/use_lens_draft_comment'; import { useUpdateComment } from '../../containers/use_update_comment'; import type { AddCommentRefObject } from '../add_comment'; @@ -28,7 +28,7 @@ export type UseUserActionsHandler = Pick< | 'handleSaveComment' | 'handleManageQuote' | 'handleDeleteComment' -> & { handleUpdate: (updatedCase: Case) => void }; +> & { handleUpdate: (updatedCase: CaseUI) => void }; const isAddCommentRef = ( ref: AddCommentRefObject | UserActionMarkdownRefObject | null | undefined diff --git a/x-pack/plugins/cases/public/containers/__mocks__/api.ts b/x-pack/plugins/cases/public/containers/__mocks__/api.ts index b29e45f6f101ed..19aea63bdb0bf6 100644 --- a/x-pack/plugins/cases/public/containers/__mocks__/api.ts +++ b/x-pack/plugins/cases/public/containers/__mocks__/api.ts @@ -7,8 +7,8 @@ import type { ActionLicense, - Cases, - Case, + CasesUI, + CaseUI, CasesStatus, FetchCasesProps, FindCaseUserActions, @@ -53,7 +53,7 @@ export const getCase = async ( caseId: string, includeComments: boolean = true, signal: AbortSignal -): Promise => Promise.resolve(basicCase); +): Promise => Promise.resolve(basicCase); export const resolveCase = async ( caseId: string, @@ -101,9 +101,9 @@ export const getCases = async ({ sortOrder: 'desc', }, signal, -}: FetchCasesProps): Promise => Promise.resolve(allCases); +}: FetchCasesProps): Promise => Promise.resolve(allCases); -export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise => +export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise => Promise.resolve(basicCasePost); export const patchCase = async ( @@ -111,18 +111,18 @@ export const patchCase = async ( updatedCase: Pick, version: string, signal: AbortSignal -): Promise => Promise.resolve([basicCase]); +): Promise => Promise.resolve([basicCase]); export const updateCases = async ( cases: CaseUpdateRequest[], signal: AbortSignal -): Promise => Promise.resolve(allCases.cases); +): Promise => Promise.resolve(allCases.cases); export const createAttachments = async ( newComment: CommentRequest, caseId: string, signal: AbortSignal -): Promise => Promise.resolve(basicCase); +): Promise => Promise.resolve(basicCase); export const deleteComment = async ( caseId: string, @@ -136,7 +136,7 @@ export const patchComment = async ( commentUpdate: string, version: string, signal: AbortSignal -): Promise => Promise.resolve(basicCaseCommentPatch); +): Promise => Promise.resolve(basicCaseCommentPatch); export const deleteCases = async (caseIds: string[], signal: AbortSignal): Promise => Promise.resolve(true); @@ -145,7 +145,7 @@ export const pushCase = async ( caseId: string, connectorId: string, signal: AbortSignal -): Promise => Promise.resolve(pushedCase); +): Promise => Promise.resolve(pushedCase); export const getActionLicense = async (signal: AbortSignal): Promise => Promise.resolve(actionLicenses); diff --git a/x-pack/plugins/cases/public/containers/api.test.tsx b/x-pack/plugins/cases/public/containers/api.test.tsx index 3f623795c819c3..1275b34e096754 100644 --- a/x-pack/plugins/cases/public/containers/api.test.tsx +++ b/x-pack/plugins/cases/public/containers/api.test.tsx @@ -78,7 +78,7 @@ jest.mock('../common/lib/kibana'); const fetchMock = jest.fn(); mockKibanaServices.mockReturnValue({ http: { fetch: fetchMock } }); -describe('Cases API', () => { +describe('CasesUI API', () => { describe('deleteCases', () => { beforeEach(() => { fetchMock.mockClear(); diff --git a/x-pack/plugins/cases/public/containers/api.ts b/x-pack/plugins/cases/public/containers/api.ts index 485162e814c5cf..d1ad89b7d2a3bb 100644 --- a/x-pack/plugins/cases/public/containers/api.ts +++ b/x-pack/plugins/cases/public/containers/api.ts @@ -9,7 +9,6 @@ import type { ValidFeatureId } from '@kbn/rule-data-utils'; import { BASE_RAC_ALERTS_API_PATH } from '@kbn/rule-registry-plugin/common/constants'; import type { CaseConnectors, - Cases, CaseUpdateRequest, FetchCasesProps, ResolvedCase, @@ -17,15 +16,14 @@ import type { CaseUserActionTypeWithAll, CaseUserActionsStats, CaseUsers, + CasesUI, } from '../../common/ui/types'; import { SeverityAll, SortFieldCase, StatusAll } from '../../common/ui/types'; import type { BulkCreateCommentRequest, CasePatchRequest, CasePostRequest, - Case, CaseResolveResponse, - Cases, UserActionFindResponse, CommentRequest, User, @@ -69,7 +67,7 @@ import { import type { ActionLicense, - Case, + CaseUI, SingleCaseMetrics, SingleCaseMetricsFeature, CaseUserActions, @@ -91,8 +89,8 @@ export const getCase = async ( caseId: string, includeComments: boolean = true, signal: AbortSignal -): Promise => { - const response = await KibanaServices.get().http.fetch(getCaseDetailsUrl(caseId), { +): Promise => { + const response = await KibanaServices.get().http.fetch(getCaseDetailsUrl(caseId), { method: 'GET', query: { includeComments, @@ -223,7 +221,7 @@ export const getCases = async ({ sortOrder: 'desc', }, signal, -}: FetchCasesProps): Promise => { +}: FetchCasesProps): Promise => { const query = { ...(filterOptions.status !== StatusAll ? { status: filterOptions.status } : {}), ...(filterOptions.severity !== SeverityAll ? { severity: filterOptions.severity } : {}), @@ -245,8 +243,8 @@ export const getCases = async ({ return convertAllCasesToCamel(decodeCasesFindResponse(response)); }; -export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise => { - const response = await KibanaServices.get().http.fetch(CASES_URL, { +export const postCase = async (newCase: CasePostRequest, signal: AbortSignal): Promise => { + const response = await KibanaServices.get().http.fetch(CASES_URL, { method: 'POST', body: JSON.stringify(newCase), signal, @@ -262,8 +260,8 @@ export const patchCase = async ( >, version: string, signal: AbortSignal -): Promise => { - const response = await KibanaServices.get().http.fetch(CASES_URL, { +): Promise => { + const response = await KibanaServices.get().http.fetch(CASES_URL, { method: 'PATCH', body: JSON.stringify({ cases: [{ ...updatedCase, id: caseId, version }] }), signal, @@ -274,12 +272,12 @@ export const patchCase = async ( export const updateCases = async ( cases: CaseUpdateRequest[], signal: AbortSignal -): Promise => { +): Promise => { if (cases.length === 0) { return []; } - const response = await KibanaServices.get().http.fetch(CASES_URL, { + const response = await KibanaServices.get().http.fetch(CASES_URL, { method: 'PATCH', body: JSON.stringify({ cases }), signal, @@ -292,12 +290,15 @@ export const postComment = async ( newComment: CommentRequest, caseId: string, signal: AbortSignal -): Promise => { - const response = await KibanaServices.get().http.fetch(`${CASES_URL}/${caseId}/comments`, { - method: 'POST', - body: JSON.stringify(newComment), - signal, - }); +): Promise => { + const response = await KibanaServices.get().http.fetch( + `${CASES_URL}/${caseId}/comments`, + { + method: 'POST', + body: JSON.stringify(newComment), + signal, + } + ); return convertCaseToCamelCase(decodeCaseResponse(response)); }; @@ -315,8 +316,8 @@ export const patchComment = async ({ version: string; signal: AbortSignal; owner: string; -}): Promise => { - const response = await KibanaServices.get().http.fetch(getCaseCommentsUrl(caseId), { +}): Promise => { + const response = await KibanaServices.get().http.fetch(getCaseCommentsUrl(caseId), { method: 'PATCH', body: JSON.stringify({ comment: commentUpdate, @@ -339,7 +340,7 @@ export const deleteComment = async ({ commentId: string; signal: AbortSignal; }): Promise => { - await KibanaServices.get().http.fetch(getCaseCommentDeleteUrl(caseId, commentId), { + await KibanaServices.get().http.fetch(getCaseCommentDeleteUrl(caseId, commentId), { method: 'DELETE', signal, }); @@ -358,8 +359,8 @@ export const pushCase = async ( caseId: string, connectorId: string, signal: AbortSignal -): Promise => { - const response = await KibanaServices.get().http.fetch( +): Promise => { + const response = await KibanaServices.get().http.fetch( getCasePushUrl(caseId, connectorId), { method: 'POST', @@ -387,8 +388,8 @@ export const createAttachments = async ( attachments: BulkCreateCommentRequest, caseId: string, signal: AbortSignal -): Promise => { - const response = await KibanaServices.get().http.fetch( +): Promise => { + const response = await KibanaServices.get().http.fetch( INTERNAL_BULK_CREATE_ATTACHMENTS_URL.replace('{case_id}', caseId), { method: 'POST', diff --git a/x-pack/plugins/cases/public/containers/configure/api.test.ts b/x-pack/plugins/cases/public/containers/configure/api.test.ts index 9099f908a78713..4df9270598ebb5 100644 --- a/x-pack/plugins/cases/public/containers/configure/api.test.ts +++ b/x-pack/plugins/cases/public/containers/configure/api.test.ts @@ -29,7 +29,7 @@ jest.mock('../../common/lib/kibana'); const fetchMock = jest.fn(); mockKibanaServices.mockReturnValue({ http: { fetch: fetchMock } }); -describe('Case Configuration API', () => { +describe('CaseUI Configuration API', () => { describe('fetch connectors', () => { beforeEach(() => { fetchMock.mockClear(); diff --git a/x-pack/plugins/cases/public/containers/mock.ts b/x-pack/plugins/cases/public/containers/mock.ts index aec5fa0df488e6..d2ff6a1c0de6f1 100644 --- a/x-pack/plugins/cases/public/containers/mock.ts +++ b/x-pack/plugins/cases/public/containers/mock.ts @@ -6,7 +6,14 @@ */ import type { FileJSON } from '@kbn/shared-ux-file-types'; -import type { ActionLicense, Cases, Case, CasesStatus, CaseUserActions, Comment } from './types'; +import type { + ActionLicense, + CasesUI, + CaseUI, + CasesStatus, + CaseUserActions, + Comment, +} from './types'; import type { ResolvedCase, @@ -208,7 +215,7 @@ export const persistableStateAttachment: PersistableComment = { version: 'WzQ3LDFc', }; -export const basicCase: Case = { +export const basicCase: CaseUI = { owner: SECURITY_SOLUTION_OWNER, closedAt: null, closedBy: null, @@ -325,7 +332,7 @@ export const basicCaseMetrics: SingleCaseMetrics = { }, }; -export const mockCase: Case = { +export const mockCase: CaseUI = { owner: SECURITY_SOLUTION_OWNER, closedAt: null, closedBy: null, @@ -357,7 +364,7 @@ export const mockCase: Case = { assignees: [], }; -export const basicCasePost: Case = { +export const basicCasePost: CaseUI = { ...basicCase, updatedAt: null, updatedBy: null, @@ -398,7 +405,7 @@ export const basicPush = { pushedBy: elasticUser, }; -export const pushedCase: Case = { +export const pushedCase: CaseUI = { ...basicCase, connector: { id: pushConnectorId, @@ -419,7 +426,7 @@ const basicAction = { type: 'title', }; -export const cases: Case[] = [ +export const cases: CaseUI[] = [ basicCase, { ...pushedCase, @@ -437,7 +444,7 @@ export const cases: Case[] = [ caseWithRegisteredAttachments, ]; -export const allCases: Cases = { +export const allCases: CasesUI = { cases, page: 1, perPage: 5, @@ -910,7 +917,7 @@ export const useGetCasesMockState = { isError: false, }; -export const basicCaseClosed: Case = { +export const basicCaseClosed: CaseUI = { ...basicCase, closedAt: '2020-02-25T23:06:33.798Z', closedBy: elasticUser, diff --git a/x-pack/plugins/cases/public/containers/use_create_attachments.tsx b/x-pack/plugins/cases/public/containers/use_create_attachments.tsx index 074b85839c4d9d..38cb5de7ee5138 100644 --- a/x-pack/plugins/cases/public/containers/use_create_attachments.tsx +++ b/x-pack/plugins/cases/public/containers/use_create_attachments.tsx @@ -9,7 +9,7 @@ import { useReducer, useCallback, useRef, useEffect } from 'react'; import { createAttachments } from './api'; import * as i18n from './translations'; -import type { Case } from './types'; +import type { CaseUI } from './types'; import { useToasts } from '../common/lib/kibana'; import type { CaseAttachmentsWithoutOwner } from '../types'; @@ -45,7 +45,7 @@ export interface PostComment { caseId: string; caseOwner: string; data: CaseAttachmentsWithoutOwner; - updateCase?: (newCase: Case) => void; + updateCase?: (newCase: CaseUI) => void; throwOnError?: boolean; } export interface UseCreateAttachments extends NewCommentState { diff --git a/x-pack/plugins/cases/public/containers/use_get_cases.tsx b/x-pack/plugins/cases/public/containers/use_get_cases.tsx index b9f55cc77682f2..356534d60cc064 100644 --- a/x-pack/plugins/cases/public/containers/use_get_cases.tsx +++ b/x-pack/plugins/cases/public/containers/use_get_cases.tsx @@ -8,7 +8,7 @@ import type { UseQueryResult } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query'; import { casesQueriesKeys, DEFAULT_TABLE_ACTIVE_PAGE, DEFAULT_TABLE_LIMIT } from './constants'; -import type { Cases, FilterOptions, QueryParams } from './types'; +import type { CasesUI, FilterOptions, QueryParams } from './types'; import { SortFieldCase, StatusAll, SeverityAll } from './types'; import { useToasts } from '../common/lib/kibana'; import * as i18n from './translations'; @@ -35,7 +35,7 @@ export const DEFAULT_QUERY_PARAMS: QueryParams = { sortOrder: 'desc', }; -export const initialData: Cases = { +export const initialData: CasesUI = { cases: [], countClosedCases: 0, countInProgressCases: 0, @@ -50,7 +50,7 @@ export const useGetCases = ( queryParams?: Partial; filterOptions?: Partial; } = {} -): UseQueryResult => { +): UseQueryResult => { const toasts = useToasts(); return useQuery( casesQueriesKeys.cases(params), 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 d13500dcbc5fad..bda1c3bc37d549 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 @@ -10,7 +10,7 @@ import type { CaseConnector } from '../../common/api'; import { pushCase } from './api'; import * as i18n from './translations'; -import type { Case } from './types'; +import type { CaseUI } from './types'; import { useToasts } from '../common/lib/kibana'; interface PushToServiceState { @@ -53,7 +53,7 @@ export interface UsePostPushToService extends PushToServiceState { pushCaseToExternalService: ({ caseId, connector, - }: PushToServiceRequest) => Promise; + }: PushToServiceRequest) => Promise; } export const usePostPushToService = (): UsePostPushToService => { diff --git a/x-pack/plugins/cases/public/containers/utils.test.ts b/x-pack/plugins/cases/public/containers/utils.test.ts index c87c81a02f8186..b7a0b17ec5ff0a 100644 --- a/x-pack/plugins/cases/public/containers/utils.test.ts +++ b/x-pack/plugins/cases/public/containers/utils.test.ts @@ -13,7 +13,7 @@ import { constructReportersFilter, } from './utils'; -import type { Case } from './types'; +import type { CaseUI } from './types'; const caseBeforeUpdate = { comments: [ @@ -24,9 +24,9 @@ const caseBeforeUpdate = { settings: { syncAlerts: true, }, -} as Case; +} as CaseUI; -const caseAfterUpdate = { title: 'My case' } as Case; +const caseAfterUpdate = { title: 'My case' } as CaseUI; describe('utils', () => { describe('valueToUpdateIsSettings', () => { diff --git a/x-pack/plugins/cases/public/containers/utils.ts b/x-pack/plugins/cases/public/containers/utils.ts index 8e5cfdaa5bdd1c..8227472a7c686e 100644 --- a/x-pack/plugins/cases/public/containers/utils.ts +++ b/x-pack/plugins/cases/public/containers/utils.ts @@ -13,8 +13,6 @@ import { pipe } from 'fp-ts/lib/pipeable'; import type { ToastInputFields } from '@kbn/core/public'; import { NO_ASSIGNEES_FILTERING_KEYWORD } from '../../common/constants'; import type { - Case, - Cases, CasesConfigurationsResponse, CasesConfigureResponse, CaseUserActionsResponse, @@ -36,7 +34,7 @@ import { SingleCaseMetricsResponseRt, CaseUserActionStatsResponseRt, } from '../../common/api'; -import type { Case, FilterOptions, UpdateByKey } from './types'; +import type { CaseUI, CasesUI, FilterOptions, UpdateByKey } from './types'; import * as i18n from './translations'; export const getTypedPayload = (a: unknown): T => a as T; @@ -49,7 +47,7 @@ export const covertToSnakeCase = (obj: Record) => export const createToasterPlainError = (message: string) => new ToasterError([message]); -export const decodeCaseResponse = (respCase?: Case) => +export const decodeCaseResponse = (respCase?: CaseUI) => pipe(CaseRt.decode(respCase), fold(throwErrors(createToasterPlainError), identity)); export const decodeCaseResolveResponse = (respCase?: CaseResolveResponse) => @@ -64,7 +62,7 @@ export const decodeSingleCaseMetricsResponse = (respCase?: SingleCaseMetricsResp fold(throwErrors(createToasterPlainError), identity) ); -export const decodeCasesResponse = (respCase?: Cases) => +export const decodeCasesResponse = (respCase?: CasesUI) => pipe(CasesRt.decode(respCase), fold(throwErrors(createToasterPlainError), identity)); export const decodeCaseConfigurationsResponse = (respCase?: CasesConfigurationsResponse) => { @@ -114,8 +112,8 @@ export class ToasterError extends Error { } } export const createUpdateSuccessToaster = ( - caseBeforeUpdate: Case, - caseAfterUpdate: Case, + caseBeforeUpdate: CaseUI, + caseAfterUpdate: CaseUI, key: UpdateByKey['updateKey'], value: UpdateByKey['updateValue'] ): ToastInputFields => { diff --git a/x-pack/plugins/cases/public/plugin.ts b/x-pack/plugins/cases/public/plugin.ts index 8897b9ccbd0460..cdd5cfa5429e9b 100644 --- a/x-pack/plugins/cases/public/plugin.ts +++ b/x-pack/plugins/cases/public/plugin.ts @@ -32,7 +32,7 @@ import { registerInternalAttachments } from './internal_attachments'; /** * @public - * A plugin for retrieving Cases UI components + * A plugin for retrieving CasesUI UI components */ export class CasesUiPlugin implements Plugin diff --git a/x-pack/plugins/cases/public/types.ts b/x-pack/plugins/cases/public/types.ts index d06b9edce9d884..be2275c8c0980e 100644 --- a/x-pack/plugins/cases/public/types.ts +++ b/x-pack/plugins/cases/public/types.ts @@ -48,7 +48,7 @@ import type { GetCasesProps } from './client/ui/get_cases'; import type { GetAllCasesSelectorModalProps } from './client/ui/get_all_cases_selector_modal'; import type { GetCreateCaseFlyoutProps } from './client/ui/get_create_case_flyout'; import type { GetRecentCasesProps } from './client/ui/get_recent_cases'; -import type { Cases, CasesStatus, CasesMetrics } from '../common/ui'; +import type { CasesUI, CasesStatus, CasesMetrics } from '../common/ui'; import type { GroupAlertsByRule } from './client/helpers/group_alerts_by_rule'; import type { getUICapabilities } from './client/helpers/capabilities'; import type { AttachmentFramework } from './client/attachment_framework/types'; @@ -103,7 +103,7 @@ export interface CasesUiStart { api: { getRelatedCases: (alertId: string, query: CasesByAlertIDRequest) => Promise; cases: { - find: (query: CasesFindRequest, signal?: AbortSignal) => Promise; + find: (query: CasesFindRequest, signal?: AbortSignal) => Promise; getCasesStatus: (query: CasesStatusRequest, signal?: AbortSignal) => Promise; getCasesMetrics: (query: CasesMetricsRequest, signal?: AbortSignal) => Promise; bulkGet: ( diff --git a/x-pack/plugins/cases/server/client/cases/bulk_get.ts b/x-pack/plugins/cases/server/client/cases/bulk_get.ts index 69597f0e77b4c6..3c2542c244874f 100644 --- a/x-pack/plugins/cases/server/client/cases/bulk_get.ts +++ b/x-pack/plugins/cases/server/client/cases/bulk_get.ts @@ -32,8 +32,8 @@ import { createCaseError } from '../../common/error'; import { asArray, flattenCaseSavedObject } from '../../common/utils'; import type { CasesClientArgs, SOWithErrors } from '../types'; import { includeFieldsRequiredForAuthentication } from '../../authorization/utils'; -import type { CaseSavedObject } from '../../common/types'; import { Operations } from '../../authorization'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; type CaseSavedObjectWithErrors = SOWithErrors; @@ -66,7 +66,7 @@ export const bulkGet = async ( const [validCases, soBulkGetErrors] = partition( cases.saved_objects, (caseInfo) => caseInfo.error === undefined - ) as [CaseSavedObject[], CaseSavedObjectWithErrors]; + ) as [CaseSavedObjectTransformed[], CaseSavedObjectWithErrors]; const { authorized: authorizedCases, unauthorized: unauthorizedCases } = await authorization.getAndEnsureAuthorizedEntities({ @@ -142,7 +142,7 @@ const throwErrorIfCaseIdsReachTheLimit = (ids: string[]) => { const constructErrors = ( soBulkGetErrors: CaseSavedObjectWithErrors, - unauthorizedCases: CaseSavedObject[] + unauthorizedCases: CaseSavedObjectTransformed[] ): CasesBulkGetResponse['errors'] => { const errors: CasesBulkGetResponse['errors'] = []; diff --git a/x-pack/plugins/cases/server/client/cases/get.ts b/x-pack/plugins/cases/server/client/cases/get.ts index 4773d67cdf3105..88668f04f7f36c 100644 --- a/x-pack/plugins/cases/server/client/cases/get.ts +++ b/x-pack/plugins/cases/server/client/cases/get.ts @@ -37,7 +37,7 @@ import type { CasesClientArgs } from '..'; import { Operations } from '../../authorization'; import { combineAuthorizedAndOwnerFilter } from '../utils'; import { CasesService } from '../../services'; -import type { CaseSavedObject } from '../../common/types'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; /** * Parameters for finding cases IDs using an alert ID @@ -181,7 +181,7 @@ export const get = async ( } = clientArgs; try { - const theCase: CaseSavedObject = await caseService.getCase({ + const theCase: CaseSavedObjectTransformed = await caseService.getCase({ id, }); diff --git a/x-pack/plugins/cases/server/client/cases/update.ts b/x-pack/plugins/cases/server/client/cases/update.ts index dffc562d0415e8..07423b49046850 100644 --- a/x-pack/plugins/cases/server/client/cases/update.ts +++ b/x-pack/plugins/cases/server/client/cases/update.ts @@ -62,7 +62,7 @@ import { Operations } from '../../authorization'; import { dedupAssignees, getClosedInfoForUpdate, getDurationForUpdate } from './utils'; import { LICENSING_CASE_ASSIGNMENT_FEATURE } from '../../common/constants'; import type { LicensingService } from '../../services/licensing'; -import type { CaseSavedObject } from '../../common/types'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; /** * Throws an error if any of the requests attempt to update the owner of a case. @@ -257,7 +257,7 @@ async function updateAlerts({ } function partitionPatchRequest( - casesMap: Map, + casesMap: Map, patchReqCases: CasePatchRequest[] ): { nonExistingCases: CasePatchRequest[]; @@ -292,7 +292,7 @@ function partitionPatchRequest( interface UpdateRequestWithOriginalCase { updateReq: CasePatchRequest; - originalCase: CaseSavedObject; + originalCase: CaseSavedObjectTransformed; } /** @@ -335,7 +335,7 @@ export const update = async ( const casesMap = myCases.saved_objects.reduce((acc, so) => { acc.set(so.id, so); return acc; - }, new Map()); + }, new Map()); const { nonExistingCases, conflictedCases, casesToAuthorize } = partitionPatchRequest( casesMap, @@ -521,11 +521,11 @@ const patchCases = async ({ const getCasesAndAssigneesToNotifyForAssignment = ( updatedCases: SavedObjectsBulkUpdateResponse, - casesMap: Map, + casesMap: Map, user: CasesClientArgs['user'] ) => { return updatedCases.saved_objects.reduce< - Array<{ assignees: CaseAssignees; theCase: CaseSavedObject }> + Array<{ assignees: CaseAssignees; theCase: CaseSavedObjectTransformed }> >((acc, updatedCase) => { const originalCaseSO = casesMap.get(updatedCase.id); @@ -554,9 +554,9 @@ const getCasesAndAssigneesToNotifyForAssignment = ( }; const mergeOriginalSOWithUpdatedSO = ( - originalSO: CaseSavedObject, + originalSO: CaseSavedObjectTransformed, updatedSO: SavedObjectsUpdateResponse -): CaseSavedObject => { +): CaseSavedObjectTransformed => { return { ...originalSO, ...updatedSO, diff --git a/x-pack/plugins/cases/server/client/metrics/get_case_metrics.test.ts b/x-pack/plugins/cases/server/client/metrics/get_case_metrics.test.ts index 8b089bd21d9391..023b951dcbf98c 100644 --- a/x-pack/plugins/cases/server/client/metrics/get_case_metrics.test.ts +++ b/x-pack/plugins/cases/server/client/metrics/get_case_metrics.test.ts @@ -21,7 +21,7 @@ import { } from '../../services/mocks'; import { mockAlertsService } from './test_utils/alerts'; import { createStatusChangeSavedObject } from './test_utils/lifespan'; -import type { CaseSavedObject } from '../../common/types'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; describe('getCaseMetrics', () => { const inProgressStatusChangeTimestamp = new Date('2021-11-23T20:00:43Z'); @@ -191,7 +191,7 @@ function createMockClientArgs() { attributes: { owner: 'security', }, - } as unknown as CaseSavedObject; + } as unknown as CaseSavedObjectTransformed; }); const alertsService = mockAlertsService(); diff --git a/x-pack/plugins/cases/server/client/utils.test.ts b/x-pack/plugins/cases/server/client/utils.test.ts index fb3e89b598b032..86854e36c5aa36 100644 --- a/x-pack/plugins/cases/server/client/utils.test.ts +++ b/x-pack/plugins/cases/server/client/utils.test.ts @@ -12,7 +12,6 @@ import { toElasticsearchQuery } from '@kbn/es-query'; import { CaseStatuses } from '../../common'; import { CaseSeverity } from '../../common/api'; -import { ESCaseSeverity, ESCaseStatus } from '../services/cases/types'; import { createSavedObjectsSerializerMock } from './mocks'; import { arraysDifference, @@ -22,6 +21,7 @@ import { constructSearch, convertSortField, } from './utils'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../common/types/case'; describe('utils', () => { describe('convertSortField', () => { @@ -401,9 +401,9 @@ describe('utils', () => { }); it.each([ - [CaseStatuses.open, ESCaseStatus.OPEN], - [CaseStatuses['in-progress'], ESCaseStatus.IN_PROGRESS], - [CaseStatuses.closed, ESCaseStatus.CLOSED], + [CaseStatuses.open, CaseStatusSavedObject.OPEN], + [CaseStatuses['in-progress'], CaseStatusSavedObject.IN_PROGRESS], + [CaseStatuses.closed, CaseStatusSavedObject.CLOSED], ])('creates a filter for status "%s"', (status, expectedStatus) => { expect(constructQueryOptions({ status }).filter).toMatchInlineSnapshot(` Object { @@ -426,10 +426,10 @@ describe('utils', () => { }); it.each([ - [CaseSeverity.LOW, ESCaseSeverity.LOW], - [CaseSeverity.MEDIUM, ESCaseSeverity.MEDIUM], - [CaseSeverity.HIGH, ESCaseSeverity.HIGH], - [CaseSeverity.CRITICAL, ESCaseSeverity.CRITICAL], + [CaseSeverity.LOW, CaseSeveritySavedObject.LOW], + [CaseSeverity.MEDIUM, CaseSeveritySavedObject.MEDIUM], + [CaseSeverity.HIGH, CaseSeveritySavedObject.HIGH], + [CaseSeverity.CRITICAL, CaseSeveritySavedObject.CRITICAL], ])('creates a filter for severity "%s"', (severity, expectedSeverity) => { expect(constructQueryOptions({ severity }).filter).toMatchInlineSnapshot(` Object { diff --git a/x-pack/plugins/cases/server/common/constants.ts b/x-pack/plugins/cases/server/common/constants.ts index 822907b83be39d..0de680a29dc304 100644 --- a/x-pack/plugins/cases/server/common/constants.ts +++ b/x-pack/plugins/cases/server/common/constants.ts @@ -7,7 +7,7 @@ import { CaseSeverity, CaseStatuses } from '../../common/api'; import { CASE_COMMENT_SAVED_OBJECT, CASE_SAVED_OBJECT } from '../../common/constants'; -import { ESCaseSeverity, ESCaseStatus } from '../services/cases/types'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from './types/case'; /** * The name of the saved object reference indicating the action connector ID. This is stored in the Saved Object reference @@ -40,28 +40,28 @@ export const EXTERNAL_REFERENCE_REF_NAME = 'externalReferenceId'; */ export const LICENSING_CASE_ASSIGNMENT_FEATURE = 'Cases user assignment'; -export const SEVERITY_EXTERNAL_TO_ESMODEL: Record = { - [CaseSeverity.LOW]: ESCaseSeverity.LOW, - [CaseSeverity.MEDIUM]: ESCaseSeverity.MEDIUM, - [CaseSeverity.HIGH]: ESCaseSeverity.HIGH, - [CaseSeverity.CRITICAL]: ESCaseSeverity.CRITICAL, +export const SEVERITY_EXTERNAL_TO_ESMODEL: Record = { + [CaseSeverity.LOW]: CaseSeveritySavedObject.LOW, + [CaseSeverity.MEDIUM]: CaseSeveritySavedObject.MEDIUM, + [CaseSeverity.HIGH]: CaseSeveritySavedObject.HIGH, + [CaseSeverity.CRITICAL]: CaseSeveritySavedObject.CRITICAL, }; -export const SEVERITY_ESMODEL_TO_EXTERNAL: Record = { - [ESCaseSeverity.LOW]: CaseSeverity.LOW, - [ESCaseSeverity.MEDIUM]: CaseSeverity.MEDIUM, - [ESCaseSeverity.HIGH]: CaseSeverity.HIGH, - [ESCaseSeverity.CRITICAL]: CaseSeverity.CRITICAL, +export const SEVERITY_ESMODEL_TO_EXTERNAL: Record = { + [CaseSeveritySavedObject.LOW]: CaseSeverity.LOW, + [CaseSeveritySavedObject.MEDIUM]: CaseSeverity.MEDIUM, + [CaseSeveritySavedObject.HIGH]: CaseSeverity.HIGH, + [CaseSeveritySavedObject.CRITICAL]: CaseSeverity.CRITICAL, }; -export const STATUS_EXTERNAL_TO_ESMODEL: Record = { - [CaseStatuses.open]: ESCaseStatus.OPEN, - [CaseStatuses['in-progress']]: ESCaseStatus.IN_PROGRESS, - [CaseStatuses.closed]: ESCaseStatus.CLOSED, +export const STATUS_EXTERNAL_TO_ESMODEL: Record = { + [CaseStatuses.open]: CaseStatusSavedObject.OPEN, + [CaseStatuses['in-progress']]: CaseStatusSavedObject.IN_PROGRESS, + [CaseStatuses.closed]: CaseStatusSavedObject.CLOSED, }; -export const STATUS_ESMODEL_TO_EXTERNAL: Record = { - [ESCaseStatus.OPEN]: CaseStatuses.open, - [ESCaseStatus.IN_PROGRESS]: CaseStatuses['in-progress'], - [ESCaseStatus.CLOSED]: CaseStatuses.closed, +export const STATUS_ESMODEL_TO_EXTERNAL: Record = { + [CaseStatusSavedObject.OPEN]: CaseStatuses.open, + [CaseStatusSavedObject.IN_PROGRESS]: CaseStatuses['in-progress'], + [CaseStatusSavedObject.CLOSED]: CaseStatuses.closed, }; diff --git a/x-pack/plugins/cases/server/common/models/case_with_comments.ts b/x-pack/plugins/cases/server/common/models/case_with_comments.ts index d6fff56b0162f0..93d4c04261f523 100644 --- a/x-pack/plugins/cases/server/common/models/case_with_comments.ts +++ b/x-pack/plugins/cases/server/common/models/case_with_comments.ts @@ -26,7 +26,8 @@ import type { CasesClientArgs } from '../../client'; import type { RefreshSetting } from '../../services/types'; import { createCaseError } from '../error'; import { AttachmentLimitChecker } from '../limiter_checker'; -import type { AlertInfo, CaseSavedObject } from '../types'; +import type { AlertInfo } from '../types'; +import type { CaseSavedObjectTransformed } from '../types/case'; import { countAlertsForID, flattenCommentSavedObjects, @@ -45,9 +46,9 @@ type CommentRequestWithId = Array<{ id: string } & CommentRequest>; */ export class CaseCommentModel { private readonly params: CaseCommentModelParams; - private readonly caseInfo: CaseSavedObject; + private readonly caseInfo: CaseSavedObjectTransformed; - private constructor(caseInfo: CaseSavedObject, params: CaseCommentModelParams) { + private constructor(caseInfo: CaseSavedObjectTransformed, params: CaseCommentModelParams) { this.caseInfo = caseInfo; this.params = params; } @@ -63,7 +64,7 @@ export class CaseCommentModel { return new CaseCommentModel(savedObject, options); } - public get savedObject(): CaseSavedObject { + public get savedObject(): CaseSavedObjectTransformed { return this.caseInfo; } @@ -173,7 +174,7 @@ export class CaseCommentModel { } } - private newObjectWithInfo(caseInfo: CaseSavedObject): CaseCommentModel { + private newObjectWithInfo(caseInfo: CaseSavedObjectTransformed): CaseCommentModel { return new CaseCommentModel(caseInfo, this.params); } diff --git a/x-pack/plugins/cases/server/common/types.ts b/x-pack/plugins/cases/server/common/types.ts index 55e2d9f9d58796..a622126f0b3059 100644 --- a/x-pack/plugins/cases/server/common/types.ts +++ b/x-pack/plugins/cases/server/common/types.ts @@ -5,13 +5,13 @@ * 2.0. */ +import type { SavedObjectsFindOptions } from '@kbn/core-saved-objects-api-server'; import type { SavedObject } from '@kbn/core-saved-objects-server'; import type { KueryNode } from '@kbn/es-query'; import type { CommentAttributes, CommentRequestExternalReferenceSOType, FileAttachmentMetadata, - SavedObjectFindOptions, } from '../../common/api'; /** @@ -22,7 +22,22 @@ export interface AlertInfo { index: string; } -export type SavedObjectFindOptionsKueryNode = Omit & { +type FindOptions = Pick< + SavedObjectsFindOptions, + | 'defaultSearchOperator' + | 'hasReferenceOperator' + | 'perPage' + | 'hasReference' + | 'fields' + | 'page' + | 'search' + | 'searchFields' + | 'sortField' + | 'sortOrder' + | 'rootSearchFields' +>; + +export type SavedObjectFindOptionsKueryNode = FindOptions & { filter?: KueryNode; }; diff --git a/x-pack/plugins/cases/server/common/types/case.ts b/x-pack/plugins/cases/server/common/types/case.ts index 2617a541baafd2..258bc2d2fb67fa 100644 --- a/x-pack/plugins/cases/server/common/types/case.ts +++ b/x-pack/plugins/cases/server/common/types/case.ts @@ -6,6 +6,7 @@ */ import type { SavedObject } from '@kbn/core-saved-objects-server'; +import type { CaseAttributes } from '../../../common/api'; import type { User, UserProfile } from './user'; export enum CaseSeveritySavedObject { @@ -21,7 +22,7 @@ export enum CaseStatusSavedObject { CLOSED = 20, } -interface CaseExternalServiceSavedObject { +export interface CaseExternalServiceSavedObject { connector_name: string; external_id: string; external_title: string; @@ -30,12 +31,12 @@ interface CaseExternalServiceSavedObject { pushed_by: User; } -type ConnectorFieldsSavedObject = Array<{ +export type ConnectorFieldsSavedObject = Array<{ key: string; value: unknown; }>; -interface ConnectorSavedObject { +export interface ConnectorSavedObject { name: string; type: string; fields: ConnectorFieldsSavedObject | null; @@ -45,8 +46,8 @@ export interface CaseSavedObjectAttributes { assignees: UserProfile[]; closed_at: string | null; closed_by: User | null; - created_at: string | null; - created_by: User | null; + created_at: string; + created_by: User; connector: ConnectorSavedObject; description: string; duration: number | null; @@ -63,4 +64,7 @@ export interface CaseSavedObjectAttributes { updated_by: User | null; } +export type CaseTransformedAttributes = CaseAttributes; + export type CaseSavedObject = SavedObject; +export type CaseSavedObjectTransformed = SavedObject; diff --git a/x-pack/plugins/cases/server/common/types/user.ts b/x-pack/plugins/cases/server/common/types/user.ts index c98fa8fc9430ac..34e5e226517e07 100644 --- a/x-pack/plugins/cases/server/common/types/user.ts +++ b/x-pack/plugins/cases/server/common/types/user.ts @@ -6,10 +6,10 @@ */ export interface User { - email: undefined | null | string; - full_name: undefined | null | string; - username: undefined | null | string; - profile_uid?: string; + email: string | null | undefined; + full_name: string | null | undefined; + username: string | null | undefined; + profile_uid?: string | undefined; } export interface UserProfile { diff --git a/x-pack/plugins/cases/server/common/utils.ts b/x-pack/plugins/cases/server/common/utils.ts index e51ea67a9df1ee..1554d5a64f20b7 100644 --- a/x-pack/plugins/cases/server/common/utils.ts +++ b/x-pack/plugins/cases/server/common/utils.ts @@ -27,7 +27,6 @@ import type { CASE_VIEW_PAGE_TABS } from '../../common/types'; import type { AlertInfo, FileAttachmentRequest } from './types'; import type { - CaseAttributes, CasePostRequest, Case, CasesFindResponse, @@ -56,7 +55,7 @@ import { getLensVisualizations, } from '../../common/utils/markdown_plugins/utils'; import { dedupAssignees } from '../client/cases/utils'; -import type { CaseSavedObject } from './types/case'; +import type { CaseSavedObjectTransformed, CaseTransformedAttributes } from './types/case'; /** * Default sort field for querying saved objects. @@ -74,7 +73,7 @@ export const transformNewCase = ({ }: { user: User; newCase: CasePostRequest; -}): CaseAttributes => ({ +}): CaseTransformedAttributes => ({ ...newCase, duration: null, severity: newCase.severity ?? CaseSeverity.LOW, @@ -121,7 +120,7 @@ export const flattenCaseSavedObject = ({ totalComment = comments.length, totalAlerts = 0, }: { - savedObject: CaseSavedObject; + savedObject: CaseSavedObjectTransformed; comments?: Array>; totalComment?: number; totalAlerts?: number; diff --git a/x-pack/plugins/cases/server/mocks.ts b/x-pack/plugins/cases/server/mocks.ts index 823acef076fe3c..8cef503691bcbb 100644 --- a/x-pack/plugins/cases/server/mocks.ts +++ b/x-pack/plugins/cases/server/mocks.ts @@ -6,14 +6,14 @@ */ import type { SavedObject } from '@kbn/core/server'; -import type { CaseSavedObject } from './common/types'; import type { CasePostRequest, CommentAttributes } from '../common/api'; import { CaseSeverity, CaseStatuses, CommentType, ConnectorTypes } from '../common/api'; import { SECURITY_SOLUTION_OWNER } from '../common/constants'; import type { CasesStart } from './types'; import { createCasesClientMock } from './client/mocks'; +import type { CaseSavedObjectTransformed } from './common/types/case'; -export const mockCases: CaseSavedObject[] = [ +export const mockCases: CaseSavedObjectTransformed[] = [ { type: 'cases', id: 'mock-id-1', 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 1d70808f14db20..2b05d6f969805e 100644 --- a/x-pack/plugins/cases/server/saved_object_types/cases.ts +++ b/x-pack/plugins/cases/server/saved_object_types/cases.ts @@ -13,7 +13,7 @@ import type { SavedObjectsType, } from '@kbn/core/server'; import { CASE_SAVED_OBJECT } from '../../common/constants'; -import type { ESCaseAttributes } from '../services/cases/types'; +import type { CaseSavedObjectAttributes } from '../common/types/case'; import { handleExport } from './import_export/export'; import { caseMigrations } from './migrations'; @@ -193,10 +193,10 @@ export const createCaseSavedObjectType = ( importableAndExportable: true, defaultSearchField: 'title', icon: 'casesApp', - getTitle: (savedObject: SavedObject) => savedObject.attributes.title, + getTitle: (savedObject: SavedObject) => savedObject.attributes.title, onExport: async ( context: SavedObjectsExportTransformContext, - objects: Array> + objects: Array> ) => handleExport({ context, objects, coreSetup, logger }), }, }); diff --git a/x-pack/plugins/cases/server/saved_object_types/import_export/export.ts b/x-pack/plugins/cases/server/saved_object_types/import_export/export.ts index 0fe7b513859815..f36f633b1b8435 100644 --- a/x-pack/plugins/cases/server/saved_object_types/import_export/export.ts +++ b/x-pack/plugins/cases/server/saved_object_types/import_export/export.ts @@ -25,7 +25,7 @@ import { } from '../../../common/constants'; import { defaultSortField } from '../../common/utils'; import { createCaseError } from '../../common/error'; -import type { ESCaseAttributes } from '../../services/cases/types'; +import type { CaseSavedObjectAttributes } from '../../common/types/case'; export async function handleExport({ context, @@ -34,13 +34,15 @@ export async function handleExport({ logger, }: { context: SavedObjectsExportTransformContext; - objects: Array>; + objects: Array>; coreSetup: CoreSetup; logger: Logger; }): Promise< Array< SavedObject< - ESCaseAttributes | CommentAttributesWithoutRefs | CaseUserActionAttributesWithoutConnectorId + | CaseSavedObjectAttributes + | CommentAttributesWithoutRefs + | CaseUserActionAttributesWithoutConnectorId > > > { diff --git a/x-pack/plugins/cases/server/saved_object_types/migrations/cases.test.ts b/x-pack/plugins/cases/server/saved_object_types/migrations/cases.test.ts index 5b2eb650806827..7638b447ee2faa 100644 --- a/x-pack/plugins/cases/server/saved_object_types/migrations/cases.test.ts +++ b/x-pack/plugins/cases/server/saved_object_types/migrations/cases.test.ts @@ -9,8 +9,8 @@ import type { SavedObjectSanitizedDoc, SavedObjectUnsanitizedDoc } from '@kbn/co import type { CaseAttributes, CaseFullExternalService } from '../../../common/api'; import { CaseSeverity, CaseStatuses, ConnectorTypes, NONE_CONNECTOR_ID } from '../../../common/api'; import { CASE_SAVED_OBJECT } from '../../../common/constants'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../../common/types/case'; import { getNoneCaseConnector } from '../../common/utils'; -import { ESCaseSeverity, ESCaseStatus } from '../../services/cases/types'; import type { ESCaseConnectorWithId } from '../../services/test_utils'; import { createExternalService } from '../../services/test_utils'; import { @@ -585,10 +585,10 @@ describe('case migrations', () => { describe('update severity', () => { it.each([ - [CaseSeverity.LOW, ESCaseSeverity.LOW], - [CaseSeverity.MEDIUM, ESCaseSeverity.MEDIUM], - [CaseSeverity.HIGH, ESCaseSeverity.HIGH], - [CaseSeverity.CRITICAL, ESCaseSeverity.CRITICAL], + [CaseSeverity.LOW, CaseSeveritySavedObject.LOW], + [CaseSeverity.MEDIUM, CaseSeveritySavedObject.MEDIUM], + [CaseSeverity.HIGH, CaseSeveritySavedObject.HIGH], + [CaseSeverity.CRITICAL, CaseSeveritySavedObject.CRITICAL], ])( 'migrates "%s" severity keyword value to matching short', (oldSeverityValue, expectedSeverityValue) => { @@ -624,7 +624,7 @@ describe('case migrations', () => { ...doc, attributes: { ...doc.attributes, - severity: ESCaseSeverity.LOW, + severity: CaseSeveritySavedObject.LOW, }, references: [], }); @@ -633,9 +633,9 @@ describe('case migrations', () => { describe('update status', () => { it.each([ - [CaseStatuses.open, ESCaseStatus.OPEN], - [CaseStatuses['in-progress'], ESCaseStatus.IN_PROGRESS], - [CaseStatuses.closed, ESCaseStatus.CLOSED], + [CaseStatuses.open, CaseStatusSavedObject.OPEN], + [CaseStatuses['in-progress'], CaseStatusSavedObject.IN_PROGRESS], + [CaseStatuses.closed, CaseStatusSavedObject.CLOSED], ])( 'migrates "%s" status keyword value to matching short', (oldStatusValue, expectedStatusValue) => { @@ -671,7 +671,7 @@ describe('case migrations', () => { ...doc, attributes: { ...doc.attributes, - status: ESCaseStatus.OPEN, + status: CaseStatusSavedObject.OPEN, }, references: [], }); diff --git a/x-pack/plugins/cases/server/saved_object_types/migrations/cases.ts b/x-pack/plugins/cases/server/saved_object_types/migrations/cases.ts index 38f91952f14699..37f204371ba834 100644 --- a/x-pack/plugins/cases/server/saved_object_types/migrations/cases.ts +++ b/x-pack/plugins/cases/server/saved_object_types/migrations/cases.ts @@ -11,7 +11,6 @@ import { cloneDeep, unset, flow } from 'lodash'; import type { SavedObjectUnsanitizedDoc, SavedObjectSanitizedDoc } from '@kbn/core/server'; import type { SanitizedCaseOwner } from '.'; import { addOwnerToSO } from '.'; -import type { ESConnectorFields } from '../../services'; import type { CaseAttributes } from '../../../common/api'; import { CaseSeverity, ConnectorTypes } from '../../../common/api'; @@ -27,7 +26,8 @@ import { } from './user_actions/connector_id'; import { CASE_TYPE_INDIVIDUAL } from './constants'; import { pipeMigrations } from './utils'; -import { ESCaseSeverity, ESCaseStatus } from '../../services/cases/types'; +import type { ConnectorFieldsSavedObject } from '../../common/types/case'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../../common/types/case'; interface UnsanitizedCaseConnector { connector_id: string; @@ -38,7 +38,7 @@ interface SanitizedCaseConnector { id: string; name: string | null; type: string | null; - fields: null | ESConnectorFields; + fields: null | ConnectorFieldsSavedObject; }; } @@ -137,8 +137,11 @@ export const addAssignees = ( export const convertSeverity = ( doc: SavedObjectUnsanitizedDoc -): SavedObjectSanitizedDoc & { severity: ESCaseSeverity }> => { - const severity = SEVERITY_EXTERNAL_TO_ESMODEL[doc.attributes.severity] ?? ESCaseSeverity.LOW; +): SavedObjectSanitizedDoc< + Omit & { severity: CaseSeveritySavedObject } +> => { + const severity = + SEVERITY_EXTERNAL_TO_ESMODEL[doc.attributes.severity] ?? CaseSeveritySavedObject.LOW; return { ...doc, attributes: { ...doc.attributes, severity }, @@ -148,8 +151,8 @@ export const convertSeverity = ( export const convertStatus = ( doc: SavedObjectUnsanitizedDoc -): SavedObjectSanitizedDoc & { status: ESCaseStatus }> => { - const status = STATUS_EXTERNAL_TO_ESMODEL[doc.attributes?.status] ?? ESCaseStatus.OPEN; +): SavedObjectSanitizedDoc & { status: CaseStatusSavedObject }> => { + const status = STATUS_EXTERNAL_TO_ESMODEL[doc.attributes?.status] ?? CaseStatusSavedObject.OPEN; return { ...doc, attributes: { ...doc.attributes, status }, diff --git a/x-pack/plugins/cases/server/services/cases/index.test.ts b/x-pack/plugins/cases/server/services/cases/index.test.ts index c84d4df964157f..ba0107eae22aae 100644 --- a/x-pack/plugins/cases/server/services/cases/index.test.ts +++ b/x-pack/plugins/cases/server/services/cases/index.test.ts @@ -41,11 +41,13 @@ import { basicCaseFields, createSOFindResponse, } from '../test_utils'; -import type { ESCaseAttributes } from './types'; -import { ESCaseSeverity, ESCaseStatus } from './types'; import { AttachmentService } from '../attachments'; import { PersistableStateAttachmentTypeRegistry } from '../../attachment_framework/persistable_state_registry'; -import type { CaseSavedObject } from '../../common/types'; +import type { + CaseSavedObjectTransformed, + CaseSavedObjectAttributes, +} from '../../common/types/case'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../../common/types/case'; const createUpdateSOResponse = ({ connector, @@ -55,15 +57,15 @@ const createUpdateSOResponse = ({ }: { connector?: ESCaseConnectorWithId; externalService?: CaseFullExternalService; - severity?: ESCaseSeverity; - status?: ESCaseStatus; -} = {}): SavedObjectsUpdateResponse => { + severity?: CaseSeveritySavedObject; + status?: CaseStatusSavedObject; +} = {}): SavedObjectsUpdateResponse => { const references: SavedObjectReference[] = createSavedObjectReferences({ connector, externalService, }); - let attributes: Partial = { total_alerts: -1, total_comments: -1 }; + let attributes: Partial = { total_alerts: -1, total_comments: -1 }; if (connector) { const { id, ...restConnector } = connector; @@ -95,9 +97,9 @@ const createFindSO = ( params: { connector?: ESCaseConnectorWithId; externalService?: CaseFullExternalService; - overrides?: Partial; + overrides?: Partial; } = {} -): SavedObjectsFindResult => ({ +): SavedObjectsFindResult => ({ ...createCaseSavedObjectResponse(params), score: 0, }); @@ -174,7 +176,7 @@ describe('CasesService', () => { describe('patch', () => { it('includes the passed in fields', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -185,14 +187,15 @@ describe('CasesService', () => { severity: CaseSeverity.CRITICAL, status: CaseStatuses['in-progress'], }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const { connector: ignoreConnector, external_service: ignoreExternalService, ...restUpdateAttributes - } = unsecuredSavedObjectsClient.update.mock.calls[0][2] as Partial; + } = unsecuredSavedObjectsClient.update.mock + .calls[0][2] as Partial; expect(restUpdateAttributes).toMatchInlineSnapshot(` Object { "assignees": Array [], @@ -228,7 +231,7 @@ describe('CasesService', () => { it('transforms the connector.fields to an array of key/value pairs', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -237,11 +240,11 @@ describe('CasesService', () => { connector: createJiraConnector(), externalService: createExternalService(), }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const { connector } = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as Partial; + .calls[0][2] as Partial; expect(connector?.fields).toMatchInlineSnapshot(` Array [ Object { @@ -262,7 +265,7 @@ describe('CasesService', () => { it('preserves the connector fields but does not have the id', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -271,11 +274,11 @@ describe('CasesService', () => { connector: createJiraConnector(), externalService: createExternalService(), }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const { connector } = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as Partial; + .calls[0][2] as Partial; expect(connector).toMatchInlineSnapshot(` Object { "fields": Array [ @@ -300,17 +303,17 @@ describe('CasesService', () => { it('removes the connector id and adds it to the references', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({ connector: createJiraConnector() }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const updateAttributes = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as Partial; + .calls[0][2] as Partial; expect(updateAttributes.connector).not.toHaveProperty('id'); const updateOptions = unsecuredSavedObjectsClient.update.mock @@ -328,7 +331,7 @@ describe('CasesService', () => { it('removes the external_service connector_id and adds it to the references', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -337,11 +340,11 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), externalService: createExternalService(), }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const updateAttributes = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as Partial; + .calls[0][2] as Partial; expect(updateAttributes.external_service).not.toHaveProperty('connector_id'); const updateOptions = unsecuredSavedObjectsClient.update.mock @@ -359,7 +362,7 @@ describe('CasesService', () => { it('builds references for external service connector id, case connector id, and includes the existing references', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -370,7 +373,7 @@ describe('CasesService', () => { }), originalCase: { references: [{ id: 'a', name: 'awesome', type: 'hello' }], - } as CaseSavedObject, + } as CaseSavedObjectTransformed, }); const updateOptions = unsecuredSavedObjectsClient.update.mock @@ -398,7 +401,7 @@ describe('CasesService', () => { it('builds references for connector_id and preserves the existing connector.id reference', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -408,7 +411,7 @@ describe('CasesService', () => { references: [ { id: '1', name: CONNECTOR_ID_REFERENCE_NAME, type: ACTION_SAVED_OBJECT_TYPE }, ], - } as CaseSavedObject, + } as CaseSavedObjectTransformed, }); const updateOptions = unsecuredSavedObjectsClient.update.mock @@ -431,7 +434,7 @@ describe('CasesService', () => { it('preserves the external_service fields except for the connector_id', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ @@ -440,11 +443,11 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), externalService: createExternalService(), }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const updateAttributes = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as Partial; + .calls[0][2] as Partial; expect(updateAttributes.external_service).toMatchInlineSnapshot(` Object { "connector_name": ".jira", @@ -463,13 +466,13 @@ describe('CasesService', () => { it('creates an empty updatedAttributes when there is no connector or external_service as input', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(unsecuredSavedObjectsClient.update.mock.calls[0][2]).toMatchInlineSnapshot( @@ -482,13 +485,13 @@ describe('CasesService', () => { it('creates a updatedAttributes field with the none connector', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({ connector: getNoneCaseConnector() }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(unsecuredSavedObjectsClient.update.mock.calls[0][2]).toMatchInlineSnapshot(` @@ -503,49 +506,49 @@ describe('CasesService', () => { }); it.each([ - [CaseSeverity.LOW, ESCaseSeverity.LOW], - [CaseSeverity.MEDIUM, ESCaseSeverity.MEDIUM], - [CaseSeverity.HIGH, ESCaseSeverity.HIGH], - [CaseSeverity.CRITICAL, ESCaseSeverity.CRITICAL], + [CaseSeverity.LOW, CaseSeveritySavedObject.LOW], + [CaseSeverity.MEDIUM, CaseSeveritySavedObject.MEDIUM], + [CaseSeverity.HIGH, CaseSeveritySavedObject.HIGH], + [CaseSeverity.CRITICAL, CaseSeveritySavedObject.CRITICAL], ])( 'properly converts "%s" severity to corresponding ES value on updating SO', async (patchParamsSeverity, expectedSeverity) => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({ severity: patchParamsSeverity }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const patchAttributes = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as ESCaseAttributes; + .calls[0][2] as CaseSavedObjectAttributes; expect(patchAttributes.severity).toEqual(expectedSeverity); } ); it.each([ - [CaseStatuses.open, ESCaseStatus.OPEN], - [CaseStatuses['in-progress'], ESCaseStatus.IN_PROGRESS], - [CaseStatuses.closed, ESCaseStatus.CLOSED], + [CaseStatuses.open, CaseStatusSavedObject.OPEN], + [CaseStatuses['in-progress'], CaseStatusSavedObject.IN_PROGRESS], + [CaseStatuses.closed, CaseStatusSavedObject.CLOSED], ])( 'properly converts "%s" status to corresponding ES value on updating SO', async (patchParamsStatus, expectedStatus) => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({ status: patchParamsStatus }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); const patchAttributes = unsecuredSavedObjectsClient.update.mock - .calls[0][2] as ESCaseAttributes; + .calls[0][2] as CaseSavedObjectAttributes; expect(patchAttributes.status).toEqual(expectedStatus); } @@ -571,7 +574,7 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), severity: CaseSeverity.LOW, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, { caseId: '2', @@ -579,7 +582,7 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), severity: CaseSeverity.MEDIUM, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, { caseId: '3', @@ -587,7 +590,7 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), severity: CaseSeverity.HIGH, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, { caseId: '4', @@ -595,18 +598,18 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), severity: CaseSeverity.CRITICAL, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); const patchResults = unsecuredSavedObjectsClient.bulkUpdate.mock - .calls[0][0] as unknown as Array>; + .calls[0][0] as unknown as Array>; - expect(patchResults[0].attributes.severity).toEqual(ESCaseSeverity.LOW); - expect(patchResults[1].attributes.severity).toEqual(ESCaseSeverity.MEDIUM); - expect(patchResults[2].attributes.severity).toEqual(ESCaseSeverity.HIGH); - expect(patchResults[3].attributes.severity).toEqual(ESCaseSeverity.CRITICAL); + expect(patchResults[0].attributes.severity).toEqual(CaseSeveritySavedObject.LOW); + expect(patchResults[1].attributes.severity).toEqual(CaseSeveritySavedObject.MEDIUM); + expect(patchResults[2].attributes.severity).toEqual(CaseSeveritySavedObject.HIGH); + expect(patchResults[3].attributes.severity).toEqual(CaseSeveritySavedObject.CRITICAL); }); it('properly converts status to corresponding ES value on bulk updating SO', async () => { @@ -626,7 +629,7 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), status: CaseStatuses.open, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, { caseId: '2', @@ -634,7 +637,7 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), status: CaseStatuses['in-progress'], }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, { caseId: '3', @@ -642,23 +645,25 @@ describe('CasesService', () => { connector: getNoneCaseConnector(), status: CaseStatuses.closed, }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); const patchResults = unsecuredSavedObjectsClient.bulkUpdate.mock - .calls[0][0] as unknown as Array>; + .calls[0][0] as unknown as Array>; - expect(patchResults[0].attributes.status).toEqual(ESCaseStatus.OPEN); - expect(patchResults[1].attributes.status).toEqual(ESCaseStatus.IN_PROGRESS); - expect(patchResults[2].attributes.status).toEqual(ESCaseStatus.CLOSED); + expect(patchResults[0].attributes.status).toEqual(CaseStatusSavedObject.OPEN); + expect(patchResults[1].attributes.status).toEqual(CaseStatusSavedObject.IN_PROGRESS); + expect(patchResults[2].attributes.status).toEqual(CaseStatusSavedObject.CLOSED); }); }); describe('post', () => { it('creates a null external_service field when the attribute was null in the creation parameters', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ connector: createJiraConnector() }), @@ -671,7 +676,9 @@ describe('CasesService', () => { }); it('includes the creation attributes excluding the connector.id and connector_id', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -682,7 +689,7 @@ describe('CasesService', () => { }); const creationAttributes = unsecuredSavedObjectsClient.create.mock - .calls[0][1] as ESCaseAttributes; + .calls[0][1] as CaseSavedObjectAttributes; expect(creationAttributes.connector).not.toHaveProperty('id'); expect(creationAttributes.external_service).not.toHaveProperty('connector_id'); expect(creationAttributes).toMatchInlineSnapshot(` @@ -769,7 +776,9 @@ describe('CasesService', () => { }); it('includes default values for total_alerts and total_comments', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -779,14 +788,16 @@ describe('CasesService', () => { }); const postAttributes = unsecuredSavedObjectsClient.create.mock - .calls[0][1] as ESCaseAttributes; + .calls[0][1] as CaseSavedObjectAttributes; expect(postAttributes.total_alerts).toEqual(-1); expect(postAttributes.total_comments).toEqual(-1); }); it('moves the connector.id and connector_id to the references', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -815,7 +826,9 @@ describe('CasesService', () => { }); it('sets fields to an empty array when it is not included with the connector', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -831,7 +844,9 @@ describe('CasesService', () => { }); it('does not create a reference for a none connector', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ connector: getNoneCaseConnector() }), @@ -844,7 +859,9 @@ describe('CasesService', () => { }); it('does not create a reference for an external_service field that is null', async () => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ connector: getNoneCaseConnector() }), @@ -857,14 +874,16 @@ describe('CasesService', () => { }); it.each([ - [CaseSeverity.LOW, ESCaseSeverity.LOW], - [CaseSeverity.MEDIUM, ESCaseSeverity.MEDIUM], - [CaseSeverity.HIGH, ESCaseSeverity.HIGH], - [CaseSeverity.CRITICAL, ESCaseSeverity.CRITICAL], + [CaseSeverity.LOW, CaseSeveritySavedObject.LOW], + [CaseSeverity.MEDIUM, CaseSeveritySavedObject.MEDIUM], + [CaseSeverity.HIGH, CaseSeveritySavedObject.HIGH], + [CaseSeverity.CRITICAL, CaseSeveritySavedObject.CRITICAL], ])( 'properly converts "%s" severity to corresponding ES value on creating SO', async (postParamsSeverity, expectedSeverity) => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -875,19 +894,21 @@ describe('CasesService', () => { }); const postAttributes = unsecuredSavedObjectsClient.create.mock - .calls[0][1] as ESCaseAttributes; + .calls[0][1] as CaseSavedObjectAttributes; expect(postAttributes.severity).toEqual(expectedSeverity); } ); it.each([ - [CaseStatuses.open, ESCaseStatus.OPEN], - [CaseStatuses['in-progress'], ESCaseStatus.IN_PROGRESS], - [CaseStatuses.closed, ESCaseStatus.CLOSED], + [CaseStatuses.open, CaseStatusSavedObject.OPEN], + [CaseStatuses['in-progress'], CaseStatusSavedObject.IN_PROGRESS], + [CaseStatuses.closed, CaseStatusSavedObject.CLOSED], ])( 'properly converts "%s" status to corresponding ES value on creating SO', async (postParamsStatus, expectedStatus) => { - unsecuredSavedObjectsClient.create.mockResolvedValue({} as SavedObject); + unsecuredSavedObjectsClient.create.mockResolvedValue( + {} as SavedObject + ); await service.postNewCase({ attributes: createCasePostParams({ @@ -898,7 +919,7 @@ describe('CasesService', () => { }); const postAttributes = unsecuredSavedObjectsClient.create.mock - .calls[0][1] as ESCaseAttributes; + .calls[0][1] as CaseSavedObjectAttributes; expect(postAttributes.status).toEqual(expectedStatus); } ); @@ -929,7 +950,7 @@ describe('CasesService', () => { connector: createJiraConnector(), externalService: createExternalService(), }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); @@ -970,10 +991,16 @@ describe('CasesService', () => { it('properly converts the severity field to the corresponding external value in the bulkPatch response', async () => { unsecuredSavedObjectsClient.bulkUpdate.mockResolvedValue({ saved_objects: [ - createCaseSavedObjectResponse({ overrides: { severity: ESCaseSeverity.LOW } }), - createCaseSavedObjectResponse({ overrides: { severity: ESCaseSeverity.MEDIUM } }), - createCaseSavedObjectResponse({ overrides: { severity: ESCaseSeverity.HIGH } }), - createCaseSavedObjectResponse({ overrides: { severity: ESCaseSeverity.CRITICAL } }), + createCaseSavedObjectResponse({ overrides: { severity: CaseSeveritySavedObject.LOW } }), + createCaseSavedObjectResponse({ + overrides: { severity: CaseSeveritySavedObject.MEDIUM }, + }), + createCaseSavedObjectResponse({ + overrides: { severity: CaseSeveritySavedObject.HIGH }, + }), + createCaseSavedObjectResponse({ + overrides: { severity: CaseSeveritySavedObject.CRITICAL }, + }), ], }); @@ -982,7 +1009,7 @@ describe('CasesService', () => { { caseId: '1', updatedAttributes: createCasePostParams({ connector: getNoneCaseConnector() }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); @@ -995,9 +1022,11 @@ describe('CasesService', () => { it('properly converts the status field to the corresponding external value in the bulkPatch response', async () => { unsecuredSavedObjectsClient.bulkUpdate.mockResolvedValue({ saved_objects: [ - createCaseSavedObjectResponse({ overrides: { status: ESCaseStatus.OPEN } }), - createCaseSavedObjectResponse({ overrides: { status: ESCaseStatus.IN_PROGRESS } }), - createCaseSavedObjectResponse({ overrides: { status: ESCaseStatus.CLOSED } }), + createCaseSavedObjectResponse({ overrides: { status: CaseStatusSavedObject.OPEN } }), + createCaseSavedObjectResponse({ + overrides: { status: CaseStatusSavedObject.IN_PROGRESS }, + }), + createCaseSavedObjectResponse({ overrides: { status: CaseStatusSavedObject.CLOSED } }), ], }); @@ -1006,7 +1035,7 @@ describe('CasesService', () => { { caseId: '1', updatedAttributes: createCasePostParams({ connector: getNoneCaseConnector() }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); @@ -1029,7 +1058,7 @@ describe('CasesService', () => { { caseId: '1', updatedAttributes: createCasePostParams({ connector: getNoneCaseConnector() }), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }, ], }); @@ -1052,7 +1081,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes).toMatchInlineSnapshot(` @@ -1076,7 +1105,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes).toMatchInlineSnapshot(` @@ -1093,7 +1122,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes).toMatchInlineSnapshot(`Object {}`); @@ -1102,13 +1131,13 @@ describe('CasesService', () => { it('returns an undefined connector if it is not returned by the update', async () => { unsecuredSavedObjectsClient.update.mockResolvedValue( - {} as SavedObjectsUpdateResponse + {} as SavedObjectsUpdateResponse ); const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res).toMatchInlineSnapshot(` @@ -1120,7 +1149,7 @@ describe('CasesService', () => { it('returns the default none connector when it cannot find the reference', async () => { const { name, type, fields } = createESJiraConnector(); - const returnValue: SavedObjectsUpdateResponse = { + const returnValue: SavedObjectsUpdateResponse = { type: CASE_SAVED_OBJECT, id: '1', attributes: { @@ -1139,7 +1168,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.connector).toMatchInlineSnapshot(` @@ -1154,7 +1183,7 @@ describe('CasesService', () => { it('returns none external service connector when it cannot find the reference', async () => { const { connector_id: id, ...restExternalConnector } = createExternalService()!; - const returnValue: SavedObjectsUpdateResponse = { + const returnValue: SavedObjectsUpdateResponse = { type: CASE_SAVED_OBJECT, id: '1', attributes: { @@ -1169,7 +1198,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.external_service?.connector_id).toBe('none'); @@ -1177,7 +1206,7 @@ describe('CasesService', () => { it('returns the saved object fields when it cannot find the reference for connector_id', async () => { const { connector_id: id, ...restExternalConnector } = createExternalService()!; - const returnValue: SavedObjectsUpdateResponse = { + const returnValue: SavedObjectsUpdateResponse = { type: CASE_SAVED_OBJECT, id: '1', attributes: { @@ -1192,7 +1221,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res).toMatchInlineSnapshot(` @@ -1228,7 +1257,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.connector).toMatchInlineSnapshot(` @@ -1254,7 +1283,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.external_service).toMatchInlineSnapshot(` @@ -1276,10 +1305,10 @@ describe('CasesService', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'properly converts "%s" severity to corresponding external value in the patch response', async (internalSeverityValue, expectedSeverity) => { @@ -1290,7 +1319,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.severity).toEqual(expectedSeverity); @@ -1298,9 +1327,9 @@ describe('CasesService', () => { ); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'properly converts "%s" status to corresponding external value in the patch response', async (internalStatusValue, expectedStatus) => { @@ -1311,7 +1340,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes.status).toEqual(expectedStatus); @@ -1324,7 +1353,7 @@ describe('CasesService', () => { const res = await service.patchCase({ caseId: '1', updatedAttributes: createCaseUpdateParams({}), - originalCase: {} as CaseSavedObject, + originalCase: {} as CaseSavedObjectTransformed, }); expect(res.attributes).not.toHaveProperty('total_alerts'); @@ -1351,10 +1380,10 @@ describe('CasesService', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'properly converts "%s" severity to corresponding external value in the post response', async (internalSeverityValue, expectedSeverity) => { @@ -1372,9 +1401,9 @@ describe('CasesService', () => { ); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'properly converts "%s" status to corresponding external value in the post response', async (internalStatusValue, expectedStatus) => { @@ -1444,10 +1473,10 @@ describe('CasesService', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'includes the properly converted "%s" severity field in the result', async (severity, expectedSeverity) => { @@ -1463,9 +1492,9 @@ describe('CasesService', () => { ); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'includes the properly converted "%s" status field in the result', async (status, expectedStatus) => { @@ -1523,16 +1552,16 @@ describe('CasesService', () => { unsecuredSavedObjectsClient.bulkGet.mockResolvedValue({ saved_objects: [ createCaseSavedObjectResponse({ - overrides: { severity: ESCaseSeverity.LOW }, + overrides: { severity: CaseSeveritySavedObject.LOW }, }), createCaseSavedObjectResponse({ - overrides: { severity: ESCaseSeverity.MEDIUM }, + overrides: { severity: CaseSeveritySavedObject.MEDIUM }, }), createCaseSavedObjectResponse({ - overrides: { severity: ESCaseSeverity.HIGH }, + overrides: { severity: CaseSeveritySavedObject.HIGH }, }), createCaseSavedObjectResponse({ - overrides: { severity: ESCaseSeverity.CRITICAL }, + overrides: { severity: CaseSeveritySavedObject.CRITICAL }, }), ], }); @@ -1548,13 +1577,13 @@ describe('CasesService', () => { unsecuredSavedObjectsClient.bulkGet.mockResolvedValue({ saved_objects: [ createCaseSavedObjectResponse({ - overrides: { status: ESCaseStatus.OPEN }, + overrides: { status: CaseStatusSavedObject.OPEN }, }), createCaseSavedObjectResponse({ - overrides: { status: ESCaseStatus.IN_PROGRESS }, + overrides: { status: CaseStatusSavedObject.IN_PROGRESS }, }), createCaseSavedObjectResponse({ - overrides: { status: ESCaseStatus.CLOSED }, + overrides: { status: CaseStatusSavedObject.CLOSED }, }), ], }); @@ -1652,7 +1681,7 @@ describe('CasesService', () => { type: ACTION_SAVED_OBJECT_TYPE, }, ], - } as unknown as SavedObject); + } as unknown as SavedObject); const res = await service.getCase({ id: 'a' }); expect(res.attributes.connector).toMatchInlineSnapshot(` @@ -1670,7 +1699,7 @@ describe('CasesService', () => { it('returns a null external_services when it is already null', async () => { unsecuredSavedObjectsClient.get.mockResolvedValue({ attributes: { external_service: null }, - } as SavedObject); + } as SavedObject); const res = await service.getCase({ id: 'a' }); expect(res.attributes.connector).toMatchInlineSnapshot(` @@ -1686,16 +1715,16 @@ describe('CasesService', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'includes the properly converted "%s" severity field in the result', async (internalSeverityValue, expectedSeverity) => { unsecuredSavedObjectsClient.get.mockResolvedValue({ attributes: { severity: internalSeverityValue }, - } as SavedObject); + } as SavedObject); const res = await service.getCase({ id: 'a' }); @@ -1704,15 +1733,15 @@ describe('CasesService', () => { ); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'includes the properly converted "%s" status field in the result', async (internalStatusValue, expectedStatus) => { unsecuredSavedObjectsClient.get.mockResolvedValue({ attributes: { status: internalStatusValue }, - } as SavedObject); + } as SavedObject); const res = await service.getCase({ id: 'a' }); @@ -1726,7 +1755,7 @@ describe('CasesService', () => { total_alerts: -1, total_comments: -1, }, - } as unknown as SavedObject); + } as unknown as SavedObject); const res = await service.getCase({ id: 'a' }); expect(res.attributes).not.toHaveProperty('total_alerts'); @@ -1760,7 +1789,7 @@ describe('CasesService', () => { page: 1, per_page: 1, aggregations: { myAggregation: { value: 0 } }, - } as SavedObjectsFindResponse); + } as SavedObjectsFindResponse); const res = await service.executeAggregations({ aggregationBuilders }); expect(res).toEqual({ myAggregation: { value: 0 } }); @@ -1773,7 +1802,7 @@ describe('CasesService', () => { page: 1, per_page: 1, aggregations: { myAggregation: { value: 0 } }, - } as SavedObjectsFindResponse); + } as SavedObjectsFindResponse); await service.executeAggregations({ aggregationBuilders, options: { perPage: 20 } }); expect(unsecuredSavedObjectsClient.find.mock.calls[0][0]).toMatchInlineSnapshot(` diff --git a/x-pack/plugins/cases/server/services/cases/index.ts b/x-pack/plugins/cases/server/services/cases/index.ts index 48a0f0a089b524..c64c0273f52d01 100644 --- a/x-pack/plugins/cases/server/services/cases/index.ts +++ b/x-pack/plugins/cases/server/services/cases/index.ts @@ -27,13 +27,7 @@ import { CASE_SAVED_OBJECT, MAX_DOCS_PER_PAGE, } from '../../../common/constants'; -import type { - Case, - CommentAttributes, - User, - CaseAttributes, - CaseStatuses, -} from '../../../common/api'; +import type { Case, CommentAttributes, User, CaseStatuses } from '../../../common/api'; import { caseStatuses } from '../../../common/api'; import type { SavedObjectFindOptionsKueryNode } from '../../common/types'; import { defaultSortField, flattenCaseSavedObject } from '../../common/utils'; @@ -51,12 +45,15 @@ import { import type { AttachmentService } from '../attachments'; import type { AggregationBuilder, AggregationResponse } from '../../client/metrics/types'; import { createCaseError } from '../../common/error'; -import type { CaseSavedObject, CaseSavedObjectAttributes } from '../../common/types/case'; +import type { + CaseSavedObjectAttributes, + CaseSavedObjectTransformed, + CaseTransformedAttributes, +} from '../../common/types/case'; import { CaseStatusSavedObject } from '../../common/types/case'; import type { GetCaseIdsByAlertIdArgs, GetCaseIdsByAlertIdAggs, - FindCaseOptions, CasesMapWithPageInfo, DeleteCaseArgs, GetCaseArgs, @@ -154,14 +151,14 @@ export class CasesService { public async findCasesGroupedByID({ caseOptions, }: { - caseOptions: FindCaseOptions; + caseOptions: SavedObjectFindOptionsKueryNode; }): Promise { const cases = await this.findCases(caseOptions); const casesMap = cases.saved_objects.reduce((accMap, caseInfo) => { accMap.set(caseInfo.id, caseInfo); return accMap; - }, new Map>()); + }, new Map>()); const commentTotals = await this.attachmentService.getter.getCaseCommentStats({ caseIds: Array.from(casesMap.keys()), @@ -263,7 +260,7 @@ export class CasesService { } } - public async getCase({ id: caseId }: GetCaseArgs): Promise { + public async getCase({ id: caseId }: GetCaseArgs): Promise { try { this.log.debug(`Attempting to GET case ${caseId}`); const caseSavedObject = await this.unsecuredSavedObjectsClient.get( @@ -279,7 +276,7 @@ export class CasesService { public async getResolveCase({ id: caseId, - }: GetCaseArgs): Promise> { + }: GetCaseArgs): Promise> { try { this.log.debug(`Attempting to resolve case ${caseId}`); const resolveCaseResult = @@ -300,7 +297,7 @@ export class CasesService { public async getCases({ caseIds, fields, - }: GetCasesArgs): Promise> { + }: GetCasesArgs): Promise> { try { this.log.debug(`Attempting to GET cases ${caseIds.join(', ')}`); const cases = await this.unsecuredSavedObjectsClient.bulkGet( @@ -315,7 +312,7 @@ export class CasesService { public async findCases( options?: SavedObjectFindOptionsKueryNode - ): Promise> { + ): Promise> { try { this.log.debug(`Attempting to find cases`); const cases = await this.unsecuredSavedObjectsClient.find({ @@ -323,6 +320,7 @@ export class CasesService { ...options, type: CASE_SAVED_OBJECT, }); + return transformFindResponseToExternalModel(cases); } catch (error) { this.log.error(`Error on find cases: ${error}`); @@ -496,7 +494,11 @@ export class CasesService { } } - public async postNewCase({ attributes, id, refresh }: PostCaseArgs): Promise { + public async postNewCase({ + attributes, + id, + refresh, + }: PostCaseArgs): Promise { try { this.log.debug(`Attempting to POST a new case`); const transformedAttributes = transformAttributesToESModel(attributes); @@ -523,7 +525,7 @@ export class CasesService { originalCase, version, refresh, - }: PatchCaseArgs): Promise> { + }: PatchCaseArgs): Promise> { try { this.log.debug(`Attempting to UPDATE case ${caseId}`); const transformedAttributes = transformAttributesToESModel(updatedAttributes); @@ -549,7 +551,7 @@ export class CasesService { public async patchCases({ cases, refresh, - }: PatchCasesArgs): Promise> { + }: PatchCasesArgs): Promise> { try { this.log.debug(`Attempting to UPDATE case ${cases.map((c) => c.caseId).join(', ')}`); diff --git a/x-pack/plugins/cases/server/services/cases/transform.test.ts b/x-pack/plugins/cases/server/services/cases/transform.test.ts index afd2de272bc421..1dee24a3a4b832 100644 --- a/x-pack/plugins/cases/server/services/cases/transform.test.ts +++ b/x-pack/plugins/cases/server/services/cases/transform.test.ts @@ -23,7 +23,7 @@ import { PUSH_CONNECTOR_ID_REFERENCE_NAME, } from '../../common/constants'; import { getNoneCaseConnector } from '../../common/utils'; -import { ESCaseSeverity, ESCaseStatus } from './types'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../../common/types/case'; describe('case transforms', () => { describe('transformUpdateResponseToExternalModel', () => { @@ -200,10 +200,10 @@ describe('case transforms', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'properly converts "%s" severity to corresponding external value "%s"', (internalSeverityValue, expectedSeverityValue) => { @@ -222,9 +222,9 @@ describe('case transforms', () => { ); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'properly converts "%s" status to corresponding ES Value "%s"', (internalStatusValue, expectedStatusValue) => { @@ -387,10 +387,10 @@ describe('case transforms', () => { }); it.each([ - [CaseSeverity.LOW, ESCaseSeverity.LOW], - [CaseSeverity.MEDIUM, ESCaseSeverity.MEDIUM], - [CaseSeverity.HIGH, ESCaseSeverity.HIGH], - [CaseSeverity.CRITICAL, ESCaseSeverity.CRITICAL], + [CaseSeverity.LOW, CaseSeveritySavedObject.LOW], + [CaseSeverity.MEDIUM, CaseSeveritySavedObject.MEDIUM], + [CaseSeverity.HIGH, CaseSeveritySavedObject.HIGH], + [CaseSeverity.CRITICAL, CaseSeveritySavedObject.CRITICAL], ])( 'properly converts "%s" severity to corresponding ES Value "%s"', (externalSeverityValue, expectedSeverityValue) => { @@ -410,9 +410,9 @@ describe('case transforms', () => { }); it.each([ - [CaseStatuses.open, ESCaseStatus.OPEN], - [CaseStatuses['in-progress'], ESCaseStatus.IN_PROGRESS], - [CaseStatuses.closed, ESCaseStatus.CLOSED], + [CaseStatuses.open, CaseStatusSavedObject.OPEN], + [CaseStatuses['in-progress'], CaseStatusSavedObject.IN_PROGRESS], + [CaseStatuses.closed, CaseStatusSavedObject.CLOSED], ])( 'properly converts "%s" status to corresponding ES Value "%s"', (externalStatusValue, expectedStatusValue) => { @@ -501,10 +501,10 @@ describe('case transforms', () => { }); it.each([ - [ESCaseSeverity.LOW, CaseSeverity.LOW], - [ESCaseSeverity.MEDIUM, CaseSeverity.MEDIUM], - [ESCaseSeverity.HIGH, CaseSeverity.HIGH], - [ESCaseSeverity.CRITICAL, CaseSeverity.CRITICAL], + [CaseSeveritySavedObject.LOW, CaseSeverity.LOW], + [CaseSeveritySavedObject.MEDIUM, CaseSeverity.MEDIUM], + [CaseSeveritySavedObject.HIGH, CaseSeverity.HIGH], + [CaseSeveritySavedObject.CRITICAL, CaseSeverity.CRITICAL], ])( 'properly converts "%s" severity to corresponding external value "%s"', (internalSeverityValue, expectedSeverityValue) => { @@ -529,9 +529,9 @@ describe('case transforms', () => { }); it.each([ - [ESCaseStatus.OPEN, CaseStatuses.open], - [ESCaseStatus.IN_PROGRESS, CaseStatuses['in-progress']], - [ESCaseStatus.CLOSED, CaseStatuses.closed], + [CaseStatusSavedObject.OPEN, CaseStatuses.open], + [CaseStatusSavedObject.IN_PROGRESS, CaseStatuses['in-progress']], + [CaseStatusSavedObject.CLOSED, CaseStatuses.closed], ])( 'properly converts "%s" status to corresponding external value "%s"', (internalStatusValue, expectedStatusValue) => { diff --git a/x-pack/plugins/cases/server/services/cases/transform.ts b/x-pack/plugins/cases/server/services/cases/transform.ts index 6adacf41f526ac..0c52b4d555165c 100644 --- a/x-pack/plugins/cases/server/services/cases/transform.ts +++ b/x-pack/plugins/cases/server/services/cases/transform.ts @@ -16,7 +16,6 @@ import type { SavedObjectsUpdateResponse, } from '@kbn/core/server'; import { ACTION_SAVED_OBJECT_TYPE } from '@kbn/actions-plugin/server'; -import type { ESCaseAttributes, ExternalServicesWithoutConnectorId } from './types'; import { CONNECTOR_ID_REFERENCE_NAME, PUSH_CONNECTOR_ID_REFERENCE_NAME, @@ -25,7 +24,7 @@ import { STATUS_ESMODEL_TO_EXTERNAL, STATUS_EXTERNAL_TO_ESMODEL, } from '../../common/constants'; -import type { CaseAttributes, CaseFullExternalService } from '../../../common/api'; +import type { CaseFullExternalService } from '../../../common/api'; import { CaseSeverity, CaseStatuses, NONE_CONNECTOR_ID } from '../../../common/api'; import { findConnectorIdReference, @@ -34,11 +33,15 @@ import { transformESConnectorToExternalModel, } from '../transform'; import { ConnectorReferenceHandler } from '../connector_reference_handler'; -import type { CaseSavedObject } from '../../common/types'; +import type { + CaseExternalServiceSavedObject, + CaseSavedObjectAttributes, + CaseTransformedAttributes, +} from '../../common/types/case'; export function transformUpdateResponsesToExternalModels( - response: SavedObjectsBulkUpdateResponse -): SavedObjectsBulkUpdateResponse { + response: SavedObjectsBulkUpdateResponse +): SavedObjectsBulkUpdateResponse { return { ...response, saved_objects: response.saved_objects.map((so) => ({ @@ -49,8 +52,8 @@ export function transformUpdateResponsesToExternalModels( } export function transformUpdateResponseToExternalModel( - updatedCase: SavedObjectsUpdateResponse -): SavedObjectsUpdateResponse { + updatedCase: SavedObjectsUpdateResponse +): SavedObjectsUpdateResponse { const { connector, external_service, @@ -64,7 +67,7 @@ export function transformUpdateResponseToExternalModel( ({ total_alerts: -1, total_comments: -1, - } as ESCaseAttributes); + } as CaseSavedObjectAttributes); const transformedConnector = transformESConnectorToExternalModel({ // if the saved object had an error the attributes field will not exist @@ -94,16 +97,16 @@ export function transformUpdateResponseToExternalModel( }; } -export function transformAttributesToESModel(caseAttributes: CaseAttributes): { - attributes: ESCaseAttributes; +export function transformAttributesToESModel(caseAttributes: CaseTransformedAttributes): { + attributes: CaseSavedObjectAttributes; referenceHandler: ConnectorReferenceHandler; }; -export function transformAttributesToESModel(caseAttributes: Partial): { - attributes: Partial; +export function transformAttributesToESModel(caseAttributes: Partial): { + attributes: Partial; referenceHandler: ConnectorReferenceHandler; }; -export function transformAttributesToESModel(caseAttributes: Partial): { - attributes: Partial; +export function transformAttributesToESModel(caseAttributes: Partial): { + attributes: Partial; referenceHandler: ConnectorReferenceHandler; } { const { connector, external_service, severity, status, ...restAttributes } = caseAttributes; @@ -154,15 +157,15 @@ function buildReferenceHandler( * definition like this: * * export function transformArrayResponseToExternalModel( - * response: SavedObjectsBulkResponse | SavedObjectsFindResponse - * ): SavedObjectsBulkResponse | SavedObjectsFindResponse { + * response: SavedObjectsBulkResponse | SavedObjectsFindResponse + * ): SavedObjectsBulkResponse | SavedObjectsFindResponse { * * See this issue for more details: https://stackoverflow.com/questions/49510832/typescript-how-to-map-over-union-array-type */ export function transformBulkResponseToExternalModel( - response: SavedObjectsBulkResponse -): SavedObjectsBulkResponse { + response: SavedObjectsBulkResponse +): SavedObjectsBulkResponse { return { ...response, saved_objects: response.saved_objects.map((so) => ({ @@ -173,8 +176,8 @@ export function transformBulkResponseToExternalModel( } export function transformFindResponseToExternalModel( - response: SavedObjectsFindResponse -): SavedObjectsFindResponse { + response: SavedObjectsFindResponse +): SavedObjectsFindResponse { return { ...response, saved_objects: response.saved_objects.map((so) => ({ @@ -185,8 +188,8 @@ export function transformFindResponseToExternalModel( } export function transformSavedObjectToExternalModel( - caseSavedObject: SavedObject -): CaseSavedObject { + caseSavedObject: SavedObject +): SavedObject { const connector = transformESConnectorOrUseDefault({ // if the saved object had an error the attributes field will not exist connector: caseSavedObject.attributes?.connector, @@ -209,7 +212,7 @@ export function transformSavedObjectToExternalModel( ({ total_alerts: -1, total_comments: -1, - } as ESCaseAttributes); + } as CaseSavedObjectAttributes); return { ...caseSavedObject, @@ -226,7 +229,7 @@ export function transformSavedObjectToExternalModel( function transformESExternalService( // this type needs to match that of CaseFullExternalService except that it does not include the connector_id, see: x-pack/plugins/cases/common/api/cases/case.ts // that's why it can be null here - externalService: ExternalServicesWithoutConnectorId | null | undefined, + externalService: CaseExternalServiceSavedObject | null | undefined, references: SavedObjectReference[] | undefined ): CaseFullExternalService | null { const connectorIdRef = findConnectorIdReference(PUSH_CONNECTOR_ID_REFERENCE_NAME, references); diff --git a/x-pack/plugins/cases/server/services/cases/types.ts b/x-pack/plugins/cases/server/services/cases/types.ts index 1b63b660abb0ac..3a57fa3eea83a4 100644 --- a/x-pack/plugins/cases/server/services/cases/types.ts +++ b/x-pack/plugins/cases/server/services/cases/types.ts @@ -6,11 +6,15 @@ */ import type { KueryNode } from '@kbn/es-query'; -import type { SavedObjectsClientContract, SavedObjectsFindOptions } from '@kbn/core/server'; -import type { Case } from '../../../common'; +import type { SavedObjectsClientContract } from '@kbn/core/server'; +import type { Case } from '../../../common/api'; import type { IndexRefresh } from '../types'; import type { User } from '../../common/types/user'; -import type { CaseSavedObjectAttributes, CaseSavedObject } from '../../common/types/case'; +import type { + CaseSavedObjectTransformed, + CaseTransformedAttributes, +} from '../../common/types/case'; +import type { SavedObjectFindOptionsKueryNode } from '../../common/types'; export interface GetCaseIdsByAlertIdArgs { alertId: string; @@ -35,23 +39,23 @@ export interface GetCasesArgs { export interface FindCommentsArgs { id: string | string[]; - options?: SavedObjectsFindOptions; + options?: SavedObjectFindOptionsKueryNode; } export interface FindCaseCommentsArgs { id: string | string[]; - options?: SavedObjectsFindOptions; + options?: SavedObjectFindOptionsKueryNode; } export interface PostCaseArgs extends IndexRefresh { - attributes: CaseSavedObjectAttributes; + attributes: CaseTransformedAttributes; id: string; } export interface PatchCase extends IndexRefresh { caseId: string; - updatedAttributes: Partial; - originalCase: CaseSavedObject; + updatedAttributes: Partial; + originalCase: CaseSavedObjectTransformed; version?: string; } @@ -68,8 +72,6 @@ export interface CasesMapWithPageInfo { total: number; } -export type FindCaseOptions = CasesFindRequest & SavedObjectsFindOptions; - export interface GetTagsArgs { unsecuredSavedObjectsClient: SavedObjectsClientContract; filter?: KueryNode; diff --git a/x-pack/plugins/cases/server/services/configure/types.ts b/x-pack/plugins/cases/server/services/configure/types.ts index 4e6ecc03955aee..853497d58aaf36 100644 --- a/x-pack/plugins/cases/server/services/configure/types.ts +++ b/x-pack/plugins/cases/server/services/configure/types.ts @@ -6,12 +6,12 @@ */ import type { CasesConfigureAttributes } from '../../../common/api'; -import type { ESCaseConnector } from '..'; +import type { ConnectorSavedObject } from '../../common/types/case'; /** * This type should only be used within the configure service. It represents how the configure saved object will be layed * out in ES. */ export type ESCasesConfigureAttributes = Omit & { - connector: ESCaseConnector; + connector: ConnectorSavedObject; }; diff --git a/x-pack/plugins/cases/server/services/index.ts b/x-pack/plugins/cases/server/services/index.ts index e15584b6ced9ea..f1bfc940a36f18 100644 --- a/x-pack/plugins/cases/server/services/index.ts +++ b/x-pack/plugins/cases/server/services/index.ts @@ -6,7 +6,6 @@ */ import type { SavedObjectsClientContract } from '@kbn/core/server'; -import type { ConnectorTypes } from '../../common/api'; export { CasesService } from './cases'; export { CaseConfigureService } from './configure'; @@ -19,14 +18,3 @@ export { UserProfileService } from './user_profiles'; export interface ClientArgs { unsecuredSavedObjectsClient: SavedObjectsClientContract; } - -export type ESConnectorFields = Array<{ - key: string; - value: unknown; -}>; - -export interface ESCaseConnector { - name: string; - type: ConnectorTypes; - fields: ESConnectorFields | null; -} diff --git a/x-pack/plugins/cases/server/services/notifications/email_notification_service.ts b/x-pack/plugins/cases/server/services/notifications/email_notification_service.ts index 2800a248b13947..8c8fd98e1a8489 100644 --- a/x-pack/plugins/cases/server/services/notifications/email_notification_service.ts +++ b/x-pack/plugins/cases/server/services/notifications/email_notification_service.ts @@ -11,7 +11,7 @@ import type { NotificationsPluginStart } from '@kbn/notifications-plugin/server' import type { SecurityPluginStart } from '@kbn/security-plugin/server'; import type { UserProfileUserInfo } from '@kbn/user-profile-components'; import { CASE_SAVED_OBJECT, MAX_CONCURRENT_SEARCHES } from '../../../common/constants'; -import type { CaseSavedObject } from '../../common/types'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; import { getCaseViewPath } from '../../common/utils'; import type { NotificationService, NotifyArgs } from './types'; @@ -46,12 +46,12 @@ export class EmailNotificationService implements NotificationService { this.publicBaseUrl = publicBaseUrl; } - private static getTitle(theCase: CaseSavedObject) { + private static getTitle(theCase: CaseSavedObjectTransformed) { return `[Elastic][Cases] ${theCase.attributes.title}`; } private static getMessage( - theCase: CaseSavedObject, + theCase: CaseSavedObjectTransformed, spaceId: string, publicBaseUrl?: IBasePath['publicBaseUrl'] ) { diff --git a/x-pack/plugins/cases/server/services/notifications/types.ts b/x-pack/plugins/cases/server/services/notifications/types.ts index 0efc326cf78351..48909c00a77d70 100644 --- a/x-pack/plugins/cases/server/services/notifications/types.ts +++ b/x-pack/plugins/cases/server/services/notifications/types.ts @@ -6,11 +6,11 @@ */ import type { CaseAssignees } from '../../../common/api'; -import type { CaseSavedObject } from '../../common/types'; +import type { CaseSavedObjectTransformed } from '../../common/types/case'; export interface NotifyArgs { assignees: CaseAssignees; - theCase: CaseSavedObject; + theCase: CaseSavedObjectTransformed; } export interface NotificationService { diff --git a/x-pack/plugins/cases/server/services/test_utils.ts b/x-pack/plugins/cases/server/services/test_utils.ts index d0108564d476ac..b93822b012f593 100644 --- a/x-pack/plugins/cases/server/services/test_utils.ts +++ b/x-pack/plugins/cases/server/services/test_utils.ts @@ -7,7 +7,6 @@ import type { SavedObject, SavedObjectReference, SavedObjectsFindResult } from '@kbn/core/server'; import { ACTION_SAVED_OBJECT_TYPE } from '@kbn/actions-plugin/server'; -import type { ESConnectorFields } from '.'; import { CONNECTOR_ID_REFERENCE_NAME, PUSH_CONNECTOR_ID_REFERENCE_NAME } from '../common/constants'; import type { CaseAttributes, @@ -17,9 +16,13 @@ import type { } from '../../common/api'; import { CaseSeverity, CaseStatuses, ConnectorTypes, NONE_CONNECTOR_ID } from '../../common/api'; import { CASE_SAVED_OBJECT, SECURITY_SOLUTION_OWNER } from '../../common/constants'; -import type { ESCaseAttributes, ExternalServicesWithoutConnectorId } from './cases/types'; -import { ESCaseSeverity, ESCaseStatus } from './cases/types'; import { getNoneCaseConnector } from '../common/utils'; +import type { + CaseExternalServiceSavedObject, + CaseSavedObjectAttributes, + ConnectorFieldsSavedObject, +} from '../common/types/case'; +import { CaseSeveritySavedObject, CaseStatusSavedObject } from '../common/types/case'; /** * This is only a utility interface to help with constructing test cases. After the migration, the ES format will no longer @@ -29,7 +32,7 @@ export interface ESCaseConnectorWithId { id: string; name: string; type: ConnectorTypes; - fields: ESConnectorFields | null; + fields: ConnectorFieldsSavedObject | null; } /** @@ -97,7 +100,7 @@ export const createExternalService = ( ...overrides, }); -export const basicESCaseFields: ESCaseAttributes = { +export const basicESCaseFields: CaseSavedObjectAttributes = { closed_at: null, closed_by: null, created_at: '2019-11-25T21:54:48.952Z', @@ -106,11 +109,11 @@ export const basicESCaseFields: ESCaseAttributes = { email: 'testemail@elastic.co', username: 'elastic', }, - severity: ESCaseSeverity.LOW, + severity: CaseSeveritySavedObject.LOW, duration: null, description: 'This is a brand new case of a bad meanie defacing data', title: 'Super Bad Security Issue', - status: ESCaseStatus.OPEN, + status: CaseStatusSavedObject.OPEN, tags: ['defacement'], updated_at: '2019-11-25T21:54:48.952Z', updated_by: { @@ -167,9 +170,9 @@ export const createCaseSavedObjectResponse = ({ }: { connector?: ESCaseConnectorWithId; externalService?: CaseFullExternalService; - overrides?: Partial; + overrides?: Partial; caseId?: string; -} = {}): SavedObject => { +} = {}): SavedObject => { const references: SavedObjectReference[] = createSavedObjectReferences({ connector, externalService, @@ -181,7 +184,7 @@ export const createCaseSavedObjectResponse = ({ fields: connector?.fields ?? null, }; - let restExternalService: ExternalServicesWithoutConnectorId | null = null; + let restExternalService: CaseExternalServiceSavedObject | null = null; if (externalService !== null) { const { connector_id: ignored, ...rest } = externalService ?? { connector_name: '.jira', diff --git a/x-pack/plugins/cases/server/services/transform.ts b/x-pack/plugins/cases/server/services/transform.ts index 50d5192610d4f6..78efd705cc29a6 100644 --- a/x-pack/plugins/cases/server/services/transform.ts +++ b/x-pack/plugins/cases/server/services/transform.ts @@ -9,7 +9,7 @@ import type { SavedObjectReference } from '@kbn/core/server'; import { ACTION_SAVED_OBJECT_TYPE } from '@kbn/actions-plugin/server'; import type { CaseConnector, ConnectorTypeFields } from '../../common/api'; import { getNoneCaseConnector } from '../common/utils'; -import type { ESCaseConnector, ESConnectorFields } from '.'; +import type { ConnectorSavedObject, ConnectorFieldsSavedObject } from '../common/types/case'; export function findConnectorIdReference( name: string, @@ -23,7 +23,7 @@ export function transformESConnectorToExternalModel({ references, referenceName, }: { - connector?: ESCaseConnector; + connector?: ConnectorSavedObject; references?: SavedObjectReference[]; referenceName: string; }): CaseConnector | undefined { @@ -32,7 +32,7 @@ export function transformESConnectorToExternalModel({ } function transformConnectorFieldsToExternalModel( - connector?: ESCaseConnector, + connector?: ConnectorSavedObject, connectorId?: string ): CaseConnector | undefined { if (!connector) { @@ -72,7 +72,7 @@ export function transformESConnectorOrUseDefault({ references, referenceName, }: { - connector?: ESCaseConnector; + connector?: ConnectorSavedObject; references?: SavedObjectReference[]; referenceName: string; }): CaseConnector { @@ -82,12 +82,12 @@ export function transformESConnectorOrUseDefault({ ); } -export function transformFieldsToESModel(connector: CaseConnector): ESConnectorFields { +export function transformFieldsToESModel(connector: CaseConnector): ConnectorFieldsSavedObject { if (!connector.fields) { return []; } - return Object.entries(connector.fields).reduce( + return Object.entries(connector.fields).reduce( (acc, [key, value]) => [ ...acc, { diff --git a/x-pack/plugins/cases/server/services/user_actions/operations/create.ts b/x-pack/plugins/cases/server/services/user_actions/operations/create.ts index ff58f9e6a52faf..351fbb9326a9ea 100644 --- a/x-pack/plugins/cases/server/services/user_actions/operations/create.ts +++ b/x-pack/plugins/cases/server/services/user_actions/operations/create.ts @@ -12,8 +12,8 @@ import type { SavedObjectsUpdateResponse, } from '@kbn/core/server'; import { get, isEmpty } from 'lodash'; +import type { CaseSavedObjectTransformed } from '../../../common/types/case'; import { CASE_SAVED_OBJECT, CASE_USER_ACTION_SAVED_OBJECT } from '../../../../common/constants'; -import type { CaseSavedObject } from '../../../common/types'; import { arraysDifference } from '../../../client/utils'; import { isUserActionType } from '../../../../common/utils/user_actions'; import type { @@ -58,7 +58,7 @@ type CreatePayloadFunction = ( ) => UserActionParameters['payload']; interface BulkCreateBulkUpdateCaseUserActions extends IndexRefresh { - originalCases: CaseSavedObject[]; + originalCases: CaseSavedObjectTransformed[]; updatedCases: Array>; user: User; } diff --git a/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts b/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts index b97235ff82247c..88ee4e7afe30f7 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/cases.test.ts @@ -7,7 +7,7 @@ import type { SavedObjectsFindResponse } from '@kbn/core/server'; import { savedObjectsRepositoryMock, loggingSystemMock } from '@kbn/core/server/mocks'; -import { ESCaseStatus } from '../../services/cases/types'; +import { CaseStatusSavedObject } from '../../common/types/case'; import type { AttachmentAggregationResult, AttachmentFrameworkAggsResult, @@ -99,7 +99,7 @@ describe('getCasesTelemetryData', () => { status: { buckets: [ { - key: ESCaseStatus.OPEN, + key: CaseStatusSavedObject.OPEN, doc_count: 2, }, ], diff --git a/x-pack/plugins/cases/server/telemetry/queries/cases.ts b/x-pack/plugins/cases/server/telemetry/queries/cases.ts index 59576fa1f45c0f..c0ff473d9a1c24 100644 --- a/x-pack/plugins/cases/server/telemetry/queries/cases.ts +++ b/x-pack/plugins/cases/server/telemetry/queries/cases.ts @@ -14,8 +14,6 @@ import { CASE_USER_ACTION_SAVED_OBJECT, OWNERS, } from '../../../common/constants'; -import { ESCaseStatus } from '../../services/cases/types'; -import type { ESCaseAttributes } from '../../services/cases/types'; import type { CollectTelemetryDataParams, CasesTelemetry, @@ -37,12 +35,14 @@ import { getReferencesAggregationQuery, getSolutionValues, } from './utils'; +import type { CaseSavedObjectAttributes } from '../../common/types/case'; +import { CaseStatusSavedObject } from '../../common/types/case'; export const getLatestCasesDates = async ({ savedObjectsClient, }: CollectTelemetryDataParams): Promise => { const find = async (sortField: string) => - savedObjectsClient.find({ + savedObjectsClient.find({ page: 1, perPage: 1, sortField, @@ -94,9 +94,12 @@ export const getCasesTelemetryData = async ({ total: casesRes.total, ...getCountsFromBuckets(aggregationsBuckets.counts), status: { - open: findValueInBuckets(aggregationsBuckets.status, ESCaseStatus.OPEN), - inProgress: findValueInBuckets(aggregationsBuckets.status, ESCaseStatus.IN_PROGRESS), - closed: findValueInBuckets(aggregationsBuckets.status, ESCaseStatus.CLOSED), + open: findValueInBuckets(aggregationsBuckets.status, CaseStatusSavedObject.OPEN), + inProgress: findValueInBuckets( + aggregationsBuckets.status, + CaseStatusSavedObject.IN_PROGRESS + ), + closed: findValueInBuckets(aggregationsBuckets.status, CaseStatusSavedObject.CLOSED), }, syncAlertsOn: findValueInBuckets(aggregationsBuckets.syncAlerts, 1), syncAlertsOff: findValueInBuckets(aggregationsBuckets.syncAlerts, 0), diff --git a/x-pack/test/functional_with_es_ssl/plugins/cases/public/application.tsx b/x-pack/test/functional_with_es_ssl/plugins/cases/public/application.tsx index e5609d1b5fe9f6..f4091d99f81bbd 100644 --- a/x-pack/test/functional_with_es_ssl/plugins/cases/public/application.tsx +++ b/x-pack/test/functional_with_es_ssl/plugins/cases/public/application.tsx @@ -58,7 +58,7 @@ const CasesFixtureAppWithContext: React.FC = (props) => { -

Cases attachment hooks

+

CasesUI attachment hooks