Skip to content

Commit f0a547f

Browse files
[Enterprise Search] Add flag to restrict width of layout (#77539)
* [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. * Add tests
1 parent 7524891 commit f0a547f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import React from 'react';
88
import { shallow } from 'enzyme';
9-
import { EuiPageSideBar, EuiButton } from '@elastic/eui';
9+
import { EuiPageSideBar, EuiButton, EuiPageBody } from '@elastic/eui';
1010

1111
import { Layout, INavContext } from './layout';
1212

@@ -15,6 +15,13 @@ describe('Layout', () => {
1515
const wrapper = shallow(<Layout navigation={null} />);
1616

1717
expect(wrapper.find('.enterpriseSearchLayout')).toHaveLength(1);
18+
expect(wrapper.find(EuiPageBody).prop('restrictWidth')).toBeFalsy();
19+
});
20+
21+
it('passes the restrictWidth prop', () => {
22+
const wrapper = shallow(<Layout navigation={null} restrictWidth />);
23+
24+
expect(wrapper.find(EuiPageBody).prop('restrictWidth')).toEqual(true);
1825
});
1926

2027
it('renders navigation', () => {

x-pack/plugins/enterprise_search/public/applications/shared/layout/layout.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import './layout.scss';
1414

1515
interface ILayoutProps {
1616
navigation: React.ReactNode;
17+
restrictWidth?: boolean;
1718
}
1819

1920
export interface INavContext {
2021
closeNavigation(): void;
2122
}
2223
export const NavContext = React.createContext({});
2324

24-
export const Layout: React.FC<ILayoutProps> = ({ children, navigation }) => {
25+
export const Layout: React.FC<ILayoutProps> = ({ children, navigation, restrictWidth }) => {
2526
const [isNavOpen, setIsNavOpen] = useState(false);
2627
const toggleNavigation = () => setIsNavOpen(!isNavOpen);
2728
const closeNavigation = () => setIsNavOpen(false);
@@ -54,7 +55,9 @@ export const Layout: React.FC<ILayoutProps> = ({ children, navigation }) => {
5455
</div>
5556
<NavContext.Provider value={{ closeNavigation }}>{navigation}</NavContext.Provider>
5657
</EuiPageSideBar>
57-
<EuiPageBody className="enterpriseSearchLayout__body">{children}</EuiPageBody>
58+
<EuiPageBody className="enterpriseSearchLayout__body" restrictWidth={restrictWidth}>
59+
{children}
60+
</EuiPageBody>
5861
</EuiPage>
5962
);
6063
};

0 commit comments

Comments
 (0)