Skip to content

Commit 7af1ed3

Browse files
fix(ObjectSummary): do not display CreateTime if CreateStep is 0 (#2018)
1 parent 29ae340 commit 7af1ed3

File tree

6 files changed

+49
-27
lines changed

6 files changed

+49
-27
lines changed

src/components/InfoViewer/formatters/common.ts

+2-1
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

+9-5
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

+10-3
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

+17-14
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

+6-4
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/utils/dataFormatters/dataFormatters.ts

+5
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)