<% current_back_url = back_url %>
<ul>
  <% if @project %>
    <% if User.current.allowed_to?(:edit_project, @project) %>
      <%= content_tag(:li, context_menu_link(l(:button_edit), settings_project_path(@project), class: 'icon icon-edit')) %>
    <% end %>

    <li class="folder">
      <a href="#" class="submenu icon icon-list"><%= l(:label_module_jump) %></a>
      <%= render_easy_custom_project_menu(@project) %>
    </li>

    <% if User.current.allowed_to?(:select_project_modules, @project) %>
      <%= content_tag(:li, context_menu_link(l(:label_module_manage), modules_project_path(@project), remote: true, method: :post, class: 'icon icon-add')) %>
    <% end %>

    <% if User.current.allowed_to?(:manage_members, @project) %>
      <%= content_tag(:li, context_menu_link(l(:label_add_members), new_project_membership_path(@project), remote: true, class: 'icon icon-add')) %>
    <% end %>

    <% if User.current.allowed_to?(:copy_project, @project) %>
      <%= content_tag(:li, link_to_project_copy(@project)) -%>
    <% end %>

    <% if User.current.allowed_to?(:add_subprojects, @project) %>
      <%= content_tag(:li, context_menu_link(l(:label_create_subproject), new_project_path(parent_id: @project), class: 'icon icon-add')) %>
    <% end %>

    <% if User.current.allowed_to?(:create_project_template, @project) %>
      <%= content_tag(:li, context_menu_link(l(:button_easy_page_create_template), {controller: 'templates', action: 'add', id: @project}, class: 'icon icon-add')) %>
    <% end %>
  <% end -%>

  <% if @all_active && User.current.allowed_to?(:close_project, @project || @projects) %>
    <%= content_tag(:li, context_menu_link(l(:button_close), bulk_close_projects_path(data: {ids: params[:ids], status: params[:status]}, back_url: current_back_url),
                                           class: 'icon icon-lock',
                                           method: :post,
                                           remote: :true,
                                           data: {confirm: l(:text_are_you_sure)}
    )) -%>
  <% end %>

  <% if @all_closed && User.current.allowed_to?(:close_project, @project || @projects) %>
    <%= content_tag(:li, context_menu_link(l(:button_reopen), bulk_reopen_projects_path(data: {ids: params[:ids], status: params[:status]}, back_url: current_back_url),
                                           class: 'icon icon-unlock',
                                           method: :post,
                                           remote: :true,
                                           data: {confirm: l(:text_are_you_sure)}
    )) -%>
  <% end %>

  <% if User.current.allowed_to?(:archive_project, @project || @projects) %>
    <%= content_tag(:li, context_menu_link(l(:button_archive), bulk_archive_projects_path(data: {ids: params[:ids], status: params[:status]}, back_url: current_back_url),
                                           class: 'icon icon-archive',
                                           method: :post,
                                           data: {confirm: l(:text_are_you_sure)}
    )) -%>
  <% end %>

  <% if @all_archived && @can_unarchive %>
    <%= content_tag(:li, context_menu_link(l(:button_unarchive), bulk_unarchive_projects_path(data: {ids: params[:ids], status: params[:status]}, back_url: current_back_url),
                                           class: 'icon icon-unlock',
                                           method: :post,
                                           data: {confirm: l(:text_are_you_sure)}
    )) -%>
  <% end %>

  <% if User.current.allowed_to?(:delete_project, @project || @projects) %>
    <%= content_tag :li, context_menu_link(l(:button_delete), bulk_destroy_projects_path(data: {ids: params[:ids], status: params[:status]}, back_url: current_back_url),
                                           class: 'icon icon-del',
                                           method: :delete,
                                           data: {confirm: l(:text_project_destroy_confirmation)}
    ) -%>
  <% end %>
</ul>