You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2022/06/28 17:24:10 UTC

[superset] 19/19: fix(db): Show the only db install guide when the db is already installed and error is existed while importing file. (#20442)

This is an automated email from the ASF dual-hosted git repository.

michaelsmolina pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 789f99341b9840fe2ef1797d28c99ec4ed5fa9b8
Author: smileydev <47...@users.noreply.github.com>
AuthorDate: Tue Jun 28 08:53:02 2022 -0400

    fix(db): Show the only db install guide when the db is already installed and error is existed while importing file. (#20442)
    
    * fix(db): make to show the db error msg when db installed and error is exist
    
    * fix(db): make to replace dbinstall str into showDbInstallInstructions
    
    (cherry picked from commit 23e62d3782e75f1ed6c7baf0d511b4464249dbf3)
---
 .../src/components/ImportModal/ErrorAlert.tsx      | 40 +++++++++++++---------
 .../src/components/ImportModal/index.tsx           |  7 +++-
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/superset-frontend/src/components/ImportModal/ErrorAlert.tsx b/superset-frontend/src/components/ImportModal/ErrorAlert.tsx
index 91ee6467f4..52bd54a796 100644
--- a/superset-frontend/src/components/ImportModal/ErrorAlert.tsx
+++ b/superset-frontend/src/components/ImportModal/ErrorAlert.tsx
@@ -31,9 +31,13 @@ export const DOCUMENTATION_LINK = supersetTextDocs
 
 export interface IProps {
   errorMessage: string;
+  showDbInstallInstructions: boolean;
 }
 
-const ErrorAlert: FunctionComponent<IProps> = ({ errorMessage }) => (
+const ErrorAlert: FunctionComponent<IProps> = ({
+  errorMessage,
+  showDbInstallInstructions,
+}) => (
   <Alert
     closable={false}
     css={(theme: SupersetTheme) => antdWarningAlertStyles(theme)}
@@ -41,21 +45,25 @@ const ErrorAlert: FunctionComponent<IProps> = ({ errorMessage }) => (
     showIcon
     message={errorMessage}
     description={
-      <>
-        <br />
-        {t(
-          'Database driver for importing maybe not installed. Visit the Superset documentation page for installation instructions:',
-        )}
-        <a
-          href={DOCUMENTATION_LINK}
-          target="_blank"
-          rel="noopener noreferrer"
-          className="additional-fields-alert-description"
-        >
-          {t('here')}
-        </a>
-        .
-      </>
+      showDbInstallInstructions ? (
+        <>
+          <br />
+          {t(
+            'Database driver for importing maybe not installed. Visit the Superset documentation page for installation instructions:',
+          )}
+          <a
+            href={DOCUMENTATION_LINK}
+            target="_blank"
+            rel="noopener noreferrer"
+            className="additional-fields-alert-description"
+          >
+            {t('here')}
+          </a>
+          .
+        </>
+      ) : (
+        ''
+      )
     }
   />
 );
diff --git a/superset-frontend/src/components/ImportModal/index.tsx b/superset-frontend/src/components/ImportModal/index.tsx
index c13546f7d3..6a980f7d20 100644
--- a/superset-frontend/src/components/ImportModal/index.tsx
+++ b/superset-frontend/src/components/ImportModal/index.tsx
@@ -300,7 +300,12 @@ const ImportModelsModal: FunctionComponent<ImportModelsModalProps> = ({
           <Button loading={importingModel}>Select file</Button>
         </Upload>
       </StyledInputContainer>
-      {errorMessage && <ErrorAlert errorMessage={errorMessage} />}
+      {errorMessage && (
+        <ErrorAlert
+          errorMessage={errorMessage}
+          showDbInstallInstructions={passwordFields.length > 0}
+        />
+      )}
       {renderPasswordFields()}
       {renderOverwriteConfirmation()}
     </Modal>