Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] clean up tooltip header and footer #41793

Merged
merged 1 commit into from
Jul 23, 2019
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

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 @@ -7,17 +7,17 @@
import React, { Fragment } from 'react';
import {
EuiButtonIcon,
EuiText,
EuiPagination,
EuiSelect,
EuiIconTip,
EuiHorizontalRule,
EuiFlexGroup,
EuiFlexItem
EuiFlexItem,
EuiTextColor
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FeatureProperties } from './feature_properties';

import { FormattedMessage } from '@kbn/i18n/react';

const ALL_LAYERS = '_ALL_LAYERS_';
const DEFAULT_PAGE_NUMBER = 0;
Expand Down Expand Up @@ -48,7 +48,6 @@ export class FeatureTooltip extends React.Component {
}

_onLayerChange = (e) => {

const layerId = e.target.value;
if (this.state.layerIdFilter === layerId) {
return;
Expand All @@ -70,14 +69,12 @@ export class FeatureTooltip extends React.Component {
};

_loadUniqueLayers = async () => {

if (this._prevFeatures === this.props.features) {
return;
}

this._prevFeatures = this.props.features;


const countByLayerId = new Map();
for (let i = 0; i < this.props.features.length; i++) {
let count = countByLayerId.get(this.props.features[i].layerId);
Expand Down Expand Up @@ -115,7 +112,6 @@ export class FeatureTooltip extends React.Component {
}
};


_renderProperties(features) {
const feature = features[this.state.pageNumber];
if (!feature) {
Expand Down Expand Up @@ -159,6 +155,7 @@ export class FeatureTooltip extends React.Component {
onChange={this._onLayerChange}
valueOfSelected={this.state.layerIdFilter}
compressed
fullWidth
aria-label={i18n.translate('xpack.maps.tooltip.layerFilterLabel', {
defaultMessage: 'Filter results by layer'
})}
Expand All @@ -167,7 +164,6 @@ export class FeatureTooltip extends React.Component {
}

_renderHeader() {

if (!this.props.isLocked) {
return null;
}
Expand All @@ -176,8 +172,8 @@ export class FeatureTooltip extends React.Component {
<EuiHorizontalRule margin="xs"/> : null;
return (
<Fragment>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem>
{this._renderLayerFilterBox()}
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -190,7 +186,6 @@ export class FeatureTooltip extends React.Component {
}

_renderFooter(filteredFeatures) {

if (filteredFeatures.length === 1) {
return null;
}
Expand All @@ -216,7 +211,6 @@ export class FeatureTooltip extends React.Component {
);
}


_onPageChange = (pageNumber) => {
this.setState({
pageNumber: pageNumber,
Expand All @@ -234,9 +228,17 @@ export class FeatureTooltip extends React.Component {
}

_renderPagination(filteredFeatures) {

const pageNumberReadout = (
<EuiText size="s"><b>{(this.state.pageNumber + 1)}</b> of <b>{filteredFeatures.length}</b></EuiText>
<EuiTextColor color="subdued">
<FormattedMessage
id="xpack.maps.tooltip.pageNumerText"
defaultMessage="{pageNumber} of {total} features"
values={{
pageNumber: this.state.pageNumber + 1,
total: filteredFeatures.length
}}
/>
</EuiTextColor>
);

const cycleArrows = (this.props.isLocked) ? (<EuiPagination
Expand Down Expand Up @@ -270,7 +272,6 @@ export class FeatureTooltip extends React.Component {
</EuiFlexGroup>
</Fragment>
);

}

render() {
Expand All @@ -284,4 +285,3 @@ export class FeatureTooltip extends React.Component {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ import { shallow } from 'enzyme';
import { FeatureTooltip } from './feature_tooltip';

class MockLayer {

constructor(id) {
this._id = id;
}
async getDisplayName() {
return `display + ${this._id}`;
}

}


const MULTI_FEATURE_MULTI_LAYER = [
{
'id': 'feature1',
Expand Down Expand Up @@ -88,7 +85,6 @@ describe('FeatureTooltip (single)', () => {
expect(component)
.toMatchSnapshot();
});

});

describe('FeatureTooltip (multi)', () => {
Expand Down Expand Up @@ -145,7 +141,4 @@ describe('FeatureTooltip (multi)', () => {
expect(component)
.toMatchSnapshot();
});



});