Skip to content

Commit

Permalink
[SIEM] [Case] Bulk status update, add comment avatar, id => title in …
Browse files Browse the repository at this point in the history
…breadcrumbs (#60410)
  • Loading branch information
stephmilovic authored Mar 19, 2020
1 parent d5989e8 commit 0163a71
Show file tree
Hide file tree
Showing 19 changed files with 565 additions and 126 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions x-pack/legacy/plugins/siem/public/containers/case/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ import {
User,
} from '../../../../../../plugins/case/common/api';
import { KibanaServices } from '../../lib/kibana';
import { AllCases, Case, CasesStatus, Comment, FetchCasesProps, SortFieldCase } from './types';
import {
AllCases,
BulkUpdateStatus,
Case,
CasesStatus,
Comment,
FetchCasesProps,
SortFieldCase,
} from './types';
import { CASES_URL } from './constants';
import {
convertToCamelCase,
Expand Down Expand Up @@ -92,7 +100,7 @@ export const getCases = async ({
};

export const postCase = async (newCase: CaseRequest): Promise<Case> => {
const response = await KibanaServices.get().http.fetch<CaseResponse>(`${CASES_URL}`, {
const response = await KibanaServices.get().http.fetch<CaseResponse>(CASES_URL, {
method: 'POST',
body: JSON.stringify(newCase),
});
Expand All @@ -104,13 +112,21 @@ export const patchCase = async (
updatedCase: Partial<CaseRequest>,
version: string
): Promise<Case[]> => {
const response = await KibanaServices.get().http.fetch<CasesResponse>(`${CASES_URL}`, {
const response = await KibanaServices.get().http.fetch<CasesResponse>(CASES_URL, {
method: 'PATCH',
body: JSON.stringify({ cases: [{ ...updatedCase, id: caseId, version }] }),
});
return convertToCamelCase<CasesResponse, Case[]>(decodeCasesResponse(response));
};

export const patchCasesStatus = async (cases: BulkUpdateStatus[]): Promise<Case[]> => {
const response = await KibanaServices.get().http.fetch<CasesResponse>(CASES_URL, {
method: 'PATCH',
body: JSON.stringify({ cases }),
});
return convertToCamelCase<CasesResponse, Case[]>(decodeCasesResponse(response));
};

export const postComment = async (newComment: CommentRequest, caseId: string): Promise<Comment> => {
const response = await KibanaServices.get().http.fetch<CommentResponse>(
`${CASES_URL}/${caseId}/comments`,
Expand Down Expand Up @@ -139,7 +155,7 @@ export const patchComment = async (
};

export const deleteCases = async (caseIds: string[]): Promise<boolean> => {
const response = await KibanaServices.get().http.fetch<string>(`${CASES_URL}`, {
const response = await KibanaServices.get().http.fetch<string>(CASES_URL, {
method: 'DELETE',
query: { ids: JSON.stringify(caseIds) },
});
Expand Down
6 changes: 6 additions & 0 deletions x-pack/legacy/plugins/siem/public/containers/case/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ export interface FetchCasesProps {
export interface ApiProps {
signal: AbortSignal;
}

export interface BulkUpdateStatus {
status: string;
id: string;
version: string;
}
Loading

0 comments on commit 0163a71

Please sign in to comment.