<%
   selected_section = controller.class::SECTION if defined?(controller.class::SECTION)
   if selected_section == Navigation::SECTION_RESOURCE && !@project && !@resource
     selected_section = Navigation::SECTION_HOME
   end

   @project = @resource unless @project || selected_section == Navigation::SECTION_HOME
%>

<script>
  (function () {
    <% if selected_section == Navigation::SECTION_RESOURCE %>
    window.sonarqube.space = 'component';
    window.sonarqube.componentKey = '<%= escape_javascript @project.key -%>';
    <% end %>

    <% if selected_section == Navigation::SECTION_CONFIGURATION %>
    window.sonarqube.space = 'settings';
    <% end %>

    window.SS.isUserAdmin = <%= logged_in? && is_admin? ? 'true' : 'false' -%>;
  })();
</script>
