Skip to content

Commit 23fad9f

Browse files
authored
Merge branch 'main' into astandrik.1984
2 parents 866eeb4 + 7af1ed3 commit 23fad9f

File tree

7 files changed

+66
-41
lines changed

7 files changed

+66
-41
lines changed

src/components/InfoViewer/formatters/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import type {TDirEntry} from '../../../types/api/schema';
2+
import {EMPTY_DATA_PLACEHOLDER} from '../../../utils/constants';
23
import {formatDateTime} from '../../../utils/dataFormatters/dataFormatters';
34
import i18n from '../i18n';
45
import {createInfoFormatter} from '../utils';
56

67
export const formatCommonItem = createInfoFormatter<TDirEntry>({
78
values: {
89
PathType: (value) => value?.substring('EPathType'.length),
9-
CreateStep: formatDateTime,
10+
CreateStep: (value) => formatDateTime(value, {defaultValue: EMPTY_DATA_PLACEHOLDER}),
1011
},
1112
labels: {
1213
PathType: i18n('common.type'),

src/containers/Tenant/Diagnostics/Overview/ChangefeedInfo/ChangefeedInfo.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ const prepareChangefeedInfo = (
2121

2222
const {Mode, Format} = streamDescription || {};
2323

24-
const created = formatCommonItem(
25-
'CreateStep',
26-
changefeedData?.PathDescription?.Self?.CreateStep,
27-
);
2824
const changefeedInfo = formatObject(formatCdcStreamItem, {
2925
Mode,
3026
Format,
3127
});
3228
const topicInfo = prepareTopicSchemaInfo(topicData);
3329

34-
return [created, ...changefeedInfo, ...topicInfo];
30+
const info = [...changefeedInfo, ...topicInfo];
31+
32+
const createStep = changefeedData?.PathDescription?.Self?.CreateStep;
33+
34+
if (Number(createStep)) {
35+
info.unshift(formatCommonItem('CreateStep', createStep));
36+
}
37+
38+
return info;
3539
};
3640

3741
interface ChangefeedProps {

src/containers/Tenant/Info/ExternalDataSource/ExternalDataSource.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ import './ExternalDataSource.scss';
1111

1212
const b = cn('ydb-external-data-source-info');
1313

14-
const prepareExternalDataSourceSummary = (data: TEvDescribeSchemeResult): InfoViewerItem[] => {
15-
return [
14+
const prepareExternalDataSourceSummary = (data: TEvDescribeSchemeResult) => {
15+
const info: InfoViewerItem[] = [
1616
{
1717
label: i18n('external-objects.source-type'),
1818
value: data.PathDescription?.ExternalDataSourceDescription?.SourceType,
1919
},
20-
formatCommonItem('CreateStep', data.PathDescription?.Self?.CreateStep),
2120
];
21+
22+
const createStep = data.PathDescription?.Self?.CreateStep;
23+
24+
if (Number(createStep)) {
25+
info.push(formatCommonItem('CreateStep', data.PathDescription?.Self?.CreateStep));
26+
}
27+
28+
return info;
2229
};
2330

2431
const prepareExternalDataSourceInfo = (data: TEvDescribeSchemeResult): InfoViewerItem[] => {

src/containers/Tenant/Info/ExternalTable/ExternalTable.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,30 @@ import './ExternalTable.scss';
1515

1616
const b = cn('ydb-external-table-info');
1717

18-
const prepareExternalTableSummary = (
19-
data: TEvDescribeSchemeResult,
20-
pathToDataSource: string,
21-
): InfoViewerItem[] => {
18+
const prepareExternalTableSummary = (data: TEvDescribeSchemeResult, pathToDataSource: string) => {
2219
const {CreateStep} = data.PathDescription?.Self || {};
2320
const {SourceType, DataSourcePath} = data.PathDescription?.ExternalTableDescription || {};
2421

2522
const dataSourceName = DataSourcePath?.split('/').pop();
2623

27-
return [
24+
const info: InfoViewerItem[] = [
2825
{label: i18n('external-objects.source-type'), value: SourceType},
29-
formatCommonItem('CreateStep', CreateStep),
30-
{
31-
label: i18n('external-objects.data-source'),
32-
value: DataSourcePath && (
33-
<span title={DataSourcePath}>
34-
<LinkWithIcon title={dataSourceName || ''} url={pathToDataSource} />
35-
</span>
36-
),
37-
},
3826
];
27+
28+
if (Number(CreateStep)) {
29+
info.push(formatCommonItem('CreateStep', CreateStep));
30+
}
31+
32+
info.push({
33+
label: i18n('external-objects.data-source'),
34+
value: DataSourcePath && (
35+
<span title={DataSourcePath}>
36+
<LinkWithIcon title={dataSourceName || ''} url={pathToDataSource} />
37+
</span>
38+
),
39+
});
40+
41+
return info;
3942
};
4043

4144
const prepareExternalTableInfo = (

src/containers/Tenant/ObjectSummary/ObjectSummary.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ export function ObjectSummary({
167167

168168
overview.push({name: i18n('field_version'), content: PathVersion});
169169

170-
overview.push({
171-
name: i18n('field_created'),
172-
content: formatDateTime(CreateStep),
173-
});
170+
if (Number(CreateStep)) {
171+
overview.push({
172+
name: i18n('field_created'),
173+
content: formatDateTime(CreateStep),
174+
});
175+
}
174176

175177
const {PathDescription} = currentObjectData;
176178

src/containers/Tenant/Schema/SchemaViewer/SchemaViewer.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
22

3-
import {skipToken} from '@reduxjs/toolkit/query';
4-
53
import {ResizeableDataTable} from '../../../../components/ResizeableDataTable/ResizeableDataTable';
64
import {TableSkeleton} from '../../../../components/TableSkeleton/TableSkeleton';
75
import {overviewApi} from '../../../../store/reducers/overview/overview';
@@ -42,23 +40,28 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
4240
// Refresh table only in Diagnostics
4341
const pollingInterval = extended ? autoRefreshInterval : undefined;
4442

45-
const {currentData: schemaData, isLoading: loading} = overviewApi.useGetOverviewQuery(
46-
{path, database: tenantName},
47-
{pollingInterval},
48-
);
49-
50-
const viewSchemaRequestParams = isViewType(type) ? {path, database: tenantName} : skipToken;
51-
52-
const {data: viewColumnsData, isLoading: isViewSchemaLoading} =
53-
viewSchemaApi.useGetViewSchemaQuery(viewSchemaRequestParams, {pollingInterval});
43+
const {currentData: tableSchemaData, isFetching: isTableSchemaFetching} =
44+
overviewApi.useGetOverviewQuery(
45+
{path, database: tenantName},
46+
{pollingInterval, skip: isViewType(type)},
47+
);
48+
const {currentData: viewColumnsData, isFetching: isViewSchemaFetching} =
49+
viewSchemaApi.useGetViewSchemaQuery(
50+
{path, database: tenantName},
51+
{pollingInterval, skip: !isViewType(type)},
52+
);
53+
54+
const loading =
55+
(isViewSchemaFetching && viewColumnsData === undefined) ||
56+
(isTableSchemaFetching && tableSchemaData === undefined);
5457

5558
const tableData = React.useMemo(() => {
5659
if (isViewType(type)) {
5760
return prepareViewSchema(viewColumnsData);
5861
}
5962

60-
return prepareSchemaData(type, schemaData);
61-
}, [schemaData, type, viewColumnsData]);
63+
return prepareSchemaData(type, tableSchemaData);
64+
}, [tableSchemaData, type, viewColumnsData]);
6265

6366
const hasAutoIncrement = React.useMemo(() => {
6467
return tableData.some((i) => i.autoIncrement);
@@ -85,7 +88,7 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
8588
return [];
8689
}, [type, extended, hasAutoIncrement, hasDefaultValue, tableData]);
8790

88-
if (loading || isViewSchemaLoading) {
91+
if (loading) {
8992
return <TableSkeleton />;
9093
}
9194

src/utils/dataFormatters/dataFormatters.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ export const formatDateTime = (
215215
value?: number | string,
216216
{withTimeZone, defaultValue = ''}: {withTimeZone?: boolean; defaultValue?: string} = {},
217217
) => {
218+
// prevent 1970-01-01 03:00
219+
if (!Number(value)) {
220+
return defaultValue;
221+
}
222+
218223
const tz = withTimeZone ? ' z' : '';
219224
const formattedData = dateTimeParse(Number(value))?.format(`YYYY-MM-DD HH:mm${tz}`);
220225

0 commit comments

Comments
 (0)