<%= form_with model: [Comment.new(commentable: @commentable)],
  local: false,
  class: 'mt-3',
  data: {
    behavior: 'add-comment local-auto-save',
    auto_save_key: "comment-#{dom_id(@commentable)}"
  } do |f| %>

  <%= f.label :content, "Add a comment", class: 'form-label' %>

  <div class="d-flex flex-nowrap">
    <%= avatar_image(current_user, size: 30) %>
    <%= f.text_area :content,
                    placeholder: 'Write your comment...',
                    rows: 5,
                    required: 'required',
                    class: 'form-control',
                    data: {
                      behavior: 'mentionable rich-toolbar drop-zone',
                      'rich-toolbar': 'defaults image',
                      'rich-toolbar-uploader': '[data-behavior~=jquery-upload]'
                    } %>

    <%= f.hidden_field :commentable_type %>
    <%= f.hidden_field :commentable_id %>
  </div>
  <div class="btn-group">
    <%= f.submit "Add comment", class: "btn btn-primary mt-2" %>
    <% if @commentable.is_a?(Issue) %>
      <button type="button" class="btn btn-primary mt-2 dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <span class="visually-hidden">Toggle comment type dropdown</span>
      </button>
      <div class="dropdown-menu">
        <% if defined?(Dradis::Pro) && defined?(Dradis::Pro::Plugins::Gateway) %>
          <%= render_view_hooks 'comments/new_public_comment' %>
        <% else %>
          <%= render partial: 'comments/new_public_comment' %>
        <% end %>
      </div>
    <% end %>
  </div>
<% end %>
