Commit c6420ce2 authored by Mario de la Ossa's avatar Mario de la Ossa

Fix milestones disappearing when changed on MR

parent edfa2e3f
...@@ -16,10 +16,10 @@ export default class MilestoneSelect { ...@@ -16,10 +16,10 @@ export default class MilestoneSelect {
typeof currentProject === 'string' ? JSON.parse(currentProject) : currentProject; typeof currentProject === 'string' ? JSON.parse(currentProject) : currentProject;
} }
this.init(els, options); MilestoneSelect.init(els, options);
} }
init(els, options) { static init(els, options) {
let $els = $(els); let $els = $(els);
if (!els) { if (!els) {
...@@ -224,7 +224,6 @@ export default class MilestoneSelect { ...@@ -224,7 +224,6 @@ export default class MilestoneSelect {
$selectBox.hide(); $selectBox.hide();
$value.css('display', ''); $value.css('display', '');
if (data.milestone != null) { if (data.milestone != null) {
data.milestone.full_path = this.currentProject.full_path;
data.milestone.remaining = timeFor(data.milestone.due_date); data.milestone.remaining = timeFor(data.milestone.due_date);
data.milestone.name = data.milestone.title; data.milestone.name = data.milestone.title;
$value.html(milestoneLinkTemplate(data.milestone)); $value.html(milestoneLinkTemplate(data.milestone));
......
...@@ -115,7 +115,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -115,7 +115,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end end
format.json do format.json do
render json: @merge_request.to_json(include: { milestone: {}, assignee: { only: [:name, :username], methods: [:avatar_url] }, labels: { methods: :text_color } }, methods: [:task_status, :task_status_short]) render json: serializer.represent(@merge_request, serializer: 'basic')
end end
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
......
...@@ -5,4 +5,8 @@ class MergeRequestBasicEntity < IssuableSidebarEntity ...@@ -5,4 +5,8 @@ class MergeRequestBasicEntity < IssuableSidebarEntity
expose :state expose :state
expose :source_branch_exists?, as: :source_branch_exists expose :source_branch_exists?, as: :source_branch_exists
expose :rebase_in_progress?, as: :rebase_in_progress expose :rebase_in_progress?, as: :rebase_in_progress
expose :milestone, using: API::Entities::Milestone
expose :labels, using: LabelEntity
expose :assignee, using: API::Entities::UserBasic
expose :task_status, :task_status_short
end end
...@@ -234,7 +234,7 @@ describe Projects::MergeRequestsController do ...@@ -234,7 +234,7 @@ describe Projects::MergeRequestsController do
body = JSON.parse(response.body) body = JSON.parse(response.body)
expect(body['assignee'].keys) expect(body['assignee'].keys)
.to match_array(%w(name username avatar_url)) .to match_array(%w(name username avatar_url id state web_url))
end end
end end
......
...@@ -14,7 +14,21 @@ ...@@ -14,7 +14,21 @@
"subscribed": { "type": ["boolean", "null"] }, "subscribed": { "type": ["boolean", "null"] },
"participants": { "type": "array" }, "participants": { "type": "array" },
"allow_collaboration": { "type": "boolean"}, "allow_collaboration": { "type": "boolean"},
"allow_maintainer_to_push": { "type": "boolean"} "allow_maintainer_to_push": { "type": "boolean"},
"assignee": {
"oneOf": [
{ "type": "null" },
{ "$ref": "user.json" }
]
},
"milestone": {
"type": [ "object", "null" ]
},
"labels": {
"type": [ "array", "null" ]
},
"task_status": { "type": "string" },
"task_status_short": { "type": "string" }
}, },
"additionalProperties": false "additionalProperties": false
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment