Update Synthetic Note for imported resource events - Direct Transfer
Resource events should be labeled as imported
as per the UI Design:
At the moment they aren't.
The resource events are:
`ResourceLabelEvent`
`ResourceMilestoneEvent`
`ResourceStateEvent`
Their corresponding system notes have an imported_from
value of 'none'
. This needs to be updated.
Once that's done we can assess whether there need to be FE changes.
These notes appear on Issues and MergeRequests and returned in the discussions.json
response, e.g:
GET /dt-import/bitbucket-cloud-4/frogger/-/merge_requests/4/discussions.json HTTP/1.1
This returns an array of items which include notes.
Sample truncated response
{
...
"notes": [{
"id": "cff7c502357ac83f98192fff3c6bc83d02d54299",
"type": "LabelNote",
"attachment": null,
"author": {
"id": 1,
"username": "root",
"name": "Administrator",
"state": "active",
"locked": false,
"avatar_url": "https://www.gravatar.com/avatar/a648a208d9afde7f053b73ce9d585dd0321c24906d3e86d47c329e8b138fd1ce?s=80\u0026d=identicon",
"status_tooltip_html": null,
"show_status": false,
"availability": null,
"path": "/root",
"bot": false
},
"created_at": "2024-07-02T13:46:41.733Z",
"updated_at": "2024-07-02T13:46:41.733Z",
"system": true,
"noteable_id": 481,
"noteable_type": "MergeRequest",
"project_id": 209,
"resolvable": false,
"confidential": false,
"internal": false,
"imported": false,
"imported_from": "none",
"noteable_iid": 4,
"commands_changes": {},
"external_author": null,
"note": "added ~872 label",
"note_html": "\u003cp dir=\"auto\"\u003eadded \u003cspan class=\"gl-label\"\u003e\u003ca href=\"/dt-import/bitbucket-cloud-4/frogger/-/merge_requests?label_name=bug\" data-reference-type=\"label\" data-original=\"~872\" data-link=\"false\" data-link-reference=\"false\" data-label=\"872\" data-project=\"209\" data-container=\"body\" data-placement=\"top\" title=\"\" class=\"gfm gfm-label has-tooltip gl-link gl-label-link\"\u003e\u003cspan class=\"gl-label-text gl-label-text-light\" data-container=\"body\" data-html=\"true\" style=\"background-color: #FF0000\"\u003ebug\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e label\u003c/p\u003e",
"current_user": {
"can_edit": false,
"can_award_emoji": true,
"can_resolve": false,
"can_resolve_discussion": false
}
The endpoint uses Issuable::DiscussionsListService
to build the payload during runtime. The change below passes the missing imported_from
argument to the note
:
--- a/app/models/synthetic_note.rb
+++ b/app/models/synthetic_note.rb
@@ -17,7 +17,8 @@ def self.note_attributes(action, event, resource, resource_parent)
noteable: resource,
event: event,
system_note_metadata: ::SystemNoteMetadata.new(action: action, id: event.discussion_id),
- resource_parent: resource_parent
+ resource_parent: resource_parent,
+ imported_from: event.respond_to?(:imported_from) ? event.imported_from : false
}
if resource_parent.is_a?(Project)
Edited by Carla Drago