You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/08/09 17:53:27 UTC

[GitHub] mistercrunch closed pull request #5580: [table editor] disable 'Sync table metadata' button for Superset views

mistercrunch closed pull request #5580: [table editor] disable 'Sync table metadata' button for Superset views
URL: https://github.com/apache/incubator-superset/pull/5580
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/components/Button.jsx b/superset/assets/src/components/Button.jsx
index 120113de7e..d895a02d20 100644
--- a/superset/assets/src/components/Button.jsx
+++ b/superset/assets/src/components/Button.jsx
@@ -12,6 +12,8 @@ const defaultProps = {
   placement: 'top',
 };
 
+const BUTTON_WRAPPER_STYLE = { display: 'inline-block', cursor: 'not-allowed' };
+
 export default function Button(props) {
   const buttonProps = Object.assign({}, props);
   const tooltip = props.tooltip;
@@ -24,8 +26,19 @@ export default function Button(props) {
       {props.children}
     </BootstrapButton>
   );
-  if (props.tooltip) {
-    button = (
+  if (tooltip) {
+    if (props.disabled) {
+      // Working around the fact that tooltips don't get triggered when buttons are disabled
+      // https://github.com/react-bootstrap/react-bootstrap/issues/1588
+      buttonProps.style = { pointerEvents: 'none' };
+      button = (
+        <div style={BUTTON_WRAPPER_STYLE}>
+          <BootstrapButton {...buttonProps} >
+            {props.children}
+          </BootstrapButton>
+        </div>);
+    }
+    return (
       <OverlayTrigger
         placement={placement}
         overlay={<Tooltip id={`${slugify(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
diff --git a/superset/assets/src/datasource/DatasourceEditor.jsx b/superset/assets/src/datasource/DatasourceEditor.jsx
index 12dfdc0ceb..1bb2082178 100644
--- a/superset/assets/src/datasource/DatasourceEditor.jsx
+++ b/superset/assets/src/datasource/DatasourceEditor.jsx
@@ -526,7 +526,13 @@ export class DatasourceEditor extends React.PureComponent {
                   columns={this.state.databaseColumns}
                   onChange={databaseColumns => this.setColumns({ databaseColumns })}
                 />
-                <Button bsStyle="primary" onClick={this.syncMetadata} className="sync-from-source">
+                <Button
+                  bsStyle="primary"
+                  onClick={this.syncMetadata}
+                  className="sync-from-source"
+                  disabled={!!datasource.sql}
+                  tooltip={datasource.sql ? t('This option is not yet available for views') : null}
+                >
                   {t('Sync columns from source')}
                 </Button>
                 {this.state.metadataLoading && <Loading />}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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