Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed May 4, 2020
1 parent 12fb8bd commit a87972b
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 31 deletions.

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 @@ -13,6 +13,11 @@
background-color: $euiColorEmptyShade !important;
pointer-events: all;

display: inline-block;
position: relative;
vertical-align: middle;
max-width: 100%;

&:enabled,
&:enabled:hover,
&:enabled:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,24 @@ interface Props {
fitToBounds: () => void;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface State {}

// eslint-disable-next-line react/prefer-stateless-function
export class FitToData extends Component<Props, State> {
render() {
if (this.props.layerList.length === 0) {
return null;
}

return (
<EuiButtonIcon
className="mapToolbarOverlay__button"
onClick={this.props.fitToBounds}
data-test-subj="fitToData"
iconType="search"
color="text"
aria-label={i18n.translate('xpack.maps.fitToData.fitButtonLabel', {
defaultMessage: 'Fit to data bounds',
})}
title={i18n.translate('xpack.maps.fitToData.fitAriaLabel', {
defaultMessage: 'Fit to data bounds',
})}
/>
);
export const FitToData: React.FunctionComponent<Props> = ({ layerList, fitToBounds }: Props) => {
if (layerList.length === 0) {
return null;
}
}

return (
<EuiButtonIcon
className="mapToolbarOverlay__button"
onClick={fitToBounds}
data-test-subj="fitToData"
iconType="search"
color="text"
aria-label={i18n.translate('xpack.maps.fitToData.fitButtonLabel', {
defaultMessage: 'Fit to data bounds',
})}
title={i18n.translate('xpack.maps.fitToData.fitAriaLabel', {
defaultMessage: 'Fit to data bounds',
})}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export class ToolbarOverlay extends React.Component {
<SetViewControl />
</EuiFlexItem>

{this._renderToolsControl()}

<EuiFlexItem>
<FitToData />
</EuiFlexItem>

{this._renderToolsControl()}
</EuiFlexGroup>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 from 'react';
import { shallow } from 'enzyme';

import { ToolbarOverlay } from './toolbar_overlay';

test('Must render zoom tools', async () => {
const component = shallow(<ToolbarOverlay />);
expect(component).toMatchSnapshot();
});

test('Must zoom tools and draw filter tools', async () => {
const component = shallow(<ToolbarOverlay addFilters={() => {}} geoFields={['coordinates']} />);
expect(component).toMatchSnapshot();
});
6 changes: 3 additions & 3 deletions x-pack/plugins/maps/public/selectors/map_selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ export const getFittableLayers = createSelector(getLayerList, layerList => {
//These are the only layer-types that implement bounding-box retrieval reliably
//This will _not_ work if Maps will allow register custom layer types
const isFittable =
layer.constructor.type === LAYER_TYPE.VECTOR ||
layer.constructor.type === LAYER_TYPE.BLENDED_VECTOR ||
layer.constructor.type === LAYER_TYPE.HEATMAP;
layer.getType() === LAYER_TYPE.VECTOR ||
layer.getType() === LAYER_TYPE.BLENDED_VECTOR ||
layer.getType() === LAYER_TYPE.HEATMAP;

return isFittable && layer.isVisible();
});
Expand Down

0 comments on commit a87972b

Please sign in to comment.