From 1616f078215f6efbc32b7d09d3adaa00abec31e1 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Wed, 16 Jun 2021 20:56:13 -0700 Subject: [PATCH] Convert Security page to new page template + misc ux enhancement disabling header actions while data is still loading --- .../applications/workplace_search/index.tsx | 4 +- .../views/security/security.test.tsx | 18 +---- .../views/security/security.tsx | 66 +++++++------------ 3 files changed, 28 insertions(+), 60 deletions(-) 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 5c2c5f7b94a6c6..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 @@ -138,9 +138,7 @@ export const WorkplaceSearchConfigured: React.FC = (props) => { - } restrictWidth readOnlyMode={readOnlyMode}> - - + { 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} - + ); };