<% content_for :title, @issue.title %>

<% content_for :sidebar do %>
  <%= render 'sidebar'%>
<% end %>

<% if @conflicting_revisions %>
  <%= render "projects/conflicting_revisions", conflicts: @conflicting_revisions, record: @issue %>
<% end %>

<% content_for :breadcrumbs do %>
  <%= render partial: 'breadcrumbs' %>
<% end %>

<!-- Main content -->
<ul class="tabs-container nav nav-tabs main-tabs">
  <li class="nav-item">
    <a href="#info-tab" data-bs-toggle="tab" class="nav-link active">
      <%= tag_and_name_for(@issue) %>
      <%= "(#{@issue.state.humanize})" %>
    </a>
  </li>
  <li class="nav-item"><a href="#evidence-tab" class="nav-link" data-bs-toggle="tab"><i class="fa-solid fa-laptop"></i> Evidence <span class="badge bg-primary text-white" data-behavior="evidence-count"><%= @issue.evidence.count %></span></a></li>
  <%= render_view_hooks 'issues/show-tabs' %>
</ul>

<div class="row p-0">
  <div class="col-12">
    <div class="content-container">
      <div class="tab-content">
        <div class="tab-pane active" id="info-tab">
          <% cache ['issue-information-tab', @issue] do %>
            <div class="note-text-inner">
              <h4 class="mb-4 header-underline">
                <span class="text-truncate" title="<%= @issue.title %>"><%= @issue.title %></span>
                <%= render partial: 'shared/liquid_loading' %>
                <%= render partial: 'actions' %>
              </h4>
              <%= render partial: 'shared/textile_content', locals: { record: @issue, preview_path: preview_project_issue_path(current_project, @issue)  } %>
              <div class="author-info">
                <span class="ms-auto">Author: <%= @issue.author || 'n/a' %></span>
              </div>
            </div>
          <% end %>
        </div>

        <div class="tab-pane" id="evidence-tab">
          <%=
            content_tag :div,
            spinner_tag,
            data: {
              behavior: 'fetch',
              path: project_issue_evidence_index_path(issue_id: @issue.id)
            }
          %>
        </div>

        <%= render_view_hooks 'issues/show-content' %>
      </div>
    </div>

    <div class="content-container">
      <%= content_tag :div,
          spinner_tag,
          data: {
            behavior: 'fetch fetch-comments',
            path: comments_path(
              comment: {
                commentable_type: @issue.class,
                commentable_id: @issue.id
              }
            )
          }
        %>

      <%= render_view_hooks('issues/comments') %>
    </div>

    <div class="content-container">
      <%= content_tag :div,
          spinner_tag,
          data: {
            behavior: 'fetch fetch-subscriptions',
            path: subscriptions_path(
              subscription: {
                subscribable_type: @issue.class,
                subscribable_id: @issue.id
              }
            )
          }
        %>
    </div>
  </div>
</div>
