Module: Nav::NewDropdownHelper

Defined in:
app/helpers/nav/new_dropdown_helper.rb

Instance Method Summary collapse

Instance Method Details

#new_dropdown_view_model(group:, project:) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/nav/new_dropdown_helper.rb', line 5

def new_dropdown_view_model(group:, project:)
  return unless current_user

  menu_sections = []

  if group&.persisted?
    menu_sections.push(group_menu_section(group))
  elsif project&.persisted?
    menu_sections.push(project_menu_section(project))
  end

  menu_sections.push(general_menu_section)

  {
    title: _("New..."),
    menu_sections: menu_sections.select { |x| x.fetch(:menu_items).any? }
  }
end