Skip to content

Show and edit the tags of families, samples and functions - #338

Open
r0ny123 wants to merge 4 commits into
masterfrom
feat/53-tags-web
Open

r0ny123 wants to merge 4 commits into
masterfrom
feat/53-tags-web

Conversation

@r0ny123

@r0ny123 r0ny123 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

The MCRITweb side of familiary/mcrit#53, on the API of familiary/mcrit#237: tags on families, samples and functions, added and removed rather than replaced (POST/DELETE /{families|samples|functions}/{id}/tags), found with the paginated search tags:"x", and counted with GET /tags.

What the pages show.

  • The family, sample and function pages show their record's tags as badges under the heading. Each links to the search for tags:"<tag>" across families, samples and functions, which lists them in the existing paginated tables. Tag names come from the corpus and are escaped.
  • The statistics page lists the tags in use with their counts.
  • The table rows show no tags; they are dense enough.

Editing (2bf9768). Contributors edit tags in the family and sample edit dialogs, and in a new tags dialog beside Rename on the function page (explore.modify_function_tags, POST, CSRF as the other edits). Saving removes and adds only the difference against what the page showed, so a tag someone else added meanwhile is kept. Tags go in before the queued rename or move job, an invalid tag refuses the whole form before anything is written, and a form without the tags field changes no tags.

API (2696349). /api passes the client's tag methods through on mcrit's own paths: POST and DELETE on /api/<families|samples|functions>/<id>/tags, contributor-only as editing in the UI is, and GET /api/tags. DELETE is accepted on those paths only. With a client that has no tag methods they answer 501.

Statistics page (d7aaecf). The tags table is laid out like the page's others since #301: an h4 heading, a col-lg-6 column instead of width:50%, and a hidden caption.

Against an mcrit without tags. No mcrit release has the tag methods yet, so the requirement is not raised. With an installed mcrit package without them, nothing about tags is shown or offered. With a package that has them and a backend that does not (version strings do not tell: #237's branch and 1.16.0 both report 1.16.0), the web asks the backend once per page, for contributors only; a 404 means nothing is offered. Checked end to end with the real McritClient against servers built from #237 and from 1.16.0: tags saved, shown, counted, found through search and cleared; both combinations without tags render as before. Once mcrit ships tags, the requirement can be raised and the hiding becomes a fallback.

Master e7e75fa is merged in.

Tests.

  • tests/testTags.py, 57 tests: the badges and links on the three pages, escaping, the statistics section, the dialogs and the function route (contributor-only, CSRF, the add-and-remove difference, an invalid tag writes nothing, a form without the field writes nothing, ordering before the rename or move job), the /api routes and their roles, and both no-tags cases.
  • tests/testTagsBrowser.py, 6 Chromium tests: editing in each dialog and the result on the page.
  • Without the change, 25 UI tests and 6 API tests fail; the rest guard the unchanged no-tags pages. The tests pass against the released mcrit and against Pass exports on as the backend's bytes instead of parsing them #237's branch; where the installed mcrit lacks the tag rules module, they use a copy of its rule.
  • The full suite: 2484 passed. ruff check . is clean.
  • README version history ("unreleased") and a Tags section in the manual.

Lighthouse on the tagged pages: Accessibility, Best Practices and SEO are 100, layout shift and contrast as on master, and no new script.

With the open PRs. ref/web-guidance-combined-5 is ref/web-guidance-combined-4 (all open PRs, #316's comment has the order) with this branch merged. What this PR needs once those have landed, as commits there:

The full suite passes there: 5300 tests. No <script> is added, so #330's nonce test and policy walk pass unchanged.

mcrit now keeps tags on families, samples and functions (familiary/mcrit#53),
and nothing here showed them. Each page shows its record's tags under the
heading, each linking to the search for what carries it, and the statistics
page lists the tags in use. Contributors edit them in the family and sample
edit dialogs and in a new tags dialog on the function page; saving removes
and adds the difference, so a tag someone added meanwhile is kept.

No mcrit release has the tag methods yet, so the requirement is not raised:
with an older mcrit package, or against a backend that answers the tag
routes with 404, nothing about tags is shown or offered.
The /api passthrough follows the client's new tag methods on mcrit's own
paths: POST and DELETE on /api/<families|samples|functions>/<id>/tags add
and remove tags, contributor-only as editing them in the UI is, and
GET /api/tags counts the tags in use. DELETE is accepted on those paths
only; with a client that has no tag methods they answer 501.
# Conflicts:
#	docs/manual/README.md
#	mcritweb/templates/single_sample.html
#	mcritweb/templates/statistics.html
#	mcritweb/templates/table/family_row.html
#	mcritweb/templates/table/sample_row.html
#	mcritweb/views/api.py
#	mcritweb/views/explore.py
The statistics page now heads its sections with h4 and sets each table
in a half-width column with a hidden caption. The tags table follows:
an h4, a col-lg-6 column instead of an inline width, and a caption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant