Skip to content

Commit

Permalink
refactor: fix CR notes
Browse files Browse the repository at this point in the history
  • Loading branch information
simcha90 committed Oct 14, 2021
1 parent 0593265 commit a3556f9
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,25 @@ export default class AdhocFilterEditPopover extends React.Component {

const { adhocFilter } = this.state;

const resultSections =
datasource?.type === 'druid'
? sections.filter(s => s !== 'CUSTOM_SQL')
: sections;

const stateIsValid = adhocFilter.isValid();
const hasUnsavedChanges = !adhocFilter.equals(propsAdhocFilter);

const sectionRenders = {};

sectionRenders.CUSTOM_SQL = (
<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>
)}
<AdhocFilterEditPopoverSqlTabContent
adhocFilter={this.state.adhocFilter}
onChange={this.onAdhocFilterChange}
options={this.props.options}
height={this.state.height}
activeKey={this.state.activeKey}
/>
</ErrorBoundary>
);

Expand All @@ -226,7 +225,7 @@ export default class AdhocFilterEditPopover extends React.Component {
data-test="filter-edit-popover"
ref={this.popoverContentRef}
>
{sections.length > 1 ? (
{resultSections.length > 1 ? (
<Tabs
id="adhoc-filter-edit-tabs"
defaultActiveKey={adhocFilter.expressionType}
Expand All @@ -236,7 +235,7 @@ export default class AdhocFilterEditPopover extends React.Component {
allowOverflow
onChange={this.onTabChange}
>
{sections.includes('SIMPLE') && (
{resultSections.includes('SIMPLE') && (
<Tabs.TabPane
className="adhoc-filter-edit-tab"
key={EXPRESSION_TYPES.SIMPLE}
Expand All @@ -245,7 +244,7 @@ export default class AdhocFilterEditPopover extends React.Component {
{sectionRenders.SIMPLE}
</Tabs.TabPane>
)}
{sections.includes('CUSTOM_SQL') && (
{resultSections.includes('CUSTOM_SQL') && (
<Tabs.TabPane
className="adhoc-filter-edit-tab"
key={EXPRESSION_TYPES.SQL}
Expand All @@ -256,7 +255,7 @@ export default class AdhocFilterEditPopover extends React.Component {
)}
</Tabs>
) : (
<SectionWrapper>{sectionRenders[sections[0]]}</SectionWrapper>
<SectionWrapper>{sectionRenders[resultSections[0]]}</SectionWrapper>
)}
<div>
<Button buttonSize="small" onClick={this.props.onClose} cta>
Expand Down

0 comments on commit a3556f9

Please sign in to comment.