diff --git a/x-pack/plugins/enterprise_search/common/types/index.ts b/x-pack/plugins/enterprise_search/common/types/index.ts
index a41a42da477ee..d5774adc0d516 100644
--- a/x-pack/plugins/enterprise_search/common/types/index.ts
+++ b/x-pack/plugins/enterprise_search/common/types/index.ts
@@ -18,6 +18,10 @@ export interface IInitialAppData {
ilmEnabled?: boolean;
isFederatedAuth?: boolean;
configuredLimits?: IConfiguredLimits;
+ access?: {
+ hasAppSearchAccess: boolean;
+ hasWorkplaceSearchAccess: boolean;
+ };
appSearch?: IAppSearchAccount;
workplaceSearch?: IWorkplaceSearchInitialData;
}
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.scss b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.scss
index 26e008e11d4fe..d937943352317 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.scss
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.scss
@@ -47,4 +47,8 @@
margin-top: $euiSizeS;
}
}
+
+ .enterpriseSearchOverview__card {
+ flex-basis: 50%;
+ }
}
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx
index 0a2c23a95d113..cd2a22a45bbb4 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.test.tsx
@@ -14,9 +14,37 @@ import { ProductCard } from './components/product_card';
describe('EnterpriseSearch', () => {
it('renders the overview page and product cards', () => {
- const wrapper = shallow();
+ const wrapper = shallow(
+
+ );
- expect(wrapper.find(EuiPage)).toHaveLength(1);
+ expect(wrapper.find(EuiPage).hasClass('enterpriseSearchOverview')).toBe(true);
expect(wrapper.find(ProductCard)).toHaveLength(2);
});
+
+ describe('access checks', () => {
+ it('does not render the App Search card if the user does not have access to AS', () => {
+ const wrapper = shallow(
+
+ );
+
+ expect(wrapper.find(ProductCard)).toHaveLength(1);
+ expect(wrapper.find(ProductCard).prop('product').ID).toEqual('workplaceSearch');
+ });
+
+ it('does not render the Workplace Search card if the user does not have access to WS', () => {
+ const wrapper = shallow(
+
+ );
+
+ expect(wrapper.find(ProductCard)).toHaveLength(1);
+ expect(wrapper.find(ProductCard).prop('product').ID).toEqual('appSearch');
+ });
+
+ it('does not render any cards if the user does not have access', () => {
+ const wrapper = shallow();
+
+ expect(wrapper.find(ProductCard)).toHaveLength(0);
+ });
+ });
});
diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.tsx
index a203add1c1ea8..373f595a6a9ea 100644
--- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.tsx
+++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/index.tsx
@@ -18,6 +18,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
+import { IInitialAppData } from '../../../common/types';
import { APP_SEARCH_PLUGIN, WORKPLACE_SEARCH_PLUGIN } from '../../../common/constants';
import { SetEnterpriseSearchChrome as SetPageChrome } from '../shared/kibana_chrome';
@@ -29,7 +30,9 @@ import AppSearchImage from './assets/app_search.png';
import WorkplaceSearchImage from './assets/workplace_search.png';
import './index.scss';
-export const EnterpriseSearch: React.FC = () => {
+export const EnterpriseSearch: React.FC = ({ access = {} }) => {
+ const { hasAppSearchAccess, hasWorkplaceSearchAccess } = access;
+
return (
@@ -55,13 +58,17 @@ export const EnterpriseSearch: React.FC = () => {
-
-
-
-
-
-
-
+
+ {hasAppSearchAccess && (
+
+
+
+ )}
+ {hasWorkplaceSearchAccess && (
+
+
+
+ )}