Welcome to mirror list, hosted at ThFree Co, Russian Federation.

zentao_menu.rb « menus « projects « sidebars « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db9e60326a45d91efa4a02c1c9769f3aa30d6207 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# frozen_string_literal: true

module Sidebars
  module Projects
    module Menus
      class ZentaoMenu < ::Sidebars::Menu
        override :configure_menu_items
        def configure_menu_items
          render?.tap { |render| add_items if render }
        end

        override :link
        def link
          zentao_integration.url
        end

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

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

        override :image_path
        def image_path
          'logos/zentao.svg'
        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

        def add_items
          add_item(open_zentao_menu_item)
        end

        private

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

        def open_zentao_menu_item
          ::Sidebars::MenuItem.new(
            title: s_('ZentaoIntegration|Open ZenTao'),
            link: zentao_integration.url,
            active_routes: {},
            item_id: :open_zentao,
            sprite_icon: 'external-link',
            container_html_options: {
              target: '_blank',
              rel: 'noopener noreferrer'
            }
          )
        end
      end
    end
  end
end

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