Browse Source

fix: restore Alert on performance landing (#24528)

I think this was accidentally lost in #17582. Table accepts setError but
doesn't do anything with it, probably because DiscoverQuery (then EventsV2)
didn't support it.

Hide the EventsRequest toast in order to not overwhelm the user. While it could
fail, it's highly unlikely to fail without DiscoverQuery also failing.
Alex Xu @ Sentry 4 years ago
parent
commit
f1fcee5178

+ 11 - 5
src/sentry/static/sentry/app/components/charts/eventsRequest.tsx

@@ -150,6 +150,10 @@ type EventsRequestPartialProps = {
    * This flag indicates whether or not this last bucket should be included in the result.
    */
   partial: boolean;
+  /**
+   * Hide error toast (used for pages which also query eventsV2)
+   */
+  hideError?: boolean;
 };
 
 type TimeAggregationProps =
@@ -206,7 +210,7 @@ class EventsRequest extends React.PureComponent<EventsRequestProps, EventsReques
   private unmounting: boolean = false;
 
   fetchData = async () => {
-    const {api, confirmedQuery, expired, name, ...props} = this.props;
+    const {api, confirmedQuery, expired, name, hideError, ...props} = this.props;
     let timeseriesData: EventsStats | MultiSeriesEventsStats | null = null;
 
     if (confirmedQuery === false) {
@@ -232,10 +236,12 @@ class EventsRequest extends React.PureComponent<EventsRequestProps, EventsReques
         api.clear();
         timeseriesData = await doEventsRequest(api, props);
       } catch (resp) {
-        if (resp && resp.responseJSON && resp.responseJSON.detail) {
-          addErrorMessage(resp.responseJSON.detail);
-        } else {
-          addErrorMessage(t('Error loading chart data'));
+        if (!hideError) {
+          if (resp && resp.responseJSON && resp.responseJSON.detail) {
+            addErrorMessage(resp.responseJSON.detail);
+          } else {
+            addErrorMessage(t('Error loading chart data'));
+          }
         }
         this.setState({
           errored: true,

+ 4 - 4
src/sentry/static/sentry/app/utils/discover/genericDiscoverQuery.tsx

@@ -38,6 +38,10 @@ export type DiscoverQueryProps = {
    * passed, but cursor will be ignored.
    */
   noPagination?: boolean;
+  /**
+   * A callback to set an error so that the error can be rendered in parent components
+   */
+  setError?: (msg: string | undefined) => void;
 };
 
 type RequestProps<P> = DiscoverQueryProps & P;
@@ -68,10 +72,6 @@ type Props<T, P> = RequestProps<P> &
      * A hook to modify data into the correct output after data has been received
      */
     afterFetch?: (data: any, props: Props<T, P>) => T;
-    /**
-     * A callback to set an error so that the error can be rendered in parent components
-     */
-    setError?: (msg: string | undefined) => void;
   };
 
 type State<T> = {

+ 0 - 2
src/sentry/static/sentry/app/utils/performance/trends/trendsDiscoverQuery.tsx

@@ -30,7 +30,6 @@ type ChildrenProps = Omit<GenericChildrenProps<TrendsData>, 'tableData'> & {
 };
 
 type Props = RequestProps & {
-  setError?: (msg: string | undefined) => void;
   children: (props: ChildrenProps) => React.ReactNode;
 };
 
@@ -39,7 +38,6 @@ type EventChildrenProps = Omit<GenericChildrenProps<TrendsDataEvents>, 'tableDat
 };
 
 type EventProps = RequestProps & {
-  setError?: (msg: string | undefined) => void;
   children: (props: EventChildrenProps) => React.ReactNode;
 };
 

+ 1 - 0
src/sentry/static/sentry/app/views/performance/landing/chart/durationChart.tsx

@@ -81,6 +81,7 @@ function DurationChart(props: Props) {
       includePrevious={false}
       yAxis={[field]}
       partial
+      hideError
     >
       {({loading, reloading, errored, timeseriesData: results}) => {
         const series = results

+ 2 - 1
src/sentry/static/sentry/app/views/performance/table.tsx

@@ -262,7 +262,7 @@ class Table extends React.Component<Props, State> {
   }
 
   render() {
-    const {eventView, organization, location} = this.props;
+    const {eventView, organization, location, setError} = this.props;
 
     const {widths} = this.state;
     const columnOrder = eventView
@@ -291,6 +291,7 @@ class Table extends React.Component<Props, State> {
           eventView={sortedEventView}
           orgSlug={organization.slug}
           location={location}
+          setError={setError}
         >
           {({pageLinks, isLoading, tableData}) => (
             <React.Fragment>