summaryrefslogtreecommitdiff
path: root/lib/sidebars/projects/menus/learn_gitlab_menu.rb
blob: 16335f5b076dd517887376a2c2c6c6bf9f1c8a75 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

module Sidebars
  module Projects
    module Menus
      class LearnGitlabMenu < ::Sidebars::Menu
        include Gitlab::Utils::StrongMemoize

        override :link
        def link
          project_learn_gitlab_path(context.project)
        end

        override :active_routes
        def active_routes
          { controller: :learn_gitlab }
        end

        override :title
        def title
          _('Learn GitLab')
        end

        override :has_pill?
        def has_pill?
          context.learn_gitlab_enabled
        end

        override :pill_count
        def pill_count
          strong_memoize(:pill_count) do
            percentage = LearnGitlab::Onboarding.new(context.project.namespace).completed_percentage

            "#{percentage}%"
          end
        end

        override :extra_nav_link_html_options
        def extra_nav_link_html_options
          {
            class: 'home',
            data: {
              track_label: 'learn_gitlab'
            }
          }
        end

        override :image_path
        def image_path
          'learn_gitlab/graduation_hat.svg'
        end

        override :render?
        def render?
          context.learn_gitlab_enabled
        end
      end
    end
  end
end