Skip to content

Commit

Permalink
Revert "Temporarily remove Layout from App Search plugin for 7.10 rel…
Browse files Browse the repository at this point in the history
…ease (#79506)" (#79702) (#79959)

This reverts commit d5b8a95.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Constance and kibanamachine committed Oct 8, 2020
1 parent 4ce78bc commit 306b002
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import React from 'react';
import { Redirect } from 'react-router-dom';
import { shallow } from 'enzyme';

import { SideNav, SideNavLink } from '../shared/layout';
import { Layout, SideNav, SideNavLink } from '../shared/layout';
import { SetupGuide } from './components/setup_guide';
import { ErrorConnecting } from './components/error_connecting';
import { EngineOverview } from './components/engine_overview';
Expand Down Expand Up @@ -51,9 +51,11 @@ describe('AppSearchConfigured', () => {
setMockActions({ initializeAppData: () => {} });
});

it('renders', () => {
it('renders with layout', () => {
const wrapper = shallow(<AppSearchConfigured />);

expect(wrapper.find(Layout)).toHaveLength(1);
expect(wrapper.find(Layout).prop('readOnlyMode')).toBeFalsy();
expect(wrapper.find(EngineOverview)).toHaveLength(1);
});

Expand Down Expand Up @@ -84,6 +86,14 @@ describe('AppSearchConfigured', () => {
expect(wrapper.find(ErrorConnecting)).toHaveLength(1);
});

it('passes readOnlyMode state', () => {
setMockValues({ myRole: {}, readOnlyMode: true });

const wrapper = shallow(<AppSearchConfigured />);

expect(wrapper.find(Layout).prop('readOnlyMode')).toEqual(true);
});

describe('ability checks', () => {
// TODO: Use this section for routes wrapped in canViewX conditionals
// e.g., it('renders settings if a user can view settings')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React, { useEffect } from 'react';
import { Route, Redirect, Switch } from 'react-router-dom';
import { useActions, useValues } from 'kea';

import { EuiPage, EuiPageBody } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { getAppSearchUrl } from '../shared/enterprise_search_url';
Expand All @@ -18,7 +17,7 @@ import { AppLogic } from './app_logic';
import { IInitialAppData } from '../../../common/types';

import { APP_SEARCH_PLUGIN } from '../../../common/constants';
import { SideNav, SideNavLink } from '../shared/layout';
import { Layout, SideNav, SideNavLink } from '../shared/layout';

import {
ROOT_PATH,
Expand Down Expand Up @@ -53,7 +52,7 @@ export const AppSearchUnconfigured: React.FC = () => (
export const AppSearchConfigured: React.FC<IInitialAppData> = (props) => {
const { initializeAppData } = useActions(AppLogic);
const { hasInitialized } = useValues(AppLogic);
const { errorConnecting } = useValues(HttpLogic);
const { errorConnecting, readOnlyMode } = useValues(HttpLogic);

useEffect(() => {
if (!hasInitialized) initializeAppData(props);
Expand All @@ -65,25 +64,23 @@ export const AppSearchConfigured: React.FC<IInitialAppData> = (props) => {
<SetupGuide />
</Route>
<Route>
<EuiPage>
<EuiPageBody restrictWidth>
{errorConnecting ? (
<ErrorConnecting />
) : (
<Switch>
<Route exact path={ROOT_PATH}>
<Redirect to={ENGINES_PATH} />
</Route>
<Route exact path={ENGINES_PATH}>
<EngineOverview />
</Route>
<Route>
<NotFound product={APP_SEARCH_PLUGIN} />
</Route>
</Switch>
)}
</EuiPageBody>
</EuiPage>
<Layout navigation={<AppSearchNav />} readOnlyMode={readOnlyMode}>
{errorConnecting ? (
<ErrorConnecting />
) : (
<Switch>
<Route exact path={ROOT_PATH}>
<Redirect to={ENGINES_PATH} />
</Route>
<Route exact path={ENGINES_PATH}>
<EngineOverview />
</Route>
<Route>
<NotFound product={APP_SEARCH_PLUGIN} />
</Route>
</Switch>
)}
</Layout>
</Route>
</Switch>
);
Expand Down

0 comments on commit 306b002

Please sign in to comment.