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

geosolutions-it / MapStore2 / 12669623181

08 Jan 2025 11:25AM UTC coverage: 76.812% (-0.3%) from 77.108%
12669623181

Pull #10731

github

web-flow
Merge f1474727f into d1ebec1ff
Pull Request #10731: Fix #10631 New MapStore Home Page

30930 of 48379 branches covered (63.93%)

827 of 1286 new or added lines in 70 files covered. (64.31%)

161 existing lines in 14 files now uncovered.

38448 of 50055 relevant lines covered (76.81%)

34.24 hits per line

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

91.67
/web/client/components/widgets/builder/wizard/map/enhancers/nodeEditor.js
1
/*
2
 * Copyright 2018, 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 { get } from 'lodash';
10
import { compose, withHandlers, withProps, withState } from 'recompose';
11

12
import {splitMapAndLayers} from '../../../../../../utils/LayersUtils';
13
import withControllableState from '../../../../../misc/enhancers/withControllableState';
14
import { settingsLifecycle } from '../../../../../TOC/enhancers/tocItemsSettings';
15
import Display from '../../../../../TOC/fragments/settings/Display';
16
/* TABS definitions */
17
import General from '../../../../../TOC/fragments/settings/General';
18
import WMSStyleComp from '../../../../../TOC/fragments/settings/WMSStyle';
19
import handleNodePropertyChanges from './handleNodePropertyChanges';
20
import mapToNodes from './mapToNodes';
21
import withCapabilitiesRetrieval from './withCapabilitiesRetrieval';
22
import withSelectedNode from './withSelectedNode';
23

24
const WMSStyle = withCapabilitiesRetrieval(WMSStyleComp);
1✔
25

26
const withDefaultTabs = withProps((props) => ({
14✔
27
    tabs: (props.tabs || [{
28✔
28
        id: 'general',
29
        titleId: 'layerProperties.general',
30
        tooltipId: 'layerProperties.general',
31
        glyph: 'wrench',
32
        visible: true,
33
        Component: General
34
    },
35
    {
36
        id: 'display',
37
        titleId: 'layerProperties.display',
38
        tooltipId: 'layerProperties.display',
39
        glyph: 'eye-open',
40
        visible: props.settings && props.settings.nodeType === 'layers',
28✔
41
        Component: Display
42
    },
43
    {
44
        id: 'style',
45
        titleId: 'layerProperties.style',
46
        tooltipId: 'layerProperties.style',
47
        glyph: 'dropper',
48
        visible: props.settings && props.settings.nodeType === 'layers' && props.element && props.element.type === "wms",
54✔
49
        Component: WMSStyle
50
    }]).filter(({ visible }) => !!visible)
42✔
51
}));
52

53
/**
54
 * Manages internal TOC node editor state exposing only
55
 * @prop {string} editNode the ID of the node to edit
56
 * @prop {object} map the map (with layers and groups)
57
 * @prop {function} onChange method called when a change has been applied
58
 * @example
59
 * // `path` can be something like `map.layers[idx].prop` (path definition of lodash get, set)
60
 * <EnhancedNodeEditor editNode={"LAYER_1"} map={map} onChange={(path, value) => set(map, path, value)} /> // set could be immutable version of lodash set
61
 */
62
export default compose(
63
    // select selected node
64
    mapToNodes,
65
    withSelectedNode,
66
    // manage settings variables for local changes (required by tocItemsSettings tabs)
67
    withState('settings', 'onUpdateSettings', {}),
68
    // transform selected node to fit tocItemsSettings props
69
    withProps(({ map = {}, selectedNode, settings = {}} = {}) => ({
11!
70
        element: selectedNode,
71
        settings: {
72
            ...settings,
73
            nodeType: selectedNode && selectedNode.nodes ? "groups" : "layers",
33✔
74
            options: {
75

76
                opacity: settings.opacity >= 0
11!
77
                    ? settings.opacity
78
                    : selectedNode.opacity >= 0
11!
79
                        ? selectedNode.opacity
80
                        : 1
81
            }
82
        },
83
        projection: map.projection,
84
        mapSize: map.size,
85
        mapBbox: map.bbox,
86
        groups: get(splitMapAndLayers(map), 'layers.groups')
87
    })),
88
    // adapter for handlers
89
    compose(
90
        handleNodePropertyChanges,
91
        withHandlers({
92
            onUpdateNode: ({changeLayerProperty = () => {}, changeGroupProperty = () => {}, editNode}) => (node, type, newProps) => {
1!
93
                if (type === "layers") {
1!
94
                    Object.keys(newProps).map(k => changeLayerProperty(editNode, k, newProps[k]));
1✔
95
                }
96
                if (type === "groups") {
1!
UNCOV
97
                    Object.keys(newProps).map(k => changeGroupProperty(editNode, k, newProps[k]));
×
98
                }
99
            }
100
        }),
101
        withHandlers({
102
            onUpdateParams: ({ settings = {}, onUpdateNode = () => { } }) => (newParams, doUpdate = true) => {
1!
103
                if (doUpdate) {
1!
104
                    onUpdateNode(
1✔
105
                        settings.node,
106
                        settings.nodeType,
107
                        { ...settings.props, ...newParams }
108
                    );
109
                }
110
            }
111
        })
112
    ),
113
    // manage local changes
114
    settingsLifecycle,
115
    // manage tabs of node editor
116
    withControllableState('activeTab', 'setActiveTab', 'general'),
117
    withDefaultTabs
118
);
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

© 2026 Coveralls, Inc