<% records.each do |record| %>
  <% if record[:project] %>
    <li class="sidebar-leaf">
      <% if record[:project].archived? %>
        <%= link_to record[:project].name, project_url(record[:project], view_mode: :archived), title: record[:project].name, class: 'sidebar-link' %>
      <% else %>
        <%= link_to record[:project].name, project_url(record[:project]), title: record[:project].name, class: 'sidebar-link' %>
      <% end %>
    </li>
  <% else %>
    <li class="sidebar-leaf">
      <% unless record[:children].empty? %>
        <i class="fas fa-caret-right toggle-branch collapsed"></i>
      <% end %>
      <%= link_to project_folder_path(record[:folder]),
          class: "sidebar-link project-folder-link folder #{'selected' if current_folder == record[:folder]}",
          title: record[:folder].name,
          data: {
            sidebar_url: sidebar_team_path(current_team, project_folder_id: record[:folder].id),
            projects_cards_url: project_folder_cards_url(record[:folder])
          } do %>
        <i class="fas fa-folder"></i>
        <%= record[:folder].name %>
      <% end%>
      <ul class="sidebar-branch">
        <%= render partial: 'shared/sidebar/projects_tree_branch.html.erb', locals: { records: record[:children] } %>
      </ul>
    </li>
  <% end %>
<% end %>
