Use ResourceLabelEvent for tracking label changes
What does this MR do?
Uses ResourceLabelEvent
model for tracking label changes on issuables instead of creating system note.
This makes it tricky to display label changes notes as it used to be because we have to mix records from Note
model with records from ResourceLabelEvent
model, and also we have to squash multiple label events together (https://gitlab.com/gitlab-org/gitlab-ce/issues/48483#scenario-5).
To make rendering of these label event possible without dramatic frontend changes, an unsaved/syntehtic Note
is created to represent label changes when displaying resource's notes. Because these syntehtic notes are not saved and don't have real note ID, a discussion ID is used as note ID for them.
Label events are mixed with classic notes only for displaying in web UI, in API label events are listed separately.
This has some implications for notes/discussions on frontend side:
- note ID is now string - (e.g.
'123'
for 'real' notes, or SHA'5309ce673a0ae2dda0b9813f1602d5ffc5a7026f'
for label event notes) - note user can be
null
for label event notes - in that caseA deleted user
is displayed in UI
Caching
Rendering notes for label events had performance issue (see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21281#note_96372665), to mitigate both time and number of queries, rendered html fragments for each label event are cached.
Known Issues
- cross group label references are not rendered properly - this will be addressed by https://gitlab.com/gitlab-org/gitlab-ce/issues/50525
What are the relevant issue numbers?
Closes #48483 (closed)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides