summaryrefslogtreecommitdiff
path: root/lib/sidebars/projects/super_sidebar_panel.rb
blob: f0ebea92525e70ff89bc5c99250c74550e565f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
41
# frozen_string_literal: true

module Sidebars
  module Projects
    class SuperSidebarPanel < ::Sidebars::Projects::Panel
      include ::Sidebars::Concerns::SuperSidebarPanel
      extend ::Gitlab::Utils::Override

      override :configure_menus
      def configure_menus
        super
        old_menus = @menus
        @menus = []

        add_menu(Sidebars::StaticMenu.new(context))
        add_menu(Sidebars::Projects::SuperSidebarMenus::PlanMenu.new(context))
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::RepositoryMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::CiCdMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::SecurityComplianceMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::DeploymentsMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::PackagesRegistriesMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::InfrastructureMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::MonitorMenu)
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::AnalyticsMenu)
        add_menu(Sidebars::UncategorizedMenu.new(context))
        pick_from_old_menus(old_menus, Sidebars::Projects::Menus::SettingsMenu)

        transform_old_menus(@menus, @scope_menu, *old_menus)
      end

      override :super_sidebar_context_header
      def super_sidebar_context_header
        {
          title: context.project.name,
          avatar: context.project.avatar_url,
          id: context.project.id
        }
      end
    end
  end
end