@@ -16,7 +16,6 @@ import { Filters } from '../model/filters';
1616import { loadConfig } from '../utils/config' ;
1717import { findFilter , getFilterDefinitions } from '../utils/filter-definitions' ;
1818import { usePrevious } from '../utils/previous-hook' ;
19- import NetflowTraffic from './netflow-traffic' ;
2019import NetflowTrafficParent from './netflow-traffic-parent' ;
2120
2221type RouteProps = K8sResourceCommon & {
@@ -39,10 +38,9 @@ type HPAProps = K8sResourceCommon & {
3938
4039export const NetflowTab : React . FC < PageComponentProps > = ( { obj } ) => {
4140 const { t } = useTranslation ( 'plugin__netobserv-plugin' ) ;
42- const [ loading , setLoading ] = React . useState ( true ) ;
4341 const initState = React . useRef < Array < 'initDone' | 'configLoading' | 'configLoaded' | 'forcedFiltersLoaded' > > ( [ ] ) ;
4442 const [ config , setConfig ] = React . useState < Config > ( defaultConfig ) ;
45- const [ forcedFilters , setForcedFilters ] = React . useState < Filters | null > ( null ) ;
43+ const [ forcedFilters , setForcedFilters ] = React . useState < Filters > ( ) ;
4644 const previous = usePrevious ( { obj } ) ;
4745
4846 React . useEffect ( ( ) => {
@@ -55,7 +53,6 @@ export const NetflowTab: React.FC<PageComponentProps> = ({ obj }) => {
5553 initState . current . push ( 'configLoading' ) ;
5654 loadConfig ( ) . then ( v => {
5755 setConfig ( v ) ;
58- setLoading ( false ) ;
5956 initState . current . push ( 'configLoaded' ) ;
6057 } ) ;
6158 }
@@ -171,26 +168,26 @@ export const NetflowTab: React.FC<PageComponentProps> = ({ obj }) => {
171168 }
172169 } , [ config , obj , previous , t ] ) ;
173170
174- return forcedFilters ? (
175- < NetflowTrafficParent >
176- < NetflowTraffic forcedFilters = { forcedFilters } isTab parentConfig = { config } / >
177- </ NetflowTrafficParent >
178- ) : (
179- < PageSection id = "pageSection" data-test = "tab-page-section" >
180- { loading ? (
181- < Bullseye data-test = "loading-tab" >
182- < Spinner size = "xl" />
183- </ Bullseye >
184- ) : (
171+ if ( ! initState . current . includes ( 'forcedFiltersLoaded' ) ) {
172+ return (
173+ < Bullseye data-test = "loading-tab" >
174+ < Spinner size = "xl" / >
175+ </ Bullseye >
176+ ) ;
177+ } else if ( forcedFilters ) {
178+ return < NetflowTrafficParent forcedFilters = { forcedFilters } isTab = { true } parentConfig = { config } /> ;
179+ } else {
180+ return (
181+ < PageSection id = "pageSection" data-test = "tab-page-section" >
185182 < EmptyState data-test = "error-state" variant = { EmptyStateVariant . small } >
186183 < Title headingLevel = "h2" size = "lg" >
187184 { t ( 'Kind not managed' ) }
188185 </ Title >
189186 < EmptyStateBody > { obj ?. kind } </ EmptyStateBody >
190187 </ EmptyState >
191- ) }
192- </ PageSection >
193- ) ;
188+ </ PageSection >
189+ ) ;
190+ }
194191} ;
195192
196193export default NetflowTab ;
0 commit comments