refactor: Introduce api resource hooks, fetch owners for chart errors (#13218)

* refactor: introduce api resource hooks, fix error owners

* comment

* vestigial comment

* not a function

* clarification

* vestigial comment

* filter the api for a leaner response

* reorganize code, add resource hook catalog

* better names

* implement state management in redux

* Revert "implement state management in redux"

This reverts commit d64d50a99f.

* add tests for hooks
This commit is contained in:
David Aaron Suddjian
2021-02-25 14:41:35 -08:00
committed by GitHub
parent 72721845e1
commit e11d0cbf44
8 changed files with 465 additions and 13 deletions

View File

@@ -25,9 +25,9 @@ import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import { Logger, LOG_ACTIONS_RENDER_CHART } from '../logger/LogUtils';
import Loading from '../components/Loading';
import RefreshChartOverlay from '../components/RefreshChartOverlay';
import ErrorMessageWithStackTrace from '../components/ErrorMessage/ErrorMessageWithStackTrace';
import ErrorBoundary from '../components/ErrorBoundary';
import ChartRenderer from './ChartRenderer';
import { ChartErrorMessage } from './ChartErrorMessage';
const propTypes = {
annotationData: PropTypes.object,
@@ -49,9 +49,6 @@ const propTypes = {
timeout: PropTypes.number,
vizType: PropTypes.string.isRequired,
triggerRender: PropTypes.bool,
owners: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
),
// state
chartAlert: PropTypes.string,
chartStatus: PropTypes.string,
@@ -152,17 +149,13 @@ class Chart extends React.PureComponent {
}
renderErrorMessage(queryResponse) {
const { chartAlert, chartStackTrace, dashboardId, owners } = this.props;
const { chartId, chartAlert, chartStackTrace, dashboardId } = this.props;
const error = queryResponse?.errors?.[0];
if (error) {
const extra = error.extra || {};
extra.owners = owners;
error.extra = extra;
}
const message = chartAlert || queryResponse?.message;
return (
<ErrorMessageWithStackTrace
<ChartErrorMessage
chartId={chartId}
error={error}
subtitle={message}
copyText={message}