diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx
index 91a21847107a95..04e252e44270bf 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.tsx
@@ -114,6 +114,16 @@ export const EngineRouter: React.FC = () => {
)}
+ {canManageEngineRelevanceTuning && (
+
+
+
+ )}
+ {canManageEngineResultSettings && (
+
+
+
+ )}
{canManageEngineSearchUi && (
@@ -131,21 +141,11 @@ export const EngineRouter: React.FC = () => {
)}
- {canManageEngineRelevanceTuning && (
-
-
-
- )}
{canManageEngineSynonyms && (
)}
- {canManageEngineResultSettings && (
-
-
-
- )}
{canViewMetaEngineSourceEngines && (
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/components/empty_state.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/components/empty_state.tsx
index e6a14d7b5cd725..df29010bd682ff 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/components/empty_state.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/components/empty_state.tsx
@@ -7,42 +7,40 @@
import React from 'react';
-import { EuiButton, EuiEmptyPrompt, EuiPanel } from '@elastic/eui';
+import { EuiButton, EuiEmptyPrompt } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { DOCS_PREFIX } from '../../../routes';
export const EmptyState: React.FC = () => (
-
-
- {i18n.translate('xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.title', {
- defaultMessage: 'Add documents to tune relevance',
- })}
-
+
+ {i18n.translate('xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.title', {
+ defaultMessage: 'Add documents to tune relevance',
+ })}
+
+ }
+ body={i18n.translate(
+ 'xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.description',
+ {
+ defaultMessage:
+ 'A schema will be automatically created for you after you index some documents.',
}
- body={i18n.translate(
- 'xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.description',
- {
- defaultMessage:
- 'A schema will be automatically created for you after you index some documents.',
- }
- )}
- actions={
-
- {i18n.translate(
- 'xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.buttonLabel',
- { defaultMessage: 'Read the relevance tuning guide' }
- )}
-
- }
- />
-
+ )}
+ actions={
+
+ {i18n.translate(
+ 'xpack.enterpriseSearch.appSearch.engine.relevanceTuning.empty.buttonLabel',
+ { defaultMessage: 'Read the relevance tuning guide' }
+ )}
+
+ }
+ />
);
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx
index 092740ac5d3cc6..48b536a954ed59 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.test.tsx
@@ -13,14 +13,14 @@ import React from 'react';
import { shallow } from 'enzyme';
-import { EuiEmptyPrompt } from '@elastic/eui';
-
-import { Loading } from '../../../shared/loading';
import { UnsavedChangesPrompt } from '../../../shared/unsaved_changes_prompt';
+import { getPageHeaderActions } from '../../../test_helpers';
-import { EmptyState } from './components';
import { RelevanceTuning } from './relevance_tuning';
+
+import { RelevanceTuningCallouts } from './relevance_tuning_callouts';
import { RelevanceTuningForm } from './relevance_tuning_form';
+import { RelevanceTuningPreview } from './relevance_tuning_preview';
describe('RelevanceTuning', () => {
const values = {
@@ -50,9 +50,9 @@ describe('RelevanceTuning', () => {
it('renders', () => {
const wrapper = subject();
+ expect(wrapper.find(RelevanceTuningCallouts).exists()).toBe(true);
expect(wrapper.find(RelevanceTuningForm).exists()).toBe(true);
- expect(wrapper.find(Loading).exists()).toBe(false);
- expect(wrapper.find(EmptyState).exists()).toBe(false);
+ expect(wrapper.find(RelevanceTuningPreview).exists()).toBe(true);
});
it('initializes relevance tuning data', () => {
@@ -60,33 +60,38 @@ describe('RelevanceTuning', () => {
expect(actions.initializeRelevanceTuning).toHaveBeenCalled();
});
- it('will render an empty message when the engine has no schema', () => {
+ it('will prevent user from leaving the page if there are unsaved changes', () => {
setMockValues({
...values,
- engineHasSchemaFields: false,
+ unsavedChanges: true,
});
- const wrapper = subject();
- expect(wrapper.find(EmptyState).dive().find(EuiEmptyPrompt).exists()).toBe(true);
- expect(wrapper.find(Loading).exists()).toBe(false);
- expect(wrapper.find(RelevanceTuningForm).exists()).toBe(false);
+ expect(subject().find(UnsavedChangesPrompt).prop('hasUnsavedChanges')).toBe(true);
});
- it('will show a loading message if data is loading', () => {
- setMockValues({
- ...values,
- dataLoading: true,
+ describe('header actions', () => {
+ it('renders a Save button that will save the current changes', () => {
+ const buttons = getPageHeaderActions(subject());
+ expect(buttons.children().length).toBe(2);
+ const saveButton = buttons.find('[data-test-subj="SaveRelevanceTuning"]');
+ saveButton.simulate('click');
+ expect(actions.updateSearchSettings).toHaveBeenCalled();
});
- const wrapper = subject();
- expect(wrapper.find(Loading).exists()).toBe(true);
- expect(wrapper.find(EmptyState).exists()).toBe(false);
- expect(wrapper.find(RelevanceTuningForm).exists()).toBe(false);
- });
- it('will prevent user from leaving the page if there are unsaved changes', () => {
- setMockValues({
- ...values,
- unsavedChanges: true,
+ it('renders a Reset button that will remove all weights and boosts', () => {
+ const buttons = getPageHeaderActions(subject());
+ expect(buttons.children().length).toBe(2);
+ const resetButton = buttons.find('[data-test-subj="ResetRelevanceTuning"]');
+ resetButton.simulate('click');
+ expect(actions.resetSearchSettings).toHaveBeenCalled();
+ });
+
+ it('will not render buttons if the engine has no schema', () => {
+ setMockValues({
+ ...values,
+ engineHasSchemaFields: false,
+ });
+ const buttons = getPageHeaderActions(subject());
+ expect(buttons.children().length).toBe(0);
});
- expect(subject().find(UnsavedChangesPrompt).prop('hasUnsavedChanges')).toBe(true);
});
});
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.tsx
index b98541a9638901..2e87d6836199bd 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning.tsx
@@ -9,43 +9,77 @@ import React, { useEffect } from 'react';
import { useActions, useValues } from 'kea';
-import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
+import { EuiFlexGroup, EuiFlexItem, EuiButton } from '@elastic/eui';
+import { i18n } from '@kbn/i18n';
-import { Loading } from '../../../shared/loading';
+import { SAVE_BUTTON_LABEL } from '../../../shared/constants';
import { UnsavedChangesPrompt } from '../../../shared/unsaved_changes_prompt';
+import { RESTORE_DEFAULTS_BUTTON_LABEL } from '../../constants';
+import { getEngineBreadcrumbs } from '../engine';
+import { AppSearchPageTemplate } from '../layout';
import { EmptyState } from './components';
+import { RELEVANCE_TUNING_TITLE } from './constants';
+import { RelevanceTuningCallouts } from './relevance_tuning_callouts';
import { RelevanceTuningForm } from './relevance_tuning_form';
-import { RelevanceTuningLayout } from './relevance_tuning_layout';
import { RelevanceTuningPreview } from './relevance_tuning_preview';
import { RelevanceTuningLogic } from '.';
export const RelevanceTuning: React.FC = () => {
const { dataLoading, engineHasSchemaFields, unsavedChanges } = useValues(RelevanceTuningLogic);
- const { initializeRelevanceTuning } = useActions(RelevanceTuningLogic);
+ const { initializeRelevanceTuning, resetSearchSettings, updateSearchSettings } = useActions(
+ RelevanceTuningLogic
+ );
useEffect(() => {
initializeRelevanceTuning();
}, []);
- if (dataLoading) return ;
-
return (
-
+
+ {SAVE_BUTTON_LABEL}
+ ,
+
+ {RESTORE_DEFAULTS_BUTTON_LABEL}
+ ,
+ ]
+ : [],
+ }}
+ isLoading={dataLoading}
+ isEmptyState={!engineHasSchemaFields}
+ emptyState={}
+ >
- {engineHasSchemaFields ? (
-
-
-
-
-
-
-
-
- ) : (
-
- )}
-
+
+
+
+
+
+
+
+
+
+
+
);
};
diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.tsx
index 5cbd291f85debf..c35cd280c7a058 100644
--- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/relevance_tuning/relevance_tuning_form/relevance_tuning_form.tsx
@@ -42,7 +42,7 @@ export const RelevanceTuningForm: React.FC = () => {
return (