@@ -13,11 +13,10 @@ import {Icon} from '../../components/Icon';
13
13
import { EmptyState } from '../../components/EmptyState' ;
14
14
import { Link as ExternalLink , Button , Loader } from '@gravity-ui/uikit' ;
15
15
import { CriticalActionDialog } from '../../components/CriticalActionDialog' ;
16
- import routes , { createHref } from '../../routes' ;
17
- import { getDefaultNodePath } from '../Node/NodePages' ;
18
16
19
17
import { TabletTable } from './TabletTable' ;
20
18
import { TabletInfo } from './TabletInfo' ;
19
+ import { TabletControls } from './TabletControls' ;
21
20
22
21
import './Tablet.scss' ;
23
22
@@ -53,19 +52,10 @@ class Tablet extends React.Component {
53
52
}
54
53
55
54
state = {
56
- typeVisibleDialog : null ,
57
- dialogVisible : false ,
58
55
isFirstFetchData : true ,
59
56
tenantPath : '-' ,
60
- disableTabletActions : false ,
61
57
} ;
62
58
63
- makeShowDialog = ( type ) => ( ) => this . setState ( { dialogVisible : true , typeVisibleDialog : type } ) ;
64
- showKillDialog = this . makeShowDialog ( 'kill' ) ;
65
- showStopDialog = this . makeShowDialog ( 'stop' ) ;
66
- showResumeDialog = this . makeShowDialog ( 'resume' ) ;
67
- hideDialog = ( ) => this . setState ( { dialogVisible : false , typeVisibleDialog : null } ) ;
68
-
69
59
fetchTabletInfo = ( ) => {
70
60
const { version, id} = this . props ;
71
61
const { isFirstFetchData} = this . state ;
@@ -85,9 +75,7 @@ class Tablet extends React.Component {
85
75
}
86
76
87
77
this . fetcher = setInterval ( ( ) => {
88
- this . props . getTablet ( id ) . then ( ( ) => {
89
- this . setState ( { disableTabletActions : false } ) ;
90
- } ) ;
78
+ this . props . getTablet ( id ) ;
91
79
} , 10000 ) ;
92
80
}
93
81
} ;
@@ -126,104 +114,6 @@ class Tablet extends React.Component {
126
114
</ li >
127
115
) ;
128
116
} ;
129
- _onKillClick = ( ) => {
130
- const { TabletId : id } = this . props . tablet ;
131
-
132
- this . setState ( { disableTabletActions : true } ) ;
133
-
134
- return window . api . killTablet ( id ) ;
135
- } ;
136
- _onStopClick = ( ) => {
137
- const { TabletId : id , HiveId : hiveId } = this . props . tablet ;
138
-
139
- this . setState ( { disableTabletActions : true } ) ;
140
-
141
- return window . api . stopTablet ( id , hiveId ) ;
142
- } ;
143
- _onResumeClick = ( ) => {
144
- const { TabletId : id , HiveId : hiveId } = this . props . tablet ;
145
-
146
- this . setState ( { disableTabletActions : true } ) ;
147
-
148
- return window . api . resumeTablet ( id , hiveId ) ;
149
- } ;
150
- renderDialog = ( ) => {
151
- const { dialogVisible, typeVisibleDialog} = this . state ;
152
-
153
- if ( ! dialogVisible ) {
154
- return null ;
155
- }
156
-
157
- switch ( typeVisibleDialog ) {
158
- case 'kill' : {
159
- return (
160
- < CriticalActionDialog
161
- visible = { dialogVisible }
162
- text = "The tablet will be restarted. Do you want to proceed?"
163
- onClose = { this . hideDialog }
164
- onConfirm = { this . _onKillClick }
165
- />
166
- ) ;
167
- }
168
- case 'stop' : {
169
- return (
170
- < CriticalActionDialog
171
- visible = { dialogVisible }
172
- text = "The tablet will be stopped. Do you want to proceed?"
173
- onClose = { this . hideDialog }
174
- onConfirm = { this . _onStopClick }
175
- />
176
- ) ;
177
- }
178
- case 'resume' : {
179
- return (
180
- < CriticalActionDialog
181
- visible = { dialogVisible }
182
- text = "The tablet will be resumed. Do you want to proceed?"
183
- onClose = { this . hideDialog }
184
- onConfirm = { this . _onResumeClick }
185
- />
186
- ) ;
187
- }
188
- default :
189
- return null ;
190
- }
191
- } ;
192
-
193
- hasHiveId = ( ) => {
194
- const { tablet} = this . props ;
195
- const { HiveId} = tablet ;
196
-
197
- return HiveId && HiveId !== '0' ;
198
- } ;
199
-
200
- isDisabledResume = ( ) => {
201
- const { tablet} = this . props ;
202
- const { disableTabletActions} = this . state ;
203
-
204
- if ( disableTabletActions ) {
205
- return true ;
206
- }
207
-
208
- return tablet . State !== 'Stopped' && tablet . State !== 'Dead' ;
209
- } ;
210
-
211
- isDisabledKill = ( ) => {
212
- const { disableTabletActions} = this . state ;
213
-
214
- return disableTabletActions ;
215
- } ;
216
-
217
- isDisabledStop = ( ) => {
218
- const { tablet} = this . props ;
219
- const { disableTabletActions} = this . state ;
220
-
221
- if ( disableTabletActions ) {
222
- return true ;
223
- }
224
-
225
- return tablet . State === 'Stopped' || tablet . State === 'Deleted' ;
226
- } ;
227
117
228
118
renderTablet = ( ) => {
229
119
const { tablet, tenantPath} = this . props ;
@@ -257,42 +147,12 @@ class Tablet extends React.Component {
257
147
{ ( tablet . Master || tablet . Leader ) && < Tag text = "Leader" type = "blue" /> }
258
148
</ div >
259
149
< TabletInfo tablet = { tablet } tenantPath = { tenantPath } />
260
- < div className = { b ( 'controls' ) } >
261
- < Button
262
- onClick = { this . showKillDialog }
263
- view = "action"
264
- disabled = { this . isDisabledKill ( ) }
265
- className = { b ( 'control' ) }
266
- >
267
- Restart
268
- </ Button >
269
- { this . hasHiveId ( ) ? (
270
- < React . Fragment >
271
- < Button
272
- onClick = { this . showStopDialog }
273
- view = "action"
274
- disabled = { this . isDisabledStop ( ) }
275
- className = { b ( 'control' ) }
276
- >
277
- Stop
278
- </ Button >
279
- < Button
280
- onClick = { this . showResumeDialog }
281
- view = "action"
282
- disabled = { this . isDisabledResume ( ) }
283
- className = { b ( 'control' ) }
284
- >
285
- Resume
286
- </ Button >
287
- </ React . Fragment >
288
- ) : null }
289
- </ div >
150
+ < TabletControls tablet = { tablet } />
290
151
</ div >
291
152
< div className = { b ( 'rigth-pane' ) } >
292
153
< TabletTable history = { this . props . history } />
293
154
</ div >
294
155
</ div >
295
- { this . renderDialog ( ) }
296
156
</ div >
297
157
) ;
298
158
} ;
0 commit comments