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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sidebars/projects/menus/zentao_menu.rb')
-rw-r--r--lib/sidebars/projects/menus/zentao_menu.rb77
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/sidebars/projects/menus/zentao_menu.rb b/lib/sidebars/projects/menus/zentao_menu.rb
new file mode 100644
index 00000000000..db9e60326a4
--- /dev/null
+++ b/lib/sidebars/projects/menus/zentao_menu.rb
@@ -0,0 +1,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