geido commented on a change in pull request #17006:
URL: https://github.com/apache/superset/pull/17006#discussion_r724196761
##########
File path:
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.jsx
##########
@@ -175,62 +179,73 @@ export default class AdhocFilterEditPopover extends
React.Component {
const stateIsValid = adhocFilter.isValid();
const hasUnsavedChanges = !adhocFilter.equals(propsAdhocFilter);
+ const simpleContent = (
+ <ErrorBoundary>
+ <AdhocFilterEditPopoverSimpleTabContent
+ operators={operators}
+ adhocFilter={this.state.adhocFilter}
+ onChange={this.onAdhocFilterChange}
+ options={options}
+ datasource={datasource}
+ onHeightChange={this.adjustHeight}
+ partitionColumn={partitionColumn}
+ popoverRef={this.popoverContentRef.current}
+ />
+ </ErrorBoundary>
+ );
+
return (
<FilterPopoverContentContainer
id="filter-edit-popover"
{...popoverProps}
data-test="filter-edit-popover"
ref={this.popoverContentRef}
>
- <Tabs
- id="adhoc-filter-edit-tabs"
- defaultActiveKey={adhocFilter.expressionType}
- className="adhoc-filter-edit-tabs"
- data-test="adhoc-filter-edit-tabs"
- style={{ minHeight: this.state.height, width: this.state.width }}
- allowOverflow
- onChange={this.onTabChange}
- >
- <Tabs.TabPane
- className="adhoc-filter-edit-tab"
- key={EXPRESSION_TYPES.SIMPLE}
- tab={t('Simple')}
- >
- <ErrorBoundary>
- <AdhocFilterEditPopoverSimpleTabContent
- adhocFilter={this.state.adhocFilter}
- onChange={this.onAdhocFilterChange}
- options={options}
- datasource={datasource}
- onHeightChange={this.adjustHeight}
- partitionColumn={partitionColumn}
- popoverRef={this.popoverContentRef.current}
- />
- </ErrorBoundary>
- </Tabs.TabPane>
- <Tabs.TabPane
- className="adhoc-filter-edit-tab"
- key={EXPRESSION_TYPES.SQL}
- tab={t('Custom SQL')}
+ {hasCustomSQL ? (
+ <Tabs
+ id="adhoc-filter-edit-tabs"
+ defaultActiveKey={adhocFilter.expressionType}
+ className="adhoc-filter-edit-tabs"
+ data-test="adhoc-filter-edit-tabs"
+ style={{ minHeight: this.state.height, width: this.state.width }}
+ allowOverflow
+ onChange={this.onTabChange}
>
- <ErrorBoundary>
- {!this.props.datasource ||
- this.props.datasource.type !== 'druid' ? (
- <AdhocFilterEditPopoverSqlTabContent
- adhocFilter={this.state.adhocFilter}
- onChange={this.onAdhocFilterChange}
- options={this.props.options}
- height={this.state.height}
- activeKey={this.state.activeKey}
- />
- ) : (
- <div className="custom-sql-disabled-message">
- Custom SQL Filters are not available on druid datasources
- </div>
- )}
- </ErrorBoundary>
- </Tabs.TabPane>
- </Tabs>
+ <Tabs.TabPane
+ className="adhoc-filter-edit-tab"
+ key={EXPRESSION_TYPES.SIMPLE}
+ tab={t('Simple')}
+ >
+ {simpleContent}
+ </Tabs.TabPane>
+ {hasCustomSQL && (
Review comment:
It appears that you are checking for `hasCustomSQL` in the above parent
block already. I am not sure how this is useful here too. This might be a
mistake in the rendering logic
##########
File path:
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.jsx
##########
@@ -175,62 +179,73 @@ export default class AdhocFilterEditPopover extends
React.Component {
const stateIsValid = adhocFilter.isValid();
const hasUnsavedChanges = !adhocFilter.equals(propsAdhocFilter);
+ const simpleContent = (
Review comment:
It would be great if we could use uppercase const when we are returning
a component. I believe it makes the code a bit more readable
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]