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

knowledgepixels / nanodash / 31467088259

11 Aug 2026 06:58AM UTC coverage: 35.579% (+0.2%) from 35.418%
31467088259

push

github

web-flow
Merge pull request #588 from knowledgepixels/584-governed-status-line

fix: recognize space-governed updates in the "Status" line

2740 of 8470 branches covered (32.35%)

Branch coverage included in aggregate %.

5239 of 13956 relevant lines covered (37.54%)

5.83 hits per line

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

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

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

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

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

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

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

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

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

91
        setVisible(justPublished || showIntroWarning);
24 !
92
    }
3 ✔
93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc