1
1
import React from 'react' ;
2
2
3
3
import { HelpPopover } from '@gravity-ui/components' ;
4
- import { Tabs } from '@gravity-ui/uikit' ;
4
+ import { Flex , Tabs } from '@gravity-ui/uikit' ;
5
5
import qs from 'qs' ;
6
6
import { Link , useLocation } from 'react-router-dom' ;
7
7
import { StringParam , useQueryParam } from 'use-query-params' ;
@@ -12,14 +12,12 @@ import {toFormattedSize} from '../../../components/FormattedBytes/utils';
12
12
import { InfoViewer } from '../../../components/InfoViewer/InfoViewer' ;
13
13
import type { InfoViewerItem } from '../../../components/InfoViewer/InfoViewer' ;
14
14
import { LinkWithIcon } from '../../../components/LinkWithIcon/LinkWithIcon' ;
15
- import { Loader } from '../../../components/Loader' ;
16
15
import SplitPane from '../../../components/SplitPane' ;
17
16
import routes , { createExternalUILink , createHref } from '../../../routes' ;
18
17
import { useGetSchemaQuery } from '../../../store/reducers/schema/schema' ;
19
18
import { TENANT_SUMMARY_TABS_IDS } from '../../../store/reducers/tenant/constants' ;
20
19
import { setSummaryTab } from '../../../store/reducers/tenant/tenant' ;
21
20
import { EPathSubType , EPathType } from '../../../types/api/schema' ;
22
- import { cn } from '../../../utils/cn' ;
23
21
import {
24
22
DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED ,
25
23
DEFAULT_SIZE_TENANT_SUMMARY_KEY ,
@@ -32,10 +30,8 @@ import {
32
30
import { useTypedDispatch , useTypedSelector } from '../../../utils/hooks' ;
33
31
import { Acl } from '../Acl/Acl' ;
34
32
import { EntityTitle } from '../EntityTitle/EntityTitle' ;
35
- import { SchemaTree } from '../Schema/SchemaTree/SchemaTree' ;
36
33
import { SchemaViewer } from '../Schema/SchemaViewer/SchemaViewer' ;
37
34
import { TENANT_INFO_TABS , TENANT_SCHEMA_TAB , TenantTabsGroups } from '../TenantPages' ;
38
- import i18n from '../i18n' ;
39
35
import { getSummaryControls } from '../utils/controls' ;
40
36
import {
41
37
PaneVisibilityActionTypes ,
@@ -44,12 +40,14 @@ import {
44
40
} from '../utils/paneVisibilityToggleHelpers' ;
45
41
import { isIndexTableType , isTableType } from '../utils/schema' ;
46
42
43
+ import { ObjectTree } from './ObjectTree' ;
44
+ import { SchemaActions } from './SchemaActions' ;
45
+ import i18n from './i18n' ;
46
+ import { b } from './shared' ;
47
47
import { transformPath } from './transformPath' ;
48
48
49
49
import './ObjectSummary.scss' ;
50
50
51
- const b = cn ( 'object-summary' ) ;
52
-
53
51
const getTenantCommonInfoState = ( ) => {
54
52
const collapsed = Boolean ( localStorage . getItem ( DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED ) ) ;
55
53
@@ -113,24 +111,31 @@ export function ObjectSummary({
113
111
114
112
return (
115
113
< div className = { b ( 'tabs' ) } >
116
- < Tabs
117
- size = "l"
118
- items = { tabsItems }
119
- activeTab = { summaryTab }
120
- wrapTo = { ( { id} , node ) => {
121
- const path = createHref ( routes . tenant , undefined , {
122
- ...queryParams ,
123
- name : tenantName ,
124
- [ TenantTabsGroups . summaryTab ] : id ,
125
- } ) ;
126
- return (
127
- < Link to = { path } key = { id } className = { b ( 'tab' ) } >
128
- { node }
129
- </ Link >
130
- ) ;
131
- } }
132
- allowNotSelected
133
- />
114
+ < Flex
115
+ className = { b ( 'tabs-inner' ) }
116
+ justifyContent = "space-between"
117
+ alignItems = "center"
118
+ >
119
+ < Tabs
120
+ size = "l"
121
+ items = { tabsItems }
122
+ activeTab = { summaryTab }
123
+ wrapTo = { ( { id} , node ) => {
124
+ const path = createHref ( routes . tenant , undefined , {
125
+ ...queryParams ,
126
+ name : tenantName ,
127
+ [ TenantTabsGroups . summaryTab ] : id ,
128
+ } ) ;
129
+ return (
130
+ < Link to = { path } key = { id } className = { b ( 'tab' ) } >
131
+ { node }
132
+ </ Link >
133
+ ) ;
134
+ } }
135
+ allowNotSelected
136
+ />
137
+ { summaryTab === TENANT_SUMMARY_TABS_IDS . schema && < SchemaActions /> }
138
+ </ Flex >
134
139
</ div >
135
140
) ;
136
141
} ;
@@ -143,21 +148,21 @@ export function ObjectSummary({
143
148
144
149
const overview : InfoViewerItem [ ] = [ ] ;
145
150
146
- overview . push ( { label : i18n ( 'summary.type ' ) , value : PathType ?. replace ( / ^ E P a t h T y p e / , '' ) } ) ;
151
+ overview . push ( { label : i18n ( 'field_type ' ) , value : PathType ?. replace ( / ^ E P a t h T y p e / , '' ) } ) ;
147
152
148
153
if ( PathSubType !== EPathSubType . EPathSubTypeEmpty ) {
149
154
overview . push ( {
150
- label : i18n ( 'summary.subtype ' ) ,
155
+ label : i18n ( 'field_subtype ' ) ,
151
156
value : PathSubType ?. replace ( / ^ E P a t h S u b T y p e / , '' ) ,
152
157
} ) ;
153
158
}
154
159
155
- overview . push ( { label : i18n ( 'summary.id ' ) , value : PathId } ) ;
160
+ overview . push ( { label : i18n ( 'field_id ' ) , value : PathId } ) ;
156
161
157
- overview . push ( { label : i18n ( 'summary.version ' ) , value : PathVersion } ) ;
162
+ overview . push ( { label : i18n ( 'field_version ' ) , value : PathVersion } ) ;
158
163
159
164
overview . push ( {
160
- label : i18n ( 'summary.created ' ) ,
165
+ label : i18n ( 'field_created ' ) ,
161
166
value : formatDateTime ( CreateStep ) ,
162
167
} ) ;
163
168
@@ -168,11 +173,11 @@ export function ObjectSummary({
168
173
169
174
overview . push (
170
175
{
171
- label : i18n ( 'summary.data -size' ) ,
176
+ label : i18n ( 'field_data -size' ) ,
172
177
value : toFormattedSize ( DataSize ) ,
173
178
} ,
174
179
{
175
- label : i18n ( 'summary.row -count' ) ,
180
+ label : i18n ( 'field_row -count' ) ,
176
181
value : formatNumber ( RowCount ) ,
177
182
} ,
178
183
) ;
@@ -196,11 +201,11 @@ export function ObjectSummary({
196
201
197
202
return [
198
203
{
199
- label : i18n ( 'summary.paths ' ) ,
204
+ label : i18n ( 'field_paths ' ) ,
200
205
value : paths ,
201
206
} ,
202
207
{
203
- label : i18n ( 'summary.shards ' ) ,
208
+ label : i18n ( 'field_shards ' ) ,
204
209
value : shards ,
205
210
} ,
206
211
] ;
@@ -211,7 +216,7 @@ export function ObjectSummary({
211
216
[ EPathType . EPathTypeDir ] : undefined ,
212
217
[ EPathType . EPathTypeTable ] : ( ) => [
213
218
{
214
- label : i18n ( 'summary.partitions ' ) ,
219
+ label : i18n ( 'field_partitions ' ) ,
215
220
value : PathDescription ?. TablePartitions ?. length ,
216
221
} ,
217
222
] ,
@@ -220,13 +225,13 @@ export function ObjectSummary({
220
225
[ EPathType . EPathTypeExtSubDomain ] : getDatabaseOverview ,
221
226
[ EPathType . EPathTypeColumnStore ] : ( ) => [
222
227
{
223
- label : i18n ( 'summary.partitions ' ) ,
228
+ label : i18n ( 'field_partitions ' ) ,
224
229
value : PathDescription ?. ColumnStoreDescription ?. ColumnShards ?. length ,
225
230
} ,
226
231
] ,
227
232
[ EPathType . EPathTypeColumnTable ] : ( ) => [
228
233
{
229
- label : i18n ( 'summary.partitions ' ) ,
234
+ label : i18n ( 'field_partitions ' ) ,
230
235
value : PathDescription ?. ColumnTableDescription ?. Sharding ?. ColumnShards ?. length ,
231
236
} ,
232
237
] ,
@@ -235,11 +240,11 @@ export function ObjectSummary({
235
240
236
241
return [
237
242
{
238
- label : i18n ( 'summary.mode ' ) ,
243
+ label : i18n ( 'field_mode ' ) ,
239
244
value : Mode ?. replace ( / ^ E C d c S t r e a m M o d e / , '' ) ,
240
245
} ,
241
246
{
242
- label : i18n ( 'summary.format ' ) ,
247
+ label : i18n ( 'field_format ' ) ,
243
248
value : Format ?. replace ( / ^ E C d c S t r e a m F o r m a t / , '' ) ,
244
249
} ,
245
250
] ;
@@ -250,11 +255,11 @@ export function ObjectSummary({
250
255
251
256
return [
252
257
{
253
- label : i18n ( 'summary.partitions ' ) ,
258
+ label : i18n ( 'field_partitions ' ) ,
254
259
value : pqGroup ?. Partitions ?. length ,
255
260
} ,
256
261
{
257
- label : i18n ( 'summary.retention ' ) ,
262
+ label : i18n ( 'field_retention ' ) ,
258
263
value : value && formatSecondsToHours ( value ) ,
259
264
} ,
260
265
] ;
@@ -271,9 +276,9 @@ export function ObjectSummary({
271
276
const dataSourceName = DataSourcePath ?. match ( / ( [ ^ / ] * ) \/ * $ / ) ?. [ 1 ] || '' ;
272
277
273
278
return [
274
- { label : i18n ( 'summary.source -type' ) , value : SourceType } ,
279
+ { label : i18n ( 'field_source -type' ) , value : SourceType } ,
275
280
{
276
- label : i18n ( 'summary.data -source' ) ,
281
+ label : i18n ( 'field_data -source' ) ,
277
282
value : DataSourcePath && (
278
283
< span title = { DataSourcePath } >
279
284
< LinkWithIcon title = { dataSourceName || '' } url = { pathToDataSource } />
@@ -284,7 +289,7 @@ export function ObjectSummary({
284
289
} ,
285
290
[ EPathType . EPathTypeExternalDataSource ] : ( ) => [
286
291
{
287
- label : i18n ( 'summary.source -type' ) ,
292
+ label : i18n ( 'field_source -type' ) ,
288
293
value : PathDescription ?. ExternalDataSourceDescription ?. SourceType ,
289
294
} ,
290
295
] ,
@@ -298,7 +303,7 @@ export function ObjectSummary({
298
303
299
304
return [
300
305
{
301
- label : i18n ( 'summary.state ' ) ,
306
+ label : i18n ( 'field_state ' ) ,
302
307
value : < AsyncReplicationState state = { state } /> ,
303
308
} ,
304
309
] ;
@@ -351,7 +356,7 @@ export function ObjectSummary({
351
356
< ClipboardButton
352
357
text = { path }
353
358
view = "flat-secondary"
354
- title = { i18n ( 'summary.copySchemaPath ' ) }
359
+ title = { i18n ( 'action_copySchemaPath ' ) }
355
360
/>
356
361
< PaneVisibilityToggleButtons
357
362
onCollapse = { onCollapseInfoHandler }
@@ -426,41 +431,3 @@ export function ObjectSummary({
426
431
427
432
return renderContent ( ) ;
428
433
}
429
-
430
- function ObjectTree ( { tenantName, path} : { tenantName : string ; path ?: string } ) {
431
- const { data : tenantData = { } , isLoading} = useGetSchemaQuery ( {
432
- path : tenantName ,
433
- database : tenantName ,
434
- } ) ;
435
- const pathData = tenantData ?. PathDescription ?. Self ;
436
-
437
- const [ , setCurrentPath ] = useQueryParam ( 'schema' , StringParam ) ;
438
-
439
- if ( ! pathData && isLoading ) {
440
- // If Loader isn't wrapped with div, SplitPane doesn't calculate panes height correctly
441
- return (
442
- < div >
443
- < Loader />
444
- </ div >
445
- ) ;
446
- }
447
-
448
- return (
449
- < div className = { b ( 'tree-wrapper' ) } >
450
- < div className = { b ( 'tree-header' ) } > { i18n ( 'summary.navigation' ) } </ div >
451
- < div className = { b ( 'tree' ) } >
452
- { pathData ? (
453
- < SchemaTree
454
- rootPath = { tenantName }
455
- // for the root pathData.Name contains the same string as tenantName,
456
- // but without the leading slash
457
- rootName = { pathData . Name || tenantName }
458
- rootType = { pathData . PathType }
459
- currentPath = { path }
460
- onActivePathUpdate = { setCurrentPath }
461
- />
462
- ) : null }
463
- </ div >
464
- </ div >
465
- ) ;
466
- }
0 commit comments