Skip to content

Commit

Permalink
do not sent status if itis set to all
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Mar 2, 2021
1 parent a453269 commit a812a98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/case/common/api/cases/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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),
Expand Down
24 changes: 8 additions & 16 deletions x-pack/plugins/case/server/routes/api/cases/find_cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
CasesFindRequestRt,
throwErrors,
caseStatuses,
StatusAll,
} from '../../../../common/api';
import { transformCases, wrapError, escapeHatch } from '../utils';
import { RouteDeps } from '../types';
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { assign } from 'lodash';
import { assign, omit } from 'lodash';

import {
StatusAll,
Expand Down Expand Up @@ -187,7 +187,7 @@ export const getCases = async ({
};
const response = await KibanaServices.get().http.fetch<CasesFindResponse>(`${CASES_URL}/_find`, {
method: 'GET',
query,
query: query.status === StatusAll ? omit(query, ['status']) : query,
signal,
});
return convertAllCasesToCamel(decodeCasesFindResponse(response));
Expand Down

0 comments on commit a812a98

Please sign in to comment.