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

knowledgepixels / nanodash / 18596035671

17 Oct 2025 02:37PM UTC coverage: 13.583% (-0.9%) from 14.51%
18596035671

push

github

tkuhn
feat(Spaces): Use context param to direct user back to space page

452 of 4210 branches covered (10.74%)

Branch coverage included in aggregate %.

1171 of 7739 relevant lines covered (15.13%)

0.68 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 java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Collections;
6
import java.util.Comparator;
7
import java.util.List;
8

9
import org.apache.commons.lang3.tuple.Pair;
10
import org.apache.wicket.markup.html.WebMarkupContainer;
11
import org.apache.wicket.markup.html.panel.Panel;
12
import org.apache.wicket.markup.repeater.Item;
13
import org.apache.wicket.markup.repeater.data.DataView;
14
import org.apache.wicket.markup.repeater.data.ListDataProvider;
15
import org.apache.wicket.request.mapper.parameter.PageParameters;
16

17
import com.knowledgepixels.nanodash.GrlcQuery;
18
import com.knowledgepixels.nanodash.Space;
19
import com.knowledgepixels.nanodash.template.Template;
20

21
public class PinGroupList extends Panel {
22

23
    public PinGroupList(String markupId, Space space) {
24
        super(markupId);
×
25

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

33
        final PageParameters qParams = new PageParameters();
×
34
        qParams.add("queryparam_space", space.getId());
×
35

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

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

78
        add(new WebMarkupContainer("emptynotice").setVisible(pinnedResourcesList.isEmpty()));
×
79
    }
×
80

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

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