Skip to content

Commit

Permalink
[Enterprise Search][Search Application] Update engines to be search a…
Browse files Browse the repository at this point in the history
…pplication (#155299)

## Summary

* Update 'engines' to be 'Search Application' in UI 
* Navigate to Search application from indices page rather than app search engine
* Pre-select index and open Create Search Application Flyout when navigated from Index page




https://user-images.githubusercontent.com/55930906/233170965-318cdc63-2953-45f8-89d3-b3f15f11ab11.mov





### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
saarikabhasi authored Apr 21, 2023
1 parent b97b18e commit d32c867
Show file tree
Hide file tree
Showing 29 changed files with 205 additions and 406 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/enterprise_search/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ export const SEARCH_EXPERIENCES_PLUGIN = {
};

export const ENGINES_PLUGIN = {
NAV_TITLE: i18n.translate('xpack.enterpriseSearch.engines.navTitle', {
defaultMessage: 'Engines',
NAV_TITLE: i18n.translate('xpack.enterpriseSearch.applications.navTitle', {
defaultMessage: 'Applications',
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ export const AddIndicesFlyout: React.FC<AddIndicesFlyoutProps> = ({ onClose }) =
const { selectedIndices, updateEngineStatus, updateEngineError } = useValues(AddIndicesLogic);
const { setSelectedIndices, submitSelectedIndices } = useActions(AddIndicesLogic);

const selectedOptions = useMemo(() => selectedIndices.map(indexToOption), [selectedIndices]);
const selectedOptions = useMemo(
() => selectedIndices.map((index) => indexToOption(index)),
[selectedIndices]
);
const onIndicesChange = useCallback(
(options: IndicesSelectComboBoxOption[]) => {
setSelectedIndices(options.map(({ value }) => value).filter(isNotNullish));
setSelectedIndices(options.map(({ label }) => label).filter(isNotNullish));
},
[setSelectedIndices]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { LogicMounter } from '../../../__mocks__/kea_logic';

import { Status } from '../../../../../common/types/api';
import { ElasticsearchIndexWithIngestion } from '../../../../../common/types/indices';

import { AddIndicesLogic, AddIndicesLogicValues } from './add_indices_logic';

Expand All @@ -18,16 +17,6 @@ const DEFAULT_VALUES: AddIndicesLogicValues = {
updateEngineStatus: Status.IDLE,
};

const makeIndexData = (name: string): ElasticsearchIndexWithIngestion => ({
count: 0,
hidden: false,
name,
total: {
docs: { count: 0, deleted: 0 },
store: { size_in_bytes: 'n/a' },
},
});

describe('AddIndicesLogic', () => {
const { mount: mountAddIndicesLogic } = new LogicMounter(AddIndicesLogic);
const { mount: mountEngineIndicesLogic } = new LogicMounter(AddIndicesLogic);
Expand All @@ -47,31 +36,16 @@ describe('AddIndicesLogic', () => {
describe('actions', () => {
describe('setSelectedIndices', () => {
it('adds the indices to selectedIndices', () => {
AddIndicesLogic.actions.setSelectedIndices([
makeIndexData('index-001'),
makeIndexData('index-002'),
]);
AddIndicesLogic.actions.setSelectedIndices(['index-001', 'index-002']);

expect(AddIndicesLogic.values.selectedIndices).toEqual([
makeIndexData('index-001'),
makeIndexData('index-002'),
]);
expect(AddIndicesLogic.values.selectedIndices).toEqual(['index-001', 'index-002']);
});

it('replaces any existing indices', () => {
AddIndicesLogic.actions.setSelectedIndices([
makeIndexData('index-001'),
makeIndexData('index-002'),
]);
AddIndicesLogic.actions.setSelectedIndices([
makeIndexData('index-003'),
makeIndexData('index-004'),
]);
AddIndicesLogic.actions.setSelectedIndices(['index-001', 'index-002']);
AddIndicesLogic.actions.setSelectedIndices(['index-003', 'index-004']);

expect(AddIndicesLogic.values.selectedIndices).toEqual([
makeIndexData('index-003'),
makeIndexData('index-004'),
]);
expect(AddIndicesLogic.values.selectedIndices).toEqual(['index-003', 'index-004']);
});
});
});
Expand Down Expand Up @@ -103,10 +77,7 @@ describe('AddIndicesLogic', () => {
it('calls addIndicesToEngine when there are selectedIndices', () => {
jest.spyOn(AddIndicesLogic.actions, 'addIndicesToEngine');

AddIndicesLogic.actions.setSelectedIndices([
makeIndexData('index-001'),
makeIndexData('index-002'),
]);
AddIndicesLogic.actions.setSelectedIndices(['index-001', 'index-002']);
AddIndicesLogic.actions.submitSelectedIndices();

expect(AddIndicesLogic.actions.addIndicesToEngine).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

import { kea, MakeLogicType } from 'kea';

import { ElasticsearchIndexWithIngestion } from '../../../../../common/types/indices';

import { UpdateEngineApiLogic } from '../../api/engines/update_engine_api_logic';

import { EngineIndicesLogic, EngineIndicesLogicActions } from './engine_indices_logic';
Expand All @@ -17,21 +15,21 @@ export interface AddIndicesLogicActions {
addIndicesToEngine: EngineIndicesLogicActions['addIndicesToEngine'];
closeAddIndicesFlyout: EngineIndicesLogicActions['closeAddIndicesFlyout'];
engineUpdated: EngineIndicesLogicActions['engineUpdated'];
setSelectedIndices: (indices: ElasticsearchIndexWithIngestion[]) => {
indices: ElasticsearchIndexWithIngestion[];
setSelectedIndices: (indices: string[]) => {
indices: string[];
};
submitSelectedIndices: () => void;
}

export interface AddIndicesLogicValues {
selectedIndices: ElasticsearchIndexWithIngestion[];
selectedIndices: string[];
updateEngineError: typeof UpdateEngineApiLogic.values.error | undefined;
updateEngineStatus: typeof UpdateEngineApiLogic.values.status;
}

export const AddIndicesLogic = kea<MakeLogicType<AddIndicesLogicValues, AddIndicesLogicActions>>({
actions: {
setSelectedIndices: (indices: ElasticsearchIndexWithIngestion[]) => ({ indices }),
setSelectedIndices: (indices: string[]) => ({ indices }),
submitSelectedIndices: () => true,
},
connect: {
Expand All @@ -46,7 +44,7 @@ export const AddIndicesLogic = kea<MakeLogicType<AddIndicesLogicValues, AddIndic
const { selectedIndices } = values;
if (selectedIndices.length === 0) return;

actions.addIndicesToEngine(selectedIndices.map(({ name }) => name));
actions.addIndicesToEngine(selectedIndices);
},
}),
path: ['enterprise_search', 'content', 'add_indices_logic'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const EngineApiIntegrationStage: React.FC = () => {
<p>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step3.intro', {
defaultMessage:
'Learn how to integrate with your engine with the language clients maintained by Elastic to help build your search experience.',
'Learn how to integrate with your search application with the language clients maintained by Elastic to help build your search experience.',
})}
</p>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const GenerateEngineApiKeyModal: React.FC<GenerateEngineApiKeyModalProps>
{i18n.translate(
'xpack.enterpriseSearch.content.engine.api.generateEngineApiKeyModal.title',
{
defaultMessage: 'Create Engine read-only API Key',
defaultMessage: 'Create Search application read-only API Key',
}
)}
</EuiModalHeaderTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,32 @@ export const SearchApplicationAPI = () => {

const steps = [
{
title: i18n.translate('xpack.enterpriseSearch.content.engine.api.step1.title', {
title: i18n.translate('xpack.enterpriseSearch.content.searchApplication.api.step1.title', {
defaultMessage: 'Generate and save API key',
}),
children: (
<>
<EuiText>
<p>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step1.apiKeyWarning', {
defaultMessage:
"Elastic does not store API keys. Once generated, you'll only be able to view the key one time. Make sure you save it somewhere secure. If you lose access to it you'll need to generate a new API key from this screen.",
})}{' '}
{i18n.translate(
'xpack.enterpriseSearch.content.searchApplication.api.step1.apiKeyWarning',
{
defaultMessage:
"Elastic does not store API keys. Once generated, you'll only be able to view the key one time. Make sure you save it somewhere secure. If you lose access to it you'll need to generate a new API key from this screen.",
}
)}{' '}
<EuiLink
href={docLinks.apiKeys}
data-telemetry-id="entSearchContent-engines-api-step1-learnMoreLink"
data-telemetry-id="entSearchContent-searchApplications-api-step1-learnMoreLink"
external
target="_blank"
>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step1.learnMoreLink', {
defaultMessage: 'Learn more about API keys.',
})}
{i18n.translate(
'xpack.enterpriseSearch.content.searchApplication.api.step1.learnMoreLink',
{
defaultMessage: 'Learn more about API keys.',
}
)}
</EuiLink>
</p>
</EuiText>
Expand All @@ -73,10 +79,10 @@ export const SearchApplicationAPI = () => {
iconSide="left"
iconType="plusInCircleFilled"
onClick={openGenerateModal}
data-telemetry-id="entSearchContent-engines-api-step1-createApiKeyButton"
data-telemetry-id="entSearchContent-searchApplications-api-step1-createApiKeyButton"
>
{i18n.translate(
'xpack.enterpriseSearch.content.engine.api.step1.createAPIKeyButton',
'xpack.enterpriseSearch.content.searchApplication.api.step1.createAPIKeyButton',
{
defaultMessage: 'Create API Key',
}
Expand All @@ -87,34 +93,37 @@ export const SearchApplicationAPI = () => {
<EuiButton
iconSide="left"
iconType="popout"
data-telemetry-id="entSearchContent-engines-api-step1-viewKeysButton"
data-telemetry-id="entSearchContent-searchApplications-api-step1-viewKeysButton"
onClick={() =>
KibanaLogic.values.navigateToUrl('/app/management/security/api_keys', {
shouldNotCreateHref: true,
})
}
>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step1.viewKeysButton', {
defaultMessage: 'View Keys',
})}
{i18n.translate(
'xpack.enterpriseSearch.content.searchApplication.api.step1.viewKeysButton',
{
defaultMessage: 'View Keys',
}
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</>
),
},
{
title: i18n.translate('xpack.enterpriseSearch.content.engine.api.step2.title', {
defaultMessage: "Copy your engine's endpoint",
title: i18n.translate('xpack.enterpriseSearch.content.searchApplication.api.step2.title', {
defaultMessage: "Copy your search application's endpoint",
}),
children: (
<>
<EuiText>
<p>
{i18n.translate(
'xpack.enterpriseSearch.content.engine.api.step2.copyEndpointDescription',
'xpack.enterpriseSearch.content.searchApplication.api.step2.copyEndpointDescription',
{
defaultMessage: "Use this URL to access your engine's API endpoints.",
defaultMessage: "Use this URL to access your search application's API endpoints.",
}
)}
</p>
Expand All @@ -131,30 +140,30 @@ export const SearchApplicationAPI = () => {
),
},
{
title: i18n.translate('xpack.enterpriseSearch.content.engine.api.step3.title', {
title: i18n.translate('xpack.enterpriseSearch.content.searchApplication.api.step3.title', {
defaultMessage: 'Learn how to call your endpoints',
}),
children: <EngineApiIntegrationStage />,
},
{
title: i18n.translate('xpack.enterpriseSearch.content.engine.api.step4.title', {
title: i18n.translate('xpack.enterpriseSearch.content.searchApplication.api.step4.title', {
defaultMessage: '(Optional) Power up your analytics',
}),
children: (
<>
<EuiText>
<p>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step4.copy', {
{i18n.translate('xpack.enterpriseSearch.content.searchApplication.api.step4.copy', {
defaultMessage:
'Your engine provides basic analytics data as part of this installation. To receive more granular and custom metrics, integrate our Behavioral Analytics script on your platform.',
'Your search application provides basic analytics data as part of this installation. To receive more granular and custom metrics, integrate our Behavioral Analytics script on your platform.',
})}
</p>
</EuiText>
<EuiSpacer size="l" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButton
data-telemetry-id="entSearchContent-engines-api-step4-learnHowLink"
data-telemetry-id="entSearchContent-searchApplications-api-step4-learnHowLink"
onClick={() =>
navigateToUrl(
generateEncodedPath(`${ANALYTICS_PLUGIN.URL}${COLLECTION_INTEGRATE_PATH}`, {
Expand All @@ -166,9 +175,12 @@ export const SearchApplicationAPI = () => {
iconSide="left"
iconType="popout"
>
{i18n.translate('xpack.enterpriseSearch.content.engine.api.step4.learnHowLink', {
defaultMessage: 'Learn how',
})}
{i18n.translate(
'xpack.enterpriseSearch.content.searchApplication.api.step4.learnHowLink',
{
defaultMessage: 'Learn how',
}
)}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('EngineError', () => {

const notFound = wrapper.find(NotFoundPrompt);
expect(notFound.prop('backToLink')).toEqual('/engines');
expect(notFound.prop('backToContent')).toEqual('Back to Engines');
expect(notFound.prop('backToContent')).toEqual('Back to Search Applications');

const telemetry = wrapper.find(SendEnterpriseSearchTelemetry);
expect(telemetry.prop('action')).toEqual('error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export const EngineError: React.FC<{ error?: HttpError; notFound?: boolean }> =
<>
<SendEnterpriseSearchTelemetry action="error" metric="not_found" />
<NotFoundPrompt
backToContent={i18n.translate('xpack.enterpriseSearch.engines.engine.notFound.action1', {
defaultMessage: 'Back to Engines',
})}
backToContent={i18n.translate(
'xpack.enterpriseSearch.searchApplications.engine.notFound.action1',
{
defaultMessage: 'Back to Search Applications',
}
)}
backToLink={ENGINES_PATH}
productSupportUrl={ENTERPRISE_SEARCH_CONTENT_PLUGIN.SUPPORT_URL}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const EngineIndices: React.FC = () => {
description: i18n.translate(
'xpack.enterpriseSearch.content.engine.indices.actions.removeIndex.title',
{
defaultMessage: 'Remove this index from engine',
defaultMessage: 'Remove this index from search application',
}
),
icon: 'minusInCircle',
Expand Down Expand Up @@ -215,7 +215,7 @@ export const EngineIndices: React.FC = () => {
'xpack.enterpriseSearch.content.engine.indices.unknownIndicesCallout.description',
{
defaultMessage:
'Some data might be unreachable from this engine. Check for any pending operations or errors on affected indices, or remove those that should no longer be used by this engine.',
'Some data might be unreachable from this search application. Check for any pending operations or errors on affected indices, or remove those that should no longer be used by this search application.',
}
)}
</p>
Expand Down Expand Up @@ -259,7 +259,7 @@ export const EngineIndices: React.FC = () => {
}}
title={i18n.translate(
'xpack.enterpriseSearch.content.engine.indices.removeIndexConfirm.title',
{ defaultMessage: 'Remove this index from the engine' }
{ defaultMessage: 'Remove this index from the Search Application' }
)}
buttonColor="danger"
cancelButtonText={CANCEL_BUTTON_LABEL}
Expand All @@ -278,7 +278,7 @@ export const EngineIndices: React.FC = () => {
'xpack.enterpriseSearch.content.engine.indices.removeIndexConfirm.description',
{
defaultMessage:
"This won't delete the index. You may add it back to this engine at a later time.",
"This won't delete the index. You may add it back to this search application at a later time.",
}
)}
</p>
Expand Down
Loading

0 comments on commit d32c867

Please sign in to comment.