<commit_before>module ExpressAdmin
  class MegaMenuComponent < ExpressTemplates::Components::Base
    # %h1 "Modules"

    # - if admin_menus.any?
    #   %nav
    #     %ul
    #       - admin_menus.each do |menu|
    #         %li
    #           = link_to eval(menu.main.path) do
    #             %i.icon{class: "icon-express_#{menu.main.title.downcase}"}
    #             %span= menu.main.title
    # - else
    #   .empty-state-wrapper
    #     %p.lead.text-muted No modules added yet.
    #     %p
    #       = link_to app_express.addons_path, class: 'button success radius' do
    #         %span.icon.ion-plus
    #           Add Module

    fragments menu_item: -> {
                        li {
                          a(href: "{{eval(menu.main.path)}}") {
                            i.icon(class: '{{"icon-express_#{menu.main.title.downcase}"}}')
                            span "{{menu.main.title}}"
                          }
                        }
                      },

              empty_state: -> {
                div._empty_state_wrapper {
                  p.lead._text_muted "No modules added yet."
                }
              },

              menu_wrapper: -> {
                li.megamenu._has_dropdown {
                  a("Manage", href: '#', onClick: 'return false;')
                  ul.dropdown._dropdown_wrapper {
                    li._megamenu_overlay {
                      div._megamenu_container {
                        h1 "Modules"
                        nav {
                          ul {
                            _yield
                          }
                        }
                        # render(partial: 'shared/express_admin/express_admin_extra_menu') rescue nil
                      }
                    }
                  }
                }
              }

    # for_each -> {admin_menus}, as: 'menu', emit: :menu_item

    wrap_with :menu_wrapper

    for_each = -> (c) {
      admin_menus.map do |menu|
        eval(c[:menu_item])
      end.join()
    }

    using_logic do |c|
      if admin_menus.any?
        c._wrap_it(self, &for_each)
      else
        c.render(:empty_state, self)
      end
    end

  end
end
<commit_msg>Use new empty state support for collections in components<commit_after>module ExpressAdmin
  class MegaMenuComponent < ExpressTemplates::Components::Base
    # %h1 "Modules"

    # - if admin_menus.any?
    #   %nav
    #     %ul
    #       - admin_menus.each do |menu|
    #         %li
    #           = link_to eval(menu.main.path) do
    #             %i.icon{class: "icon-express_#{menu.main.title.downcase}"}
    #             %span= menu.main.title
    # - else
    #   .empty-state-wrapper
    #     %p.lead.text-muted No modules added yet.
    #     %p
    #       = link_to app_express.addons_path, class: 'button success radius' do
    #         %span.icon.ion-plus
    #           Add Module

    fragments menu_item: -> {
                        li {
                          a(href: "{{eval(menu.main.path)}}") {
                            i.icon(class: '{{"icon-express_#{menu.main.title.downcase}"}}')
                            span "{{menu.main.title}}"
                          }
                        }
                      },

              empty_state: -> {
                div._empty_state_wrapper {
                  p.lead._text_muted "No modules added yet."
                }
              },

              menu_wrapper: -> {
                li.megamenu._has_dropdown {
                  a("Manage", href: '#', onClick: 'return false;')
                  ul.dropdown._dropdown_wrapper {
                    li._megamenu_overlay {
                      div._megamenu_container {
                        h1 "Modules"
                        nav {
                          ul {
                            _yield
                          }
                        }
                        # render(partial: 'shared/express_admin/express_admin_extra_menu') rescue nil
                      }
                    }
                  }
                }
              }

    for_each -> {admin_menus}, as: 'menu', emit: :menu_item, empty: :empty_state

    wrap_with :menu_wrapper, dont_wrap_if: -> { admin_menus.empty? }

  end
end

{'fraction_non_alphanumeric': 0.10499300046663555, 'fraction_numerical': 0.0009332711152589828, 'mean_word_length': 1.0375475285171103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670665', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1166, 'n_words': 201}