<% phases = Phase.titles(plan.template.id) %>
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="<%= (active_page?(plan_path(plan), true) ? 'active' : '') %>">
    <a href="<%= plan_path(plan) %>" role="tab" aria-controls="content"><%= _('Project Details') %></a>
  </li>
  <li role="presentation" class="<%= (active_page?(overview_plan_path(plan)) ? 'active' : '') %>">
    <%= link_to(_('Plan overview'), overview_plan_path(plan), role: 'tab', 'aria-controls': 'content') %>
  </li>
  <% phases.each do |phase| %>
    <li role="presentation" class="<%= (active_page?(edit_plan_path(plan.id, phase_id: phase.id)) ? 'active' : '') %>">
      <a href="<%= edit_plan_path(plan.id, phase_id: phase.id) %>" role="tab" aria-controls="content">
        <%= (phases.size > 1 ? phase.title : _('Write Plan')) %>
      </a>
    </li>
  <% end %>
  <% if plan.administerable_by?(current_user) || (current_user.can_org_admin? && current_user.org.plans.include?(plan)) %>
    <li role="presentation" class="<%= (active_page?(share_plan_path(plan)) ? 'active' : '') %>">
      <a href="<%= share_plan_path(plan) %>" role="tab" aria-controls="content"><%= _('Share') %></a>
    </li>
  <% end %>
  <% if plan.readable_by?(current_user.id) %>
    <li role="presentation" class="<%= (active_page?(download_plan_path(plan)) ? 'active' : '') %>">
      <a href="<%= download_plan_path(plan) %>" role="tab" aria-controls="content"><%= _('Download') %></a>
    </li>
  <% end %>
</ul>
<div class="tab-content">
  <div id="content" role="tabpanel" class="tab-pane active">
    <div class="panel panel-default">
      <div class="panel-body">
        <%= yield %>
      </div>
    </div>
  </div>
</div>