diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx
index fb0ea822206400..28169afd4bdebc 100644
--- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.test.tsx
@@ -88,7 +88,7 @@ describe('WorkplaceSearchConfigured', () => {
const wrapper = shallow();
- expect(wrapper.find(ErrorState)).toHaveLength(2);
+ expect(wrapper.find(ErrorState)).toHaveLength(1);
});
it('passes readOnlyMode state', () => {
diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx
index dd263c3bd69f5d..6961f45bae757a 100644
--- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/index.tsx
@@ -96,13 +96,7 @@ export const WorkplaceSearchConfigured: React.FC = (props) => {
- {errorConnecting ? (
-
- ) : (
- } restrictWidth readOnlyMode={readOnlyMode}>
-
-
- )}
+
= (props) => {
- } restrictWidth readOnlyMode={readOnlyMode}>
-
-
+
{
- describe('non-happy-path states', () => {
- it('isLoading', () => {
- const wrapper = shallow();
+ it('calls initialize function', async () => {
+ shallow();
- expect(wrapper.find(Loading)).toHaveLength(1);
- });
+ expect(mockActions.initializeOverview).toHaveBeenCalled();
});
- describe('happy-path states', () => {
- it('calls initialize function', async () => {
- mount();
-
- expect(mockActions.initializeOverview).toHaveBeenCalled();
- });
+ it('renders onboarding state', () => {
+ setMockValues({ dataLoading: false });
+ const wrapper = shallow();
- it('renders onboarding state', () => {
- setMockValues({ dataLoading: false });
- const wrapper = shallow();
+ expect(wrapper.find(OnboardingSteps)).toHaveLength(1);
+ expect(wrapper.find(OrganizationStats)).toHaveLength(1);
+ expect(wrapper.find(RecentActivity)).toHaveLength(1);
+ });
- expect(wrapper.find(ViewContentHeader)).toHaveLength(1);
- expect(wrapper.find(OnboardingSteps)).toHaveLength(1);
- expect(wrapper.find(OrganizationStats)).toHaveLength(1);
- expect(wrapper.find(RecentActivity)).toHaveLength(1);
+ it('renders when onboarding complete', () => {
+ setMockValues({
+ dataLoading: false,
+ hasUsers: true,
+ hasOrgSources: true,
+ isOldAccount: true,
+ organization: {
+ name: 'foo',
+ defaultOrgName: 'bar',
+ },
});
+ const wrapper = shallow();
- it('renders when onboarding complete', () => {
- setMockValues({
- dataLoading: false,
- hasUsers: true,
- hasOrgSources: true,
- isOldAccount: true,
- organization: {
- name: 'foo',
- defaultOrgName: 'bar',
- },
- });
- const wrapper = shallow();
-
- expect(wrapper.find(OnboardingSteps)).toHaveLength(0);
- });
+ expect(wrapper.find(OnboardingSteps)).toHaveLength(0);
});
});
diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx
index 9242bd8b6fbddf..0049c5b732d3d0 100644
--- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/overview/overview.tsx
@@ -12,11 +12,8 @@ import { useActions, useValues } from 'kea';
import { EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
-import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
-import { Loading } from '../../../shared/loading';
-import { SendWorkplaceSearchTelemetry as SendTelemetry } from '../../../shared/telemetry';
import { AppLogic } from '../../app_logic';
-import { ViewContentHeader } from '../../components/shared/view_content_header';
+import { WorkplaceSearchPageTemplate } from '../../components/layout';
import { OnboardingSteps } from './onboarding_steps';
import { OrganizationStats } from './organization_stats';
@@ -54,26 +51,31 @@ export const Overview: React.FC = () => {
initializeOverview();
}, [initializeOverview]);
- if (dataLoading) {
- return ;
- }
-
const hideOnboarding = hasUsers && hasOrgSources && isOldAccount && orgName !== defaultOrgName;
- const headerTitle = hideOnboarding ? HEADER_TITLE : ONBOARDING_HEADER_TITLE;
- const headerDescription = hideOnboarding ? HEADER_DESCRIPTION : ONBOARDING_HEADER_DESCRIPTION;
+ const headerTitle = dataLoading || hideOnboarding ? HEADER_TITLE : ONBOARDING_HEADER_TITLE;
+ const headerDescription =
+ dataLoading || hideOnboarding ? HEADER_DESCRIPTION : ONBOARDING_HEADER_DESCRIPTION;
return (
- <>
-
-
-
-
- {!hideOnboarding && }
-
+
+ {!hideOnboarding && (
+ <>
+
+
+ >
+ )}
- >
+
);
};
diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx
index c9720eb6c1c042..2871299df0cd02 100644
--- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.test.tsx
@@ -14,11 +14,8 @@ import { shallow } from 'enzyme';
import { EuiSwitch, EuiConfirmModal } from '@elastic/eui';
-import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
-
-import { Loading } from '../../../shared/loading';
import { UnsavedChangesPrompt } from '../../../shared/unsaved_changes_prompt';
-import { ViewContentHeader } from '../../components/shared/view_content_header';
+import { getPageHeaderActions } from '../../../test_helpers';
import { Security } from './security';
@@ -59,9 +56,7 @@ describe('Security', () => {
setMockValues({ ...mockValues, hasPlatinumLicense: false });
const wrapper = shallow();
- expect(wrapper.find(SetPageChrome)).toHaveLength(1);
expect(wrapper.find(UnsavedChangesPrompt)).toHaveLength(1);
- expect(wrapper.find(ViewContentHeader)).toHaveLength(1);
expect(wrapper.find(EuiSwitch).prop('disabled')).toEqual(true);
});
@@ -71,13 +66,6 @@ describe('Security', () => {
expect(wrapper.find(EuiSwitch).prop('disabled')).toEqual(false);
});
- it('returns Loading when loading', () => {
- setMockValues({ ...mockValues, dataLoading: true });
- const wrapper = shallow();
-
- expect(wrapper.find(Loading)).toHaveLength(1);
- });
-
it('handles switch click', () => {
const wrapper = shallow();
@@ -92,8 +80,8 @@ describe('Security', () => {
setMockValues({ ...mockValues, unsavedChanges: true });
const wrapper = shallow();
- const header = wrapper.find(ViewContentHeader).dive();
- header.find('[data-test-subj="SaveSettingsButton"]').prop('onClick')!({} as any);
+ const headerActions = getPageHeaderActions(wrapper);
+ headerActions.find('[data-test-subj="SaveSettingsButton"]').prop('onClick')!({} as any);
const modal = wrapper.find(EuiConfirmModal);
modal.prop('onConfirm')!({} as any);
diff --git a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.tsx b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.tsx
index b746344b3806bb..6cf1831dc07e7e 100644
--- a/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/workplace_search/views/security/security.tsx
@@ -22,13 +22,10 @@ import {
EuiConfirmModal,
} from '@elastic/eui';
-import { FlashMessages } from '../../../shared/flash_messages';
-import { SetWorkplaceSearchChrome as SetPageChrome } from '../../../shared/kibana_chrome';
import { LicensingLogic } from '../../../shared/licensing';
-import { Loading } from '../../../shared/loading';
import { UnsavedChangesPrompt } from '../../../shared/unsaved_changes_prompt';
+import { WorkplaceSearchPageTemplate } from '../../components/layout';
import { LicenseCallout } from '../../components/shared/license_callout';
-import { ViewContentHeader } from '../../components/shared/view_content_header';
import {
SECURITY_UNSAVED_CHANGES_MESSAGE,
RESET_BUTTON,
@@ -72,44 +69,24 @@ export const Security: React.FC = () => {
initializeSourceRestrictions();
}, []);
- if (dataLoading) return ;
-
const savePrivateSources = () => {
saveSourceRestrictions();
hideConfirmModal();
};
- const headerActions = (
-
-
-
- {RESET_BUTTON}
-
-
-
-
- {SAVE_SETTINGS_BUTTON}
-
-
-
- );
-
- const header = (
- <>
-
-
- >
- );
+ const headerActions = [
+
+ {RESET_BUTTON}
+ ,
+
+ {SAVE_SETTINGS_BUTTON}
+ ,
+ ];
const allSourcesToggle = (
{
);
return (
- <>
-
-
+
- {header}
{allSourcesToggle}
{!hasPlatinumLicense && platinumLicenseCallout}
{sourceTables}
{confirmModalVisible && confirmModal}
- >
+
);
};