eschutho commented on code in PR #20281:
URL: https://github.com/apache/superset/pull/20281#discussion_r918202513


##########
superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx:
##########
@@ -272,35 +311,54 @@ class DatasourceControl extends React.PureComponent {
 
     const queryDatasourceMenu = (
       <Menu onClick={this.handleMenuItemClick}>
-        <Menu.Item key={QUERY_PREVIEW}>{t('Query preview')}</Menu.Item>
+        <Menu.Item key={QUERY_PREVIEW}>
+          <ModalTrigger
+            triggerNode={
+              <span data-test="view-query-menu-item">{t('Query 
preview')}</span>
+            }
+            modalTitle={t('Query preview')}
+            modalBody={
+              <ViewQuery
+                sql={datasource?.sql || datasource?.select_star || ''}
+              />
+            }
+            modalFooter={
+              <ViewQueryModalFooter
+                changeDatasource={this.toggleSaveDatasetModal}
+                datasource={datasource}
+              />
+            }
+            draggable={false}
+            resizable={false}
+            responsive
+          />
+        </Menu.Item>
         <Menu.Item key={VIEW_IN_SQL_LAB}>{t('View in SQL Lab')}</Menu.Item>
         <Menu.Item key={SAVE_AS_DATASET}>{t('Save as dataset')}</Menu.Item>
       </Menu>
     );
 
     const { health_check_message: healthCheckMessage } = datasource;
 
-    let extra = {};
+    let extra;
     if (datasource?.extra) {
-      try {
-        extra = JSON.parse(datasource?.extra);
-      } catch {} // eslint-disable-line no-empty
+      if (isString(datasource.extra)) {
+        try {
+          extra = JSON.parse(datasource?.extra);

Review Comment:
   don't think you need the optional chaining here b/c of the if statement 
above.



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to