Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SIEM] [Case] Bulk status update, add comment avatar, id => title in breadcrumbs #60410

Merged
merged 11 commits into from
Mar 19, 2020

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