Add PersonalSnippetReferenceFilter for personal snippets

What does this MR do and why?

Add PersonalSnippetReferenceFilter for personal snippets.

Transforms references like $123 when there's a matching personal snippet with that ID. Takes place after SnippetReferenceFilter, which will catch that one if it refers to a project-level one with that ID. (They share an ID namespace so it's never ambiguous.) Takes care to never match a cross-namespace snippet reference like abc/def$123.

References

Screenshots or screen recordings

Note that, like all other reference filters, text (like $24) which resolves to an object you can see is linked and enriched. If you don't have the ability to view the target, it just stays as plain text.

Similarly, if you specify a full autolinked URL to an object you can see, the visible text is changed to the reference syntax and the link is enriched. If you don't have the ability to view the target, it just stays as the autolinked URL; no changes, no enrichment.

Note that neither autolinked URL is enriched in the "before" view.

Here's the Markdown source used:

Here's a personal snippet belonging to me (@root) which is private: $24

And and here's one which is public: $25!

Here I link to the first one by URL instead of text: http://gdk-oc.local:13000/-/snippets/24

And here to the second one by URL: http://gdk-oc.local:13000/-/snippets/25
Before After
Logged in as @root image image
Anonymous user image image

How to set up and validate locally

  1. Check out the branch 🌴
  2. Enable the personal_snippet_reference_filters feature flag.
  3. Make some personal snippets at http://gdk.test:3000/dashboard/snippets.
  4. Refer to them with their ID with the $123 syntax in comments (including on snippet), in the snippet description itself, work item and MR descriptions, etc.
  5. Also try pasting in the full URL to the snippet and check that it gets rendered as a reference (fixes Personal Snippet URLs aren't replaced by their ... (#217306)).

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Asherah Connor

Merge request reports

Loading