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

geosolutions-it / MapStore2 / 14246996716

03 Apr 2025 03:34PM UTC coverage: 76.922% (-0.05%) from 76.971%
14246996716

Pull #10925

github

web-flow
Merge 775cc2f92 into 646bb6e37
Pull Request #10925: #10923, #10924: Disabling GeoFence Rules and Add filter by IP for GeoFence rules

31068 of 48387 branches covered (64.21%)

61 of 109 new or added lines in 10 files covered. (55.96%)

147 existing lines in 34 files now uncovered.

38588 of 50165 relevant lines covered (76.92%)

35.81 hits per line

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

47.62
/web/client/plugins/TOC/containers/RemoveNodesButton.jsx
1
/*
2
 * Copyright 2024, 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, { useState } from 'react';
10
import { connect } from 'react-redux';
11
import { removeNode } from '../../../actions/layers';
12
import ConfirmModal from '../../../components/layout/ConfirmDialog';
13
import Portal from '../../../components/misc/Portal';
14

15

16
const getRemoveNodes = (node) => {
1✔
17
    return [
×
18
        ...(node?.id ? [ node ] : []),
×
19
        ...(node?.nodes || []).map(getRemoveNodes).flat()
×
20
    ];
21
};
22
/**
23
 * This component provides the remove node actions to make them available inside the toolbar or context menu
24
 */
25
const RemoveNodesButton = connect(() => ({}), {
42✔
26
    onRemove: removeNode
27
})(({
28
    onRemove,
29
    status,
30
    itemComponent,
31
    selectedNodes,
32
    statusTypes,
33
    nodeTypes,
34
    config,
35
    rootGroupId,
36
    ...props
37
}) => {
38

39
    const ItemComponent = itemComponent;
42✔
40
    const [showDeleteDialog, setShowDeleteDialog] = useState(null);
42✔
41

42
    function handleRemoveNodes() {
43
        const { nodes } = showDeleteDialog || {};
×
44
        const nodesToRemove = getRemoveNodes({ id: null, nodes });
×
45
        nodesToRemove.forEach((node) => {
×
46
            onRemove(node.id, node?.nodes ? nodeTypes.GROUP : nodeTypes.LAYER);
×
47
        });
48
        setShowDeleteDialog(null);
×
49
    }
50

51
    if (selectedNodes?.[0]?.id === rootGroupId) {
42!
52
        return null;
×
53
    }
54

55
    if (config.activateRemoveLayer === false && [statusTypes.LAYER, statusTypes.LAYERS].includes(status)) {
42!
56
        return null;
×
57
    }
58

59
    if (config.activateRemoveGroup === false && [statusTypes.GROUP, statusTypes.GROUPS].includes(status)) {
42!
60
        return null;
×
61
    }
62

63
    const isSelectedGroup = [statusTypes.GROUP, statusTypes.GROUPS, statusTypes.BOTH].includes(status);
42✔
64
    const isSingleLayer = statusTypes.LAYER === status;
42✔
65
    return (
42✔
66
        <>
67
            {[statusTypes.LAYER, statusTypes.LAYERS, statusTypes.GROUP, statusTypes.GROUPS, statusTypes.BOTH].includes(status) ? <ItemComponent
42✔
68
                {...props}
69
                glyph="trash"
70
                active={showDeleteDialog}
71
                labelId={
72
                    isSelectedGroup
8!
73
                        ? 'toc.toolTrashGroupTooltip'
74
                        : isSingleLayer
8!
75
                            ? 'toc.toolTrashLayerTooltip'
76
                            : 'toc.toolTrashLayersTooltip'
77
                }
78
                tooltipId={
79
                    isSelectedGroup
8!
80
                        ? 'toc.toolTrashGroupTooltip'
81
                        : isSingleLayer
8!
82
                            ? 'toc.toolTrashLayerTooltip'
83
                            : 'toc.toolTrashLayersTooltip'
84
                }
85
                onClick={() => setShowDeleteDialog({ nodes: selectedNodes.map(({ node }) => node) })}
×
86
            /> : null}
87
            <Portal>
88
                <ConfirmModal
89
                    show= {!!showDeleteDialog}
UNCOV
90
                    onCancel={() => setShowDeleteDialog(null)}
×
91
                    onConfirm={handleRemoveNodes}
92
                    preventHide
93
                    titleId= { isSelectedGroup ? "layerProperties.deleteLayerGroupMessage" : "layerProperties.deleteLayerMessage" }
42!
94
                    confirmId={`layerProperties.delete`}
95
                    cancelId={`cancel`}
96
                    variant="danger"
97
                />
98
            </Portal>
99
        </>
100
    );
101
});
102

103
export default RemoveNodesButton;
104

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