Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class AdhocFilterEditPopoverSqlTabContent extends React.Component
super(props);
this.onSqlExpressionChange = this.onSqlExpressionChange.bind(this);
this.onSqlExpressionClauseChange = this.onSqlExpressionClauseChange.bind(this);
this.handleAceEditorRef = this.handleAceEditorRef.bind(this);

this.selectProps = {
multi: false,
Expand All @@ -59,6 +60,10 @@ export default class AdhocFilterEditPopoverSqlTabContent extends React.Component
}
}

componentDidUpdate() {
this.aceEditorRef.editor.resize();
}

onSqlExpressionClauseChange(clause) {
this.props.onChange(this.props.adhocFilter.duplicateWith({
clause: clause && clause.clause,
Expand All @@ -73,6 +78,12 @@ export default class AdhocFilterEditPopoverSqlTabContent extends React.Component
}));
}

handleAceEditorRef(ref) {
if (ref) {
this.aceEditorRef = ref;
}
}

render() {
const { adhocFilter, height } = this.props;

Expand Down Expand Up @@ -101,6 +112,7 @@ export default class AdhocFilterEditPopoverSqlTabContent extends React.Component
</FormGroup>
<FormGroup>
<AceEditor
ref={this.handleAceEditorRef}
mode="sql"
theme="github"
height={(height - 100) + 'px'}
Expand Down
15 changes: 15 additions & 0 deletions superset/assets/src/explore/components/AdhocMetricEditPopover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default class AdhocMetricEditPopover extends React.Component {
this.onDragDown = this.onDragDown.bind(this);
this.onMouseMove = this.onMouseMove.bind(this);
this.onMouseUp = this.onMouseUp.bind(this);
this.handleAceEditorRef = this.handleAceEditorRef.bind(this);
this.refreshAceEditor = this.refreshAceEditor.bind(this);
this.state = {
adhocMetric: this.props.adhocMetric,
width: startingWidth,
Expand Down Expand Up @@ -137,6 +139,16 @@ export default class AdhocMetricEditPopover extends React.Component {
document.removeEventListener('mousemove', this.onMouseMove);
}

handleAceEditorRef(ref) {
if (ref) {
this.aceEditorRef = ref;
}
}

refreshAceEditor() {
setTimeout(() => this.aceEditorRef.editor.resize(), 0);
}

render() {
const {
adhocMetric: propsAdhocMetric,
Expand Down Expand Up @@ -200,6 +212,8 @@ export default class AdhocMetricEditPopover extends React.Component {
defaultActiveKey={adhocMetric.expressionType}
className="adhoc-metric-edit-tabs"
style={{ height: this.state.height, width: this.state.width }}
onSelect={this.refreshAceEditor}
animation={false}
>
<Tab className="adhoc-metric-edit-tab" eventKey={EXPRESSION_TYPES.SIMPLE} title="Simple">
<FormGroup>
Expand All @@ -216,6 +230,7 @@ export default class AdhocMetricEditPopover extends React.Component {
<Tab className="adhoc-metric-edit-tab" eventKey={EXPRESSION_TYPES.SQL} title="Custom SQL">
<FormGroup>
<AceEditor
ref={this.handleAceEditorRef}
mode="sql"
theme="github"
height={(this.state.height - 43) + 'px'}
Expand Down