cantino/huginn

View on GitHub
app/views/agents/_options.erb

Summary

Maintainability
Test Coverage
<% if agent.is_form_configurable? %>
  <fieldset>
    <% if agent.persisted? %>
      <%= hidden_field_tag 'agent[type]', @agent.type %>
    <% end %>
    <legend>Options</legend>
    <% agent.form_configurable_attributes.each do |attribute| %>
      <div class="form-group">
        <%= label_tag attribute %>
        <%= agent.option_field_for(attribute) %>
        <span class="glyphicon glyphicon-ok form-control-feedback hidden"></span>
        <span class="glyphicon glyphicon-remove form-control-feedback hidden"></span>
      </div>
    <% end %>
  </fieldset>
<% else %>
  <div class="form-group">
    <%= label_tag :options %>
    <span class="glyphicon glyphicon-question-sign hover-help" data-content="In this JSON hash, interpolation is available in almost all values using the Liquid templating language.<p>Available template variables include the following:<dl><dt><code>message</code>, <code>url</code>, etc.</dt><dd>Refers to the corresponding key's value of each incoming event's payload.</dd><dt><code>agent</code></dt><dd>Refers to the agent that created each incoming event.  It has attributes like <code>type</code>, <code>name</code> and <code>options</code>, so <code>{{agent.type}}</code> will expand to <code>WebsiteAgent</code> if an incoming event is created by that agent.</dd></dl></p><p>To access user credentials, use the <code>credential</code> tag like this: <code>{% credential <em>bare_key_name</em> %}</code></p>"></span>
    <textarea rows="15" id="agent_options" name="agent[options]" class="form-control live-json-editor">
      <%= Utils.jsonify((agent.new_record? && agent.options == {}) ? agent.default_options : agent.options) %>
    </textarea>
  </div>
<% end %>
<div class="form-group">
  <%= submit_tag "Save", :class => "btn btn-primary" %>
  <% if agent.can_dry_run? %>
    <%= button_tag class: 'btn btn-default agent-dry-run-button', type: 'button', 'data-action-url' => agent.persisted? ? agent_dry_runs_path(agent) : dry_runs_path(type: agent.type), 'data-with-event-mode' => agent_dry_run_with_event_mode(agent) do %><%= icon_tag('glyphicon-refresh') %> Dry Run<% end %>
  <% end %>
</div>