Skip to content

Commit

Permalink
Merge branch 'main' into issue_156630
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jun 22, 2023
2 parents 5d29bb1 + 590e5c6 commit 8cb3683
Show file tree
Hide file tree
Showing 110 changed files with 2,990 additions and 2,691 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { EuiButtonEmpty, EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { CoreStart, HttpStart } from '@kbn/core/public';
import React from 'react';
import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public';
import type { SearchSessionsMgmtAPI } from '../lib/api';
import type { AsyncSearchIntroDocumentation } from '../lib/documentation';
import { SearchSessionsMgmtTable } from './table';
Expand All @@ -29,7 +30,7 @@ interface Props {

export function SearchSessionsMgmtMain({ documentation, ...tableProps }: Props) {
return (
<>
<KibanaThemeProvider theme$={tableProps.core.theme.theme$}>
<EuiPageHeader
pageTitle={
<FormattedMessage
Expand Down Expand Up @@ -60,6 +61,6 @@ export function SearchSessionsMgmtMain({ documentation, ...tableProps }: Props)

<EuiSpacer size="l" />
<SearchSessionsMgmtTable data-test-subj="search-sessions-mgmt-table" {...tableProps} />
</>
</KibanaThemeProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const ResultsLinks: FC<Props> = ({
getAdditionalLinks.map(async (asyncCardGetter) => {
const results = await asyncCardGetter({
dataViewId,
globalState,
});
if (Array.isArray(results)) {
return await Promise.all(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import { mockHttpValues } from '../../../__mocks__/kea_logic';

import { nextTick } from '@kbn/test-jest-helpers';

import { createEngine } from './create_engine_api_logic';
import { createSearchApplication } from './create_search_application_api_logic';

describe('CreateEngineApiLogic', () => {
describe('CreateSearchApplicationApiLogic', () => {
const { http } = mockHttpValues;
beforeEach(() => {
jest.clearAllMocks();
});
describe('createEngine', () => {
describe('createSearchApplication', () => {
it('calls correct api', async () => {
const engine = { engineName: 'my-engine', indices: ['an-index'] };
const searchApplication = { indices: ['an-index'], name: 'my-search-application' };
const response = { result: 'created' };
const promise = Promise.resolve(response);
http.put.mockReturnValue(promise);
const result = createEngine(engine);
const result = createSearchApplication(searchApplication);
await nextTick();
expect(http.put).toHaveBeenCalledWith(
'/internal/enterprise_search/search_applications/my-engine',
'/internal/enterprise_search/search_applications/my-search-application',
{
body: '{"indices":["an-index"],"name":"my-engine"}',
body: '{"indices":["an-index"],"name":"my-search-application"}',
query: { create: true },
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,34 @@ import { EnterpriseSearchApplicationUpsertResponse } from '../../../../../common
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

export interface CreateEngineApiParams {
engineName: string;
export interface CreateSearchApplicationApiParams {
indices: string[];
name: string;
}

export type CreateEngineApiResponse = EnterpriseSearchApplicationUpsertResponse;
export type CreateSearchApplicationApiResponse = EnterpriseSearchApplicationUpsertResponse;

export type CreateEngineApiLogicActions = Actions<CreateEngineApiParams, CreateEngineApiResponse>;
export type CreateSearchApplicationApiLogicActions = Actions<
CreateSearchApplicationApiParams,
CreateSearchApplicationApiResponse
>;

export const createEngine = async ({
engineName,
export const createSearchApplication = async ({
name,
indices,
}: CreateEngineApiParams): Promise<CreateEngineApiResponse> => {
const route = `/internal/enterprise_search/search_applications/${engineName}`;
}: CreateSearchApplicationApiParams): Promise<CreateSearchApplicationApiResponse> => {
const route = `/internal/enterprise_search/search_applications/${name}`;

return await HttpLogic.values.http.put<EnterpriseSearchApplicationUpsertResponse>(route, {
body: JSON.stringify({ indices, name: engineName }),
body: JSON.stringify({ indices, name }),
query: { create: true },
});
};

export const CreateEngineApiLogic = createApiLogic(['create_engine_api_logic'], createEngine, {
showErrorFlash: false,
});
export const CreateSearchApplicationApiLogic = createApiLogic(
['search_applications', 'create_search_application_api_logic'],
createSearchApplication,
{
showErrorFlash: false,
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import { mockHttpValues } from '../../../__mocks__/kea_logic';

import { nextTick } from '@kbn/test-jest-helpers';

import { deleteEngine } from './delete_engines_api_logic';
import { deleteSearchApplication } from './delete_search_application_api_logic';

describe('deleteEngineApiLogic', () => {
describe('DeleteSearchApplicationAPILogic', () => {
const { http } = mockHttpValues;
beforeEach(() => {
jest.clearAllMocks();
});
describe('deleteEngine', () => {
describe('deleteSearchApplication', () => {
it('calls correct api', async () => {
const promise = Promise.resolve();
http.post.mockReturnValue(promise);
const result = deleteEngine({ engineName: 'deleteEngineName' });
const result = deleteSearchApplication({ searchApplicationName: 'search-application' });
await nextTick();
expect(http.delete).toHaveBeenCalledWith(
'/internal/enterprise_search/search_applications/deleteEngineName'
'/internal/enterprise_search/search_applications/search-application'
);
await expect(result).resolves;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';

import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

export interface DeleteSearchApplicationApiLogicArguments {
searchApplicationName: string;
}
export interface DeleteSearchApplicationApiLogicResponse {
searchApplicationName: string;
}

export const deleteSearchApplication = async ({
searchApplicationName,
}: DeleteSearchApplicationApiLogicArguments): Promise<DeleteSearchApplicationApiLogicResponse> => {
const route = `/internal/enterprise_search/search_applications/${searchApplicationName}`;
await HttpLogic.values.http.delete<DeleteSearchApplicationApiLogicResponse>(route);
return { searchApplicationName };
};
export const DeleteSearchApplicationAPILogic = createApiLogic(
['search_applications', 'delete_search_application_api_logic'],
deleteSearchApplication,
{
showSuccessFlashFn: ({ searchApplicationName }) =>
i18n.translate(
'xpack.enterpriseSearch.searchApplications.list.deleteSearchApplication.successToast.title',
{
defaultMessage: '{searchApplicationName} has been deleted',
values: {
searchApplicationName,
},
}
),
}
);

export type DeleteSearchApplicationApiLogicActions = Actions<
DeleteSearchApplicationApiLogicArguments,
DeleteSearchApplicationApiLogicResponse
>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_lo
import { INPUT_THROTTLE_DELAY_MS } from '../../../shared/constants/timers';
import { HttpLogic } from '../../../shared/http';

export interface EnginesFetchIndicesApiParams {
export interface SearchApplicationsFetchIndicesApiParams {
searchQuery?: string;
}

export interface EnginesFetchIndicesApiResponse {
export interface SearchApplicationsFetchIndicesApiResponse {
indices: ElasticsearchIndexWithIngestion[];
meta: Meta;
searchQuery?: string;
Expand All @@ -26,7 +26,7 @@ const INDEX_SEARCH_PAGE_SIZE = 40;

export const fetchIndices = async ({
searchQuery,
}: EnginesFetchIndicesApiParams): Promise<EnginesFetchIndicesApiResponse> => {
}: SearchApplicationsFetchIndicesApiParams): Promise<SearchApplicationsFetchIndicesApiResponse> => {
const { http } = HttpLogic.values;
const route = '/internal/enterprise_search/indices';
const query = {
Expand All @@ -45,15 +45,15 @@ export const fetchIndices = async ({
return { ...response, searchQuery };
};

export const FetchIndicesForEnginesAPILogic = createApiLogic(
['content', 'engines_fetch_indices_api_logic'],
export const FetchIndicesForSearchApplicationsAPILogic = createApiLogic(
['search_applications', 'fetch_indices_api_logic'],
fetchIndices,
{
requestBreakpointMS: INPUT_THROTTLE_DELAY_MS,
}
);

export type FetchIndicesForEnginesAPILogicActions = Actions<
EnginesFetchIndicesApiParams,
EnginesFetchIndicesApiResponse
export type FetchIndicesForSearchApplicationsAPILogicActions = Actions<
SearchApplicationsFetchIndicesApiParams,
SearchApplicationsFetchIndicesApiResponse
>;
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import { mockHttpValues } from '../../../__mocks__/kea_logic';

import { nextTick } from '@kbn/test-jest-helpers';

import { fetchEngine } from './fetch_engine_api_logic';
import { fetchSearchApplication } from './fetch_search_application_api_logic';

describe('FetchEngineApiLogic', () => {
describe('FetchSearchApplicationApiLogic', () => {
const { http } = mockHttpValues;
beforeEach(() => {
jest.clearAllMocks();
});
describe('fetchEngine', () => {
describe('fetchSearchApplication', () => {
it('calls correct api', async () => {
const promise = Promise.resolve('result');
http.get.mockReturnValue(promise);
const result = fetchEngine({ engineName: 'my-engine' });
const result = fetchSearchApplication({ name: 'search-application' });
await nextTick();
expect(http.get).toHaveBeenCalledWith(
'/internal/enterprise_search/search_applications/my-engine'
'/internal/enterprise_search/search_applications/search-application'
);
await expect(result).resolves.toEqual('result');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,26 @@ import { EnterpriseSearchApplicationDetails } from '../../../../../common/types/
import { Actions, createApiLogic } from '../../../shared/api_logic/create_api_logic';
import { HttpLogic } from '../../../shared/http';

export interface FetchEngineApiParams {
engineName: string;
export interface FetchSearchApplicationApiParams {
name: string;
}

export type FetchEngineApiResponse = EnterpriseSearchApplicationDetails;
export type FetchSearchApplicationApiResponse = EnterpriseSearchApplicationDetails;

export const fetchEngine = async ({
engineName,
}: FetchEngineApiParams): Promise<FetchEngineApiResponse> => {
const route = `/internal/enterprise_search/search_applications/${engineName}`;
export const fetchSearchApplication = async ({
name,
}: FetchSearchApplicationApiParams): Promise<FetchSearchApplicationApiResponse> => {
const route = `/internal/enterprise_search/search_applications/${name}`;

return await HttpLogic.values.http.get<EnterpriseSearchApplicationDetails>(route);
};

export const FetchEngineApiLogic = createApiLogic(['fetch_engine_api_logic'], fetchEngine);
export const FetchSearchApplicationApiLogic = createApiLogic(
['search_applications', 'fetch_search_application_api_logic'],
fetchSearchApplication
);

export type FetchEngineApiLogicActions = Actions<FetchEngineApiParams, FetchEngineApiResponse>;
export type FetchSearchApplicationApiLogicActions = Actions<
FetchSearchApplicationApiParams,
FetchSearchApplicationApiResponse
>;
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import { mockHttpValues } from '../../../__mocks__/kea_logic';

import { nextTick } from '@kbn/test-jest-helpers';

import { fetchEngineFieldCapabilities } from './fetch_engine_field_capabilities_api_logic';
import { fetchSearchApplicationFieldCapabilities } from './fetch_search_application_field_capabilities_api_logic';

describe('FetchEngineFieldCapabilitiesApiLogic', () => {
describe('FetchSearchApplicationFieldCapabilitiesApiLogic', () => {
const { http } = mockHttpValues;
beforeEach(() => {
jest.clearAllMocks();
});
describe('fetchEngineFieldCapabilities', () => {
describe('fetchSearchApplicationFieldCapabilities', () => {
it('requests the field_capabilities api', async () => {
const promise = Promise.resolve({ result: 'result' });
http.get.mockReturnValue(promise);
const result = fetchEngineFieldCapabilities({ engineName: 'foobar' });
const result = fetchSearchApplicationFieldCapabilities({ name: 'foobar' });
await nextTick();
expect(http.get).toHaveBeenCalledWith(
'/internal/enterprise_search/search_applications/foobar/field_capabilities'
Expand Down
Loading

0 comments on commit 8cb3683

Please sign in to comment.