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 1c2b8b7d4e83d..ef2f48dbe6c20 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 @@ -39,7 +39,10 @@ export const EmptyState: React.FC = () => { return ( <> {showDeprecationCallout ? ( - + ) : ( <>> )} diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/deprecation_callout/deprecation_callout.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/deprecation_callout/deprecation_callout.tsx index b9d1157843df1..0c8ba65291ecf 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/deprecation_callout/deprecation_callout.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/deprecation_callout/deprecation_callout.tsx @@ -15,85 +15,100 @@ import { docLinks } from '../doc_links'; interface DeprecationCalloutProps { onDismissAction: () => void; + restrictWidth?: boolean; } export const EnterpriseSearchDeprecationCallout: React.FC = ({ onDismissAction, + restrictWidth = false, }) => { + const maxWidth = restrictWidth ? '75%' : '100%'; + const cssStyles = { + maxWidth, + marginLeft: 'auto', + marginRight: 'auto', + marginTop: '16px', + marginBottom: '16px', + }; return ( - - - - + + + + + {i18n.translate( + 'xpack.enterpriseSearch.deprecationCallout.viewWorkplaceSearchBlog', + { + defaultMessage: 'blog post', + } + )} + + ), + appSearchBlogUrl: ( + + {i18n.translate('xpack.enterpriseSearch.deprecationCallout.viewAppSearchBlog', { + defaultMessage: 'blog post', + })} + + ), + }} + /> + + + + - {i18n.translate('xpack.enterpriseSearch.deprecationCallout.viewWorkplaceSearchBlog', { - defaultMessage: 'blog post', - })} - - ), - appSearchBlogUrl: ( + Learn more + + + - {i18n.translate('xpack.enterpriseSearch.deprecationCallout.viewAppSearchBlog', { - defaultMessage: 'blog post', + {i18n.translate('xpack.enterpriseSearch.deprecationCallout.dismissLink', { + defaultMessage: 'Dismiss', })} - ), - }} - /> - - - - - Learn more - - - - - {i18n.translate('xpack.enterpriseSearch.deprecationCallout.dissmissLink', { - defaultMessage: 'Dismiss', - })} - - - - + + + + ); }; diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.test.tsx index cde080aa70fbd..f293f092ff0f5 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.test.tsx @@ -11,9 +11,10 @@ import { setMockValues } from '../../__mocks__/kea_logic'; import React from 'react'; -import { shallow } from 'enzyme'; +import { mount, shallow } from 'enzyme'; import { EuiButton, EuiLink, EuiEmptyPrompt } from '@elastic/eui'; +import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { RolesEmptyPrompt } from './roles_empty_prompt'; @@ -74,4 +75,37 @@ describe('RolesEmptyPrompt', () => { expect(onEnable).toHaveBeenCalled(); }); + + describe('deprecation callout', () => { + it('renders the deprecation callout when user can manage engines', () => { + const wrapper = shallow(); + expect(wrapper.find('EnterpriseSearchDeprecationCallout')).toHaveLength(1); + }); + + it('renders the deprecation callout when user cannot manage engines', () => { + const wrapper = shallow(); + expect(wrapper.find('EnterpriseSearchDeprecationCallout')).toHaveLength(1); + }); + + it('dismisses the deprecation callout', () => { + const wrapper = mount( + + + + ); + + sessionStorage.setItem('appSearchHideDeprecationCallout', 'false'); + expect(wrapper.find('EnterpriseSearchDeprecationCallout')).toHaveLength(1); + + wrapper.find('button[data-test-subj="euiDismissCalloutButton"]').simulate('click'); + expect(wrapper.find('EnterpriseSearchDeprecationCallout')).toHaveLength(0); + expect(sessionStorage.getItem('appSearchHideDeprecationCallout')).toEqual('true'); + }); + + it('does not render the deprecation callout if dismissed', () => { + sessionStorage.setItem('appSearchHideDeprecationCallout', 'true'); + const wrapper = shallow(); + expect(wrapper.find('EnterpriseSearchDeprecationCallout')).toHaveLength(0); + }); + }); }); diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.tsx index 8b3b6ad4d6975..4a9e969916d2f 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/role_mapping/roles_empty_prompt.tsx @@ -11,6 +11,7 @@ import { useValues } from 'kea'; import { EuiEmptyPrompt, EuiButton, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; +import { EnterpriseSearchDeprecationCallout } from '../deprecation_callout/deprecation_callout'; import { KibanaLogic } from '../kibana/kibana_logic'; import { ProductName } from '../types'; @@ -38,42 +39,61 @@ export const RolesEmptyPrompt: React.FC = ({ onEnable, docsLink, productN ); + const [showDeprecationCallout, setShowDeprecationCallout] = React.useState( + !sessionStorage.getItem('appSearchHideDeprecationCallout') + ); + + const onDismissDeprecationCallout = () => { + setShowDeprecationCallout(false); + sessionStorage.setItem('appSearchHideDeprecationCallout', 'true'); + }; + if (!currentUser) { return null; } return ( - {ROLES_DISABLED_TITLE}} - body={ - <> - {ROLES_DISABLED_DESCRIPTION(productName)} - {ROLES_DISABLED_NOTE} - > - } - actions={[ - - {ENABLE_ROLES_BUTTON} - , - rbacDisabledLabel, - , - - {ENABLE_ROLES_LINK} - , - ]} - /> + <> + {showDeprecationCallout ? ( + + ) : ( + <>> + )} + {ROLES_DISABLED_TITLE}} + body={ + <> + {ROLES_DISABLED_DESCRIPTION(productName)} + {ROLES_DISABLED_NOTE} + > + } + actions={[ + + {ENABLE_ROLES_BUTTON} + , + rbacDisabledLabel, + , + + {ENABLE_ROLES_LINK} + , + ]} + /> + > ); };
{ROLES_DISABLED_DESCRIPTION(productName)}
{ROLES_DISABLED_NOTE}