Commit 09ff9bc7 authored by Douwe Maan's avatar Douwe Maan

Easily (un)mark merge request as WIP using link

Fixes #3768
parent acf9778e
......@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.6.0 (unreleased)
- Improve the formatting for the user page bio (Connor Shea)
- Fix avatar stretching by providing a cropping feature (Johann Pardanaud)
- Easily (un)mark merge request as WIP using link
- Use specialized system notes when MR is (un)marked as WIP
v 8.5.1
......
class @IssuableForm
wipRegex: /^\[?WIP(\]|:| )\s*/i
constructor: (@form) ->
GitLab.GfmAutoComplete.setup()
new UsersSelect()
......@@ -14,6 +15,8 @@ class @IssuableForm
@form.on "submit", @resetAutosave
@form.on "click", ".btn-cancel", @resetAutosave
@initWip()
initAutosave: ->
new Autosave @titleField, [
document.location.pathname,
......@@ -30,3 +33,41 @@ class @IssuableForm
resetAutosave: =>
@titleField.data("autosave").reset()
@descriptionField.data("autosave").reset()
initWip: ->
return unless @form.find(".js-wip-explanation").length
@form.on "click", ".js-remove-wip", @removeWip
@form.on "click", ".js-add-wip", @addWip
@titleField.on "change", @renderWipExplanation
@renderWipExplanation()
workInProgress: ->
@titleField.val().match(@wipRegex)
renderWipExplanation: =>
if @workInProgress()
@form.find(".js-wip-explanation").show()
@form.find(".js-no-wip-explanation").hide()
else
@form.find(".js-wip-explanation").hide()
@form.find(".js-no-wip-explanation").show()
removeWip: (event) =>
event.preventDefault()
return unless @workInProgress()
@titleField.val @titleField.val().replace(@wipRegex, "")
@renderWipExplanation()
addWip: (event) =>
event.preventDefault()
return if @workInProgress()
@titleField.val "WIP: #{@titleField.val()}"
@renderWipExplanation()
......@@ -2,7 +2,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled
before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :builds, :merge, :merge_check,
:ci_status, :toggle_subscription, :cancel_merge_when_build_succeeds
:ci_status, :toggle_subscription, :cancel_merge_when_build_succeeds, :remove_wip
]
before_action :closes_issues, only: [:edit, :update, :show, :diffs, :commits, :builds]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :builds]
......@@ -17,7 +17,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :authorize_create_merge_request!, only: [:new, :create]
# Allow modify merge_request
before_action :authorize_update_merge_request!, only: [:close, :edit, :update, :sort]
before_action :authorize_update_merge_request!, only: [:close, :edit, :update, :remove_wip, :sort]
def index
terms = params['issue_search']
......@@ -161,6 +161,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def remove_wip
MergeRequests::UpdateService.new(project, current_user, title: @merge_request.wipless_title).execute(@merge_request)
redirect_to namespace_project_merge_request_path(@project.namespace, @project, @merge_request),
notice: "The merge request can now be merged."
end
def merge_check
@merge_request.check_if_can_be_merged
......
......@@ -2,4 +2,10 @@
This merge request is currently a Work In Progress
%p
When this merge request is ready, remove the "WIP" prefix from the title to allow it to be merged.
When this merge request is ready,
- text = 'remove the "WIP" prefix from the title'
- if can?(current_user, :update_merge_request, @merge_request)
= link_to text, remove_wip_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), method: :post
- else
= text
to allow it to be merged.
......@@ -13,11 +13,15 @@
- if issuable.is_a?(MergeRequest)
%p.help-block
- if issuable.work_in_progress?
Remove the <code>WIP</code> prefix from the title to allow this
.js-wip-explanation
%a{href: "#", class: "js-remove-wip", data: { }}
Remove the <code>WIP</code> prefix from the title
to allow this
<strong>Work In Progress</strong> merge request to be merged when it's ready.
- else
Start the title with <code>[WIP]</code> or <code>WIP:</code> to prevent a
.js-no-wip-explanation
%a{href: "#", class: "js-add-wip"}
Start the title with <code>[WIP]</code> or <code>WIP:</code>
to prevent a
<strong>Work In Progress</strong> merge request from being merged before it's ready.
.form-group.detail-page-description
= f.label :description, 'Description', class: 'control-label'
......
......@@ -599,6 +599,7 @@ Rails.application.routes.draw do
post :cancel_merge_when_build_succeeds
get :ci_status
post :toggle_subscription
post :remove_wip
end
collection do
......
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