debian-mirror-gitlab/spec/support/helpers/navbar_structure_helper.rb

64 lines
1.8 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module NavbarStructureHelper
def insert_after_nav_item(before_nav_item_name, new_nav_item:)
expect(structure).to include(a_hash_including(nav_item: before_nav_item_name))
2020-11-24 15:15:51 +05:30
index = structure.find_index { |h| h[:nav_item] == before_nav_item_name if h }
2020-04-22 19:07:51 +05:30
structure.insert(index + 1, new_nav_item)
end
def insert_after_sub_nav_item(before_sub_nav_item_name, within:, new_sub_nav_item_name:)
expect(structure).to include(a_hash_including(nav_item: within))
2020-11-24 15:15:51 +05:30
hash = structure.find { |h| h[:nav_item] == within if h }
2020-04-22 19:07:51 +05:30
expect(hash).to have_key(:nav_sub_items)
expect(hash[:nav_sub_items]).to include(before_sub_nav_item_name)
index = hash[:nav_sub_items].find_index(before_sub_nav_item_name)
hash[:nav_sub_items].insert(index + 1, new_sub_nav_item_name)
end
2020-10-24 23:57:45 +05:30
def insert_package_nav(within)
insert_after_nav_item(
within,
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
end
2021-04-29 21:17:54 +05:30
def insert_container_nav
2020-10-24 23:57:45 +05:30
insert_after_sub_nav_item(
_('Package Registry'),
within: _('Packages & Registries'),
new_sub_nav_item_name: _('Container Registry')
)
end
2021-01-29 00:20:46 +05:30
2021-04-29 21:17:54 +05:30
def insert_dependency_proxy_nav
2021-01-29 00:20:46 +05:30
insert_after_sub_nav_item(
_('Package Registry'),
within: _('Packages & Registries'),
new_sub_nav_item_name: _('Dependency Proxy')
)
end
2021-04-29 21:17:54 +05:30
def insert_infrastructure_registry_nav
insert_after_sub_nav_item(
_('Package Registry'),
within: _('Packages & Registries'),
new_sub_nav_item_name: _('Infrastructure Registry')
)
end
2021-11-18 22:05:49 +05:30
def insert_infrastructure_google_cloud_nav
insert_after_sub_nav_item(
_('Terraform'),
within: _('Infrastructure'),
new_sub_nav_item_name: _('Google Cloud')
)
end
2020-04-22 19:07:51 +05:30
end