betodealmeida commented on a change in pull request #16170:
URL: https://github.com/apache/superset/pull/16170#discussion_r686291060



##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -852,25 +852,36 @@ const DatabaseModal: 
FunctionComponent<DatabaseModalProps> = ({
     setTabKey(key);
   };
 
-  const renderStepTwoAlert = () =>
-    db?.engine && (
-      <StyledAlertMargin>
-        <Alert
-          closable={false}
-          css={(theme: SupersetTheme) => antDAlertStyles(theme)}
-          type="info"
-          showIcon
-          message={
-            engineSpecificAlertMapping[db.engine]?.message ||
-            connectionAlert?.DEFAULT?.message
-          }
-          description={
-            engineSpecificAlertMapping[db.engine]?.description ||
-            connectionAlert?.DEFAULT?.description
-          }
-        />
-      </StyledAlertMargin>
+  const renderStepTwoAlert = () => {
+    const path = window.location.hostname;
+    let ipAlert = connectionAlert.REGIONAL_IPS.default;

Review comment:
       We should add some guards here, no? Something like:
   
   ```suggestion
       let ipAlert = connectionAlert?.REGIONAL_IPS?.default || '';
   ```

##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -852,25 +852,36 @@ const DatabaseModal: 
FunctionComponent<DatabaseModalProps> = ({
     setTabKey(key);
   };
 
-  const renderStepTwoAlert = () =>
-    db?.engine && (
-      <StyledAlertMargin>
-        <Alert
-          closable={false}
-          css={(theme: SupersetTheme) => antDAlertStyles(theme)}
-          type="info"
-          showIcon
-          message={
-            engineSpecificAlertMapping[db.engine]?.message ||
-            connectionAlert?.DEFAULT?.message
-          }
-          description={
-            engineSpecificAlertMapping[db.engine]?.description ||
-            connectionAlert?.DEFAULT?.description
-          }
-        />
-      </StyledAlertMargin>
+  const renderStepTwoAlert = () => {
+    const path = window.location.hostname;

Review comment:
       A comment here... a `path` has a well-defined meaning in the context of 
URLs, it's the part after `hostname:port`. Let's call this `hostname`, since 
it's what it is:
   
   ```suggestion
       const hostname = window.location.hostname;
   ```

##########
File path: 
superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx
##########
@@ -852,25 +852,36 @@ const DatabaseModal: 
FunctionComponent<DatabaseModalProps> = ({
     setTabKey(key);
   };
 
-  const renderStepTwoAlert = () =>
-    db?.engine && (
-      <StyledAlertMargin>
-        <Alert
-          closable={false}
-          css={(theme: SupersetTheme) => antDAlertStyles(theme)}
-          type="info"
-          showIcon
-          message={
-            engineSpecificAlertMapping[db.engine]?.message ||
-            connectionAlert?.DEFAULT?.message
-          }
-          description={
-            engineSpecificAlertMapping[db.engine]?.description ||
-            connectionAlert?.DEFAULT?.description
-          }
-        />
-      </StyledAlertMargin>
+  const renderStepTwoAlert = () => {
+    const path = window.location.hostname;
+    let ipAlert = connectionAlert.REGIONAL_IPS.default;
+    const regionalIPs = Object.keys(connectionAlert.REGIONAL_IPS);
+    regionalIPs.forEach(regex => {
+      if (regex.match(path)) {
+        ipAlert = connectionAlert.REGIONAL_IPS[regex];
+      }
+    });

Review comment:
       You can iterate over key:vale pairs directly:
   
   ```suggestion
       const regionalIPs = connectionAlert?.REGIONAL_IPS || {};
       Object.entries(regionalIPs).forEach(([regex, ipRange]) => {
         if (regex.match(hostname)) {
           ipAlert = ipRange;
         }
       });
   ```




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

To unsubscribe, e-mail: [email protected]

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