Add toggle links for using default message and description on change merge commit message container

This commit is contained in:
Gabriel Gizotti 2016-11-25 19:49:56 +10:00
parent b4764a8dd2
commit 00a842eacc
2 changed files with 29 additions and 0 deletions

View file

@ -41,6 +41,7 @@
Modify commit message
.js-toggle-content.hide.prepend-top-default
= render 'shared/commit_message_container', params: params,
description: @merge_request.description,
text: @merge_request.merge_commit_message,
rows: 14, hint: true

View file

@ -14,3 +14,31 @@
%p.hint
Try to keep the first line under 52 characters
and the others under 72.
- if local_assigns[:description]
%p.hint.use-description-hint
= link_to "#", class: "use-description-link" do
Use Merge Request description as merge commit message
%p.hint.use-default-message-hint.hide
= link_to "#", class: "use-default-message-link" do
Use default Gitlab merge commit message
:javascript
$('.use-description-link').on('click', function(e) {
e.preventDefault();
$('.use-description-hint').hide();
$('.use-default-message-hint').show();
$('.js-commit-message').val("#{escape_javascript local_assigns[:description]}");
});
$('.use-default-message-link').on('click', function(e) {
e.preventDefault();
var defaultMessage = "#{escape_javascript (params[:commit_message] || local_assigns[:text] || local_assigns[:placeholder])}";
$('.use-description-hint').show();
$('.use-default-message-hint').hide();
$('.js-commit-message').val(defaultMessage);
});