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/gitlab/nav/top_nav_menu_builder.rb')
-rw-r--r--lib/gitlab/nav/top_nav_menu_builder.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/gitlab/nav/top_nav_menu_builder.rb b/lib/gitlab/nav/top_nav_menu_builder.rb
new file mode 100644
index 00000000000..721ae1889b8
--- /dev/null
+++ b/lib/gitlab/nav/top_nav_menu_builder.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Nav
+ class TopNavMenuBuilder
+ def initialize
+ @primary = []
+ @secondary = []
+ end
+
+ def add_primary_menu_item(**args)
+ add_menu_item(dest: @primary, **args)
+ end
+
+ def add_secondary_menu_item(**args)
+ add_menu_item(dest: @secondary, **args)
+ end
+
+ def build
+ {
+ primary: @primary,
+ secondary: @secondary
+ }
+ end
+
+ private
+
+ def add_menu_item(dest:, **args)
+ item = ::Gitlab::Nav::TopNavMenuItem.build(**args)
+
+ dest.push(item)
+ end
+ end
+ end
+end