@@ -15,7 +15,7 @@ import {
15
15
EuiFlexItem ,
16
16
EuiSelect ,
17
17
EuiOverlayMask ,
18
- EuiConfirmModal
18
+ EuiConfirmModal ,
19
19
} from '@elastic/eui' ;
20
20
21
21
import { connect } from 'react-redux' ;
@@ -30,7 +30,7 @@ import {
30
30
} from '../../../../../redux/actions/statusActions' ;
31
31
32
32
import StatusHandler from './utils/status-handler' ;
33
- import { getToasts } from '../../../../../kibana-services' ;
33
+ import { getToasts } from '../../../../../kibana-services' ;
34
34
import { WzButtonPermissions } from '../../../../../components/common/permissions/button' ;
35
35
36
36
import { UI_ERROR_SEVERITIES } from '../../../../../react-services/error-orchestrator/types' ;
@@ -47,7 +47,7 @@ class WzStatusActionButtons extends Component {
47
47
this . statusHandler = StatusHandler ;
48
48
this . state = {
49
49
isModalVisible : false ,
50
- isRestarting : false
50
+ isRestarting : false ,
51
51
} ;
52
52
}
53
53
@@ -72,7 +72,7 @@ class WzStatusActionButtons extends Component {
72
72
this . showToast (
73
73
'success' ,
74
74
'Restarting cluster, it will take up to 30 seconds.' ,
75
- 3000
75
+ 3000 ,
76
76
) ;
77
77
} catch ( error ) {
78
78
this . setState ( { isRestarting : false } ) ;
@@ -131,9 +131,11 @@ class WzStatusActionButtons extends Component {
131
131
this . props . updateLoadingStatus ( true ) ;
132
132
this . props . updateSelectedNode ( node ) ;
133
133
134
- const agentsCountByManagerNodes = await this . statusHandler . clusterAgentsCount ( ) ;
134
+ const agentsCountByManagerNodes =
135
+ await this . statusHandler . clusterAgentsCount ( ) ;
135
136
136
- const { connection : agentsCount } = agentsCountByManagerNodes ?. data ?. data ?. agent_status ;
137
+ const { connection : agentsCount } =
138
+ agentsCountByManagerNodes ?. data ?. data ?. agent_status ;
137
139
138
140
const agentsActiveCoverage = (
139
141
( agentsCount . active / agentsCount . total ) *
@@ -168,7 +170,7 @@ class WzStatusActionButtons extends Component {
168
170
error : {
169
171
error : error ,
170
172
message : error . message || error ,
171
- title : `${ error . name } : Node ${ node } is down`
173
+ title : `${ error . name } : Node ${ node } is down` ,
172
174
} ,
173
175
} ;
174
176
getErrorOrchestrator ( ) . handleError ( options ) ;
@@ -192,7 +194,7 @@ class WzStatusActionButtons extends Component {
192
194
getToasts ( ) . add ( {
193
195
color : color ,
194
196
title : text ,
195
- toastLifeTimeMs : time
197
+ toastLifeTimeMs : time ,
196
198
} ) ;
197
199
} ;
198
200
@@ -201,7 +203,7 @@ class WzStatusActionButtons extends Component {
201
203
for ( const node of listNodes ) {
202
204
options . push ( {
203
205
value : node . name ,
204
- text : `${ node . name } (${ node . type } )`
206
+ text : `${ node . name } (${ node . type } )` ,
205
207
} ) ;
206
208
}
207
209
return options ;
@@ -212,33 +214,35 @@ class WzStatusActionButtons extends Component {
212
214
} ;
213
215
214
216
render ( ) {
215
- const {
216
- isLoading,
217
- listNodes,
218
- selectedNode,
219
- clusterEnabled,
220
- } = this . props . state ;
217
+ const { isLoading, listNodes, selectedNode, clusterEnabled } =
218
+ this . props . state ;
221
219
222
220
let options = this . transforToOptions ( listNodes ) ;
223
221
224
222
// Select node
225
- const selectNode = (
226
- < EuiSelect
227
- id = "selectNode"
228
- options = { options }
229
- value = { selectedNode }
230
- onChange = { this . changeNode }
231
- disabled = { isLoading || this . state . isRestarting }
232
- aria-label = "Select node"
233
- />
234
- ) ;
223
+ const selectNode = selectedNode ? (
224
+ < EuiFlexItem grow = { false } >
225
+ < EuiSelect
226
+ id = 'selectNode'
227
+ options = { options }
228
+ value = { selectedNode }
229
+ onChange = { this . changeNode }
230
+ disabled = { isLoading || this . state . isRestarting }
231
+ aria-label = 'Select node'
232
+ />
233
+ </ EuiFlexItem >
234
+ ) : null ;
235
235
236
236
// Restart button
237
237
const restartButton = (
238
238
< WzButtonPermissions
239
239
buttonType = 'empty'
240
- permissions = { [ clusterEnabled ? { action : 'cluster:restart' , resource : 'node:id:*' } : { action : 'manager:restart' , resource : '*:*:*' } ] }
241
- iconType = "refresh"
240
+ permissions = { [
241
+ clusterEnabled
242
+ ? { action : 'cluster:restart' , resource : 'node:id:*' }
243
+ : { action : 'manager:restart' , resource : '*:*:*' } ,
244
+ ] }
245
+ iconType = 'refresh'
242
246
onClick = { async ( ) => this . setState ( { isModalVisible : true } ) }
243
247
isDisabled = { isLoading }
244
248
isLoading = { this . state . isRestarting }
@@ -268,9 +272,9 @@ class WzStatusActionButtons extends Component {
268
272
}
269
273
this . setState ( { isModalVisible : false } ) ;
270
274
} }
271
- cancelButtonText = " Cancel"
272
- confirmButtonText = " Confirm"
273
- defaultFocusedButton = " cancel"
275
+ cancelButtonText = ' Cancel'
276
+ confirmButtonText = ' Confirm'
277
+ defaultFocusedButton = ' cancel'
274
278
> </ EuiConfirmModal >
275
279
</ EuiOverlayMask >
276
280
) ;
@@ -281,7 +285,7 @@ class WzStatusActionButtons extends Component {
281
285
{ selectedNode !== null && (
282
286
< EuiFlexItem grow = { false } > { restartButton } </ EuiFlexItem >
283
287
) }
284
- { selectedNode && < EuiFlexItem grow = { false } > { selectNode } </ EuiFlexItem > }
288
+ { selectNode }
285
289
{ modal }
286
290
</ Fragment >
287
291
) ;
@@ -290,7 +294,7 @@ class WzStatusActionButtons extends Component {
290
294
291
295
const mapStateToProps = state => {
292
296
return {
293
- state : state . statusReducers
297
+ state : state . statusReducers ,
294
298
} ;
295
299
} ;
296
300
@@ -299,13 +303,14 @@ const mapDispatchToProps = dispatch => {
299
303
updateLoadingStatus : status => dispatch ( updateLoadingStatus ( status ) ) ,
300
304
updateListDaemons : listDaemons => dispatch ( updateListDaemons ( listDaemons ) ) ,
301
305
updateNodeInfo : nodeInfo => dispatch ( updateNodeInfo ( nodeInfo ) ) ,
302
- updateSelectedNode : selectedNode => dispatch ( updateSelectedNode ( selectedNode ) ) ,
306
+ updateSelectedNode : selectedNode =>
307
+ dispatch ( updateSelectedNode ( selectedNode ) ) ,
303
308
updateStats : stats => dispatch ( updateStats ( stats ) ) ,
304
- updateAgentInfo : agentInfo => dispatch ( updateAgentInfo ( agentInfo ) )
309
+ updateAgentInfo : agentInfo => dispatch ( updateAgentInfo ( agentInfo ) ) ,
305
310
} ;
306
311
} ;
307
312
308
313
export default connect (
309
314
mapStateToProps ,
310
- mapDispatchToProps
315
+ mapDispatchToProps ,
311
316
) ( WzStatusActionButtons ) ;
0 commit comments