• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 19710972030

26 Nov 2025 03:38PM UTC coverage: 76.665% (-0.3%) from 76.929%
19710972030

Pull #11119

github

web-flow
Fix maven publish (#11739)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32272 of 50209 branches covered (64.28%)

3 of 3 new or added lines in 2 files covered. (100.0%)

3018 existing lines in 249 files now uncovered.

40157 of 52380 relevant lines covered (76.66%)

37.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/web/client/plugins/Toolbar.jsx
1
/*
2
 * Copyright 2016, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import React from 'react';
10

11
import PropTypes from 'prop-types';
12
import { connect } from 'react-redux';
13
import { CSSTransitionGroup } from 'react-transition-group';
14
import { isFeatureGridOpen } from '../selectors/featuregrid';
15
import { mapLayoutValuesSelector } from '../selectors/maplayout';
16
import { createSelector } from 'reselect';
17
import ToolsContainer from './containers/ToolsContainer';
18

19
class AnimatedContainer extends React.Component {
20
    render() {
21
        const {children, ...props} = this.props;
1✔
22
        return (<CSSTransitionGroup {...props} transitionName="toolbarexpand" transitionEnterTimeout={500} transitionLeaveTimeout={300}>
1✔
23
            {children}
24
        </CSSTransitionGroup>);
25
    }
26
}
27
// only for tests
28
class NormalContainer extends React.Component {
29
    render() {
30
        const { children, ...props } = this.props;
4✔
31
        return (<div {...props}>
4✔
32
            {children}
33
        </div>);
34
    }
35
}
36

37
class Toolbar extends React.Component {
38
    static propTypes = {
1✔
39
        id: PropTypes.string,
40
        tools: PropTypes.array,
41
        style: PropTypes.object,
42
        panelStyle: PropTypes.object,
43
        panelClassName: PropTypes.string,
44
        disableAnimation: PropTypes.bool,
45
        active: PropTypes.string,
46
        items: PropTypes.array,
47
        allVisible: PropTypes.bool,
48
        layout: PropTypes.string,
49
        stateSelector: PropTypes.string,
50
        buttonStyle: PropTypes.string,
51
        buttonSize: PropTypes.string,
52
        pressedButtonStyle: PropTypes.string,
53
        btnConfig: PropTypes.object
54
    };
55

56
    static contextTypes = {
1✔
57
        messages: PropTypes.object,
58
        router: PropTypes.object
59
    };
60

61
    static defaultProps = {
1✔
62
        id: "mapstore-toolbar",
63
        style: {},
64
        panelStyle: {
65
            minWidth: "300px",
66
            right: "52px",
67
            zIndex: 100,
68
            position: "absolute",
69
            overflow: "auto",
70
            left: "450px"
71
        },
72
        panelClassName: "toolbar-panel",
73
        disableAnimation: false,
74
        items: [],
75
        allVisible: true,
76
        layout: "vertical",
77
        stateSelector: "toolbar",
78
        buttonStyle: 'primary',
79
        buttonSize: null,
80
        pressedButtonStyle: 'success',
81
        btnConfig: {
82
            className: "square-button"
83
        }
84
    };
85

86
    getPanel = (tool) => {
2✔
UNCOV
87
        if (tool.panel === true) {
×
88
            return tool.plugin;
×
89
        }
UNCOV
90
        return tool.panel;
×
91
    };
92

93
    getPanels = () => {
2✔
94
        return this.getTools()
5✔
95
            .filter((tool) => tool.panel)
8✔
UNCOV
96
            .map((tool) => ({name: tool.name, title: tool.title, cfg: tool.cfg, panel: this.getPanel(tool), items: tool.items, wrap: tool.wrap || false}));
×
97
    };
98

99
    getTools = () => {
2✔
100
        const hidableItems = this.props.items.filter((item) => !item.alwaysVisible) || [];
26!
101
        const unsorted = this.props.items
10✔
102
            .filter((item) =>
103
                item.alwaysVisible // items not hidden (by expander)
26✔
104
                || hidableItems.length === 1 // if the item is only one, the expander will not show, instead we have only the item
105
                || this.props.allVisible) // expanded state, all items are visible, no filtering.
106
            .filter(item => item.showWhen ? item.showWhen(this.props) : true) // optional display option (used by expander, that depends on other)
18✔
107
            .map((item, index) => Object.assign({}, item, {position: item.position || index}));
16!
108
        return unsorted.sort((a, b) => a.position - b.position);
10✔
109
    };
110

111
    render() {
112
        const Container = this.props.disableAnimation ? NormalContainer : AnimatedContainer;
5✔
113
        return (<ToolsContainer id={this.props.id} className={"mapToolbar btn-group-" + this.props.layout}
5✔
114
            toolCfg={this.props.btnConfig}
115
            container={Container}
116
            toolStyle={this.props.buttonStyle}
117
            activeStyle={this.props.pressedButtonStyle}
118
            toolSize={this.props.buttonSize}
119
            stateSelector={this.props.stateSelector}
120
            tools={this.getTools()}
121
            panels={this.getPanels()}
122
            activePanel={this.props.active}
123
            style={this.props.layout !== 'vertical' ? {...this.props.style, display: 'flex'} : this.props.style}
5!
124
            panelStyle={this.props.panelStyle}
125
            panelClassName={this.props.panelClassName}
126
        />);
127
    }
128
}
129

130
const toolbarSelector = stateSelector => createSelector([
1✔
131
    state => state.controls && state.controls[stateSelector] && state.controls[stateSelector].active,
5✔
132
    state => state.controls && state.controls[stateSelector] && state.controls[stateSelector].expanded,
5✔
133
    isFeatureGridOpen,
134
    state => mapLayoutValuesSelector(state, {right: true, bottom: true})
5✔
135
], (active, allVisible, featuregridOpen, style) => ({
2✔
136
    active,
137
    allVisible,
138
    stateSelector,
139
    layout: featuregridOpen ? 'horizontal' : 'vertical',
2!
140
    style
141
}));
142

143
/**
144
 * Container for map tools, rendered in the bottom right corner of the map.
145
 * @name Toolbar
146
 * @class
147
 * @memberof plugins
148
 */
149
export default {
150
    ToolbarPlugin: (stateSelector = 'toolbar') => connect(toolbarSelector(stateSelector))(Toolbar),
1!
151
    reducers: {controls: require('../reducers/controls').default}
152
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc