-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [Maps] show vector tile labels on top * experiment with new sort algorithm * clean up * remove old sort method * add unit test for sort layer * tslint * clean up * make labelsOnTop configurable * tslint * more tslint * add another test case for single layer move * clarify should messages * fix assert not null operators * review feedback * update snapshot Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
3fd55b2
commit 3546349
Showing
15 changed files
with
577 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
x-pack/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { AnyAction, Dispatch } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import { LayerSettings } from './layer_settings'; | ||
import { | ||
updateLayerLabel, | ||
updateLayerMaxZoom, | ||
updateLayerMinZoom, | ||
updateLayerAlpha, | ||
updateLabelsOnTop, | ||
} from '../../../actions'; | ||
|
||
function mapDispatchToProps(dispatch: Dispatch<AnyAction>) { | ||
return { | ||
updateLabel: (id: string, label: string) => dispatch(updateLayerLabel(id, label)), | ||
updateMinZoom: (id: string, minZoom: number) => dispatch(updateLayerMinZoom(id, minZoom)), | ||
updateMaxZoom: (id: string, maxZoom: number) => dispatch(updateLayerMaxZoom(id, maxZoom)), | ||
updateAlpha: (id: string, alpha: number) => dispatch(updateLayerAlpha(id, alpha)), | ||
updateLabelsOnTop: (id: string, areLabelsOnTop: boolean) => | ||
dispatch(updateLabelsOnTop(id, areLabelsOnTop)), | ||
}; | ||
} | ||
|
||
const connectedLayerSettings = connect(null, mapDispatchToProps)(LayerSettings); | ||
export { connectedLayerSettings as LayerSettings }; |
87 changes: 0 additions & 87 deletions
87
x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js
This file was deleted.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
...ck/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { ChangeEvent, Fragment } from 'react'; | ||
import { | ||
EuiTitle, | ||
EuiPanel, | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiSpacer, | ||
EuiSwitch, | ||
EuiSwitchEvent, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { MAX_ZOOM } from '../../../../common/constants'; | ||
import { AlphaSlider } from '../../../components/alpha_slider'; | ||
import { ValidatedDualRange } from '../../../../../../../src/plugins/kibana_react/public'; | ||
import { ILayer } from '../../../classes/layers/layer'; | ||
|
||
interface Props { | ||
layer: ILayer; | ||
updateLabel: (layerId: string, label: string) => void; | ||
updateMinZoom: (layerId: string, minZoom: number) => void; | ||
updateMaxZoom: (layerId: string, maxZoom: number) => void; | ||
updateAlpha: (layerId: string, alpha: number) => void; | ||
updateLabelsOnTop: (layerId: string, areLabelsOnTop: boolean) => void; | ||
} | ||
|
||
export function LayerSettings(props: Props) { | ||
const minVisibilityZoom = props.layer.getMinSourceZoom(); | ||
const maxVisibilityZoom = MAX_ZOOM; | ||
const layerId = props.layer.getId(); | ||
|
||
const onLabelChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const label = event.target.value; | ||
props.updateLabel(layerId, label); | ||
}; | ||
|
||
const onZoomChange = (value: [string, string]) => { | ||
props.updateMinZoom(layerId, Math.max(minVisibilityZoom, parseInt(value[0], 10))); | ||
props.updateMaxZoom(layerId, Math.min(maxVisibilityZoom, parseInt(value[1], 10))); | ||
}; | ||
|
||
const onAlphaChange = (alpha: number) => { | ||
props.updateAlpha(layerId, alpha); | ||
}; | ||
|
||
const onLabelsOnTopChange = (event: EuiSwitchEvent) => { | ||
props.updateLabelsOnTop(layerId, event.target.checked); | ||
}; | ||
|
||
const renderZoomSliders = () => { | ||
return ( | ||
<ValidatedDualRange | ||
label={i18n.translate('xpack.maps.layerPanel.settingsPanel.visibleZoomLabel', { | ||
defaultMessage: 'Visibility', | ||
})} | ||
formRowDisplay="columnCompressed" | ||
min={minVisibilityZoom} | ||
max={maxVisibilityZoom} | ||
value={[props.layer.getMinZoom(), props.layer.getMaxZoom()]} | ||
showInput="inputWithPopover" | ||
showRange | ||
showLabels | ||
onChange={onZoomChange} | ||
allowEmptyRange={false} | ||
compressed | ||
prepend={i18n.translate('xpack.maps.layerPanel.settingsPanel.visibleZoom', { | ||
defaultMessage: 'Zoom levels', | ||
})} | ||
/> | ||
); | ||
}; | ||
|
||
const renderLabel = () => { | ||
return ( | ||
<EuiFormRow | ||
label={i18n.translate('xpack.maps.layerPanel.settingsPanel.layerNameLabel', { | ||
defaultMessage: 'Name', | ||
})} | ||
display="columnCompressed" | ||
> | ||
<EuiFieldText value={props.layer.getLabel()} onChange={onLabelChange} compressed /> | ||
</EuiFormRow> | ||
); | ||
}; | ||
|
||
const renderShowLabelsOnTop = () => { | ||
if (!props.layer.supportsLabelsOnTop()) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<EuiFormRow display="columnCompressedSwitch"> | ||
<EuiSwitch | ||
label={i18n.translate('xpack.maps.layerPanel.settingsPanel.labelsOnTop', { | ||
defaultMessage: `Show labels on top`, | ||
})} | ||
checked={props.layer.areLabelsOnTop()} | ||
onChange={onLabelsOnTopChange} | ||
data-test-subj="mapLayerPanelApplyGlobalQueryCheckbox" | ||
compressed | ||
/> | ||
</EuiFormRow> | ||
); | ||
}; | ||
|
||
return ( | ||
<Fragment> | ||
<EuiPanel> | ||
<EuiTitle size="xs"> | ||
<h5> | ||
<FormattedMessage | ||
id="xpack.maps.layerPanel.layerSettingsTitle" | ||
defaultMessage="Layer settings" | ||
/> | ||
</h5> | ||
</EuiTitle> | ||
|
||
<EuiSpacer size="m" /> | ||
{renderLabel()} | ||
{renderZoomSliders()} | ||
<AlphaSlider alpha={props.layer.getAlpha()} onChange={onAlphaChange} /> | ||
{renderShowLabelsOnTop()} | ||
</EuiPanel> | ||
|
||
<EuiSpacer size="s" /> | ||
</Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.