summaryrefslogtreecommitdiff
path: root/lib/sidebars/projects/menus/zentao_menu.rb
blob: 1b5ba900a86899afcd64688417cb099befc33fd7 (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
# frozen_string_literal: true

module Sidebars
  module Projects
    module Menus
      class ZentaoMenu < ::Sidebars::Menu
        override :link
        def link
          zentao_integration.url
        end

        override :title
        def title
          s_('ZentaoIntegration|ZenTao')
        end

        override :title_html_options
        def title_html_options
          {
            id: 'js-onboarding-settings-link'
          }
        end

        override :sprite_icon
        def sprite_icon
          'external-link'
        end

        # Hardcode sizes so image doesn't flash before CSS loads https://gitlab.com/gitlab-org/gitlab/-/issues/321022
        override :image_html_options
        def image_html_options
          {
            size: 16
          }
        end

        override :render?
        def render?
          return false if zentao_integration.blank?

          zentao_integration.active?
        end

        private

        def zentao_integration
          @zentao_integration ||= context.project.zentao_integration
        end
      end
    end
  end
end

::Sidebars::Projects::Menus::ZentaoMenu.prepend_mod