<%# Copyright (C) The Arvados Authors. All rights reserved.

SPDX-License-Identifier: AGPL-3.0 %>

<%
  wf_def = ActiveSupport::HashWithIndifferentAccess.new YAML::load(@object.definition) if @object.definition
  wf_def = wf_def[:"$graph"].andand[0] || wf_def if wf_def

  items = {}
  baseCommand = wf_def.andand["baseCommand"]
  items['baseCommand'] = baseCommand if baseCommand

  args = wf_def.andand["arguments"]
  items['arguments'] = args if args

  hints = wf_def.andand["hints"]
  items['hints'] = hints if hints

  inputs = wf_def.andand["inputs"]
  items['inputs'] = inputs if inputs

  outputs = wf_def.andand["outputs"]
  items['outputs'] = outputs if outputs

  # preload the collections
  collections_pdhs = []
  items.each do |k, v|
    v.to_s.scan(/([0-9a-f]{32}\+\d+)/).each {|l| collections_pdhs += l}
  end
  collections_pdhs.compact.uniq
  preload_for_pdhs collections_pdhs if collections_pdhs.any?
  preload_links_for_objects collections_pdhs if collections_pdhs.any?
%>

  <div class="col-md-12">
    <table class="table table-condensed" style="table-layout:fixed;">
      <col width="15%" />
      <col width="85%" />

      <% items.each do |k, v| %>
          <tr>
            <td valign="top">
              <%= k %>:
            </td>
            <td>
              <% val = JSON.pretty_generate(v) %>
              <%= render partial: 'show_text_with_locators', locals: {data_height: 300, text_data: val} %>
            </td>
          </tr>
      <% end %>
    </table>
  </div>