etr2460 commented on a change in pull request #10274:
URL: 
https://github.com/apache/incubator-superset/pull/10274#discussion_r452448790



##########
File path: superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx
##########
@@ -0,0 +1,234 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useState } from 'react';
+import { Modal } from 'react-bootstrap';
+import { styled, supersetTheme } from '@superset-ui/style';
+import { t, tn } from '@superset-ui/translation';
+
+import { noOp } from 'src/utils/common';
+import Icon from '../Icon';
+import Button from '../../views/datasetList/Button';
+import { SupersetError } from './types';
+import {
+  ERROR_DATASOURCE_TOO_LARGE,
+  ERROR_DATASOURCE_UNDER_LOAD,
+} from './constants';
+import CopyToClipboard from '../CopyToClipboard';
+
+const ErrorAlert = styled.div`
+  align-items: center;
+  background-color: ${({ theme }) => theme.colors.error.light2};
+  border-radius: ${({ theme }) => theme.borderRadius}px;
+  border: 1px solid ${({ theme }) => theme.colors.error.base};
+  color: ${({ theme }) => theme.colors.error.dark2};
+  padding: ${({ theme }) => 2 * theme.gridUnit}px;
+  width: 100%;
+
+  .topRow {
+    display: flex;
+    justify-content: space-between;
+  }
+
+  .errorBody {
+    padding-top: ${({ theme }) => theme.gridUnit}px;
+    padding-left: ${({ theme }) => 8 * theme.gridUnit}px;
+  }
+
+  .icon {
+    margin-right: ${({ theme }) => 2 * theme.gridUnit}px;
+  }
+
+  .link {
+    color: ${({ theme }) => theme.colors.error.dark2};
+    text-decoration: underline;
+  }
+`;
+
+const ErrorModal = styled(Modal)`
+  color: ${({ theme }) => theme.colors.error.dark2};
+
+  .icon {
+    margin-right: ${({ theme }) => 2 * theme.gridUnit}px;
+  }
+
+  .header {
+    align-items: center;
+    background-color: ${({ theme }) => theme.colors.error.light2};
+    display: flex;
+    justify-content: space-between;
+    font-size: ${({ theme }) => theme.typography.sizes.l}px;
+
+    // Remove clearfix hack as Superset is only used on modern browsers
+    ::before,
+    ::after {
+      content: unset;
+    }
+  }
+`;
+
+const LeftSideContent = styled.div`
+  align-items: center;
+  display: flex;
+`;
+
+interface TimeoutErrorExtra {
+  location: 'chart' | 'dashboard' | 'sqllab';
+  owners?: string[];
+  timeout: number;
+}
+
+function TimeoutErrorMessage({
+  error,
+}: {
+  error: SupersetError<TimeoutErrorExtra>;
+}) {
+  const [isModalOpen, setIsModalOpen] = useState(false);
+  const [isMessageExpanded, setIsMessageExpanded] = useState(false);
+  const { extra } = error;
+
+  const title = ['chart', 'dashboard'].includes(extra.location)
+    ? tn(
+        'We’re having trouble loading this visualization. Queries are set to 
timeout after %s second.',
+        'We’re having trouble loading this visualization. Queries are set to 
timeout after %s seconds.',
+        extra.timeout,
+        extra.timeout,
+      )
+    : tn(
+        'We’re having trouble loading these results. Queries are set to 
timeout after %s second.',
+        'We’re having trouble loading these results. Queries are set to 
timeout after %s seconds.',
+        extra.timeout,
+        extra.timeout,
+      );
+
+  const message = (
+    <>
+      <p>
+        {t('This may be triggered by:')}
+        <br />
+        {ERROR_DATASOURCE_TOO_LARGE.message}{' '}
+        <a
+          href={ERROR_DATASOURCE_TOO_LARGE.link}
+          rel="noopener noreferrer"
+          target="_blank"
+        >
+          <i className="fa fa-external-link" />
+        </a>
+        <br />
+        {ERROR_DATASOURCE_UNDER_LOAD.message}{' '}
+        <a
+          href={ERROR_DATASOURCE_UNDER_LOAD.link}
+          rel="noopener noreferrer"
+          target="_blank"
+        >
+          <i className="fa fa-external-link" />
+        </a>
+      </p>
+      {['chart', 'dashboard'].includes(extra.location) && extra.owners && (
+        <>
+          <br />
+          <p>{t('Please reach out to the Chart Owner(s) for assistance.')}</p>
+          <p>{t('Chart Owner(s): %s', extra.owners.join(', '))}</p>
+        </>
+      )}
+    </>
+  );
+
+  const copyText = `${title}
+${t('This may be triggered by:')}
+${ERROR_DATASOURCE_TOO_LARGE.message}
+${ERROR_DATASOURCE_UNDER_LOAD.message}`;
+
+  return (
+    <ErrorAlert>
+      <div className="topRow">
+        <LeftSideContent>

Review comment:
       It was originally, but we needed the same styling in both the error 
alert and the modal, and the classes didn't work because the Modal is rendered 
outside the usual dom flow. The two choices were define the same class twice in 
2 different styled components or create a new styled component just for this. I 
chose the latter, but can move back to the other way if you prefer




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to