Skip to content

Commit 117fa3d

Browse files
committed
Add changes to request decision component to support marksmith editor
1 parent f86aea7 commit 117fa3d

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/api/app/assets/javascripts/webui/canned_responses.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ function setupCannedResponses() { // jshint ignore:line
1212
}
1313
// we have to enable the submit button for the comments form
1414
$(e.target).closest('[class*="-comment-form"]').find('input[type="submit"]').prop('disabled', false);
15+
$('.decision-add-comment').prop('disabled', false);
1516
});
1617
}

src/api/app/assets/javascripts/webui/comment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function handlingCommentEvents() {
3232
// Disable submit button if textarea is empty and enable otherwise
3333
$(document).on('input', '.write-and-preview textarea', function(e) {
3434
validateForm(e);
35+
$('.decision-add-comment').prop('disabled', false);
3536
resizeTextarea(this);
3637
});
3738

src/api/app/components/request_decision_component.html.haml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.request-decision.mt-n1
2-
= form_with(url: request_changerequest_path, html: { id: 'request_handle_form' }, local: true) do |form|
2+
= form_with(model: @bs_request.reviews.new, url: request_changerequest_path, html: { id: 'request_handle_form' }, local: true) do |form|
33
= hidden_field_tag(:number, @bs_request.number)
44
.pb-2{ 'data-canned-controller': '' }
55
- if policy(Comment.new(commentable: @bs_request)).locked?
@@ -10,12 +10,12 @@
1010
- decision_placeholder = "Write your comment or decision...(markdown is only supported for comments, not for decisions)"
1111
= render WriteAndPreviewComponent.new(form: form, preview_message_url: preview_comments_path, canned_responses_enabled: true,
1212
message_body_param: 'comment[body]',
13-
text_area_attributes: { object_name: 'reason', id_suffix: 'new_comment',
13+
text_area_attributes: { object_name: 'reason', id_suffix: 'new_comment', required: true,
1414
placeholder: decision_placeholder})
1515
.mt-2#decision-buttons-row
1616
%div
1717
- if policy(Comment.new(commentable:@bs_request)).create?
18-
= submit_tag 'Add comment', class: 'btn btn-outline-primary me-2', data: { disable_with: 'Creating comment...' }, name: 'commented'
18+
= submit_tag 'Add comment', class: 'btn btn-outline-primary me-2 decision-add-comment', data: { disable_with: 'Creating comment...' }, name: 'commented', disabled: true
1919
%div
2020
- if policy(@bs_request).revoke_request?
2121
= submit_tag('Revoke request', name: 'revoked', class: 'btn btn-danger me-2',

src/api/app/components/request_decision_component.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class RequestDecisionComponent < ApplicationComponent
2+
# This is required to help marksmith render the markdown editor
3+
delegate :main_app, to: :helpers
4+
25
def initialize(bs_request:, package_maintainers:, show_project_maintainer_hint:)
36
super
47

src/api/app/controllers/webui/request_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def changerequest
214214

215215
if changestate == 'commented'
216216

217-
build_new_comment(@bs_request, body: params[:reason])
217+
build_new_comment(@bs_request, body: params.dig(:review, :reason))
218218

219219
elsif change_state(changestate, params)
220220
# TODO: Make this work for each submit action individually
@@ -440,7 +440,7 @@ def change_state(newstate, params)
440440
newstate: newstate,
441441
force: true,
442442
user: User.session.login,
443-
comment: params[:reason]
443+
comment: params.dig(:review, :reason)
444444
}
445445
begin
446446
request.change_state(opts)

0 commit comments

Comments
 (0)