Skip to content

feat(views): label template links with the template's own label - #935

Merged
tkuhn merged 1 commit into
masterfrom
feat/template-label-fallback
Nov 18, 2026
Merged

tkuhn merged 1 commit into
masterfrom
feat/template-label-fallback

Conversation

@tkuhn

@tkuhn tkuhn commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Problem

A query column ending in template_iri is rendered as a link to the template's form. Its text comes from the sibling …_label column, and when that column is empty the link shows the bare template IRI.

That happened on the I-ADOPT space: its pinned template was pinned by pasting the IRI …/RAlibtZp…/template instead of choosing it from the list, so the pin nanopub recorded no nt:hasLabelFromApi, and the 📋 Pinned templates view showed the IRI. Nanodash knows that template's label anyway, from the template listings.

Change

  • TemplateData.getKnownTemplateLabel(id) returns the label of a template that is known here already: from a loaded Template, or else from the assertion/provenance/pubinfo listings. It never fetches anything, so rendering a long list costs no extra requests. It takes both forms of template ID, the nanopub URI and an embedded template-node IRI.
  • QueryResult.templateLinkLabel(…) picks the label to show: the sibling label column, then the known label, then null so the caller can fall back to the IRI as before. List, table and item-list views all use it for template_iri cells.
  • New TemplateDataKnownLabelTest covers lookup by nanopub URI, by template-node IRI, an unknown template, and a missing ID.

This doesn't conflict with #917: that PR changes how the listings are loaded but never leaves them null, and its hunks in TemplateData don't overlap with this one.

Matching view change (already live)

The pinned-templates query used to build its own HTML link, so it could not benefit from this change. Two new versions were published on 2026-11-18:

Pinned-template links therefore already open the latest template version (template-version=latest). With this PR, a pin that recorded no label shows the template's label instead of its IRI.

Tests

mvn test -Dtest='TemplateDataKnownLabelTest,QueryResultPublishLinkTest': 14 tests, all passing. Not tried in a running instance.

🤖 Generated with Claude Code

A template_iri cell without a label in its sibling column showed the bare
template IRI. It now falls back to the template's label as Nanodash already
knows it, from a loaded template or from the template listings, without
fetching anything. Only a template unknown here still shows its IRI.

Seen on the I-ADOPT space, whose pinned template was pinned by pasting its
IRI, so the pin recorded no label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tkuhn
tkuhn merged commit dd47c52 into master Nov 18, 2026
8 checks passed
@tkuhn
tkuhn deleted the feat/template-label-fallback branch November 18, 2026 15:29
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant