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

knowledgepixels / nanodash / 27622310436

16 Jun 2026 01:49PM UTC coverage: 26.963% (+6.3%) from 20.697%
27622310436

Pull #483

github

web-flow
Merge dbba567c9 into 663f14f46
Pull Request #483: Space/resource About pages, ref-aware spaces, and magic query params

1542 of 6717 branches covered (22.96%)

Branch coverage included in aggregate %.

3407 of 11638 relevant lines covered (29.27%)

4.31 hits per line

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

45.45
src/main/java/com/knowledgepixels/nanodash/component/JustPublishedMessagePanel.java
1
package com.knowledgepixels.nanodash.component;
2

3
import org.apache.wicket.ajax.AjaxRequestTarget;
4
import org.apache.wicket.ajax.markup.html.AjaxLink;
5
import org.apache.wicket.markup.html.WebMarkupContainer;
6
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
7
import org.apache.wicket.markup.html.link.ExternalLink;
8
import org.apache.wicket.markup.html.panel.Panel;
9
import org.apache.wicket.model.Model;
10
import org.apache.wicket.request.mapper.parameter.PageParameters;
11
import org.nanopub.Nanopub;
12
import org.nanopub.NanopubUtils;
13
import org.nanopub.vocabulary.NPX;
14

15
import com.knowledgepixels.nanodash.NanodashSession;
16
import com.knowledgepixels.nanodash.Utils;
17
import com.knowledgepixels.nanodash.domain.User;
18
import com.knowledgepixels.nanodash.page.ExplorePage;
19
import com.knowledgepixels.nanodash.page.ProfilePage;
20
import com.knowledgepixels.nanodash.page.UserPage;
21

22
/**
23
 * Title-bar message panel rendering up to two stacked boxes:
24
 * <ul>
25
 *   <li>a blue "successfully published" confirmation box, shown only right after
26
 *       publishing (i.e. when the page carries a "just-published" parameter) and
27
 *       dismissable via a close button; and</li>
28
 *   <li>a red "you haven't published an introduction yet" warning box, shown on
29
 *       <em>every</em> page (no close button) whenever a logged-in user with a
30
 *       local key has not yet published an introduction linking that key to their
31
 *       ORCID. It disappears only once such an introduction is published.</li>
32
 * </ul>
33
 */
34
public class JustPublishedMessagePanel extends Panel {
35

36
    public JustPublishedMessagePanel(String id, PageParameters parameters) {
37
        super(id);
9✔
38
        // Placeholder tag so the centered title-bar slot collapses cleanly when
39
        // there is nothing to show.
40
        setOutputMarkupPlaceholderTag(true);
12✔
41

42
        NanodashSession session = NanodashSession.get();
6✔
43
        String justPublishedId = parameters.get("just-published").toString("");
18✔
44
        boolean justPublished = !justPublishedId.isEmpty();
15!
45

46
        // --- Confirmation box: only right after publishing; dismissable. ---
47
        final WebMarkupContainer confirmBox = new WebMarkupContainer("confirmBox");
15✔
48
        confirmBox.setOutputMarkupPlaceholderTag(true);
12✔
49
        confirmBox.setVisible(justPublished);
12✔
50
        add(confirmBox);
27✔
51
        if (justPublished) {
6!
52
            confirmBox.add(new AjaxLink<Void>("confirmClose") {
×
53
                @Override
54
                public void onClick(AjaxRequestTarget target) {
55
                    confirmBox.setVisible(false);
×
56
                    target.add(confirmBox);
×
57
                }
×
58
            }.setBody(Model.of("×")));
×
59
            Nanopub np = Utils.getAsNanopub(justPublishedId);
×
60
            String label = (np != null ? NanopubUtils.getLabel(np) : null);
×
61
            if (label == null || label.isEmpty()) label = Utils.getShortNameFromURI(justPublishedId);
×
62
            confirmBox.add(new BookmarkablePageLink<Void>("link", ExplorePage.class, new PageParameters().set("id", justPublishedId)).setBody(Model.of(label)));
×
63
            // Remember a freshly-published introduction so the warning below clears.
64
            if (np != null && Utils.usesPredicateInAssertion(np, NPX.DECLARED_BY)) session.setIntroPublishedNow();
×
65
        } else {
×
66
            confirmBox.add(new WebMarkupContainer("confirmClose").setVisible(false));
42✔
67
            confirmBox.add(new WebMarkupContainer("link").setVisible(false));
42✔
68
        }
69

70
        // --- Missing-introduction warning: shown on every page (no close button).
71
        // The user can only get rid of it by publishing an introduction. Gated on
72
        // having a local key + ORCID, so users who cannot yet publish one (no
73
        // profile set up) are not nagged. A just-published introduction takes a
74
        // moment to register, so it is suppressed for 5 minutes after publishing. ---
75
        boolean canPublishIntro = session.getUserIri() != null && session.getKeyPair() != null;
15!
76
        boolean hasLocalIntro = session.getLocalIntroCount() > 0;
15!
77
        boolean recentlyPublishedIntro = session.getTimeSinceLastIntroPublished() <= 5 * 60 * 1000;
21!
78
        if (canPublishIntro && !hasLocalIntro && session.hasIntroPublished()) User.refreshUsers();
6!
79
        boolean showIntroWarning = canPublishIntro && !hasLocalIntro && !recentlyPublishedIntro;
12!
80
        WebMarkupContainer introBox = new WebMarkupContainer("introBox");
15✔
81
        introBox.setVisible(showIntroWarning);
12✔
82
        String introProfileUrl = session.getUserIri() != null
9!
83
                ? UserPage.MOUNT_PATH + "?id=" + Utils.urlEncode(session.getUserIri()) + "&tab=about"
×
84
                : ProfilePage.MOUNT_PATH + "?message=publish-intro";
6✔
85
        introBox.add(new ExternalLink("profile-link", introProfileUrl));
39✔
86
        add(introBox);
27✔
87

88
        setVisible(justPublished || showIntroWarning);
24!
89
    }
3✔
90
}
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