mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[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.
This commit is contained in:
parent
222b79df7e
commit
a8f4849911
@ -12,6 +12,8 @@ const defaultProps = {
|
|||||||
placement: 'top',
|
placement: 'top',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const BUTTON_WRAPPER_STYLE = { display: 'inline-block', cursor: 'not-allowed' };
|
||||||
|
|
||||||
export default function Button(props) {
|
export default function Button(props) {
|
||||||
const buttonProps = Object.assign({}, props);
|
const buttonProps = Object.assign({}, props);
|
||||||
const tooltip = props.tooltip;
|
const tooltip = props.tooltip;
|
||||||
@ -24,8 +26,19 @@ export default function Button(props) {
|
|||||||
{props.children}
|
{props.children}
|
||||||
</BootstrapButton>
|
</BootstrapButton>
|
||||||
);
|
);
|
||||||
if (props.tooltip) {
|
if (tooltip) {
|
||||||
button = (
|
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
|
<OverlayTrigger
|
||||||
placement={placement}
|
placement={placement}
|
||||||
overlay={<Tooltip id={`${slugify(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
|
overlay={<Tooltip id={`${slugify(tooltip)}-tooltip`}>{tooltip}</Tooltip>}
|
||||||
|
@ -526,7 +526,13 @@ export class DatasourceEditor extends React.PureComponent {
|
|||||||
columns={this.state.databaseColumns}
|
columns={this.state.databaseColumns}
|
||||||
onChange={databaseColumns => this.setColumns({ 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')}
|
{t('Sync columns from source')}
|
||||||
</Button>
|
</Button>
|
||||||
{this.state.metadataLoading && <Loading />}
|
{this.state.metadataLoading && <Loading />}
|
||||||
|
Loading…
Reference in New Issue
Block a user