forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maps] Add global fit to data (elastic#64702)
- Loading branch information
1 parent
b27d7c0
commit 67e4113
Showing
12 changed files
with
213 additions
and
5 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
44 changes: 44 additions & 0 deletions
44
...s/public/connected_components/toolbar_overlay/__snapshots__/toolbar_overlay.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
x-pack/plugins/maps/public/connected_components/toolbar_overlay/fit_to_data/fit_to_data.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,38 @@ | ||
/* | ||
* 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 { EuiButtonIcon } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { ILayer } from '../../../layers/layer'; | ||
|
||
interface Props { | ||
layerList: ILayer[]; | ||
fitToBounds: () => void; | ||
} | ||
|
||
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="expand" | ||
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', | ||
})} | ||
/> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/maps/public/connected_components/toolbar_overlay/fit_to_data/index.ts
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,29 @@ | ||
/* | ||
* 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 { MapStoreState } from '../../../reducers/store'; | ||
import { fitToDataBounds } from '../../../actions/map_actions'; | ||
import { getFittableLayers } from '../../../selectors/map_selectors'; | ||
import { FitToData } from './fit_to_data'; | ||
|
||
function mapStateToProps(state: MapStoreState) { | ||
return { | ||
layerList: getFittableLayers(state), | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(dispatch: Dispatch<AnyAction>) { | ||
return { | ||
fitToBounds: () => { | ||
dispatch(fitToDataBounds()); | ||
}, | ||
}; | ||
} | ||
|
||
const connectedFitToData = connect(mapStateToProps, mapDispatchToProps)(FitToData); | ||
export { connectedFitToData as FitToData }; |
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
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/maps/public/connected_components/toolbar_overlay/toolbar_overlay.test.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,21 @@ | ||
/* | ||
* 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'; | ||
|
||
// @ts-ignore | ||
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
6
...toc_entry/toc_entry_actions_popover/__snapshots__/toc_entry_actions_popover.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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