@@ -3,10 +3,11 @@ import PropTypes from 'prop-types';
3
3
import { connect } from 'react-redux' ;
4
4
import cn from 'bem-cn-lite' ;
5
5
import DataTable from '@yandex-cloud/react-data-table' ;
6
- import { Loader , RadioButton , Label } from '@yandex-cloud/uikit' ;
6
+ import { RadioButton , Label } from '@yandex-cloud/uikit' ;
7
7
8
8
import StorageFilter from './StorageFilter/StorageFilter' ;
9
9
import { AutoFetcher } from '../../utils/autofetcher' ;
10
+ import { TableSkeleton } from '../../components/TableSkeleton/TableSkeleton' ;
10
11
11
12
import {
12
13
getStorageInfo ,
@@ -68,17 +69,14 @@ class Storage extends React.Component {
68
69
storageType,
69
70
setHeader,
70
71
getNodesList,
71
- getStorageInfo,
72
72
} = this . props ;
73
73
74
74
this . autofetcher = new AutoFetcher ( ) ;
75
75
getNodesList ( ) ;
76
76
if ( tenant || nodeId ) {
77
77
setVisibleEntities ( VisibleEntities . All ) ;
78
- getStorageInfo ( {
79
- tenant,
78
+ this . getStorageInfo ( {
80
79
filter : FILTER_OPTIONS . All ,
81
- nodeId,
82
80
type : storageType ,
83
81
} ) ;
84
82
} else {
@@ -88,16 +86,12 @@ class Storage extends React.Component {
88
86
link : createHref ( routes . cluster , { activeTab : CLUSTER_PAGES . storage . id } ) ,
89
87
} ,
90
88
] ) ;
91
- getStorageInfo ( {
92
- tenant,
93
- nodeId,
89
+ this . getStorageInfo ( {
94
90
filter : FILTER_OPTIONS . Missing ,
95
91
type : storageType ,
96
92
} ) ;
97
93
this . autofetcher . fetch ( ( ) =>
98
- getStorageInfo ( {
99
- tenant,
100
- nodeId,
94
+ this . getStorageInfo ( {
101
95
filter : FILTER_OPTIONS . Missing ,
102
96
type : storageType ,
103
97
} ) ,
@@ -107,30 +101,23 @@ class Storage extends React.Component {
107
101
108
102
componentDidUpdate ( prevProps ) {
109
103
const {
110
- tenant,
111
104
visibleEntities,
112
- getStorageInfo,
113
- nodeId,
114
105
storageType,
115
106
autorefresh,
116
107
database,
117
108
} = this . props ;
118
109
119
110
const startFetch = ( ) => {
120
- getStorageInfo ( {
121
- tenant,
111
+ this . getStorageInfo ( {
122
112
filter : FILTER_OPTIONS [ visibleEntities ] ,
123
- nodeId,
124
113
type : storageType ,
125
114
} ) ;
126
115
127
116
this . autofetcher . stop ( ) ;
128
117
this . autofetcher . start ( ) ;
129
118
this . autofetcher . fetch ( ( ) =>
130
- getStorageInfo ( {
131
- tenant,
119
+ this . getStorageInfo ( {
132
120
filter : FILTER_OPTIONS [ visibleEntities ] ,
133
- nodeId,
134
121
type : storageType ,
135
122
} ) ,
136
123
) ;
@@ -157,11 +144,25 @@ class Storage extends React.Component {
157
144
this . props . setInitialState ( ) ;
158
145
}
159
146
147
+ getStorageInfo ( data ) {
148
+ const {
149
+ tenant,
150
+ nodeId,
151
+ getStorageInfo,
152
+ } = this . props ;
153
+
154
+ getStorageInfo ( {
155
+ tenant,
156
+ nodeId,
157
+ ...data ,
158
+ } , {
159
+ concurrentId : 'getStorageInfo' ,
160
+ } ) ;
161
+ }
162
+
160
163
renderLoader ( ) {
161
164
return (
162
- < div className = { b ( 'loader' ) } >
163
- < Loader size = "m" />
164
- </ div >
165
+ < TableSkeleton className = { b ( 'loader' ) } />
165
166
) ;
166
167
}
167
168
@@ -200,8 +201,9 @@ class Storage extends React.Component {
200
201
} ;
201
202
202
203
renderControls ( ) {
203
- const { setStorageFilter, visibleEntities, storageType, flatListStorageEntities} =
204
+ const { setStorageFilter, visibleEntities, storageType, flatListStorageEntities, loading , wasLoaded } =
204
205
this . props ;
206
+ const showLoader = loading && ! wasLoaded ;
205
207
return (
206
208
< div className = { b ( 'controls' ) } >
207
209
< div className = { b ( 'search' ) } >
@@ -232,25 +234,28 @@ class Storage extends React.Component {
232
234
</ RadioButton >
233
235
< Label theme = "info" size = "m" > { `${
234
236
storageType === StorageTypes . groups ? 'Groups' : 'Nodes'
235
- } : ${ flatListStorageEntities . length } `} </ Label >
237
+ } : ${ ( showLoader ) ? '...' : flatListStorageEntities . length } `} </ Label >
236
238
</ div >
237
239
) ;
238
240
}
239
241
240
242
render ( ) {
241
243
const { loading, wasLoaded, error} = this . props ;
242
- if ( loading && ! wasLoaded ) {
243
- return this . renderLoader ( ) ;
244
- } else if ( error ) {
245
- return < div > { error . statusText } </ div > ;
246
- } else {
247
- return (
248
- < div className = { b ( ) } >
249
- { this . renderControls ( ) }
250
- { this . renderDataTable ( ) }
251
- </ div >
252
- ) ;
253
- }
244
+ const showLoader = loading && ! wasLoaded ;
245
+
246
+ return (
247
+ < div className = { b ( ) } >
248
+ { this . renderControls ( ) }
249
+ { error && (
250
+ < div > { error . statusText } </ div >
251
+ ) }
252
+ { showLoader ? (
253
+ this . renderLoader ( )
254
+ ) : (
255
+ this . renderDataTable ( )
256
+ ) }
257
+ </ div >
258
+ ) ;
254
259
}
255
260
}
256
261
0 commit comments