Skip to content

fix(UptimeViewer): do not show StartTime if DisconnectTime present #1864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/components/UptimeViewer/UptimeViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import {DefinitionList} from '@gravity-ui/uikit';

import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
Expand All @@ -17,33 +19,33 @@ interface NodeUptimeProps {

export function NodeUptime({StartTime, DisconnectTime}: NodeUptimeProps) {
let uptime: string | undefined;
let content: React.ReactNode = null;

if (DisconnectTime) {
uptime = getDowntimeFromDateFormatted(DisconnectTime);
content = (
<DefinitionList.Item key={'DisconnectTime'} name={i18n('disconnect-time')}>
{formatDateTime(DisconnectTime, {withTimeZone: true})}
</DefinitionList.Item>
);
} else if (StartTime) {
uptime = getUptimeFromDateFormatted(StartTime);
content = (
<DefinitionList.Item key={'StartTime'} name={i18n('start-time')}>
{formatDateTime(StartTime, {withTimeZone: true})}
</DefinitionList.Item>
);
}

if (!uptime) {
return EMPTY_DATA_PLACEHOLDER;
}

return (
<CellWithPopover
placement={['top', 'auto']}
content={
<DefinitionList responsive>
{StartTime ? (
<DefinitionList.Item key={'StartTime'} name={i18n('start-time')}>
{formatDateTime(StartTime, {withTimeZone: true})}
</DefinitionList.Item>
) : null}
{DisconnectTime ? (
<DefinitionList.Item key={'DisconnectTime'} name={i18n('disconnect-time')}>
{formatDateTime(DisconnectTime, {withTimeZone: true})}
</DefinitionList.Item>
) : null}
</DefinitionList>
}
Comment on lines -33 to -46
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I assumed, that if node is disconnected, there will be no StartTime in the response. However, StartTime may be cached somewhere on backend and we could receive both StartTime and DisconnectTime for disconnected node, in this case we have both values in the tooltip with different timestamps. After this fix StartTime will be in popover only if there is no DisconnectTime

disabled={!content}
content={<DefinitionList responsive>{content}</DefinitionList>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a case if content is null

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled popup if no content

>
{uptime}
</CellWithPopover>
Expand Down
Loading