From 99906279d2afd533b2dfb0121804171b67d0e1c8 Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Tue, 15 Sep 2020 14:23:20 -0500 Subject: [PATCH 1/2] [Enterprise Search] Add flag to restrict with of layout This PR adds a boolean flag to restrict the width of the Enterprise Search layout file for use in Workplace Search. --- .../public/applications/shared/layout/layout.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.tsx index b4497140b65b7..e122c4d5cfdfa 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.tsx @@ -14,6 +14,7 @@ import './layout.scss'; interface ILayoutProps { navigation: React.ReactNode; + restrictWidth?: boolean; } export interface INavContext { @@ -21,7 +22,7 @@ export interface INavContext { } export const NavContext = React.createContext({}); -export const Layout: React.FC = ({ children, navigation }) => { +export const Layout: React.FC = ({ children, navigation, restrictWidth }) => { const [isNavOpen, setIsNavOpen] = useState(false); const toggleNavigation = () => setIsNavOpen(!isNavOpen); const closeNavigation = () => setIsNavOpen(false); @@ -54,7 +55,9 @@ export const Layout: React.FC = ({ children, navigation }) => { {navigation} - {children} + + {children} + ); }; From f7ed9ddf95327b9f45b0f93e8f532e798655f88b Mon Sep 17 00:00:00 2001 From: scottybollinger Date: Tue, 15 Sep 2020 15:08:46 -0500 Subject: [PATCH 2/2] Add tests --- .../public/applications/shared/layout/layout.test.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.test.tsx index 4053f2f4bb613..623e6e47167d2 100644 --- a/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { EuiPageSideBar, EuiButton } from '@elastic/eui'; +import { EuiPageSideBar, EuiButton, EuiPageBody } from '@elastic/eui'; import { Layout, INavContext } from './layout'; @@ -15,6 +15,13 @@ describe('Layout', () => { const wrapper = shallow(); expect(wrapper.find('.enterpriseSearchLayout')).toHaveLength(1); + expect(wrapper.find(EuiPageBody).prop('restrictWidth')).toBeFalsy(); + }); + + it('passes the restrictWidth prop', () => { + const wrapper = shallow(); + + expect(wrapper.find(EuiPageBody).prop('restrictWidth')).toEqual(true); }); it('renders navigation', () => {