11import React from 'react' ;
22
33import { HelpPopover } from '@gravity-ui/components' ;
4- import { Tabs } from '@gravity-ui/uikit' ;
4+ import { Flex , Tabs } from '@gravity-ui/uikit' ;
55import qs from 'qs' ;
66import { Link , useLocation } from 'react-router-dom' ;
77import { StringParam , useQueryParam } from 'use-query-params' ;
@@ -12,14 +12,12 @@ import {toFormattedSize} from '../../../components/FormattedBytes/utils';
1212import { InfoViewer } from '../../../components/InfoViewer/InfoViewer' ;
1313import type { InfoViewerItem } from '../../../components/InfoViewer/InfoViewer' ;
1414import { LinkWithIcon } from '../../../components/LinkWithIcon/LinkWithIcon' ;
15- import { Loader } from '../../../components/Loader' ;
1615import SplitPane from '../../../components/SplitPane' ;
1716import routes , { createExternalUILink , createHref } from '../../../routes' ;
1817import { useGetSchemaQuery } from '../../../store/reducers/schema/schema' ;
1918import { TENANT_SUMMARY_TABS_IDS } from '../../../store/reducers/tenant/constants' ;
2019import { setSummaryTab } from '../../../store/reducers/tenant/tenant' ;
2120import { EPathSubType , EPathType } from '../../../types/api/schema' ;
22- import { cn } from '../../../utils/cn' ;
2321import {
2422 DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED ,
2523 DEFAULT_SIZE_TENANT_SUMMARY_KEY ,
@@ -32,10 +30,8 @@ import {
3230import { useTypedDispatch , useTypedSelector } from '../../../utils/hooks' ;
3331import { Acl } from '../Acl/Acl' ;
3432import { EntityTitle } from '../EntityTitle/EntityTitle' ;
35- import { SchemaTree } from '../Schema/SchemaTree/SchemaTree' ;
3633import { SchemaViewer } from '../Schema/SchemaViewer/SchemaViewer' ;
3734import { TENANT_INFO_TABS , TENANT_SCHEMA_TAB , TenantTabsGroups } from '../TenantPages' ;
38- import i18n from '../i18n' ;
3935import { getSummaryControls } from '../utils/controls' ;
4036import {
4137 PaneVisibilityActionTypes ,
@@ -44,12 +40,14 @@ import {
4440} from '../utils/paneVisibilityToggleHelpers' ;
4541import { isIndexTableType , isTableType } from '../utils/schema' ;
4642
43+ import { ObjectTree } from './ObjectTree' ;
44+ import { SchemaActions } from './SchemaActions' ;
45+ import i18n from './i18n' ;
46+ import { b } from './shared' ;
4747import { transformPath } from './transformPath' ;
4848
4949import './ObjectSummary.scss' ;
5050
51- const b = cn ( 'object-summary' ) ;
52-
5351const getTenantCommonInfoState = ( ) => {
5452 const collapsed = Boolean ( localStorage . getItem ( DEFAULT_IS_TENANT_COMMON_INFO_COLLAPSED ) ) ;
5553
@@ -113,24 +111,31 @@ export function ObjectSummary({
113111
114112 return (
115113 < 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 >
134139 </ div >
135140 ) ;
136141 } ;
@@ -143,21 +148,21 @@ export function ObjectSummary({
143148
144149 const overview : InfoViewerItem [ ] = [ ] ;
145150
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 / , '' ) } ) ;
147152
148153 if ( PathSubType !== EPathSubType . EPathSubTypeEmpty ) {
149154 overview . push ( {
150- label : i18n ( 'summary.subtype ' ) ,
155+ label : i18n ( 'field_subtype ' ) ,
151156 value : PathSubType ?. replace ( / ^ E P a t h S u b T y p e / , '' ) ,
152157 } ) ;
153158 }
154159
155- overview . push ( { label : i18n ( 'summary.id ' ) , value : PathId } ) ;
160+ overview . push ( { label : i18n ( 'field_id ' ) , value : PathId } ) ;
156161
157- overview . push ( { label : i18n ( 'summary.version ' ) , value : PathVersion } ) ;
162+ overview . push ( { label : i18n ( 'field_version ' ) , value : PathVersion } ) ;
158163
159164 overview . push ( {
160- label : i18n ( 'summary.created ' ) ,
165+ label : i18n ( 'field_created ' ) ,
161166 value : formatDateTime ( CreateStep ) ,
162167 } ) ;
163168
@@ -168,11 +173,11 @@ export function ObjectSummary({
168173
169174 overview . push (
170175 {
171- label : i18n ( 'summary.data -size' ) ,
176+ label : i18n ( 'field_data -size' ) ,
172177 value : toFormattedSize ( DataSize ) ,
173178 } ,
174179 {
175- label : i18n ( 'summary.row -count' ) ,
180+ label : i18n ( 'field_row -count' ) ,
176181 value : formatNumber ( RowCount ) ,
177182 } ,
178183 ) ;
@@ -182,11 +187,11 @@ export function ObjectSummary({
182187
183188 const getDatabaseOverview = ( ) => [
184189 {
185- label : i18n ( 'summary.paths ' ) ,
190+ label : i18n ( 'field_paths ' ) ,
186191 value : PathDescription ?. DomainDescription ?. PathsInside ,
187192 } ,
188193 {
189- label : i18n ( 'summary.shards ' ) ,
194+ label : i18n ( 'field_shards ' ) ,
190195 value : PathDescription ?. DomainDescription ?. ShardsInside ,
191196 } ,
192197 ] ;
@@ -196,7 +201,7 @@ export function ObjectSummary({
196201 [ EPathType . EPathTypeDir ] : undefined ,
197202 [ EPathType . EPathTypeTable ] : ( ) => [
198203 {
199- label : i18n ( 'summary.partitions ' ) ,
204+ label : i18n ( 'field_partitions ' ) ,
200205 value : PathDescription ?. TablePartitions ?. length ,
201206 } ,
202207 ] ,
@@ -205,13 +210,13 @@ export function ObjectSummary({
205210 [ EPathType . EPathTypeExtSubDomain ] : getDatabaseOverview ,
206211 [ EPathType . EPathTypeColumnStore ] : ( ) => [
207212 {
208- label : i18n ( 'summary.partitions ' ) ,
213+ label : i18n ( 'field_partitions ' ) ,
209214 value : PathDescription ?. ColumnStoreDescription ?. ColumnShards ?. length ,
210215 } ,
211216 ] ,
212217 [ EPathType . EPathTypeColumnTable ] : ( ) => [
213218 {
214- label : i18n ( 'summary.partitions ' ) ,
219+ label : i18n ( 'field_partitions ' ) ,
215220 value : PathDescription ?. ColumnTableDescription ?. Sharding ?. ColumnShards ?. length ,
216221 } ,
217222 ] ,
@@ -220,11 +225,11 @@ export function ObjectSummary({
220225
221226 return [
222227 {
223- label : i18n ( 'summary.mode ' ) ,
228+ label : i18n ( 'field_mode ' ) ,
224229 value : Mode ?. replace ( / ^ E C d c S t r e a m M o d e / , '' ) ,
225230 } ,
226231 {
227- label : i18n ( 'summary.format ' ) ,
232+ label : i18n ( 'field_format ' ) ,
228233 value : Format ?. replace ( / ^ E C d c S t r e a m F o r m a t / , '' ) ,
229234 } ,
230235 ] ;
@@ -235,11 +240,11 @@ export function ObjectSummary({
235240
236241 return [
237242 {
238- label : i18n ( 'summary.partitions ' ) ,
243+ label : i18n ( 'field_partitions ' ) ,
239244 value : pqGroup ?. Partitions ?. length ,
240245 } ,
241246 {
242- label : i18n ( 'summary.retention ' ) ,
247+ label : i18n ( 'field_retention ' ) ,
243248 value : value && formatSecondsToHours ( value ) ,
244249 } ,
245250 ] ;
@@ -256,9 +261,9 @@ export function ObjectSummary({
256261 const dataSourceName = DataSourcePath ?. match ( / ( [ ^ / ] * ) \/ * $ / ) ?. [ 1 ] || '' ;
257262
258263 return [
259- { label : i18n ( 'summary.source -type' ) , value : SourceType } ,
264+ { label : i18n ( 'field_source -type' ) , value : SourceType } ,
260265 {
261- label : i18n ( 'summary.data -source' ) ,
266+ label : i18n ( 'field_data -source' ) ,
262267 value : DataSourcePath && (
263268 < span title = { DataSourcePath } >
264269 < LinkWithIcon title = { dataSourceName || '' } url = { pathToDataSource } />
@@ -269,7 +274,7 @@ export function ObjectSummary({
269274 } ,
270275 [ EPathType . EPathTypeExternalDataSource ] : ( ) => [
271276 {
272- label : i18n ( 'summary.source -type' ) ,
277+ label : i18n ( 'field_source -type' ) ,
273278 value : PathDescription ?. ExternalDataSourceDescription ?. SourceType ,
274279 } ,
275280 ] ,
@@ -283,7 +288,7 @@ export function ObjectSummary({
283288
284289 return [
285290 {
286- label : i18n ( 'summary.state ' ) ,
291+ label : i18n ( 'field_state ' ) ,
287292 value : < AsyncReplicationState state = { state } /> ,
288293 } ,
289294 ] ;
@@ -336,7 +341,7 @@ export function ObjectSummary({
336341 < ClipboardButton
337342 text = { path }
338343 view = "flat-secondary"
339- title = { i18n ( 'summary.copySchemaPath ' ) }
344+ title = { i18n ( 'action_copySchemaPath ' ) }
340345 />
341346 < PaneVisibilityToggleButtons
342347 onCollapse = { onCollapseInfoHandler }
@@ -411,41 +416,3 @@ export function ObjectSummary({
411416
412417 return renderContent ( ) ;
413418}
414-
415- function ObjectTree ( { tenantName, path} : { tenantName : string ; path ?: string } ) {
416- const { data : tenantData = { } , isLoading} = useGetSchemaQuery ( {
417- path : tenantName ,
418- database : tenantName ,
419- } ) ;
420- const pathData = tenantData ?. PathDescription ?. Self ;
421-
422- const [ , setCurrentPath ] = useQueryParam ( 'schema' , StringParam ) ;
423-
424- if ( ! pathData && isLoading ) {
425- // If Loader isn't wrapped with div, SplitPane doesn't calculate panes height correctly
426- return (
427- < div >
428- < Loader />
429- </ div >
430- ) ;
431- }
432-
433- return (
434- < div className = { b ( 'tree-wrapper' ) } >
435- < div className = { b ( 'tree-header' ) } > { i18n ( 'summary.navigation' ) } </ div >
436- < div className = { b ( 'tree' ) } >
437- { pathData ? (
438- < SchemaTree
439- rootPath = { tenantName }
440- // for the root pathData.Name contains the same string as tenantName,
441- // but without the leading slash
442- rootName = { pathData . Name || tenantName }
443- rootType = { pathData . PathType }
444- currentPath = { path }
445- onActivePathUpdate = { setCurrentPath }
446- />
447- ) : null }
448- </ div >
449- </ div >
450- ) ;
451- }
0 commit comments