1- import React , { useEffect , useReducer } from 'react' ;
1+ import React , { ReactNode , useEffect , useReducer } from 'react' ;
22import { useDispatch , useSelector } from 'react-redux' ;
33import { Link } from 'react-router-dom' ;
44import cn from 'bem-cn-lite' ;
@@ -16,7 +16,7 @@ import CopyToClipboard from '../../../components/CopyToClipboard/CopyToClipboard
1616import InfoViewer from '../../../components/InfoViewer/InfoViewer' ;
1717import Icon from '../../../components/Icon/Icon' ;
1818
19- import type { EPathSubType , EPathType , TDirEntry } from '../../../types/api/schema' ;
19+ import { EPathSubType , EPathType , TDirEntry } from '../../../types/api/schema' ;
2020import { isColumnEntityType , isIndexTable , isTableType } from '../utils/schema' ;
2121
2222import {
@@ -151,14 +151,35 @@ function ObjectSummary(props: ObjectSummaryProps) {
151151 } ;
152152
153153 const renderObjectOverview = ( ) => {
154- const startTimeInMilliseconds = Number ( currentSchemaData ?. CreateStep ) ;
155- let createTime = '' ;
156- if ( startTimeInMilliseconds ) {
157- createTime = new Date ( startTimeInMilliseconds ) . toUTCString ( ) ;
154+ // verbose mapping to guarantee a correct render for new path types
155+ // TS will error when a new type is added but not mapped here
156+ const pathTypeToComponent : Record < EPathType , ( ( ) => ReactNode ) | undefined > = {
157+ [ EPathType . EPathTypeInvalid ] : undefined ,
158+ [ EPathType . EPathTypeDir ] : undefined ,
159+ [ EPathType . EPathTypeTable ] : undefined ,
160+ [ EPathType . EPathTypeSubDomain ] : undefined ,
161+ [ EPathType . EPathTypeTableIndex ] : undefined ,
162+ [ EPathType . EPathTypeExtSubDomain ] : undefined ,
163+ [ EPathType . EPathTypeColumnStore ] : undefined ,
164+ [ EPathType . EPathTypeColumnTable ] : undefined ,
165+ [ EPathType . EPathTypeCdcStream ] : ( ) => undefined ,
166+ } ;
167+
168+ let component = currentSchemaData ?. PathType && pathTypeToComponent [ currentSchemaData . PathType ] ?.( ) ;
169+
170+ if ( ! component ) {
171+ const startTimeInMilliseconds = Number ( currentSchemaData ?. CreateStep ) ;
172+ let createTime = '' ;
173+ if ( startTimeInMilliseconds ) {
174+ createTime = new Date ( startTimeInMilliseconds ) . toUTCString ( ) ;
175+ }
176+
177+ component = < InfoViewer info = { [ { label : 'Create time' , value : createTime } ] } /> ;
158178 }
179+
159180 return (
160181 < div className = { b ( 'overview-wrapper' ) } >
161- < InfoViewer info = { [ { label : 'Create time' , value : createTime } ] } />
182+ { component }
162183 </ div >
163184 ) ;
164185 } ;
0 commit comments