@@ -3,10 +3,11 @@ import PropTypes from 'prop-types';
33import { connect } from 'react-redux' ;
44import cn from 'bem-cn-lite' ;
55import DataTable from '@yandex-cloud/react-data-table' ;
6- import { Loader , RadioButton , Label } from '@yandex-cloud/uikit' ;
6+ import { RadioButton , Label } from '@yandex-cloud/uikit' ;
77
88import StorageFilter from './StorageFilter/StorageFilter' ;
99import { AutoFetcher } from '../../utils/autofetcher' ;
10+ import { TableSkeleton } from '../../components/TableSkeleton/TableSkeleton' ;
1011
1112import {
1213 getStorageInfo ,
@@ -68,17 +69,14 @@ class Storage extends React.Component {
6869 storageType,
6970 setHeader,
7071 getNodesList,
71- getStorageInfo,
7272 } = this . props ;
7373
7474 this . autofetcher = new AutoFetcher ( ) ;
7575 getNodesList ( ) ;
7676 if ( tenant || nodeId ) {
7777 setVisibleEntities ( VisibleEntities . All ) ;
78- getStorageInfo ( {
79- tenant,
78+ this . getStorageInfo ( {
8079 filter : FILTER_OPTIONS . All ,
81- nodeId,
8280 type : storageType ,
8381 } ) ;
8482 } else {
@@ -88,16 +86,12 @@ class Storage extends React.Component {
8886 link : createHref ( routes . cluster , { activeTab : CLUSTER_PAGES . storage . id } ) ,
8987 } ,
9088 ] ) ;
91- getStorageInfo ( {
92- tenant,
93- nodeId,
89+ this . getStorageInfo ( {
9490 filter : FILTER_OPTIONS . Missing ,
9591 type : storageType ,
9692 } ) ;
9793 this . autofetcher . fetch ( ( ) =>
98- getStorageInfo ( {
99- tenant,
100- nodeId,
94+ this . getStorageInfo ( {
10195 filter : FILTER_OPTIONS . Missing ,
10296 type : storageType ,
10397 } ) ,
@@ -107,30 +101,23 @@ class Storage extends React.Component {
107101
108102 componentDidUpdate ( prevProps ) {
109103 const {
110- tenant,
111104 visibleEntities,
112- getStorageInfo,
113- nodeId,
114105 storageType,
115106 autorefresh,
116107 database,
117108 } = this . props ;
118109
119110 const startFetch = ( ) => {
120- getStorageInfo ( {
121- tenant,
111+ this . getStorageInfo ( {
122112 filter : FILTER_OPTIONS [ visibleEntities ] ,
123- nodeId,
124113 type : storageType ,
125114 } ) ;
126115
127116 this . autofetcher . stop ( ) ;
128117 this . autofetcher . start ( ) ;
129118 this . autofetcher . fetch ( ( ) =>
130- getStorageInfo ( {
131- tenant,
119+ this . getStorageInfo ( {
132120 filter : FILTER_OPTIONS [ visibleEntities ] ,
133- nodeId,
134121 type : storageType ,
135122 } ) ,
136123 ) ;
@@ -157,11 +144,25 @@ class Storage extends React.Component {
157144 this . props . setInitialState ( ) ;
158145 }
159146
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+
160163 renderLoader ( ) {
161164 return (
162- < div className = { b ( 'loader' ) } >
163- < Loader size = "m" />
164- </ div >
165+ < TableSkeleton className = { b ( 'loader' ) } />
165166 ) ;
166167 }
167168
@@ -200,8 +201,9 @@ class Storage extends React.Component {
200201 } ;
201202
202203 renderControls ( ) {
203- const { setStorageFilter, visibleEntities, storageType, flatListStorageEntities} =
204+ const { setStorageFilter, visibleEntities, storageType, flatListStorageEntities, loading , wasLoaded } =
204205 this . props ;
206+ const showLoader = loading && ! wasLoaded ;
205207 return (
206208 < div className = { b ( 'controls' ) } >
207209 < div className = { b ( 'search' ) } >
@@ -232,25 +234,28 @@ class Storage extends React.Component {
232234 </ RadioButton >
233235 < Label theme = "info" size = "m" > { `${
234236 storageType === StorageTypes . groups ? 'Groups' : 'Nodes'
235- } : ${ flatListStorageEntities . length } `} </ Label >
237+ } : ${ ( showLoader ) ? '...' : flatListStorageEntities . length } `} </ Label >
236238 </ div >
237239 ) ;
238240 }
239241
240242 render ( ) {
241243 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+ ) ;
254259 }
255260}
256261
0 commit comments