Module: Koi::Menu

Defined in:
lib/koi/menu.rb,
lib/koi/menu/builder.rb

Defined Under Namespace

Classes: Builder

Constant Summary collapse

@@priority =
{}
@@modules =
{}
@@advanced =
{}

Class Method Summary collapse

Class Method Details

.admin_menu(context) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/koi/menu.rb', line 14

def admin_menu(context)
  builder = Builder.new
  builder.add_menu(title: "Priority") do |b|
    b.add_link(title: "View site", url: "/", target: :blank)
    b.add_link(title: "Dashboard", url: context.main_app.admin_dashboard_path)
    b.add_items(priority)
    b.add_button(title: "Logout", url: context.main_app.admin_session_path, http_method: :delete)
  end
  builder.add_menu(title: "Modules") do |b|
    b.add_items(modules)
  end
  builder.add_menu(title: "Advanced") do |b|
    b.add_items(advanced)

    if Object.const_defined?("Flipper::UI")
      b.add_link(title:  "Flipper", url: context.main_app.admin_root_path.concat("/flipper"),
                 target: :blank)
    end
    if Object.const_defined?("Sidekiq::Web")
      b.add_link(title:  "Sidekiq", url: context.main_app.admin_root_path.concat("sidekiq"),
                 target: :blank)
    end
    b.add_button(title:       "Clear cache", url: context.main_app.admin_cache_path,
                 http_method: :delete)
  end
  builder.render
end