Repository navigation
fix: loading states unified across the app #3608
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| fix: show a neutral spinner while charts load | ||
|
|
||
| Chart tiles now show a spinner with "Loading Chart Data..." while a query is in | ||
| flight, including when the previous result was empty. Before, they kept showing | ||
| "No data found within time range." until the new query finished. Loaders now | ||
| default to a neutral gray instead of yellow. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { memo } from 'react'; | ||
| import cx from 'classnames'; | ||
| import { | ||
| Bar, | ||
| BarChart, | ||
|
|
@@ -9,7 +8,7 @@ import { | |
| XAxis, | ||
| YAxis, | ||
| } from 'recharts'; | ||
| import { Flex } from '@mantine/core'; | ||
| import { Flex, Loader } from '@mantine/core'; | ||
|
|
||
| import type { NumberFormat } from '@/types'; | ||
| import { useContentFontSize } from '@/useUserPreferences'; | ||
|
|
@@ -86,6 +85,7 @@ export const DBBarChart = (props: CategoricalChartProps) => { | |
| <ChartContainer title={props.title} toolbarItems={toolbarItems}> | ||
| {isLoading && !data ? ( | ||
| <div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
| <Loader size="xs" mr="xs" /> | ||
| Loading Chart Data... | ||
| </div> | ||
| ) : isError && error ? ( | ||
|
|
@@ -96,13 +96,11 @@ export const DBBarChart = (props: CategoricalChartProps) => { | |
| variant={props.errorVariant} | ||
| /> | ||
| ) : data?.data.length === 0 ? ( | ||
| <div | ||
| className={cx( | ||
| 'd-flex h-100 w-100 align-items-center justify-content-center text-muted', | ||
| { 'effect-pulse': isPlaceholderData }, | ||
| )} | ||
| > | ||
| No data found within time range. | ||
| <div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
| {isPlaceholderData && <Loader size="xs" mr="xs" />} | ||
| {isPlaceholderData | ||
| ? 'Loading Chart Data...' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — New loading copy uses Title Case The new strings 'Loading Chart Data...' break the REQUIRED rule "UI text: use sentence case". The PR description itself writes "Loading chart data...". Use 'Loading chart data...' in all the new branches. Also update the existing initial-loading branches and the test assertions that match on the old text. Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| : 'No data found within time range.'} | ||
| </div> | ||
| ) : ( | ||
| <Flex | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import { | |
| ChartConfigWithDateRange, | ||
| DisplayType, | ||
| } from '@hyperdx/common-utils/dist/types'; | ||
| import { Popover, Portal } from '@mantine/core'; | ||
| import { Loader, Popover, Portal } from '@mantine/core'; | ||
| import { | ||
| IconChartAreaLine, | ||
| IconChartBar, | ||
|
|
@@ -1088,6 +1088,7 @@ function DBTimeChartComponent({ | |
| <ChartContainer title={title} toolbarItems={toolbarItemsMemo}> | ||
| {isLoading && !data ? ( | ||
| <div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
| <Loader size="xs" mr="xs" /> | ||
| Loading Chart Data... | ||
| </div> | ||
| ) : isError ? ( | ||
|
|
@@ -1103,7 +1104,10 @@ function DBTimeChartComponent({ | |
| /> | ||
| ) : graphResults.length === 0 ? ( | ||
| <div className="d-flex h-100 w-100 align-items-center justify-content-center text-muted"> | ||
| No data found within time range. | ||
| {isLoadingOrPlaceholder && <Loader size="xs" mr="xs" />} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 major — Time chart can get stuck on "Loading Chart Data..." if the previous-period query fails The empty branch now keys off Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond |
||
| {isLoadingOrPlaceholder | ||
| ? 'Loading Chart Data...' | ||
| : 'No data found within time range.'} | ||
| </div> | ||
| ) : ( | ||
| <> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — Same loading/empty markup copied into 8 chart components
The same
<div className="d-flex h-100 ... text-muted"><Loader size="xs" mr="xs" />Loading Chart Data...</div>block and the matching isPlaceholderData ternary are now repeated in DBBarChart, DBHistogramChart, DBListBarChart, DBNumberChart, DBPieChart, DBTableChart, DBTimeChart and ServiceDashboardSlowestEventsTile (one copy has already drifted, see that finding). Move it into one sharedChartLoadingState/ChartEmptyState({ isLoading })component next toChartErrorState, and have every chart use it.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond