6
6
7
7
import { EuiButtonEmpty , EuiFlexGroup , EuiFlexItem , EuiIcon } from '@elastic/eui' ;
8
8
import { pickBy } from 'lodash/fp' ;
9
- import React , { useCallback } from 'react' ;
9
+ import React , { forwardRef , useCallback } from 'react' ;
10
10
import styled from 'styled-components' ;
11
11
import { OutPortal } from 'react-reverse-portal' ;
12
12
@@ -24,30 +24,37 @@ import { APP_ID, ADD_DATA_PATH, APP_DETECTIONS_PATH } from '../../../../common/c
24
24
import { useGlobalHeaderPortal } from '../../hooks/use_global_header_portal' ;
25
25
import { LinkAnchor } from '../links' ;
26
26
27
- const Wrapper = styled . header < { $globalFullScreen : boolean } > `
28
- ${ ( { $globalFullScreen , theme } ) => `
27
+ const Wrapper = styled . header `
28
+ ${ ( { theme } ) => `
29
29
background: ${ theme . eui . euiColorEmptyShade } ;
30
30
border-bottom: ${ theme . eui . euiBorderThin } ;
31
- padding-top: ${ $globalFullScreen ? theme . eui . paddingSizes . s : theme . eui . paddingSizes . m } ;
32
31
width: 100%;
33
32
z-index: ${ theme . eui . euiZNavigation } ;
33
+ position: fixed;
34
34
` }
35
35
` ;
36
36
Wrapper . displayName = 'Wrapper' ;
37
37
38
+ const WrapperContent = styled . div < { $globalFullScreen : boolean } > `
39
+ display: ${ ( { $globalFullScreen } ) => ( $globalFullScreen ? 'none' : 'block' ) } ;
40
+ padding-top: ${ ( { $globalFullScreen, theme } ) =>
41
+ $globalFullScreen ? theme . eui . paddingSizes . s : theme . eui . paddingSizes . m } ;
42
+ ` ;
43
+
44
+ WrapperContent . displayName = 'WrapperContent' ;
45
+
38
46
const FlexItem = styled ( EuiFlexItem ) `
39
47
min-width: 0;
40
48
` ;
41
49
FlexItem . displayName = 'FlexItem' ;
42
50
43
- const FlexGroup = styled ( EuiFlexGroup ) < { $globalFullScreen : boolean ; $ hasSibling : boolean } > `
44
- ${ ( { $globalFullScreen , $ hasSibling, theme } ) => `
51
+ const FlexGroup = styled ( EuiFlexGroup ) < { $hasSibling : boolean } > `
52
+ ${ ( { $hasSibling, theme } ) => `
45
53
border-bottom: ${ theme . eui . euiBorderThin } ;
46
54
margin-bottom: 1px;
47
55
padding-bottom: 4px;
48
56
padding-left: ${ theme . eui . paddingSizes . l } ;
49
57
padding-right: ${ gutterTimeline } ;
50
- ${ $globalFullScreen ? 'display: none;' : '' }
51
58
${ $hasSibling ? `border-bottom: ${ theme . eui . euiBorderThin } ;` : 'border-bottom-width: 0px;' }
52
59
` }
53
60
` ;
@@ -56,77 +63,74 @@ FlexGroup.displayName = 'FlexGroup';
56
63
interface HeaderGlobalProps {
57
64
hideDetectionEngine ?: boolean ;
58
65
}
59
- export const HeaderGlobal = React . memo < HeaderGlobalProps > ( ( { hideDetectionEngine = false } ) => {
60
- const { globalHeaderPortalNode } = useGlobalHeaderPortal ( ) ;
61
- const { globalFullScreen } = useFullScreen ( ) ;
62
- const search = useGetUrlSearch ( navTabs . overview ) ;
63
- const { application, http } = useKibana ( ) . services ;
64
- const { navigateToApp } = application ;
65
- const basePath = http . basePath . get ( ) ;
66
- const goToOverview = useCallback (
67
- ( ev ) => {
68
- ev . preventDefault ( ) ;
69
- navigateToApp ( `${ APP_ID } :${ SecurityPageName . overview } ` , { path : search } ) ;
70
- } ,
71
- [ navigateToApp , search ]
72
- ) ;
73
-
74
- return (
75
- < Wrapper className = "siemHeaderGlobal" $globalFullScreen = { globalFullScreen } >
76
- < FlexGroup
77
- alignItems = "center"
78
- $globalFullScreen = { globalFullScreen }
79
- $hasSibling = { globalHeaderPortalNode . hasChildNodes ( ) }
80
- justifyContent = "spaceBetween"
81
- wrap
82
- >
83
- < >
84
- < FlexItem >
85
- < EuiFlexGroup alignItems = "center" responsive = { false } >
86
- < FlexItem grow = { false } >
87
- < LinkAnchor onClick = { goToOverview } href = { getAppOverviewUrl ( search ) } >
88
- < EuiIcon aria-label = { i18n . SECURITY_SOLUTION } type = "logoSecurity" size = "l" />
89
- </ LinkAnchor >
90
- </ FlexItem >
66
+ export const HeaderGlobal = React . memo (
67
+ forwardRef < HTMLDivElement , HeaderGlobalProps > ( ( { hideDetectionEngine = false } , ref ) => {
68
+ const { globalHeaderPortalNode } = useGlobalHeaderPortal ( ) ;
69
+ const { globalFullScreen } = useFullScreen ( ) ;
70
+ const search = useGetUrlSearch ( navTabs . overview ) ;
71
+ const { application, http } = useKibana ( ) . services ;
72
+ const { navigateToApp } = application ;
73
+ const basePath = http . basePath . get ( ) ;
74
+ const goToOverview = useCallback (
75
+ ( ev ) => {
76
+ ev . preventDefault ( ) ;
77
+ navigateToApp ( `${ APP_ID } :${ SecurityPageName . overview } ` , { path : search } ) ;
78
+ } ,
79
+ [ navigateToApp , search ]
80
+ ) ;
81
+ return (
82
+ < Wrapper ref = { ref } className = "siemHeaderGlobal" >
83
+ < WrapperContent $globalFullScreen = { globalFullScreen } >
84
+ < FlexGroup
85
+ alignItems = "center"
86
+ $hasSibling = { globalHeaderPortalNode . hasChildNodes ( ) }
87
+ justifyContent = "spaceBetween"
88
+ wrap
89
+ >
90
+ < FlexItem >
91
+ < EuiFlexGroup alignItems = "center" responsive = { false } >
92
+ < FlexItem grow = { false } >
93
+ < LinkAnchor onClick = { goToOverview } href = { getAppOverviewUrl ( search ) } >
94
+ < EuiIcon aria-label = { i18n . SECURITY_SOLUTION } type = "logoSecurity" size = "l" />
95
+ </ LinkAnchor >
96
+ </ FlexItem >
91
97
92
- < FlexItem component = "nav" >
93
- < SiemNavigation
94
- display = "condensed"
95
- navTabs = {
96
- hideDetectionEngine
97
- ? pickBy ( ( _ , key ) => key !== SecurityPageName . detections , navTabs )
98
- : navTabs
99
- }
100
- />
101
- </ FlexItem >
102
- </ EuiFlexGroup >
103
- </ FlexItem >
98
+ < FlexItem component = "nav" >
99
+ < SiemNavigation
100
+ display = "condensed"
101
+ navTabs = {
102
+ hideDetectionEngine
103
+ ? pickBy ( ( _ , key ) => key !== SecurityPageName . detections , navTabs )
104
+ : navTabs
105
+ }
106
+ />
107
+ </ FlexItem >
108
+ </ EuiFlexGroup >
109
+ </ FlexItem >
110
+ < FlexItem grow = { false } >
111
+ < EuiFlexGroup alignItems = "center" gutterSize = "s" responsive = { false } wrap >
112
+ { window . location . pathname . includes ( APP_DETECTIONS_PATH ) && (
113
+ < FlexItem grow = { false } >
114
+ < MlPopover />
115
+ </ FlexItem >
116
+ ) }
104
117
105
- < FlexItem grow = { false } >
106
- < EuiFlexGroup alignItems = "center" gutterSize = "s" responsive = { false } wrap >
107
- { window . location . pathname . includes ( APP_DETECTIONS_PATH ) && (
108
118
< FlexItem grow = { false } >
109
- < MlPopover />
119
+ < EuiButtonEmpty
120
+ data-test-subj = "add-data"
121
+ href = { `${ basePath } ${ ADD_DATA_PATH } ` }
122
+ iconType = "plusInCircle"
123
+ >
124
+ { i18n . BUTTON_ADD_DATA }
125
+ </ EuiButtonEmpty >
110
126
</ FlexItem >
111
- ) }
112
-
113
- < FlexItem grow = { false } >
114
- < EuiButtonEmpty
115
- data-test-subj = "add-data"
116
- href = { `${ basePath } ${ ADD_DATA_PATH } ` }
117
- iconType = "plusInCircle"
118
- >
119
- { i18n . BUTTON_ADD_DATA }
120
- </ EuiButtonEmpty >
121
- </ FlexItem >
122
- </ EuiFlexGroup >
123
- </ FlexItem >
124
- </ >
125
- </ FlexGroup >
126
- < div >
127
- < OutPortal node = { globalHeaderPortalNode } />
128
- </ div >
129
- </ Wrapper >
130
- ) ;
131
- } ) ;
127
+ </ EuiFlexGroup >
128
+ </ FlexItem >
129
+ </ FlexGroup >
130
+ < OutPortal node = { globalHeaderPortalNode } />
131
+ </ WrapperContent >
132
+ </ Wrapper >
133
+ ) ;
134
+ } )
135
+ ) ;
132
136
HeaderGlobal . displayName = 'HeaderGlobal' ;
0 commit comments