-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: show more information when loading chart #27255
Changes from all commits
35ecd28
55f38de
aa12368
410c1c9
8916010
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 |
---|---|---|
|
@@ -128,6 +128,20 @@ const Styles = styled.div` | |
} | ||
`; | ||
|
||
const LoadingDiv = styled.div` | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
`; | ||
|
||
const MessageSpan = styled.span` | ||
display: block; | ||
margin: ${({ theme }) => theme.gridUnit * 4}px auto; | ||
width: fit-content; | ||
color: ${({ theme }) => theme.colors.grayscale.base}; | ||
`; | ||
|
||
const MonospaceDiv = styled.div` | ||
font-family: ${({ theme }) => theme.typography.families.monospace}; | ||
word-break: break-word; | ||
|
@@ -232,16 +246,49 @@ class Chart extends React.PureComponent { | |
); | ||
} | ||
|
||
renderSpinner(databaseName) { | ||
const message = databaseName | ||
? t('Waiting on %s', databaseName) | ||
: t('Waiting on database...'); | ||
|
||
return ( | ||
<LoadingDiv> | ||
<Loading position="inline-centered" /> | ||
<MessageSpan>{message}</MessageSpan> | ||
</LoadingDiv> | ||
); | ||
} | ||
|
||
renderChartContainer() { | ||
return ( | ||
<div className="slice_container" data-test="slice-container"> | ||
{this.props.isInView || | ||
!isFeatureEnabled(FeatureFlag.DashboardVirtualization) || | ||
isCurrentUserBot() ? ( | ||
<ChartRenderer | ||
{...this.props} | ||
source={this.props.dashboardId ? 'dashboard' : 'explore'} | ||
data-test={this.props.vizType} | ||
/> | ||
) : ( | ||
<Loading /> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
const { | ||
height, | ||
chartAlert, | ||
chartStatus, | ||
datasource, | ||
errorMessage, | ||
chartIsStale, | ||
queriesResponse = [], | ||
width, | ||
} = this.props; | ||
const databaseName = datasource?.database?.name; | ||
|
||
const isLoading = chartStatus === 'loading'; | ||
this.renderContainerStartTime = Logger.getTimestamp(); | ||
|
@@ -297,20 +344,9 @@ class Chart extends React.PureComponent { | |
height={height} | ||
width={width} | ||
> | ||
<div className="slice_container" data-test="slice-container"> | ||
{this.props.isInView || | ||
!isFeatureEnabled(FeatureFlag.DashboardVirtualization) || | ||
isCurrentUserBot() ? ( | ||
<ChartRenderer | ||
{...this.props} | ||
source={this.props.dashboardId ? 'dashboard' : 'explore'} | ||
data-test={this.props.vizType} | ||
/> | ||
) : ( | ||
<Loading /> | ||
)} | ||
</div> | ||
{isLoading && <Loading />} | ||
{isLoading | ||
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.
This means that 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. D'oh, you're right, let me fix this. Thanks! |
||
? this.renderSpinner(databaseName) | ||
: this.renderChartContainer()} | ||
</Styles> | ||
</ErrorBoundary> | ||
); | ||
|
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.
According to Typescript the datasource/database can be
undefined
which will show in the interface. Can we handle this case?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.
Maybe use "Waiting on database..." when the database name is not available.