55 * 2.0.
66 */
77
8+ import type { FunctionComponent } from 'react' ;
89import React , { memo , useEffect , useState } from 'react' ;
910import type { AppMountParameters } from 'kibana/public' ;
1011import { EuiCode , EuiEmptyPrompt , EuiErrorBoundary , EuiPanel , EuiPortal } from '@elastic/eui' ;
1112import type { History } from 'history' ;
1213import { createHashHistory } from 'history' ;
13- import { Router , Redirect , Route , Switch } from 'react-router-dom' ;
14+ import { Router , Redirect , Route , Switch , useRouteMatch } from 'react-router-dom' ;
1415import { FormattedMessage } from '@kbn/i18n/react' ;
1516import { i18n } from '@kbn/i18n' ;
1617import styled from 'styled-components' ;
@@ -39,7 +40,7 @@ import { Error, Loading, SettingFlyout, FleetSetupLoading } from './components';
3940import type { UIExtensionsStorage } from './types' ;
4041
4142import { FLEET_ROUTING_PATHS } from './constants' ;
42- import { DefaultLayout , WithoutHeaderLayout } from './layouts' ;
43+ import { DefaultLayout , DefaultPageTitle , WithoutHeaderLayout , WithHeaderLayout } from './layouts' ;
4344import { AgentPolicyApp } from './sections/agent_policy' ;
4445import { DataStreamApp } from './sections/data_stream' ;
4546import { AgentsApp } from './sections/agents' ;
@@ -48,11 +49,18 @@ import { EnrollmentTokenListPage } from './sections/agents/enrollment_token_list
4849
4950const FEEDBACK_URL = 'https://ela.st/fleet-feedback' ;
5051
51- const ErrorLayout = ( { children } : { children : JSX . Element } ) => (
52+ const ErrorLayout : FunctionComponent < { isAddIntegrationsPath : boolean } > = ( {
53+ isAddIntegrationsPath,
54+ children,
55+ } ) => (
5256 < EuiErrorBoundary >
53- < DefaultLayout >
54- < WithoutHeaderLayout > { children } </ WithoutHeaderLayout >
55- </ DefaultLayout >
57+ { isAddIntegrationsPath ? (
58+ < WithHeaderLayout leftColumn = { < DefaultPageTitle /> } > { children } </ WithHeaderLayout >
59+ ) : (
60+ < DefaultLayout >
61+ < WithoutHeaderLayout > { children } </ WithoutHeaderLayout >
62+ </ DefaultLayout >
63+ ) }
5664 </ EuiErrorBoundary >
5765) ;
5866
@@ -71,6 +79,8 @@ export const WithPermissionsAndSetup: React.FC = memo(({ children }) => {
7179 const [ isInitialized , setIsInitialized ] = useState ( false ) ;
7280 const [ initializationError , setInitializationError ] = useState < Error | null > ( null ) ;
7381
82+ const isAddIntegrationsPath = ! ! useRouteMatch ( FLEET_ROUTING_PATHS . add_integration_to_policy ) ;
83+
7484 useEffect ( ( ) => {
7585 ( async ( ) => {
7686 setIsPermissionsLoading ( false ) ;
@@ -109,7 +119,7 @@ export const WithPermissionsAndSetup: React.FC = memo(({ children }) => {
109119
110120 if ( isPermissionsLoading || permissionsError ) {
111121 return (
112- < ErrorLayout >
122+ < ErrorLayout isAddIntegrationsPath = { isAddIntegrationsPath } >
113123 { isPermissionsLoading ? (
114124 < Loading />
115125 ) : permissionsError === 'REQUEST_ERROR' ? (
@@ -168,7 +178,7 @@ export const WithPermissionsAndSetup: React.FC = memo(({ children }) => {
168178
169179 if ( ! isInitialized || initializationError ) {
170180 return (
171- < ErrorLayout >
181+ < ErrorLayout isAddIntegrationsPath = { isAddIntegrationsPath } >
172182 { initializationError ? (
173183 < Error
174184 title = {
@@ -314,9 +324,7 @@ export const AppRoutes = memo(
314324
315325 { /* TODO: Move this route to the Integrations app */ }
316326 < Route path = { FLEET_ROUTING_PATHS . add_integration_to_policy } >
317- < DefaultLayout >
318- < CreatePackagePolicyPage />
319- </ DefaultLayout >
327+ < CreatePackagePolicyPage />
320328 </ Route >
321329
322330 < Redirect to = { FLEET_ROUTING_PATHS . agents } />
0 commit comments