2020-03-19 11:09:41 -04:00
|
|
|
# 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-09-04 08:08:27 -04:00
|
|
|
index = structure.find_index { |h| h[:nav_item] == before_nav_item_name if h }
|
2020-03-19 11:09:41 -04:00
|
|
|
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-09-04 08:08:27 -04:00
|
|
|
hash = structure.find { |h| h[:nav_item] == within if h }
|
2020-03-19 11:09:41 -04:00
|
|
|
|
|
|
|
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-07-21 08:09:30 -04:00
|
|
|
|
2021-11-24 13:14:31 -05:00
|
|
|
def insert_before_sub_nav_item(after_sub_nav_item_name, within:, new_sub_nav_item_name:)
|
|
|
|
expect(structure).to include(a_hash_including(nav_item: within))
|
|
|
|
hash = structure.find { |h| h[:nav_item] == within if h }
|
|
|
|
|
|
|
|
expect(hash).to have_key(:nav_sub_items)
|
|
|
|
expect(hash[:nav_sub_items]).to include(after_sub_nav_item_name)
|
|
|
|
|
|
|
|
index = hash[:nav_sub_items].find_index(after_sub_nav_item_name)
|
|
|
|
hash[:nav_sub_items].insert(index, new_sub_nav_item_name)
|
|
|
|
end
|
|
|
|
|
2020-07-21 08:09:30 -04:00
|
|
|
def insert_package_nav(within)
|
|
|
|
insert_after_nav_item(
|
|
|
|
within,
|
|
|
|
new_nav_item: {
|
2022-09-05 20:12:24 -04:00
|
|
|
nav_item: _('Packages and registries'),
|
2020-07-21 08:09:30 -04:00
|
|
|
nav_sub_items: [_('Package Registry')]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-10-29 20:10:32 -04:00
|
|
|
def insert_customer_relations_nav(within)
|
|
|
|
insert_after_nav_item(
|
|
|
|
within,
|
|
|
|
new_nav_item: {
|
|
|
|
nav_item: _('Customer relations'),
|
|
|
|
nav_sub_items: [
|
|
|
|
_('Contacts'),
|
|
|
|
_('Organizations')
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-04-01 08:08:56 -04:00
|
|
|
def insert_container_nav
|
2020-07-21 08:09:30 -04:00
|
|
|
insert_after_sub_nav_item(
|
|
|
|
_('Package Registry'),
|
2022-09-05 20:12:24 -04:00
|
|
|
within: _('Packages and registries'),
|
2020-07-21 08:09:30 -04:00
|
|
|
new_sub_nav_item_name: _('Container Registry')
|
|
|
|
)
|
|
|
|
end
|
2020-11-13 16:09:31 -05:00
|
|
|
|
2021-04-01 08:08:56 -04:00
|
|
|
def insert_dependency_proxy_nav
|
2020-11-13 16:09:31 -05:00
|
|
|
insert_after_sub_nav_item(
|
|
|
|
_('Package Registry'),
|
2022-09-05 20:12:24 -04:00
|
|
|
within: _('Packages and registries'),
|
2020-11-13 16:09:31 -05:00
|
|
|
new_sub_nav_item_name: _('Dependency Proxy')
|
|
|
|
)
|
|
|
|
end
|
2021-04-01 08:08:56 -04:00
|
|
|
|
|
|
|
def insert_infrastructure_registry_nav
|
|
|
|
insert_after_sub_nav_item(
|
|
|
|
_('Package Registry'),
|
2022-09-05 20:12:24 -04:00
|
|
|
within: _('Packages and registries'),
|
2021-04-01 08:08:56 -04:00
|
|
|
new_sub_nav_item_name: _('Infrastructure Registry')
|
|
|
|
)
|
|
|
|
end
|
2021-09-29 14:12:42 -04:00
|
|
|
|
2022-03-10 16:08:21 -05:00
|
|
|
def insert_harbor_registry_nav(within)
|
|
|
|
insert_after_sub_nav_item(
|
|
|
|
within,
|
2022-09-05 20:12:24 -04:00
|
|
|
within: _('Packages and registries'),
|
2022-03-10 16:08:21 -05:00
|
|
|
new_sub_nav_item_name: _('Harbor Registry')
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-09-11 14:10:42 -04:00
|
|
|
def insert_observability_nav
|
|
|
|
insert_after_nav_item(
|
|
|
|
_('Kubernetes'),
|
|
|
|
new_nav_item: {
|
|
|
|
nav_item: _('Observability'),
|
|
|
|
nav_sub_items: []
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-09-29 14:12:42 -04:00
|
|
|
def insert_infrastructure_google_cloud_nav
|
|
|
|
insert_after_sub_nav_item(
|
|
|
|
_('Terraform'),
|
|
|
|
within: _('Infrastructure'),
|
|
|
|
new_sub_nav_item_name: _('Google Cloud')
|
|
|
|
)
|
|
|
|
end
|
2022-04-14 05:10:34 -04:00
|
|
|
|
2022-04-20 05:09:31 -04:00
|
|
|
def project_analytics_sub_nav_item
|
2022-04-14 05:10:34 -04:00
|
|
|
[
|
|
|
|
_('Value stream'),
|
|
|
|
_('CI/CD'),
|
|
|
|
(_('Code review') if Gitlab.ee?),
|
|
|
|
(_('Merge request') if Gitlab.ee?),
|
|
|
|
_('Repository')
|
|
|
|
]
|
|
|
|
end
|
2022-04-20 05:09:31 -04:00
|
|
|
|
|
|
|
def group_analytics_sub_nav_item
|
|
|
|
[
|
|
|
|
_('Contribution')
|
|
|
|
]
|
|
|
|
end
|
2020-03-19 11:09:41 -04:00
|
|
|
end
|
2022-04-14 05:10:34 -04:00
|
|
|
|
|
|
|
NavbarStructureHelper.prepend_mod
|