diff --git a/x-pack/plugins/case/common/api/cases/case.ts b/x-pack/plugins/case/common/api/cases/case.ts index 8924ce78aa1c3..33a93952b0e2d 100644 --- a/x-pack/plugins/case/common/api/cases/case.ts +++ b/x-pack/plugins/case/common/api/cases/case.ts @@ -10,7 +10,7 @@ import * as rt from 'io-ts'; import { NumberFromString } from '../saved_object'; import { UserRT } from '../user'; import { CommentResponseRt } from './comment'; -import { CasesStatusResponseRt, CaseStatusFilterRt, CaseStatusRt } from './status'; +import { CasesStatusResponseRt, CaseStatusRt } from './status'; import { CaseConnectorRt, ESCaseConnector } from '../connectors'; import { SubCaseResponseRt } from './sub_case'; @@ -102,7 +102,7 @@ export const CasePostRequestRt = rt.intersection([ export const CasesFindRequestRt = rt.partial({ type: CaseTypeRt, tags: rt.union([rt.array(rt.string), rt.string]), - status: CaseStatusFilterRt, + status: CaseStatusRt, reporters: rt.union([rt.array(rt.string), rt.string]), defaultSearchOperator: rt.union([rt.literal('AND'), rt.literal('OR')]), fields: rt.array(rt.string), diff --git a/x-pack/plugins/case/server/routes/api/cases/find_cases.ts b/x-pack/plugins/case/server/routes/api/cases/find_cases.ts index ac58631b05081..bc6907f52b9eb 100644 --- a/x-pack/plugins/case/server/routes/api/cases/find_cases.ts +++ b/x-pack/plugins/case/server/routes/api/cases/find_cases.ts @@ -16,7 +16,6 @@ import { CasesFindRequestRt, throwErrors, caseStatuses, - StatusAll, } from '../../../../common/api'; import { transformCases, wrapError, escapeHatch } from '../utils'; import { RouteDeps } from '../types'; @@ -38,21 +37,14 @@ export function initFindCasesApi({ caseService, router, logger }: RouteDeps) { CasesFindRequestRt.decode(request.query), fold(throwErrors(Boom.badRequest), identity) ); - const queryArgs = - queryParams.status === StatusAll - ? { - tags: queryParams.tags, - reporters: queryParams.reporters, - sortByField: queryParams.sortField, - caseType: queryParams.type, - } - : { - tags: queryParams.tags, - reporters: queryParams.reporters, - sortByField: queryParams.sortField, - status: queryParams.status, - caseType: queryParams.type, - }; + const queryArgs = { + tags: queryParams.tags, + reporters: queryParams.reporters, + sortByField: queryParams.sortField, + status: queryParams.status, + caseType: queryParams.type, + }; + const caseQueries = constructQueryOptions(queryArgs); const cases = await caseService.findCasesGroupedByID({ client, diff --git a/x-pack/plugins/security_solution/public/cases/containers/api.ts b/x-pack/plugins/security_solution/public/cases/containers/api.ts index 20fef78d003ed..9cd1467e09090 100644 --- a/x-pack/plugins/security_solution/public/cases/containers/api.ts +++ b/x-pack/plugins/security_solution/public/cases/containers/api.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { assign } from 'lodash'; +import { assign, omit } from 'lodash'; import { StatusAll, @@ -187,7 +187,7 @@ export const getCases = async ({ }; const response = await KibanaServices.get().http.fetch(`${CASES_URL}/_find`, { method: 'GET', - query, + query: query.status === StatusAll ? omit(query, ['status']) : query, signal, }); return convertAllCasesToCamel(decodeCasesFindResponse(response));