1- import React , { useContext , useEffect , useState , useMemo } from 'react' ;
1+ import React , { useContext , useEffect , useState } from 'react' ;
22import PropTypes from 'prop-types' ;
33import {
44 Switch ,
@@ -29,7 +29,6 @@ const PF_BACK_100 = 'var(--pf-v5-global--BackgroundColor--100)';
2929const JenkinsJobAnalysisView = ( { view, defaultTab= 'heatmap' } ) => {
3030 const context = useContext ( IbutsuContext ) ;
3131 const { primaryObject} = context ;
32-
3332 const [ searchParams ] = useSearchParams ( ) ;
3433
3534 const [ isAreaChart , setIsAreaChart ] = useState ( false ) ;
@@ -43,7 +42,6 @@ const JenkinsJobAnalysisView =({view, defaultTab='heatmap'}) => {
4342 const [ barchartParams , setBarchartParams ] = useState ( { } ) ;
4443 const [ linechartParams , setLinechartParams ] = useState ( { } ) ;
4544
46- // Tab state and navigation hooks/effects
4745 const { activeTab, onTabSelect} = useTabHook (
4846 [ 'heatmap' , 'overall-health' , 'build-durations' ] ,
4947 defaultTab
@@ -116,36 +114,6 @@ const JenkinsJobAnalysisView =({view, defaultTab='heatmap'}) => {
116114 return color ;
117115 } ;
118116
119- const heatmapParam = useMemo ( ( ) => {
120- if ( activeTab === 'heatmap' ) {
121- return (
122- < div style = { { backgroundColor : PF_BACK_100 , float : 'right' , clear : 'none' , marginBottom : '-2em' , padding : '0.2em 1em' , width : '30em' } } >
123- < ParamDropdown
124- dropdownItems = { [ 'Yes' , 'No' ] }
125- defaultValue = { ( countSkips ? 'Yes' : 'No' ) }
126- handleSelect = { ( value ) => setCountSkips ( value === 'Yes' ) }
127- tooltip = "Count skips as failure:"
128- />
129- </ div > )
130- }
131- } , [ activeTab ] ) ;
132-
133- const overallSwitch = useMemo ( ( ) => {
134- if ( activeTab === 'overall-health' ) {
135- return (
136- < div style = { { backgroundColor : PF_BACK_100 , float : 'right' , clear : 'none' , marginBottom : '-2em' , padding : '0.5em 1em' } } >
137- < Switch
138- id = "bar-chart-switch"
139- labelOff = "Change to Area Chart"
140- label = "Change to Bar Chart"
141- isChecked = { isAreaChart }
142- onChange = { ( _ , checked ) => setIsAreaChart ( checked ) }
143- />
144- </ div >
145- )
146- }
147- } , [ activeTab ] ) ;
148-
149117 return (
150118 < React . Fragment >
151119 < div style = { { backgroundColor : PF_BACK_100 , float : 'right' , clear : 'right' , marginBottom : '-2em' , padding : '0.2em 1em' , width : '30em' } } >
@@ -156,10 +124,29 @@ const JenkinsJobAnalysisView =({view, defaultTab='heatmap'}) => {
156124 tooltip = "Number of builds:"
157125 />
158126 </ div >
159- { heatmapParam }
160- { overallSwitch }
127+ { activeTab === 'heatmap' &&
128+ < div style = { { backgroundColor : PF_BACK_100 , float : 'right' , clear : 'none' , marginBottom : '-2em' , padding : '0.2em 1em' , width : '30em' } } >
129+ < ParamDropdown
130+ dropdownItems = { [ 'Yes' , 'No' ] }
131+ defaultValue = { ( countSkips ? 'Yes' : 'No' ) }
132+ handleSelect = { ( value ) => setCountSkips ( value === 'Yes' ) }
133+ tooltip = "Count skips as failure:"
134+ />
135+ </ div >
136+ }
137+ { activeTab === 'overall-health' &&
138+ < div style = { { backgroundColor : PF_BACK_100 , float : 'right' , clear : 'none' , marginBottom : '-2em' , padding : '0.5em 1em' } } >
139+ < Switch
140+ id = "bar-chart-switch"
141+ labelOff = "Change to Area Chart"
142+ label = "Change to Bar Chart"
143+ isChecked = { isAreaChart }
144+ onChange = { ( _ , checked ) => setIsAreaChart ( checked ) }
145+ />
146+ </ div >
147+ }
161148 < Tabs activeKey = { activeTab } onSelect = { onTabSelect } isBox >
162- < Tab key = 'heatmap' eventKey = 'heatmap' title = "Heatmap" >
149+ < Tab eventKey = 'heatmap' title = "Heatmap" >
163150 { ! isLoading && activeTab === 'heatmap' &&
164151 < FilterHeatmapWidget
165152 title = { heatmapParams . job_name }
@@ -170,7 +157,7 @@ const JenkinsJobAnalysisView =({view, defaultTab='heatmap'}) => {
170157 />
171158 }
172159 </ Tab >
173- < Tab key = 'overall-health' eventKey = 'overall-health' title = "Overall Health" >
160+ < Tab eventKey = 'overall-health' title = "Overall Health" >
174161 { ! isLoading && ! isAreaChart && activeTab === 'overall-health' &&
175162 < GenericBarWidget
176163 title = { 'Test counts for ' + barchartParams . job_name }
@@ -221,7 +208,7 @@ const JenkinsJobAnalysisView =({view, defaultTab='heatmap'}) => {
221208 />
222209 }
223210 </ Tab >
224- < Tab key = 'build-durations' eventKey = 'build-durations' title = "Build Duration" >
211+ < Tab eventKey = 'build-durations' title = "Build Duration" >
225212 { ! isLoading && activeTab === 'build-durations' &&
226213 < GenericAreaWidget
227214 title = { 'Durations for ' + linechartParams . job_name }
0 commit comments