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



##########
File path: superset-frontend/src/components/ErrorMessage/TimeoutErrorMessage.tsx
##########
@@ -0,0 +1,221 @@
+/**
+ * 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 { ErrorMessageComponentProps } from './types';
+import { ERROR_CODES } from './errorCodes';
+import CopyToClipboard from '../CopyToClipboard';
+import ErrorCode from './ErrorCode';
+
+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%;
+
+  .top-row {
+    display: flex;
+    justify-content: space-between;
+  }
+
+  .error-body {
+    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 {
+  owners?: string[];
+  timeout: number;
+}
+
+function TimeoutErrorMessage({
+  error,
+  location,
+}: ErrorMessageComponentProps<TimeoutErrorExtra>) {
+  const [isModalOpen, setIsModalOpen] = useState(false);
+  const [isMessageExpanded, setIsMessageExpanded] = useState(false);
+  const { extra } = error;
+
+  const title = (['dashboard', 'explore'] as (string | undefined)[]).includes(
+    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:')}

Review comment:
       I am thinking the logic for `this may be triggered by`, should come from 
a standard, general json format generated from backend. 
   front-end should not decide what error is caused by what reason. Front-end 
timeout limit is defined in config, it's not something _decided_ by front-end.
   




----------------------------------------------------------------
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