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 @@ -89,7 +89,7 @@ export class ColorMapSelect extends Component {
};

_renderColorStopsInput() {
if (this.props.supportsAutoDomain && !this.props.useCustomColorMap) {
if (!this.props.isCustomOnly && !this.props.useCustomColorMap) {
return null;
}

Expand Down Expand Up @@ -122,17 +122,21 @@ export class ColorMapSelect extends Component {
}

_renderColorMapSelections() {
if (this.props.isCustomOnly) {
return null;
}

const colorMapOptionsWithCustom = [
{
value: CUSTOM_COLOR_MAP,
inputDisplay: this.props.customOptionLabel,
'data-test-subj': `colorMapSelectOption_${CUSTOM_COLOR_MAP}`,
},
...(this.props.supportsAutoDomain ? this.props.colorMapOptions : []),
...this.props.colorMapOptions,
];

let valueOfSelected;
if (this.props.useCustomColorMap || !this.props.supportsAutoDomain) {
if (this.props.useCustomColorMap) {
valueOfSelected = CUSTOM_COLOR_MAP;
} else {
valueOfSelected = this.props.colorMapOptions.find(
Expand All @@ -147,28 +151,29 @@ export class ColorMapSelect extends Component {
) : null;

return (
<EuiFlexGroup gutterSize={'none'}>
{toggle}
<EuiFlexItem>
<EuiSuperSelect
disabled={!this.props.supportsAutoDomain}
compressed
options={colorMapOptionsWithCustom}
onChange={this._onColorMapSelect}
valueOfSelected={valueOfSelected}
hasDividers={true}
data-test-subj={`colorMapSelect_${this.props.styleProperty.getStyleName()}`}
/>
</EuiFlexItem>
</EuiFlexGroup>
<Fragment>
<EuiFlexGroup gutterSize={'none'}>
{toggle}
<EuiFlexItem>
<EuiSuperSelect
compressed
options={colorMapOptionsWithCustom}
onChange={this._onColorMapSelect}
valueOfSelected={valueOfSelected}
hasDividers={true}
data-test-subj={`colorMapSelect_${this.props.styleProperty.getStyleName()}`}
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />
</Fragment>
);
}

render() {
return (
<Fragment>
{this._renderColorMapSelections()}
<EuiSpacer size="s" />
{this._renderColorStopsInput()}
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function DynamicColorForm({
if (styleProperty.isOrdinal()) {
return (
<ColorMapSelect
supportsAutoDomain={field.supportsAutoDomain}
isCustomOnly={!field.supportsAutoDomain}
colorMapOptions={COLOR_GRADIENTS}
customOptionLabel={i18n.translate('xpack.maps.style.customColorRampLabel', {
defaultMessage: 'Custom color ramp',
Expand All @@ -100,9 +100,7 @@ export function DynamicColorForm({
colorMapType={COLOR_MAP_TYPE.ORDINAL}
color={styleOptions.color}
customColorMap={styleOptions.customColorRamp}
useCustomColorMap={
!field.supportsAutoDomain || _.get(styleOptions, 'useCustomColorRamp', false)
}
useCustomColorMap={_.get(styleOptions, 'useCustomColorRamp', false)}
styleProperty={styleProperty}
showColorMapTypeToggle={showColorMapTypeToggle}
swatches={swatches}
Expand All @@ -111,7 +109,7 @@ export function DynamicColorForm({
} else if (styleProperty.isCategorical()) {
return (
<ColorMapSelect
supportsAutoDomain={field.supportsAutoDomain}
isCustomOnly={!field.supportsAutoDomain}
colorMapOptions={COLOR_PALETTES}
customOptionLabel={i18n.translate('xpack.maps.style.customColorPaletteLabel', {
defaultMessage: 'Custom color palette',
Expand All @@ -121,9 +119,7 @@ export function DynamicColorForm({
colorMapType={COLOR_MAP_TYPE.CATEGORICAL}
color={styleOptions.colorCategory}
customColorMap={styleOptions.customColorPalette}
useCustomColorMap={
!field.supportsAutoDomain || _.get(styleOptions, 'useCustomColorPalette', false)
}
useCustomColorMap={_.get(styleOptions, 'useCustomColorPalette', false)}
styleProperty={styleProperty}
showColorMapTypeToggle={showColorMapTypeToggle}
swatches={swatches}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,16 @@ export class StyleMapSelect extends Component {
};

_renderCustomStopsInput() {
if (!this.props.useCustomMap) {
return !this.props.isCustomOnly && !this.props.useCustomMap
? null
: this.props.renderCustomStopsInput(this._onCustomMapChange);
}

_renderMapSelect() {
if (this.props.isCustomOnly) {
return null;
}

return (
<Fragment>
<EuiSpacer size="s" />
{this.props.renderCustomStopsInput(this._onCustomMapChange)}
</Fragment>
);
}

render() {
const mapOptionsWithCustom = [
{
value: CUSTOM_MAP,
Expand Down Expand Up @@ -87,6 +84,15 @@ export class StyleMapSelect extends Component {
hasDividers={true}
compressed
/>
<EuiSpacer size="s" />
</Fragment>
);
}

render() {
return (
<Fragment>
{this._renderMapSelect()}
{this._renderCustomStopsInput()}
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ export function DynamicIconForm({
};

function renderIconMapSelect() {
if (!styleOptions.field || !styleOptions.field.name) {
const field = styleProperty.getField();
if (!field) {
return null;
}

return (
<IconMapSelect
{...styleOptions}
useCustomIconMap={_.get(styleOptions, 'useCustomColorRamp', false)}
styleProperty={styleProperty}
onChange={onIconMapChange}
isDarkMode={isDarkMode}
symbolOptions={symbolOptions}
isCustomOnly={!field.supportsAutoDomain()}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import React from 'react';

import { StyleMapSelect } from '../style_map_select';
import { i18n } from '@kbn/i18n';
import { getIconPaletteOptions } from '../../symbol_utils';
import { IconStops } from './icon_stops';
import { getIconPaletteOptions } from '../../symbol_utils';

export function IconMapSelect({
customIconStops,
Expand All @@ -19,6 +19,7 @@ export function IconMapSelect({
styleProperty,
symbolOptions,
useCustomIconMap,
isCustomOnly,
}) {
function onMapSelectChange({ customMapStops, selectedMapId, useCustomMap }) {
onChange({
Expand All @@ -41,20 +42,18 @@ export function IconMapSelect({
);
}

const field = styleProperty.getField();
const defaultOptions = field.supportsAutoDomain() ? getIconPaletteOptions(isDarkMode) : [];

return (
<StyleMapSelect
onChange={onMapSelectChange}
customOptionLabel={i18n.translate('xpack.maps.styles.icon.customMapLabel', {
defaultMessage: 'Custom icon palette',
})}
options={defaultOptions}
options={getIconPaletteOptions(isDarkMode)}
customMapStops={customIconStops}
useCustomMap={field.supportsAutoDomain() ? useCustomIconMap : true}
useCustomMap={useCustomIconMap}
selectedMapId={iconPaletteId}
renderCustomStopsInput={renderCustomIconStopsInput}
isCustomOnly={isCustomOnly}
/>
);
}