<commit_before><div class="form_content">
  <textarea id="artifact_template_build" class="template">
    <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => com.thoughtworks.go.config.BuildArtifactConfig.new}} %>
  </textarea>

  <textarea id="artifact_template_test" class="template">
    <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => com.thoughtworks.go.config.TestArtifactConfig.new}} %>
  </textarea>

  <textarea id="artifact_template_external" class="template">
    <%= render :partial => 'external_artifact_form', :locals => {:scope => {:var_form => scope[:form], :external_artifact => com.thoughtworks.go.config.PluggableArtifactConfig.new, :artifact_meta_data_store => scope[:artifact_meta_data_store], :artifact_plugin_to_view => scope[:artifact_plugin_to_view], :plugin_name_to_id => scope[:plugin_name_to_id]}} %>
  </textarea>

  <div class="artifact-container">
    <% scope[:built_in_collection].each do |artifact| -%>
      <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => artifact}} %>
    <%- end -%>

    <% scope[:external_artifact_collection].each do |external_artifact| %>
      <% if external_artifact.getPluginId().blank? %>
        <%= render :partial => 'external_artifact_key_value_form', :locals => {:scope => {:external_artifact => external_artifact}} %>
      <% else %>
        <%= render :partial => 'external_artifact_form', :locals => {:scope => {:var_form => scope[:form], :external_artifact => external_artifact, :artifact_meta_data_store => scope[:artifact_meta_data_store], :artifact_plugin_to_view => scope[:artifact_plugin_to_view], :plugin_name_to_id => scope[:plugin_name_to_id]}} %>
      <% end %>
      <%- end -%>
  </div>

  <div class="row expanded add_new_artifact">
    <div class="name_value_cell columns medium-12 large-12 end">
      <label>Select type:</label>
      <select class="small" id="select_artifact_type">
        <option value="Build Artifact">Build</option>
        <option value="Test Artifact">Test</option>
        <option value="External Artifact">External</option>
      </select>
      <%= action_icon({:type => "add", :text => 'Add', :href => "#", :class => "skip_dirty_stop add_artifact_button",
                       :id => "add_artifact"}) %>
    </div>
  </div>
</div>
<script type="text/javascript">
  function hookupStoresAutoComplete() {
    jQuery(".stores_auto_complete").autocomplete(<%== scope[:artifact_store_ids] %>, {
      multiple:      false,
      minChars:      0,
      matchContains: true,
      selectFirst:   false,
      width:         248
    });
  }

  function determineAppropriateFormToShow() {
    switch (jQuery('#select_artifact_type').val()) {
      case 'Build Artifact':
        addFormRowFor('#artifact_template_build');
        break;
      case 'Test Artifact':
        addFormRowFor('#artifact_template_test');
        break;
      case 'External Artifact':
        addFormRowFor('#artifact_template_external');
        hookupStoresAutoComplete();
        addOnSelectListenerForPluginDropdown();
        jQuery("input[name='job[artifactConfigs][][storeId]']").keyup(addOnChangeListenerForStoreInput);
        break;
    }
  }

  function addOnSelectListenerForPluginDropdown() {
    jQuery('.artifact_plugin_selection').change(function (event) {
      var inputElement  = jQuery(this);
      var selectedInput = event.currentTarget || event.target;
      var pluginNameToId = <%== scope[:plugin_name_to_id].to_json %>;
      showAppropriatePluginView(pluginNameToId[selectedInput.value], inputElement);
    })
  }<commit_msg>Show plugin for on select of artifact store name from autocomplete dropdown<commit_after><div class="form_content">
  <textarea id="artifact_template_build" class="template">
    <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => com.thoughtworks.go.config.BuildArtifactConfig.new}} %>
  </textarea>

  <textarea id="artifact_template_test" class="template">
    <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => com.thoughtworks.go.config.TestArtifactConfig.new}} %>
  </textarea>

  <textarea id="artifact_template_external" class="template">
    <%= render :partial => 'external_artifact_form', :locals => {:scope => {:var_form => scope[:form], :external_artifact => com.thoughtworks.go.config.PluggableArtifactConfig.new, :artifact_meta_data_store => scope[:artifact_meta_data_store], :artifact_plugin_to_view => scope[:artifact_plugin_to_view], :plugin_name_to_id => scope[:plugin_name_to_id]}} %>
  </textarea>

  <div class="artifact-container">
    <% scope[:built_in_collection].each do |artifact| -%>
      <%= render :partial => 'builtin_artifact_form', :locals => {:scope => {:var_form => scope[:form], :builtin_artifact => artifact}} %>
    <%- end -%>

    <% scope[:external_artifact_collection].each do |external_artifact| %>
      <% if external_artifact.getPluginId().blank? %>
        <%= render :partial => 'external_artifact_key_value_form', :locals => {:scope => {:external_artifact => external_artifact}} %>
      <% else %>
        <%= render :partial => 'external_artifact_form', :locals => {:scope => {:var_form => scope[:form], :external_artifact => external_artifact, :artifact_meta_data_store => scope[:artifact_meta_data_store], :artifact_plugin_to_view => scope[:artifact_plugin_to_view], :plugin_name_to_id => scope[:plugin_name_to_id]}} %>
      <% end %>
      <%- end -%>
  </div>

  <div class="row expanded add_new_artifact">
    <div class="name_value_cell columns medium-12 large-12 end">
      <label>Select type:</label>
      <select class="small" id="select_artifact_type">
        <option value="Build Artifact">Build</option>
        <option value="Test Artifact">Test</option>
        <option value="External Artifact">External</option>
      </select>
      <%= action_icon({:type => "add", :text => 'Add', :href => "#", :class => "skip_dirty_stop add_artifact_button",
                       :id => "add_artifact"}) %>
    </div>
  </div>
</div>
<script type="text/javascript">
  function hookupStoresAutoComplete() {
    jQuery(".stores_auto_complete").autocomplete(<%== scope[:artifact_store_ids] %>, {
      multiple:      false,
      minChars:      0,
      matchContains: true,
      selectFirst:   false,
      width:         248
    });
  }

  function determineAppropriateFormToShow() {
    switch (jQuery('#select_artifact_type').val()) {
      case 'Build Artifact':
        addFormRowFor('#artifact_template_build');
        break;
      case 'Test Artifact':
        addFormRowFor('#artifact_template_test');
        break;
      case 'External Artifact':
        addFormRowFor('#artifact_template_external');
        hookupStoresAutoComplete();
        addOnSelectListenerForPluginDropdown();
        jQuery("input[name='job[artifactConfigs][][storeId]']").on('input propertychange paste result',addOnChangeListenerForStoreInput);
        break;
    }
  }

  function addOnSelectListenerForPluginDropdown() {
    jQuery('.artifact_plugin_selection').change(function (event) {
      var inputElement  = jQuery(this);
      var selectedInput = event.currentTarget || event.target;
      var pluginNameToId = <%== scope[:plugin_name_to_id].to_json %>;
      showAppropriatePluginView(pluginNameToId[selectedInput.value], inputElement);
    })
  }
{'fraction_non_alphanumeric': 0.15667413361444196, 'fraction_numerical': 0.002108314665963895, 'mean_word_length': 4.371549893842888, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 165, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6275422', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2220, 'n_words': 384}