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

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2021-02-03 03:08:05 +0300
committerEvan Read <eread@gitlab.com>2021-04-06 07:36:24 +0300
commit1698c76cd01c5b3757335ba9b010c9732f38eeb2 (patch)
tree839c8528fae12860c7f7e9b448e993f4b8e82c66 /lib
parentb84f28e790547c0cd86623638dc794cb5b6c4c1c (diff)
Unify global navigation for docs site
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/navigation.rb40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/gitlab/navigation.rb b/lib/gitlab/navigation.rb
index 25281f9c..fafd846d 100644
--- a/lib/gitlab/navigation.rb
+++ b/lib/gitlab/navigation.rb
@@ -11,30 +11,25 @@ module Gitlab
@item = item
disable_inactive_sections!
+ omnibus_only_items!
end
def nav_items
- @nav_items ||= nav_items_exists ? items[nav_items_dir] : items["/_data/default-nav.yaml"]
+ @nav_items ||= items["/_data/default-nav.yaml"]
end
def element_href(element)
- is_ee_prefixed ? "/ee/#{element.url}" : "/#{dir}/#{element.url}"
+ "/#{element.url}"
end
def show_element?(element)
- item.path == "/#{dir}/#{element.url}"
+ item.path == "/#{element.url}"
end
def id_for(element)
element.title.gsub(/[\s\/\(\)]/, '')
end
- def optional_ee_badge(element)
- return unless element.ee_only?
-
- %(<span class="badges-drop global-nav-badges" data-toggle="tooltip" data-placement="top" title="Available in #{element.ee_tier}">#{icon('information-o', 14)}</span>)
- end
-
def children
@children ||= nav_items.fetch(:sections, []).map { |section| Section.new(section) }
end
@@ -51,6 +46,22 @@ module Gitlab
end
end
+ # Remove sections and categories menu items missing in Omnibus
+ def omnibus_only_items!
+ return unless omnibus?
+
+ children.filter! do |section|
+ if allowed_link?(section.url)
+ section.children.filter! { |category| allowed_link?(category.url) }
+ true
+ end
+ end
+ end
+
+ def allowed_link?(link)
+ link.start_with?('ee/') || link.start_with?('http')
+ end
+
def has_active_element?(collection)
return false unless collection
@@ -61,16 +72,5 @@ module Gitlab
@dir ||= item.identifier.to_s[%r{(?<=/)[^/]+}]
end
- def nav_items_dir
- @nav_items_dir ||= "/_data/#{dir}-nav.yaml"
- end
-
- def nav_items_exists
- !items[nav_items_dir].nil?
- end
-
- def is_ee_prefixed
- !nav_items_exists && dir != 'ce'
- end
end
end