-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109468 from maryliag/backport23.1-109164
release-23.1: ui: show warning when data is not old enough
- Loading branch information
Showing
14 changed files
with
150 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
pkg/ui/workspaces/cluster-ui/src/timeScaleDropdown/timeScaleLabel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import React, { useContext } from "react"; | ||
import moment from "moment-timezone"; | ||
import { TimeScale } from "./timeScaleTypes"; | ||
import { FormattedTimescale } from "./formattedTimeScale"; | ||
import classNames from "classnames/bind"; | ||
import timeScaleStyles from "../timeScaleDropdown/timeScale.module.scss"; | ||
import { Icon } from "@cockroachlabs/ui-components"; | ||
import { Tooltip } from "antd"; | ||
import "antd/lib/tooltip/style"; | ||
import { Timezone } from "src/timestamp"; | ||
import { dateFormat, timeFormat } from "./timeScaleDropdown"; | ||
import { TimezoneContext } from "src/contexts/timezoneContext"; | ||
import { toRoundedDateRange } from "./utils"; | ||
|
||
const timeScaleStylesCx = classNames.bind(timeScaleStyles); | ||
|
||
interface TimeScaleLabelProps { | ||
timeScale: TimeScale; | ||
requestTime: moment.Moment; | ||
oldestDataTime?: moment.Moment; | ||
} | ||
|
||
export const TimeScaleLabel: React.FC<TimeScaleLabelProps> = ({ | ||
timeScale, | ||
requestTime, | ||
oldestDataTime, | ||
}): React.ReactElement => { | ||
const period = ( | ||
<FormattedTimescale ts={timeScale} requestTime={moment(requestTime)} /> | ||
); | ||
const label = ( | ||
<> | ||
Showing aggregated stats from{" "} | ||
<span className={timeScaleStylesCx("bold")}>{period}</span> | ||
</> | ||
); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const [start, _] = toRoundedDateRange(timeScale); | ||
const showWarning = oldestDataTime && oldestDataTime.diff(start, "hours") > 1; | ||
const timezone = useContext(TimezoneContext); | ||
const oldestTz = moment(oldestDataTime)?.tz(timezone); | ||
const oldestLabel = ( | ||
<> | ||
{`SQL Stats are available since ${oldestTz?.format( | ||
dateFormat, | ||
)} ${oldestTz?.format(timeFormat)} `} | ||
<Timezone /> | ||
</> | ||
); | ||
|
||
const warning = ( | ||
<Tooltip placement="bottom" title={oldestLabel}> | ||
<Icon | ||
iconName="Caution" | ||
fill="warning" | ||
className={timeScaleStylesCx("warning-icon-area")} | ||
/> | ||
</Tooltip> | ||
); | ||
|
||
return ( | ||
<> | ||
{showWarning && warning} {label} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.