only include _html fields when asked for
This commit is contained in:
		
							parent
							
								
									6021ab6f77
								
							
						
					
					
						commit
						5428e91374
					
				|  | @ -100,12 +100,12 @@ const Api = { | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   // Return Merge Request for project
 |   // Return Merge Request for project
 | ||||||
|   mergeRequest(projectPath, mergeRequestId) { |   mergeRequest(projectPath, mergeRequestId, params = {}) { | ||||||
|     const url = Api.buildUrl(Api.mergeRequestPath) |     const url = Api.buildUrl(Api.mergeRequestPath) | ||||||
|       .replace(':id', encodeURIComponent(projectPath)) |       .replace(':id', encodeURIComponent(projectPath)) | ||||||
|       .replace(':mrid', mergeRequestId); |       .replace(':mrid', mergeRequestId); | ||||||
| 
 | 
 | ||||||
|     return axios.get(url); |     return axios.get(url, { params }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   mergeRequests(params = {}) { |   mergeRequests(params = {}) { | ||||||
|  |  | ||||||
|  | @ -40,8 +40,8 @@ export default { | ||||||
|   getProjectData(namespace, project) { |   getProjectData(namespace, project) { | ||||||
|     return Api.project(`${namespace}/${project}`); |     return Api.project(`${namespace}/${project}`); | ||||||
|   }, |   }, | ||||||
|   getProjectMergeRequestData(projectId, mergeRequestId) { |   getProjectMergeRequestData(projectId, mergeRequestId, params = {}) { | ||||||
|     return Api.mergeRequest(projectId, mergeRequestId); |     return Api.mergeRequest(projectId, mergeRequestId, params); | ||||||
|   }, |   }, | ||||||
|   getProjectMergeRequestChanges(projectId, mergeRequestId) { |   getProjectMergeRequestChanges(projectId, mergeRequestId) { | ||||||
|     return Api.mergeRequestChanges(projectId, mergeRequestId); |     return Api.mergeRequestChanges(projectId, mergeRequestId); | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ export const getMergeRequestData = ( | ||||||
|   new Promise((resolve, reject) => { |   new Promise((resolve, reject) => { | ||||||
|     if (!state.projects[projectId].mergeRequests[mergeRequestId] || force) { |     if (!state.projects[projectId].mergeRequests[mergeRequestId] || force) { | ||||||
|       service |       service | ||||||
|         .getProjectMergeRequestData(projectId, mergeRequestId) |         .getProjectMergeRequestData(projectId, mergeRequestId, { render_html: true }) | ||||||
|         .then(({ data }) => { |         .then(({ data }) => { | ||||||
|           commit(types.SET_MERGE_REQUEST, { |           commit(types.SET_MERGE_REQUEST, { | ||||||
|             projectPath: projectId, |             projectPath: projectId, | ||||||
|  |  | ||||||
|  | @ -388,12 +388,6 @@ module API | ||||||
|       expose :id, :iid |       expose :id, :iid | ||||||
|       expose(:project_id) { |entity| entity&.project.try(:id) } |       expose(:project_id) { |entity| entity&.project.try(:id) } | ||||||
|       expose :title, :description |       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 |       expose :state, :created_at, :updated_at | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | @ -538,6 +532,12 @@ module API | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     class MergeRequestBasic < ProjectEntity |     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 :target_branch, :source_branch | ||||||
|       expose :upvotes do |merge_request, options| |       expose :upvotes do |merge_request, options| | ||||||
|         if options[:issuable_metadata] |         if options[:issuable_metadata] | ||||||
|  |  | ||||||
|  | @ -232,6 +232,7 @@ module API | ||||||
| 
 | 
 | ||||||
|       params do |       params do | ||||||
|         requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request' |         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 |       end | ||||||
|       desc 'Get a single merge request' do |       desc 'Get a single merge request' do | ||||||
|         success Entities::MergeRequest |         success Entities::MergeRequest | ||||||
|  | @ -239,7 +240,7 @@ module API | ||||||
|       get ':id/merge_requests/:merge_request_iid' do |       get ':id/merge_requests/:merge_request_iid' do | ||||||
|         merge_request = find_merge_request_with_access(params[:merge_request_iid]) |         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 |       end | ||||||
| 
 | 
 | ||||||
|       desc 'Get the participants of a merge request' do |       desc 'Get the participants of a merge request' do | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue