Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-87368
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 6, 2021
2 parents 0c034a2 + a26f20e commit 3f63bdf
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 50 deletions.
1 change: 1 addition & 0 deletions src/plugins/region_map/public/get_deprecation_message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function getDeprecationMessage(vis: Vis) {
const bucketAggs = vis.data?.aggs?.byType('buckets');
if (bucketAggs?.length && bucketAggs[0].type.dslName === 'terms') {
createUrlParams.termsFieldName = bucketAggs[0].getField()?.name;
createUrlParams.termsSize = bucketAggs[0].getParam('size');
}

const metricAggs = vis.data?.aggs?.byType('metrics');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ export const Timeline: React.FC<Props> = ({ interval, yAxisFormatter, isVisible
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup alignItems={'center'}>
<EuiFlexGroup alignItems={'center'} responsive={false}>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize={'s'} alignItems={'center'}>
<EuiFlexGroup gutterSize={'s'} alignItems={'center'} responsive={false}>
<EuiFlexItem grow={false}>
<EuiIcon color={colorTransformer(chartMetric.color)} type={'dot'} />
</EuiFlexItem>
Expand All @@ -240,7 +240,7 @@ export const Timeline: React.FC<Props> = ({ interval, yAxisFormatter, isVisible
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize={'s'} alignItems={'center'}>
<EuiFlexGroup gutterSize={'s'} alignItems={'center'} responsive={false}>
<EuiFlexItem
grow={false}
style={{ backgroundColor: '#D36086', height: 5, width: 10 }}
Expand Down Expand Up @@ -317,6 +317,9 @@ const TimelineHeader = euiStyled.div`
width: 100%;
padding: ${(props) => props.theme.eui.paddingSizes.s} ${(props) =>
props.theme.eui.paddingSizes.m};
@media only screen and (max-width: 767px) {
margin-top: 30px;
}
`;

const TimelineChartContainer = euiStyled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ export const LegendControls = ({
button={buttonComponent}
>
<EuiPopoverTitle>Legend Options</EuiPopoverTitle>
<EuiForm style={{ width: 500 }}>
<EuiForm style={{ minWidth: 400 }}>
<EuiFormRow
fullWidth
display="columnCompressed"
label={i18n.translate('xpack.infra.legendControls.colorPaletteLabel', {
defaultMessage: 'Color palette',
Expand All @@ -211,7 +210,6 @@ export const LegendControls = ({
</>
</EuiFormRow>
<EuiFormRow
fullWidth
display="columnCompressed"
label={i18n.translate('xpack.infra.legendControls.stepsLabel', {
defaultMessage: 'Number of colors',
Expand All @@ -220,12 +218,11 @@ export const LegendControls = ({
<EuiRange
id="steps"
min={2}
max={20}
max={18}
step={1}
value={draftLegend.steps}
onChange={handleStepsChange}
showValue
compressed
fullWidth
/>
</EuiFormRow>
Expand All @@ -243,6 +240,10 @@ export const LegendControls = ({
checked={draftLegend.reverseColors}
onChange={handleReverseColors}
compressed
style={{
position: 'relative',
top: '8px',
}}
/>
</EuiFormRow>
<EuiFormRow
Expand All @@ -259,6 +260,10 @@ export const LegendControls = ({
checked={draftAuto}
onChange={handleAutoChange}
compressed
style={{
position: 'relative',
top: '8px',
}}
/>
</EuiFormRow>
<EuiFormRow
Expand Down Expand Up @@ -316,7 +321,7 @@ export const LegendControls = ({
</div>
</EuiFormRow>
<EuiSpacer size="m" />
<EuiFlexGroup justifyContent="flexEnd">
<EuiFlexGroup justifyContent="flexEnd" responsive={false}>
<EuiFlexItem grow={false}>
<EuiButtonEmpty type="submit" size="s" onClick={handleCancelClick}>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const PalettePreview = ({ steps, palette, reverse }: Props) => {
};

const Swatch = euiStyled.div`
width: 16px;
width: 15px;
height: 12px;
flex: 0 0 auto;
&:first-child {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Props {

export const SwatchLabel = ({ label, color }: Props) => {
return (
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>
<EuiColorPickerSwatch color={color} />
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ type ESGeoLineSourceSyncMeta = {
sortField: string;
};

type ESTermSourceSyncMeta = {
size: number;
};

export type VectorSourceSyncMeta =
| ESSearchSourceSyncMeta
| ESGeoGridSourceSyncMeta
| ESGeoLineSourceSyncMeta
| ESTermSourceSyncMeta
| null;

export type VectorSourceRequestMeta = MapFilters & {
Expand All @@ -54,10 +59,9 @@ export type VectorSourceRequestMeta = MapFilters & {
sourceMeta: VectorSourceSyncMeta;
};

export type VectorJoinSourceRequestMeta = Omit<
VectorSourceRequestMeta,
'geogridPrecision' | 'sourceMeta'
> & { sourceQuery?: Query };
export type VectorJoinSourceRequestMeta = Omit<VectorSourceRequestMeta, 'geogridPrecision'> & {
sourceQuery?: Query;
};

export type VectorStyleRequestMeta = MapFilters & {
dynamicStyleFields: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export type ESTermSourceDescriptor = AbstractESAggSourceDescriptor & {
indexPatternTitle?: string;
term: string; // term field name
whereQuery?: Query;
size?: number;
};

export type KibanaRegionmapSourceDescriptor = AbstractSourceDescriptor & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import uuid from 'uuid/v4';
import {
AggDescriptor,
ColorDynamicOptions,
ESTermSourceDescriptor,
LayerDescriptor,
} from '../../../common/descriptor_types';
import {
Expand Down Expand Up @@ -48,6 +49,7 @@ export function createRegionMapLayerDescriptor({
emsLayerId,
leftFieldName,
termsFieldName,
termsSize,
colorSchema,
indexPatternId,
indexPatternTitle,
Expand All @@ -58,6 +60,7 @@ export function createRegionMapLayerDescriptor({
emsLayerId?: string;
leftFieldName?: string;
termsFieldName?: string;
termsSize?: number;
colorSchema: string;
indexPatternId?: string;
indexPatternTitle?: string;
Expand All @@ -78,21 +81,25 @@ export function createRegionMapLayerDescriptor({
const colorPallette = NUMERICAL_COLOR_PALETTES.find((pallette) => {
return pallette.value.toLowerCase() === colorSchema.toLowerCase();
});
const termSourceDescriptor: ESTermSourceDescriptor = {
type: SOURCE_TYPES.ES_TERM_SOURCE,
id: joinId,
indexPatternId,
indexPatternTitle: indexPatternTitle ? indexPatternTitle : indexPatternId,
term: termsFieldName,
metrics: [metricsDescriptor],
applyGlobalQuery: true,
applyGlobalTime: true,
};
if (termsSize !== undefined) {
termSourceDescriptor.size = termsSize;
}
return VectorLayer.createDescriptor({
label,
joins: [
{
leftField: leftFieldName,
right: {
type: SOURCE_TYPES.ES_TERM_SOURCE,
id: joinId,
indexPatternId,
indexPatternTitle: indexPatternTitle ? indexPatternTitle : indexPatternId,
term: termsFieldName,
metrics: [metricsDescriptor],
applyGlobalQuery: true,
applyGlobalTime: true,
},
right: termSourceDescriptor,
},
],
sourceDescriptor: EMSFileSource.createDescriptor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ export class VectorLayer extends AbstractLayer {
sourceQuery: joinSource.getWhereQuery(),
applyGlobalQuery: joinSource.getApplyGlobalQuery(),
applyGlobalTime: joinSource.getApplyGlobalTime(),
sourceMeta: joinSource.getSyncMeta(),
};
const prevDataRequest = this.getDataRequest(sourceDataId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import {
ESTermSourceDescriptor,
VectorJoinSourceRequestMeta,
VectorSourceSyncMeta,
} from '../../../../common/descriptor_types';
import { Adapters } from '../../../../../../../src/plugins/inspector/common/adapters';
import { PropertiesMap } from '../../../../common/elasticsearch_util';
Expand Down Expand Up @@ -124,7 +125,9 @@ export class ESTermSource extends AbstractESAggSource {
const indexPattern = await this.getIndexPattern();
const searchSource: ISearchSource = await this.makeSearchSource(searchFilters, 0);
const termsField = getField(indexPattern, this._termField.getName());
const termsAgg = { size: DEFAULT_MAX_BUCKETS_LIMIT };
const termsAgg = {
size: this._descriptor.size !== undefined ? this._descriptor.size : DEFAULT_MAX_BUCKETS_LIMIT,
};
searchSource.setField('aggs', {
[TERMS_AGG_NAME]: {
terms: addFieldToDSL(termsAgg, termsField),
Expand Down Expand Up @@ -162,4 +165,12 @@ export class ESTermSource extends AbstractESAggSource {
getFieldNames(): string[] {
return this.getMetricFields().map((esAggMetricField) => esAggMetricField.getName());
}

getSyncMeta(): VectorSourceSyncMeta | null {
return this._descriptor.size !== undefined
? {
size: this._descriptor.size,
}
: null;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export function MetricEditor({
initialValue={
typeof metric.percentile === 'number' ? metric.percentile : DEFAULT_PERCENTILE
}
display="columnCompressed"
/>
);
}
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/maps/public/components/validated_number_input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { Component, ChangeEvent } from 'react';
import { EuiFieldNumber, EuiFormRow } from '@elastic/eui';
import React, { Component, ChangeEvent, ReactNode } from 'react';
// @ts-expect-error
import { EuiFieldNumber, EuiFormRow, EuiFormRowDisplayKeys } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import _ from 'lodash';

Expand All @@ -21,6 +22,8 @@ interface Props {
max: number;
onChange: (value: number) => void;
label: string;
display?: EuiFormRowDisplayKeys;
helpText?: ReactNode;
}

function getErrorMessage(min: number, max: number): string {
Expand Down Expand Up @@ -97,7 +100,8 @@ export class ValidatedNumberInput extends Component<Props, State> {
label={this.props.label}
isInvalid={!this.state.isValid}
error={this.state.errorMessage ? [this.state.errorMessage] : []}
display="columnCompressed"
display={this.props.display}
helpText={this.props.helpText}
>
<EuiFieldNumber
isInvalid={!this.state.isValid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import React, { Fragment } from 'react';
import _ from 'lodash';
import uuid from 'uuid/v4';

import {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ export class Join extends Component {
loadError: undefined,
});
this._loadRightFields(indexPatternId);
// eslint-disable-next-line no-unused-vars
const { term, ...restOfRight } = this.props.join.right;
this.props.onChange({
leftField: this.props.join.leftField,
right: {
id: this.props.join.right.id,
...restOfRight,
indexPatternId,
indexPatternTitle,
},
Expand All @@ -97,6 +99,16 @@ export class Join extends Component {
});
};

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

_onMetricsChange = (metrics) => {
this.props.onChange({
leftField: this.props.join.leftField,
Expand Down Expand Up @@ -161,7 +173,7 @@ export class Join extends Component {
);
globalFilterCheckbox = (
<GlobalFilterCheckbox
applyGlobalQuery={right.applyGlobalQuery}
applyGlobalQuery={right.applyGlobalQuery === 'undefined' ? true : right.applyGlobalQuery}
setApplyGlobalQuery={this._onApplyGlobalQueryChange}
label={i18n.translate('xpack.maps.layerPanel.join.applyGlobalQueryCheckboxLabel', {
defaultMessage: `Apply global filter to join`,
Expand Down Expand Up @@ -209,8 +221,10 @@ export class Join extends Component {
rightSourceName={rightSourceName}
onRightSourceChange={this._onRightSourceChange}
rightValue={right.term}
rightSize={right.size}
rightFields={rightFields}
onRightFieldChange={this._onRightFieldChange}
onRightSizeChange={this._onRightSizeChange}
/>
</EuiFlexItem>

Expand Down
Loading

0 comments on commit 3f63bdf

Please sign in to comment.