@@ -33,7 +33,7 @@ import {
33
33
NavExpandable ,
34
34
NavItem ,
35
35
NavList ,
36
- PageSidebar
36
+ PageSidebar ,
37
37
} from "@patternfly/react-core" ;
38
38
39
39
import { Routes , Route , Link , Navigate } from "react-router-dom" ;
@@ -73,7 +73,9 @@ function withRouter(Component) {
73
73
< Component
74
74
{ ...props }
75
75
router = { { location, navigate, params } } // intended usage
76
- location = { location } navigate = { navigate } params = { params } // what the code currently expects
76
+ location = { location }
77
+ navigate = { navigate }
78
+ params = { params } // what the code currently expects
77
79
/>
78
80
) ;
79
81
}
@@ -95,7 +97,7 @@ class PageLayout extends React.PureComponent {
95
97
isMobileView : false ,
96
98
user : "anonymous" ,
97
99
timePeriod : 60 ,
98
- suppress : JSON . parse ( localStorage . getItem ( SUPPRESS_NOTIFICATIONS ) ) || false
100
+ suppress : JSON . parse ( localStorage . getItem ( SUPPRESS_NOTIFICATIONS ) ) || false ,
99
101
} ;
100
102
this . isDropdownOpen = false ;
101
103
@@ -108,10 +110,10 @@ class PageLayout extends React.PureComponent {
108
110
{ name : "addresses" , pre : true } ,
109
111
{ name : "links" , pre : true } ,
110
112
{ name : "connections" , pre : true } ,
111
- { name : "logs" , pre : true }
113
+ { name : "logs" , pre : true } ,
112
114
] ,
113
115
visualizations : [ { name : "topology" } , { name : "flow" , title : "Message flow" } ] ,
114
- details : [ { name : "entities" } , { name : "schema" } ]
116
+ details : [ { name : "entities" } , { name : "schema" } ] ,
115
117
} ;
116
118
this . state . connecting = true ;
117
119
this . tryInitialConnect ( ) ;
@@ -138,9 +140,7 @@ class PageLayout extends React.PureComponent {
138
140
} ;
139
141
140
142
handleIdleTimeout = ( ) => {
141
- this . props . history . replace (
142
- `${ this . props . location . pathname } ${ this . props . location . search } `
143
- ) ;
143
+ this . props . navigate ( `${ this . props . location . pathname } ${ this . props . location . search } ` ) ;
144
144
} ;
145
145
146
146
tryInitialConnect = ( ) => {
@@ -149,15 +149,15 @@ class PageLayout extends React.PureComponent {
149
149
address : window . location . hostname ,
150
150
port : window . location . port === "" ? defaultPort : window . location . port ,
151
151
timeout : 2000 ,
152
- reconnect : true
152
+ reconnect : true ,
153
153
} ;
154
154
this . service . connect ( connectOptions ) . then (
155
155
( ) => {
156
156
this . handleConnect ( "/dashboard" ) ;
157
157
} ,
158
158
( ) => {
159
159
//this.service.disconnect();
160
- this . props . history . replace ( "/" ) ;
160
+ this . props . navigate ( "/" ) ;
161
161
this . setState ( { connecting : false } ) ;
162
162
}
163
163
) ;
@@ -187,10 +187,10 @@ class PageLayout extends React.PureComponent {
187
187
if ( this . lastLocation ) {
188
188
to = this . lastLocation ;
189
189
}
190
- this . props . history . push ( to ) ;
190
+ this . props . navigate ( to ) ;
191
191
this . setState ( {
192
192
isConnectFormOpen : false ,
193
- connected : true
193
+ connected : true ,
194
194
} ) ;
195
195
}
196
196
} ;
@@ -265,7 +265,7 @@ class PageLayout extends React.PureComponent {
265
265
activeItem,
266
266
activeGroup,
267
267
connected : true ,
268
- isConnectFormOpen : false
268
+ isConnectFormOpen : false ,
269
269
} ) ;
270
270
this . props . navigate ( connectPath ) ;
271
271
}
@@ -276,7 +276,7 @@ class PageLayout extends React.PureComponent {
276
276
onNavSelect = result => {
277
277
this . setState ( {
278
278
activeItem : result . itemId ,
279
- activeGroup : result . groupId
279
+ activeGroup : result . groupId ,
280
280
} ) ;
281
281
} ;
282
282
@@ -290,19 +290,19 @@ class PageLayout extends React.PureComponent {
290
290
291
291
onNavToggleDesktop = ( ) => {
292
292
this . setState ( {
293
- isNavOpenDesktop : ! this . state . isNavOpenDesktop
293
+ isNavOpenDesktop : ! this . state . isNavOpenDesktop ,
294
294
} ) ;
295
295
} ;
296
296
297
297
onNavToggleMobile = ( ) => {
298
298
this . setState ( {
299
- isNavOpenMobile : ! this . state . isNavOpenMobile
299
+ isNavOpenMobile : ! this . state . isNavOpenMobile ,
300
300
} ) ;
301
301
} ;
302
302
303
303
onPageResize = ( { mobileView, windowSize } ) => {
304
304
this . setState ( {
305
- isMobileView : mobileView
305
+ isMobileView : mobileView ,
306
306
} ) ;
307
307
} ;
308
308
@@ -322,7 +322,7 @@ class PageLayout extends React.PureComponent {
322
322
message,
323
323
timestamp,
324
324
severity,
325
- silent
325
+ silent,
326
326
} ) ;
327
327
}
328
328
} ;
@@ -447,20 +447,24 @@ class PageLayout extends React.PureComponent {
447
447
448
448
// don't allow access to this component unless we are logged in
449
449
// https://gist.github.com/mjackson/d54b40a094277b7afdd6b81f51a0393f
450
- const RequireLogin = ( props ) => {
451
- const { component : Component , ...more } = props
452
-
453
- return this . state . connected ? < Component
454
- service = { this . service }
455
- handleAddNotification = { this . handleAddNotification }
456
- { ...this . props }
457
- { ...more }
458
- location = { this . props . history . location }
459
- /> : < Navigate
460
- to = { `/login${ this . state . connecting ? "/connecting" : "" } ` }
461
- state = { { from : this . props . history . location } }
462
- /> ;
463
- }
450
+ const RequireLogin = props => {
451
+ const { component : Component , ...more } = props ;
452
+
453
+ return this . state . connected ? (
454
+ < Component
455
+ service = { this . service }
456
+ handleAddNotification = { this . handleAddNotification }
457
+ { ...this . props }
458
+ { ...more }
459
+ location = { this . props . location }
460
+ />
461
+ ) : (
462
+ < Navigate
463
+ to = { `/login${ this . state . connecting ? "/connecting" : "" } ` }
464
+ state = { { from : this . props . location } }
465
+ />
466
+ ) ;
467
+ } ;
464
468
465
469
const connectForm = ( ) => {
466
470
return this . state . isConnectFormOpen ? (
@@ -501,7 +505,8 @@ class PageLayout extends React.PureComponent {
501
505
{ connectForm ( ) }
502
506
< Routes >
503
507
< Route
504
- exact path = { "/" }
508
+ exact
509
+ path = { "/" }
505
510
element = {
506
511
< RequireLogin
507
512
throughputChartData = { this . throughputChartData }
@@ -520,21 +525,22 @@ class PageLayout extends React.PureComponent {
520
525
/>
521
526
}
522
527
/>
523
- < Route path = "/overview/:entity" element = { < RequireLogin component = { OverviewPage } /> } />
528
+ < Route
529
+ path = "/overview/:entity"
530
+ element = { < RequireLogin component = { OverviewPage } /> }
531
+ />
524
532
< Route
525
533
path = "/details"
526
- element = {
527
- < RequireLogin
528
- schema = { this . schema }
529
- component = { DetailsTablePage }
530
- />
531
- }
534
+ element = { < RequireLogin schema = { this . schema } component = { DetailsTablePage } /> }
535
+ />
536
+ < Route path = "/topology" element = { < RequireLogin component = { TopologyPage } /> } />
537
+ < Route path = "/flow" element = { < RequireLogin component = { MessageFlowPage } /> } />
538
+ < Route path = "/logs" element = { < RequireLogin component = { LogDetails } /> } />
539
+ < Route path = "/entities" element = { < RequireLogin component = { EntitiesPage } /> } />
540
+ < Route
541
+ path = "/schema"
542
+ element = { < RequireLogin schema = { this . schema } component = { SchemaPage } /> }
532
543
/>
533
- < Route path = "/topology" element = { < RequireLogin component = { TopologyPage } /> } />
534
- < Route path = "/flow" element = { < RequireLogin component = { MessageFlowPage } /> } />
535
- < Route path = "/logs" element = { < RequireLogin component = { LogDetails } /> } />
536
- < Route path = "/entities" element = { < RequireLogin component = { EntitiesPage } /> } />
537
- < Route path = "/schema" element = { < RequireLogin schema = { this . schema } component = { SchemaPage } /> } />
538
544
< Route
539
545
path = "/login/*"
540
546
element = {
0 commit comments