ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/_tabs.html.haml

Summary

Maintainability
Test Coverage
- if @tabs
  #custom-tabs-wrapper.miq_custom_tab_wrapper
    - if @path.present?
      = react('CustomURLTabs', {:tabs => @tabs, :path => @path, :currentTab => @current_tab, :checkForChanges => @check_for_changes})
    - else
      %ul{'role' => 'tablist', :class => "nav nav-tabs #{@layout == 'dashboard' ? 'nav-tabs-pf' : nil}"}
        - @tabs.each_with_index do |tab, tab_index|
          - tab_id = tab[1].split(" ")[0]
          - if tab[0] == @active_tab
            %li.active{'role' => 'tab', 'tabindex' => tab_index, 'aria-selected' => "true", :id => "#{tab_id}_tab", 'aria-controls' => tab_id}
              %a
                = h(tab[1])
          - else
            %li{'role' => 'tab', 'tabindex' => tab_index, 'aria-selected' => "false", :id => "#{tab_id}_tab", 'aria-controls' => tab_id}
              - if tab[0] == ""
                %a= h(tab[1])
              - else
                - if %w(new edit).include?(tab[0].split("_")[0])
                  - if %w(report ops).include?(@layout)
                    = link_to(tab[1],
                      {:action => 'change_tab',
                      :tab    => tab[0],
                      :id     => tab[0]},
                      "data-miq_sparkle_on"  => true,
                      "data-miq_sparkle_off" => true,
                      :remote                => true,
                      "data-method"          => :post)
                  - else
                    = link_to(tab[1], :action => 'change_tab', 'uib-tab' => tab[0], :id => tab[0])
                - else
                  - if %w(report ops).include?(@layout)
                    - if @layout == "ops"
                      = link_to(tab[1],
                        {:action => 'change_tab',
                        :tab    => tab[0],
                        :id     => tab[0]},
                        "data-miq_sparkle_on"  => true,
                        "data-miq_sparkle_off" => true,
                        :remote                => true,
                        "data-method"          => :post)
                    - else
                      = link_to(tab[1],
                        {:action => 'change_tab',
                        :tab    => tab[0],
                        :id     => tab[0]},
                        "data-miq_check_for_changes" => true,
                        "data-miq_sparkle_on"        => true,
                        "data-miq_sparkle_off"       => true,
                        :remote                      => true,
                        "data-method"                => :post)
                  - else
                    = link_to(tab[1], {:action => 'change_tab', 'uib-tab' => tab[0], :id => tab[0]}, :onclick => "return miqCheckForChanges()")
      %br{:clear => "all"}/
- if !@tabs && (@lastaction == "show_list" || !@edit && !session[:menu_click])
  - if @edit && @edit[:adv_search_applied] != nil && !session[:menu_click]
    %h1
      = h(@title + @edit[:adv_search_applied][:text] + " ")
      - if (@default_search && @default_search.name != @edit[:adv_search_applied][:name]) || !@default_search
        (#{link_to("clear", {:action => 'adv_search_clear'}, :method => :post, :class => 'active')})
  - else
    - if @right_cell_text
      %h1#explorer_title
        %span#explorer_title_text
          = safe_right_cell_text
    - else
      %h1
        = _(@title)