Skip to content

Commit

Permalink
add checkbox to join UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Nov 13, 2019
1 parent a7efb25 commit 645f3c4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import React from 'react';
import { EuiFormRow, EuiSwitch } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

export function GlobalFilterCheckbox({ applyGlobalQuery, setApplyGlobalQuery }) {
const label = i18n.translate('xpack.maps.layerPanel.applyGlobalQueryCheckboxLabel', {
defaultMessage: `Apply global filter to source`,
});

export function GlobalFilterCheckbox({ applyGlobalQuery, customLabel, setApplyGlobalQuery }) {
const onApplyGlobalQueryChange = event => {
setApplyGlobalQuery(event.target.checked);
};
Expand All @@ -18,9 +22,7 @@ export function GlobalFilterCheckbox({ applyGlobalQuery, setApplyGlobalQuery })
display="columnCompressedSwitch"
>
<EuiSwitch
label={i18n.translate('xpack.maps.layerPanel.applyGlobalQueryCheckboxLabel', {
defaultMessage: `Apply global filter to source`,
})}
label={customLabel ? customLabel : label}
checked={applyGlobalQuery}
onChange={onApplyGlobalQueryChange}
data-test-subj="mapLayerPanelApplyGlobalQueryCheckbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { i18n } from '@kbn/i18n';
import { JoinExpression } from './join_expression';
import { MetricsExpression } from './metrics_expression';
import { WhereExpression } from './where_expression';
import { GlobalFilterCheckbox } from '../../../../components/global_filter_checkbox';

import {
indexPatternService,
Expand Down Expand Up @@ -168,6 +169,16 @@ export class Join extends Component {
});
}

_onApplyGlobalQueryChange = applyGlobalQuery => {
this.props.onChange({
leftField: this.props.join.leftField,
right: {
...this.props.join.right,
applyGlobalQuery,
},
});
}

render() {
const {
join,
Expand All @@ -184,6 +195,7 @@ export class Join extends Component {
const isJoinConfigComplete = join.leftField && right.indexPatternId && right.term;

let metricsExpression;
let globalFilterCheckbox;
if (isJoinConfigComplete) {
metricsExpression = (
<EuiFlexItem grow={false}>
Expand All @@ -194,6 +206,15 @@ export class Join extends Component {
/>
</EuiFlexItem>
);
globalFilterCheckbox = (
<GlobalFilterCheckbox
applyGlobalQuery={right.applyGlobalQuery}
setApplyGlobalQuery={this._onApplyGlobalQueryChange}
customLabel={i18n.translate('xpack.maps.layerPanel.join.applyGlobalQueryCheckboxLabel', {
defaultMessage: `Apply global filter to join`,
})}
/>
);
}

let whereExpression;
Expand Down Expand Up @@ -234,6 +255,8 @@ export class Join extends Component {

{whereExpression}

{globalFilterCheckbox}

<EuiButtonIcon
className="mapJoinItem__delete"
iconType="trash"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export function JoinEditor({ joins, layer, onChange }) {
...joins,
{
right: {
id: uuid()
id: uuid(),
applyGlobalQuery: true,
}
}
]);
Expand Down
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/maps/public/layers/sources/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export class AbstractSource {
}

getApplyGlobalQuery() {
console.log(this._descriptor.applyGlobalQuery);
return !!this._descriptor.applyGlobalQuery;
}

Expand Down

0 comments on commit 645f3c4

Please sign in to comment.