diff options
author | Phil Hughes <me@iamphill.com> | 2018-07-03 09:09:20 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-07-05 15:44:54 +0100 |
commit | 5428e913749b0c3b8f306167f585295434d944d6 (patch) | |
tree | 9756de0ac29eb2a9f6f781dfdd920d3aef93ed70 | |
parent | 6021ab6f779c81fa84ef042a66573c232cd74def (diff) | |
download | gitlab-ce-5428e913749b0c3b8f306167f585295434d944d6.tar.gz |
only include _html fields when asked for
-rw-r--r-- | app/assets/javascripts/api.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/ide/services/index.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/merge_request.js | 2 | ||||
-rw-r--r-- | lib/api/entities.rb | 12 | ||||
-rw-r--r-- | lib/api/merge_requests.rb | 3 |
5 files changed, 13 insertions, 12 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 0ca0e8f35dd..422becb7db8 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -100,12 +100,12 @@ const Api = { }, // Return Merge Request for project - mergeRequest(projectPath, mergeRequestId) { + mergeRequest(projectPath, mergeRequestId, params = {}) { const url = Api.buildUrl(Api.mergeRequestPath) .replace(':id', encodeURIComponent(projectPath)) .replace(':mrid', mergeRequestId); - return axios.get(url); + return axios.get(url, { params }); }, mergeRequests(params = {}) { diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js index 3e939f0c1a3..49a481f25d5 100644 --- a/app/assets/javascripts/ide/services/index.js +++ b/app/assets/javascripts/ide/services/index.js @@ -40,8 +40,8 @@ export default { getProjectData(namespace, project) { return Api.project(`${namespace}/${project}`); }, - getProjectMergeRequestData(projectId, mergeRequestId) { - return Api.mergeRequest(projectId, mergeRequestId); + getProjectMergeRequestData(projectId, mergeRequestId, params = {}) { + return Api.mergeRequest(projectId, mergeRequestId, params); }, getProjectMergeRequestChanges(projectId, mergeRequestId) { return Api.mergeRequestChanges(projectId, mergeRequestId); diff --git a/app/assets/javascripts/ide/stores/actions/merge_request.js b/app/assets/javascripts/ide/stores/actions/merge_request.js index 4aa151abcb7..6bdf9dc3028 100644 --- a/app/assets/javascripts/ide/stores/actions/merge_request.js +++ b/app/assets/javascripts/ide/stores/actions/merge_request.js @@ -9,7 +9,7 @@ export const getMergeRequestData = ( new Promise((resolve, reject) => { if (!state.projects[projectId].mergeRequests[mergeRequestId] || force) { service - .getProjectMergeRequestData(projectId, mergeRequestId) + .getProjectMergeRequestData(projectId, mergeRequestId, { render_html: true }) .then(({ data }) => { commit(types.SET_MERGE_REQUEST, { projectPath: projectId, diff --git a/lib/api/entities.rb b/lib/api/entities.rb index cabbb5c746f..27b4ee83773 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -388,12 +388,6 @@ module API expose :id, :iid expose(:project_id) { |entity| entity&.project.try(:id) } expose :title, :description - expose :title_html do |entity| - MarkupHelper::markdown_field(entity, :title) - end - expose :description_html do |entity| - MarkupHelper::markdown_field(entity, :description) - end expose :state, :created_at, :updated_at end @@ -538,6 +532,12 @@ module API end class MergeRequestBasic < ProjectEntity + expose :title_html, if: -> (_, options) { options[:render_html] } do |entity| + MarkupHelper::markdown_field(entity, :title) + end + expose :description_html, if: -> (_, options) { options[:render_html] } do |entity| + MarkupHelper::markdown_field(entity, :description) + end expose :target_branch, :source_branch expose :upvotes do |merge_request, options| if options[:issuable_metadata] diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 0f46bc4c98e..b42d411022c 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -232,6 +232,7 @@ module API params do requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request' + optional :render_html, type: Boolean, desc: 'Returns the description and title rendered html' end desc 'Get a single merge request' do success Entities::MergeRequest @@ -239,7 +240,7 @@ module API get ':id/merge_requests/:merge_request_iid' do merge_request = find_merge_request_with_access(params[:merge_request_iid]) - present merge_request, with: Entities::MergeRequest, current_user: current_user, project: user_project + present merge_request, with: Entities::MergeRequest, current_user: current_user, project: user_project, render_html: params[:render_html] end desc 'Get the participants of a merge request' do |