Skip to content
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: new chart error panel #1850

Merged
merged 10 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
43 changes: 25 additions & 18 deletions packages/chart/src/Chart.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component, ReactElement, RefObject } from 'react';
import deepEqual from 'deep-equal';
import memoize from 'memoize-one';
import { CopyButton, Popper } from '@deephaven/components';
import {
vsLoading,
dhGraphLineDown,
Expand Down Expand Up @@ -33,6 +32,7 @@ import { bindAllMethods } from '@deephaven/utils';
import createPlotlyComponent from './plotly/createPlotlyComponent';
import Plotly from './plotly/Plotly';
import ChartModel from './ChartModel';
import ChartErrorOverlay from './ChartErrorOverlay';
import { ChartTheme } from './ChartTheme';
import ChartUtils, { ChartModelSettings } from './ChartUtils';
import './Chart.scss';
Expand Down Expand Up @@ -415,6 +415,10 @@ class Chart extends Component<ChartProps, ChartState> {
this.setState({ shownError: null });
}

handleDownsampleErrorClose(): void {
this.setState({ downsamplingError: null });
}

handleModelEvent(event: CustomEvent): void {
const { type, detail } = event;
log.debug2('Received data update', type, detail);
Expand Down Expand Up @@ -704,23 +708,26 @@ class Chart extends Component<ChartProps, ChartState> {
style={{ height: '100%', width: '100%' }}
/>
)}
<Popper
className="chart-error-popper"
options={{ placement: 'top' }}
isShown={shownError != null}
onExited={this.handleErrorClose}
closeOnBlur
interactive
>
{shownError != null && (
<>
<div className="chart-error">{shownError}</div>
<CopyButton tooltip="Copy Error" copy={shownError}>
Copy Error
</CopyButton>
</>
)}
</Popper>
{downsamplingError != null && shownError == null && (
<ChartErrorOverlay
errorMessage={`${downsamplingError}`}
onDiscard={() => {
this.handleDownsampleErrorClose();
}}
onConfirm={() => {
this.handleDownsampleErrorClose();
this.handleDownsampleClick();
}}
/>
)}
{shownError != null && (
<ChartErrorOverlay
errorMessage={`${shownError}`}
onDiscard={() => {
this.handleErrorClose();
}}
/>
)}
</div>
);
}
Expand Down
14 changes: 14 additions & 0 deletions packages/chart/src/ChartErrorOverlay.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import '@deephaven/components/scss/custom.scss';

.chart-error-overlay {
.chart-error-overlay-content {
.btn {
margin-top: $spacer-3;
margin-right: $spacer-3;
}
.info-message,
.waiting-filter-list {
text-align: left;
}
}
}
52 changes: 52 additions & 0 deletions packages/chart/src/ChartErrorOverlay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ReactElement } from 'react';
import { CopyButton, Button } from '@deephaven/components';
import './ChartErrorOverlay.scss';

interface ChartErrorOverlayProps {
errorMessage: string;
onDiscard?: () => void;
onCancel?: () => void;
onConfirm?: () => void;
'data-testid'?: string;
}

function ChartErrorOverlay({
errorMessage,
onDiscard,
onConfirm,
onCancel,
'data-testid': dataTestId,
}: ChartErrorOverlayProps): ReactElement {
const messageTestId =
dataTestId != null ? `${dataTestId}-message` : undefined;

return (
<div className="chart-panel-overlay chart-error-overlay">
<div className="chart-panel-overlay-content chart-error-overlay-content">
<div className="info-message" data-testid={messageTestId}>
{errorMessage}
<CopyButton copy={errorMessage} style={{ margin: '0' }} />
</div>
<div>
{onCancel && (
<Button onClick={onCancel} kind="secondary">
Cancel
</Button>
)}
{onDiscard && (
<Button onClick={onDiscard} kind="secondary">
Dismiss
</Button>
)}
{onConfirm && !undismissableError && (

Check failure on line 41 in packages/chart/src/ChartErrorOverlay.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'undismissableError'.

Check failure on line 41 in packages/chart/src/ChartErrorOverlay.tsx

View workflow job for this annotation

GitHub Actions / unit

Unexpected any value in conditional. An explicit comparison or type cast is required
<Button onClick={onConfirm} kind="primary">
Continue
</Button>
)}
</div>
</div>
</div>
);
}

export default ChartErrorOverlay;
Loading