mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Cases] Pass owner to the getRelatedCases API (#127446)
This commit is contained in:
parent
11e497f3a4
commit
e6a9f779d3
4 changed files with 35 additions and 9 deletions
|
@ -115,6 +115,14 @@ Arguments
|
|||
| Property | Description | Type |
|
||||
| -------- | ------------ | ------ |
|
||||
| alertId | The alert ID | string |
|
||||
| query | The alert ID | object |
|
||||
|
||||
`query`
|
||||
|
||||
| Property | Description | Type |
|
||||
| -------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
||||
| owner | The type of cases to retrieve given an alert ID. If no owner is provided, all cases that the user has access to will be returned. | string \| string[] \| undefined |
|
||||
|
||||
|
||||
Response
|
||||
|
||||
|
|
|
@ -26,12 +26,21 @@ describe('createClientAPI', () => {
|
|||
http.get.mockResolvedValue(res);
|
||||
|
||||
it('should return the correct response', async () => {
|
||||
expect(await api.getRelatedCases('alert-id')).toEqual(res);
|
||||
expect(await api.getRelatedCases('alert-id', { owner: 'test' })).toEqual(res);
|
||||
});
|
||||
|
||||
it('should have been called with the correct path', async () => {
|
||||
await api.getRelatedCases('alert-id');
|
||||
expect(http.get).toHaveBeenCalledWith('/api/cases/alerts/alert-id');
|
||||
await api.getRelatedCases('alert-id', { owner: 'test' });
|
||||
expect(http.get).toHaveBeenCalledWith('/api/cases/alerts/alert-id', {
|
||||
query: { owner: 'test' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept an empty object with no owner', async () => {
|
||||
await api.getRelatedCases('alert-id', {});
|
||||
expect(http.get).toHaveBeenCalledWith('/api/cases/alerts/alert-id', {
|
||||
query: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
*/
|
||||
|
||||
import { HttpStart } from 'kibana/public';
|
||||
import { CasesByAlertId, getCasesFromAlertsUrl } from '../../../common/api';
|
||||
import { CasesByAlertId, CasesByAlertIDRequest, getCasesFromAlertsUrl } from '../../../common/api';
|
||||
import { CasesUiStart } from '../../types';
|
||||
|
||||
export const createClientAPI = ({ http }: { http: HttpStart }) => {
|
||||
export const createClientAPI = ({ http }: { http: HttpStart }): CasesUiStart['api'] => {
|
||||
return {
|
||||
getRelatedCases: async (alertId: string): Promise<CasesByAlertId> =>
|
||||
http.get<CasesByAlertId>(getCasesFromAlertsUrl(alertId)),
|
||||
getRelatedCases: async (
|
||||
alertId: string,
|
||||
query: CasesByAlertIDRequest
|
||||
): Promise<CasesByAlertId> =>
|
||||
http.get<CasesByAlertId>(getCasesFromAlertsUrl(alertId), { query }),
|
||||
};
|
||||
};
|
||||
|
|
|
@ -20,7 +20,12 @@ import type { LensPublicStart } from '../../lens/public';
|
|||
import type { SecurityPluginSetup } from '../../security/public';
|
||||
import type { SpacesPluginStart } from '../../spaces/public';
|
||||
import type { TriggersAndActionsUIPublicPluginStart as TriggersActionsStart } from '../../triggers_actions_ui/public';
|
||||
import { CasesByAlertId, CommentRequestAlertType, CommentRequestUserType } from '../common/api';
|
||||
import {
|
||||
CasesByAlertId,
|
||||
CasesByAlertIDRequest,
|
||||
CommentRequestAlertType,
|
||||
CommentRequestUserType,
|
||||
} from '../common/api';
|
||||
import { UseCasesAddToExistingCaseModal } from './components/all_cases/selector_modal/use_cases_add_to_existing_case_modal';
|
||||
import { UseCasesAddToNewCaseFlyout } from './components/create/flyout/use_cases_add_to_new_case_flyout';
|
||||
import type { CasesOwners } from './client/helpers/can_use_cases';
|
||||
|
@ -68,7 +73,7 @@ export interface RenderAppProps {
|
|||
|
||||
export interface CasesUiStart {
|
||||
api: {
|
||||
getRelatedCases: (alertId: string) => Promise<CasesByAlertId>;
|
||||
getRelatedCases: (alertId: string, query: CasesByAlertIDRequest) => Promise<CasesByAlertId>;
|
||||
};
|
||||
ui: {
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue