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

knowledgepixels / nanodash / 23058020851

13 Mar 2026 03:30PM UTC coverage: 15.702% (+0.02%) from 15.686%
23058020851

push

github

web-flow
Merge pull request #394 from knowledgepixels/393-read-only-pinned-section

Make obsolete Pinned section read-only

710 of 5491 branches covered (12.93%)

Branch coverage included in aggregate %.

1754 of 10201 relevant lines covered (17.19%)

2.36 hits per line

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

0.0
src/main/java/com/knowledgepixels/nanodash/component/PinGroupList.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.GrlcQuery;
4
import com.knowledgepixels.nanodash.domain.Space;
5
import com.knowledgepixels.nanodash.template.Template;
6
import org.apache.commons.lang3.tuple.Pair;
7
import org.apache.wicket.markup.html.panel.Panel;
8
import org.apache.wicket.markup.repeater.Item;
9
import org.apache.wicket.markup.repeater.data.DataView;
10
import org.apache.wicket.markup.repeater.data.ListDataProvider;
11
import org.apache.wicket.request.mapper.parameter.PageParameters;
12

13
import java.io.Serializable;
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.Comparator;
17
import java.util.List;
18

19
public class PinGroupList extends Panel {
20

21
    public PinGroupList(String markupId, Space space) {
22
        super(markupId);
×
23

24
        final PageParameters tParams = new PageParameters();
×
25
        tParams.set("param_space", space.getId());
×
26
        tParams.set("context", space.getId());
×
27
        if (space.getDefaultProvenance() != null) {
×
28
            tParams.set("prtemplate", space.getDefaultProvenance().stringValue());
×
29
        }
30

31
        final PageParameters qParams = new PageParameters();
×
32
        qParams.set("queryparam_space", space.getId());
×
33

34
        List<Pair<String, List<Serializable>>> pinnedResourcesList = new ArrayList<>();
×
35
        List<String> pinGroupTags = new ArrayList<>(space.getPinGroupTags());
×
36
        Collections.sort(pinGroupTags);
×
37
        List<Serializable> pinnedResources = new ArrayList<>(space.getPinnedResources());
×
38
        for (String tag : pinGroupTags) {
×
39
            for (Object pinned : space.getPinnedResourceMap().get(tag)) {
×
40
                pinnedResources.remove(pinned);
×
41
            }
×
42
            List<Serializable> list = new ArrayList<>(space.getPinnedResourceMap().get(tag));
×
43
            Collections.sort(list, new Comparator<Serializable>() {
×
44
                @Override
45
                public int compare(Serializable s0, Serializable s1) {
46
                    return getName(s0).compareTo(getName(s1));
×
47
                }
48
            });
49
            pinnedResourcesList.add(Pair.of(tag, list));
×
50
        }
×
51
        if (!pinnedResources.isEmpty()) {
×
52
            String l = pinnedResourcesList.isEmpty() ? "Resources" : "Other Resources";
×
53
            pinnedResourcesList.add(Pair.of(l, pinnedResources));
×
54
        }
55

56
        add(new DataView<Pair<String, List<Serializable>>>("pin-groups", new ListDataProvider<>(pinnedResourcesList)) {
×
57
            @Override
58
            protected void populateItem(Item<Pair<String, List<Serializable>>> item) {
59
                item.add(new ItemListPanel<Serializable>(
×
60
                        "pin-group",
61
                        item.getModelObject().getLeft(),
×
62
                        item.getModelObject().getRight(),
×
63
                        (o) -> {
64
                            if (o instanceof Template t) {
×
65
                                t.addToLabelMap(space.getId(), space.getLabel());
×
66
                                return new TemplateItem("item", t, tParams, false);
×
67
                            }
68
                            if (o instanceof GrlcQuery q) {
×
69
                                return new QueryItem("item", q, qParams, false);
×
70
                            }
71
                            return null;
×
72
                        }));
73
            }
×
74
        });
75

76
        setVisible(!pinnedResourcesList.isEmpty());
×
77
    }
×
78

79
    private static String getName(Serializable s) {
80
        if (s instanceof GrlcQuery q) return q.getLabel();
×
81
        if (s instanceof Template t) return t.getLabel();
×
82
        return s.toString();
×
83
    }
84

85
}
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