superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: [table editor] disable 'Sync table metadata' button for Superset views (#5580)
Date Thu, 09 Aug 2018 17:53:28 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new a8f4849  [table editor] disable 'Sync table metadata' button for Superset views (#5580)
a8f4849 is described below

commit a8f48499115dbce4291a275348d2dcf9c34ee2da
Author: Maxime Beauchemin <maximebeauchemin@gmail.com>
AuthorDate: Thu Aug 9 10:53:25 2018 -0700

    [table editor] disable 'Sync table metadata' button for Superset views (#5580)
    
    This was a bit tricky since there's a bug in react-bootstrap that make
    it tricky to show a tooltip on a disabled button.
---
 superset/assets/src/components/Button.jsx           | 17 +++++++++++++++--
 superset/assets/src/datasource/DatasourceEditor.jsx |  8 +++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/superset/assets/src/components/Button.jsx b/superset/assets/src/components/Button.jsx
index 120113d..d895a02 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 12dfdc0..1bb2082 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 />}


Mime
View raw message