From 0e7daa360295863ed3288e4bd0c5f0907bd4b6fc Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 23 Apr 2021 11:04:49 -0700 Subject: [PATCH 1/4] Hide layout/nav --- .../applications/app_search/index.test.tsx | 2 +- .../public/applications/app_search/index.tsx | 74 ++++++++++--------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx index 62a0ccc01f29a..6cc21c6bb4a9f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/index.test.tsx @@ -64,7 +64,7 @@ describe('AppSearchConfigured', () => { }); it('renders with layout', () => { - expect(wrapper.find(Layout)).toHaveLength(2); + expect(wrapper.find(Layout)).toHaveLength(1); expect(wrapper.find(Layout).last().prop('readOnlyMode')).toBeFalsy(); expect(wrapper.find(EnginesOverview)).toHaveLength(1); expect(wrapper.find(EngineRouter)).toHaveLength(1); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/index.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/index.tsx index 3a46a90d20d66..549eeeead1c8b 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/index.tsx @@ -10,6 +10,8 @@ import { Route, Redirect, Switch } from 'react-router-dom'; import { useValues } from 'kea'; +import { EuiPage, EuiPageBody } from '@elastic/eui'; + import { APP_SEARCH_PLUGIN } from '../../../common/constants'; import { InitialAppData } from '../../../common/types'; import { HttpLogic } from '../shared/http'; @@ -85,44 +87,46 @@ export const AppSearchConfigured: React.FC> = (props) = - } readOnlyMode={readOnlyMode}> - {errorConnecting ? ( - - ) : ( - - - - - - - - - - - - - - {canViewRoleMappings && ( - - + + + {errorConnecting ? ( + + ) : ( + + + - )} - {canManageEngines && ( - - + + - )} - {canManageMetaEngines && ( - - + + - )} - - - - - )} - + + + + {canViewRoleMappings && ( + + + + )} + {canManageEngines && ( + + + + )} + {canManageMetaEngines && ( + + + + )} + + + + + )} + + ); From 0ddfe9143fafa8ee03ccc4cd1d140b0aa2b4f062 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 23 Apr 2021 11:24:51 -0700 Subject: [PATCH 2/4] Remove create engine buttons --- .../engines/engines_overview.test.tsx | 53 ------------------- .../components/engines/engines_overview.tsx | 45 ---------------- 2 files changed, 98 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx index c47b169ede364..438d3415f5446 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.test.tsx @@ -12,8 +12,6 @@ import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; -import { EuiEmptyPrompt } from '@elastic/eui'; - import { LoadingState, EmptyState } from './components'; import { EnginesTable } from './components/tables/engines_table'; import { MetaEnginesTable } from './components/tables/meta_engines_table'; @@ -42,8 +40,6 @@ describe('EnginesOverview', () => { }, metaEnginesLoading: false, hasPlatinumLicense: false, - // AppLogic - myRole: { canManageEngines: false }, // MetaEnginesTableLogic expandedSourceEngines: {}, conflictingEnginesSets: {}, @@ -103,20 +99,6 @@ describe('EnginesOverview', () => { expect(actions.loadEngines).toHaveBeenCalled(); }); - describe('when the user can manage/create engines', () => { - it('renders a create engine button which takes users to the create engine page', () => { - setMockValues({ - ...valuesWithEngines, - myRole: { canManageEngines: true }, - }); - const wrapper = shallow(); - - expect( - wrapper.find('[data-test-subj="appSearchEnginesEngineCreationButton"]').prop('to') - ).toEqual('/engine_creation'); - }); - }); - describe('when the account has a platinum license', () => { it('renders a 2nd meta engines table & makes a 2nd meta engines call', () => { setMockValues({ @@ -128,41 +110,6 @@ describe('EnginesOverview', () => { expect(wrapper.find(MetaEnginesTable)).toHaveLength(1); expect(actions.loadMetaEngines).toHaveBeenCalled(); }); - - describe('when the user can manage/create engines', () => { - it('renders a create engine button which takes users to the create meta engine page', () => { - setMockValues({ - ...valuesWithEngines, - hasPlatinumLicense: true, - myRole: { canManageEngines: true }, - }); - const wrapper = shallow(); - - expect( - wrapper.find('[data-test-subj="appSearchEnginesMetaEngineCreationButton"]').prop('to') - ).toEqual('/meta_engine_creation'); - }); - - describe('when metaEngines is empty', () => { - it('contains an EuiEmptyPrompt that takes users to the create meta engine page', () => { - setMockValues({ - ...valuesWithEngines, - hasPlatinumLicense: true, - myRole: { canManageEngines: true }, - metaEngines: [], - }); - const wrapper = shallow(); - const metaEnginesTable = wrapper.find(MetaEnginesTable).dive(); - const emptyPrompt = metaEnginesTable.dive().find(EuiEmptyPrompt).dive(); - - expect( - emptyPrompt - .find('[data-test-subj="appSearchMetaEnginesEmptyStateCreationButton"]') - .prop('to') - ).toEqual('/meta_engine_creation'); - }); - }); - }); }); describe('pagination', () => { diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.tsx index 4e17278d25d1a..69c7dcaa6e691 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/engines_overview.tsx @@ -21,19 +21,14 @@ import { import { FlashMessages } from '../../../shared/flash_messages'; import { LicensingLogic } from '../../../shared/licensing'; -import { EuiButtonTo } from '../../../shared/react_router_helpers'; import { convertMetaToPagination, handlePageChange } from '../../../shared/table_pagination'; import { SendAppSearchTelemetry as SendTelemetry } from '../../../shared/telemetry'; -import { AppLogic } from '../../app_logic'; import { EngineIcon, MetaEngineIcon } from '../../icons'; -import { ENGINE_CREATION_PATH, META_ENGINE_CREATION_PATH } from '../../routes'; import { EnginesOverviewHeader, LoadingState, EmptyState } from './components'; import { EnginesTable } from './components/tables/engines_table'; import { MetaEnginesTable } from './components/tables/meta_engines_table'; import { - CREATE_AN_ENGINE_BUTTON_LABEL, - CREATE_A_META_ENGINE_BUTTON_LABEL, ENGINES_TITLE, META_ENGINE_EMPTY_PROMPT_DESCRIPTION, META_ENGINE_EMPTY_PROMPT_TITLE, @@ -45,9 +40,6 @@ import './engines_overview.scss'; export const EnginesOverview: React.FC = () => { const { hasPlatinumLicense } = useValues(LicensingLogic); - const { - myRole: { canManageEngines }, - } = useValues(AppLogic); const { dataLoading, @@ -89,19 +81,6 @@ export const EnginesOverview: React.FC = () => { - - {canManageEngines && ( - - {CREATE_AN_ENGINE_BUTTON_LABEL} - - )} - @@ -127,19 +106,6 @@ export const EnginesOverview: React.FC = () => { - - {canManageEngines && ( - - {CREATE_A_META_ENGINE_BUTTON_LABEL} - - )} - { {META_ENGINE_EMPTY_PROMPT_TITLE}} body={

{META_ENGINE_EMPTY_PROMPT_DESCRIPTION}

} - actions={ - canManageEngines && ( - - {CREATE_A_META_ENGINE_BUTTON_LABEL} - - ) - } /> } onChange={handlePageChange(onMetaEnginesPagination)} From 00c9cf2493f570de0ff9eeca3d538436688b9136 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 23 Apr 2021 11:29:32 -0700 Subject: [PATCH 3/4] Switch table links back to external --- .../tables/engine_link_helpers.test.tsx | 11 +++++++---- .../components/tables/engine_link_helpers.tsx | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx index 5d91c724068e7..32ea74cc5ca52 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.test.tsx @@ -6,12 +6,13 @@ */ import { mockKibanaValues, mockTelemetryActions } from '../../../../../__mocks__'; +import '../../../../../__mocks__/enterprise_search_url.mock'; import React from 'react'; import { shallow } from 'enzyme'; -import { EuiLinkTo } from '../../../../../shared/react_router_helpers'; +import { EuiLink } from '@elastic/eui'; import { navigateToEngine, renderEngineLink } from './engine_link_helpers'; @@ -21,7 +22,9 @@ describe('navigateToEngine', () => { it('sends the user to the engine page and triggers a telemetry event', () => { navigateToEngine('engine-a'); - expect(navigateToUrl).toHaveBeenCalledWith('/engines/engine-a'); + expect(navigateToUrl).toHaveBeenCalledWith('http://localhost:3002/as/engines/engine-a', { + shouldNotCreateHref: true, + }); expect(sendAppSearchTelemetry).toHaveBeenCalledWith({ action: 'clicked', metric: 'engine_table_link', @@ -34,9 +37,9 @@ describe('renderEngineLink', () => { it('renders a link to the engine with telemetry', () => { const wrapper = shallow(
{renderEngineLink('engine-b')}
); - const link = wrapper.find(EuiLinkTo); + const link = wrapper.find(EuiLink); - expect(link.prop('to')).toEqual('/engines/engine-b'); + expect(link.prop('href')).toEqual('http://localhost:3002/as/engines/engine-b'); link.simulate('click'); expect(sendAppSearchTelemetry).toHaveBeenCalledWith({ diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.tsx index a3350d1ef9939..f31e0e8981b08 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/tables/engine_link_helpers.tsx @@ -7,8 +7,10 @@ import React from 'react'; +import { EuiLink } from '@elastic/eui'; + +import { getAppSearchUrl } from '../../../../../shared/enterprise_search_url'; import { KibanaLogic } from '../../../../../shared/kibana'; -import { EuiLinkTo } from '../../../../../shared/react_router_helpers'; import { TelemetryLogic } from '../../../../../shared/telemetry'; import { ENGINE_PATH } from '../../../../routes'; import { generateEncodedPath } from '../../../../utils/encode_path_params'; @@ -22,15 +24,20 @@ const sendEngineTableLinkClickTelemetry = () => { export const navigateToEngine = (engineName: string) => { sendEngineTableLinkClickTelemetry(); - KibanaLogic.values.navigateToUrl(generateEncodedPath(ENGINE_PATH, { engineName })); + KibanaLogic.values.navigateToUrl( + getAppSearchUrl(generateEncodedPath(ENGINE_PATH, { engineName })), + { shouldNotCreateHref: true } + ); }; export const renderEngineLink = (engineName: string) => ( - {engineName} - + ); From df9ad364c755be4861002104a65b1d16c39a939a Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Fri, 23 Apr 2021 12:59:26 -0700 Subject: [PATCH 4/4] Switch empty engines CTA to external link/remove sample engine CTA --- .../engines/components/empty_state.test.tsx | 10 ++-------- .../engines/components/empty_state.tsx | 17 ++++++++--------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx index 222041c9f85a3..3fdf6816d623e 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import '../../../../__mocks__/kea.mock'; +import '../../../../__mocks__/enterprise_search_url.mock'; import { setMockValues, mockTelemetryActions } from '../../../../__mocks__'; import React from 'react'; @@ -14,8 +14,6 @@ import { shallow, ShallowWrapper } from 'enzyme'; import { EuiEmptyPrompt } from '@elastic/eui'; -import { SampleEngineCreationCta } from '../../sample_engine_creation_cta'; - import { EmptyState } from './'; describe('EmptyState', () => { @@ -37,10 +35,6 @@ describe('EmptyState', () => { expect(wrapper.find('[data-test-subj="AdminEmptyEnginesPrompt"]')).toHaveLength(1); }); - it('contains a sample engine CTA', () => { - expect(prompt.find(SampleEngineCreationCta)).toHaveLength(1); - }); - describe('create engine button', () => { let button: ShallowWrapper; @@ -54,7 +48,7 @@ describe('EmptyState', () => { }); it('sends a user to engine creation', () => { - expect(button.prop('to')).toEqual('/engine_creation'); + expect(button.prop('href')).toEqual('http://localhost:3002/as/engines/new'); }); }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.tsx index 6911015e39d4a..1ef051437c4cb 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engines/components/empty_state.tsx @@ -9,15 +9,12 @@ import React from 'react'; import { useValues, useActions } from 'kea'; -import { EuiPageContent, EuiEmptyPrompt, EuiSpacer } from '@elastic/eui'; +import { EuiPageContent, EuiEmptyPrompt, EuiSpacer, EuiButton } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { EuiButtonTo } from '../../../../shared/react_router_helpers'; +import { getAppSearchUrl } from '../../../../shared/enterprise_search_url'; import { TelemetryLogic } from '../../../../shared/telemetry'; import { AppLogic } from '../../../app_logic'; -import { ENGINE_CREATION_PATH } from '../../../routes'; - -import { SampleEngineCreationCta } from '../../sample_engine_creation_cta/sample_engine_creation_cta'; import { EnginesOverviewHeader } from './header'; @@ -56,10 +53,13 @@ export const EmptyState: React.FC = () => { } actions={ <> - sendAppSearchTelemetry({ action: 'clicked', @@ -71,9 +71,8 @@ export const EmptyState: React.FC = () => { 'xpack.enterpriseSearch.appSearch.emptyState.createFirstEngineCta', { defaultMessage: 'Create an engine' } )} - + - } />