<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  external_tool ||= nil
  tool ||= external_tool
  classes = []
  if tool
    Lti::ResourcePlacement::PLACEMENTS.each do |type|
      classes << "has_#{type}" if tool.try("has_#{type}")
    end
  end
%>

<div class="external_tool <%= classes.join(" ") %> <%= 'blank' unless tool %>" id="external_tool_<%= tool ? tool.id : 'blank' %>" data-id="<%= tool && tool.id %>" style="<%= hidden unless tool %>" data-workflow_state="<%= tool.try(:workflow_state) %>">
  <div class="header clearfix">
    <div class="name"><%= tool.try(:name) %></div>
    <div class="links">
      <a href="#" rel="<%= context_url(@context, :context_external_tool_url, tool ? tool.id : "{{ id }}") %>" class="update_tool_url edit_tool_link" title="<%= t :edit_tool, "Edit Tool" %>"><%= image_tag "edit.png", :alt => t('Edit Tool') %></a>
      <a href="#" class="delete_tool_link" title="<%= t :delete_tool, "Delete Tool" %>"><%= image_tag "delete.png", :alt => t('Delete Tool') %></a>
    </div>
    <div class="clear"></div>
    <div class="custom_fields_string" style="display: none;"><%= tool.try(:custom_fields_string) %></div>
  </div>
  <div class="content">
    <table class="formtable">
      <tr>
        <td><%= before_label :privacy, "Privacy" %></td>
        <td class="readable_state"><%= tool.try(:readable_state) %></td>
      </tr><tr>
        <td><%= before_label :consumer_key, "Consumer Key" %></td>
        <td class="consumer_key"><%= tool.try(:consumer_key) %></td>
      </tr><tr class="tool_url" style="<%= hidden if tool.try(:url).blank? %>">
        <td><%= before_label :url, "URL" %></td>
        <td class="url"><%= tool.try(:url) %></td>
      </tr><tr class="tool_domain" style="<%= hidden if tool.try(:domain).blank? %>">
        <td><%= before_label :domain, "Domain" %></td>
        <td class="domain"><%= tool.try(:domain) %></td>
      </tr><tr>
        <td><%= before_label :description, "Description" %></td>
        <td class="description" style="font-size: 0.8em;">
          <%= tool.try(:description) %>
        </td>
      </tr>
      <tr class="tool_vendor_help_link" style="<%= hidden if tool.try(:vendor_help_link).blank? %>">
        <td><%= before_label :vendor_help_link, "Vendor Help Link" %></td>
        <td>
          <% url = tool.try(:vendor_help_link) %>
          <a href="<%= url %>" class="vendor_help_link"><%= url %></a>
        </td>
      </tr>
      <tr class="extras">
        <td><%= before_label :extras, "Extras" %></td>
        <td>
          <div class="editor_button"><%= t :editor_button_configured, "Editor button configured" %></div>
          <div class="resource_selection"><%= t :resource_selection_configured, "Resource selection configured" %></div>
          <div class="course_navigation"><%= t :course_navigation_configured, "Course navigation configured" %></div>
          <div class="user_navigation"><%= t :user_navigation_configured, "User navigation configured" %></div>
          <div class="account_navigation"><%= t :account_navigation_configured, "Account navigation configured" %></div>
          <div class="homework_submission"><%= t :homework_submission_configured, "Homework submission configured" %></div>
        </td>
      </tr>
    </table>
  </div>
</div>
