• 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

45.0
/web/client/plugins/WidgetsBuilder.jsx
1
/*
2
 * Copyright 2017, 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
import PropTypes from 'prop-types';
11
import epics from '../epics/widgetsbuilder';
12
import { createPlugin } from '../utils/PluginsUtils';
13

14
import DockPanel from "../components/misc/panels/DockPanel";
15

16
import {connect} from 'react-redux';
17
import {createSelector} from 'reselect';
18
import { compose } from 'recompose';
19

20
import {setControlProperty} from '../actions/controls';
21

22
import {mapLayoutValuesSelector} from '../selectors/maplayout';
23
import {widgetBuilderSelector, widgetBuilderAvailable} from '../selectors/controls';
24
import { dependenciesSelector, availableDependenciesForEditingWidgetSelector} from '../selectors/widgets';
25
import { toggleConnection, createWidget } from '../actions/widgets';
26
import withMapExitButton from './widgetbuilder/enhancers/withMapExitButton';
27
import WidgetTypeBuilder from './widgetbuilder/WidgetTypeBuilder';
28
import FeatureEditorButton from './widgetbuilder/FeatureEditorButton';
29
const Builder = compose(
1✔
30
    connect(
31
        createSelector(
32
            dependenciesSelector,
33
            availableDependenciesForEditingWidgetSelector,
34
            (dependencies, availableDependenciesProps) => ({ dependencies, ...availableDependenciesProps }))
×
35
        , { toggleConnection }),
36
    withMapExitButton
37
)(WidgetTypeBuilder);
38

39
class SideBarComponent extends React.Component {
40
     static propTypes = {
1✔
41
         id: PropTypes.string,
42
         enabled: PropTypes.bool,
43
         limitDockHeight: PropTypes.bool,
44
         fluid: PropTypes.bool,
45
         zIndex: PropTypes.number,
46
         dockSize: PropTypes.number,
47
         position: PropTypes.string,
48
         onMount: PropTypes.func,
49
         onUnmount: PropTypes.func,
50
         onClose: PropTypes.func,
51
         dimMode: PropTypes.string,
52
         src: PropTypes.string,
53
         style: PropTypes.object,
54
         layout: PropTypes.object
55
     };
56
     static defaultProps = {
1✔
57
         id: "widgets-builder-plugin",
58
         enabled: false,
59
         dockSize: 500,
60
         limitDockHeight: true,
61
         zIndex: 10000,
62
         fluid: false,
63
         dimMode: "none",
64
         position: "left",
65
         onMount: () => {},
66
         onUnmount: () => {},
67
         onClose: () => {},
68
         layout: {}
69
     };
70
     componentDidMount() {
71
         this.props.onMount();
×
72
     }
73

74
     componentWillUnmount() {
75
         this.props.onUnmount();
×
76
     }
77
     render() {
78
         return (
×
79
             <DockPanel
80
                 open={this.props.enabled}
81
                 size={this.props.dockSize}
82
                 zIndex={this.props.zIndex}
83
                 position={this.props.position}
84
                 className="widgets-builder"
85
                 bsStyle="primary"
86
                 hideHeader
87
                 style={{...this.props.layout, background: "white"}}>
88
                 <Builder
89
                     enabled={this.props.enabled}
90
                     onClose={this.props.onClose}
91
                     typeFilter={({ type } = {}) => type !== 'map' && type !== 'legend'}
×
92
                 />
93
             </DockPanel>);
94

95
     }
96
}
97
/**
98
 * Editor for map widgets
99
 * @memberof plugins
100
 * @name WidgetsBuilder
101
 * @class
102
 *
103
 */
104
const Plugin = connect(
1✔
105
    createSelector(
106
        widgetBuilderSelector,
107
        state => mapLayoutValuesSelector(state, {height: true}),
×
108
        (enabled, layout) => ({
×
109
            enabled,
110
            layout
111
        })), {
112
        onMount: () => setControlProperty("widgetBuilder", "available", true),
×
113
        onUnmount: () => setControlProperty("widgetBuilder", "available", false),
×
114
        onClose: setControlProperty.bind(null, "widgetBuilder", "enabled", false, false)
115
    }
116
)(SideBarComponent);
117

118
const WidgetsBuilderButton = connect((state) => ({ available: widgetBuilderAvailable(state) }), {
1✔
119
    onClick: createWidget
120
})(({
121
    onClick,
122
    selectedNodes,
123
    status,
124
    itemComponent,
125
    statusTypes,
126
    available,
127
    ...props
128
}) => {
129
    const ItemComponent = itemComponent;
1✔
130
    const layer = selectedNodes?.[0]?.node;
1✔
131
    if (available && [statusTypes.LAYER].includes(status) && layer?.search && layer.search !== 'vector') {
1!
132
        return (
1✔
133
            <ItemComponent
134
                {...props}
135
                glyph="stats"
136
                tooltipId={'toc.createWidget'}
UNCOV
137
                onClick={() => layer?.error ? onClick({ mapSync: false }) : onClick()} // allows anyway to create a widget, not connected to map
×
138
            />
139
        );
140
    }
UNCOV
141
    return null;
×
142
});
143

144
export default createPlugin('WidgetsBuilder', {
145
    component: Plugin,
146
    epics,
147
    containers: {
148
        TOC: {
149
            doNotHide: true,
150
            name: "WidgetBuilder",
151
            target: 'toolbar',
152
            Component: WidgetsBuilderButton,
153
            position: 10
154
        },
155
        FeatureEditor: {
156
            doNotHide: true,
157
            target: "toolbar",
158
            position: 21,
159
            Component: FeatureEditorButton
160
        }
161
    }
162
});
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