Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
fdb0790ab5
commit
0e08747b3d
|
|
@ -55,7 +55,7 @@ GitLab marketing-related entries are occasionally shown on the Help page. To hid
|
|||
|
||||
You can specify a custom URL to which users are directed when they:
|
||||
|
||||
- Select **Support** from the Help dropdown list.
|
||||
- Select **Help > Support**.
|
||||
- Select **See our website for help** on the Help page.
|
||||
|
||||
1. On the left sidebar, at the bottom, select **Admin Area**.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module Gitlab
|
|||
"--broken encoding: #{encoding}"
|
||||
end
|
||||
|
||||
def detect_encoding(data, limit: CharlockHolmes::EncodingDetector::DEFAULT_BINARY_SCAN_LEN, cache_key: nil)
|
||||
def detect_encoding(data, limit: CharlockHolmes::EncodingDetector::DEFAULT_BINARY_SCAN_LEN)
|
||||
return if data.nil?
|
||||
|
||||
CharlockHolmes::EncodingDetector.new(limit).detect(data)
|
||||
|
|
@ -54,8 +54,8 @@ module Gitlab
|
|||
# EncodingDetector checks the first 1024 * 1024 bytes for NUL byte, libgit2 checks
|
||||
# only the first 8000 (https://github.com/libgit2/libgit2/blob/2ed855a9e8f9af211e7274021c2264e600c0f86b/src/filter.h#L15),
|
||||
# which is what we use below to keep a consistent behavior.
|
||||
def detect_libgit2_binary?(data, cache_key: nil)
|
||||
detect = detect_encoding(data, limit: 8000, cache_key: cache_key)
|
||||
def detect_libgit2_binary?(data)
|
||||
detect = detect_encoding(data, limit: 8000)
|
||||
detect && detect[:type] == :binary
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
def binary?(data, cache_key: nil)
|
||||
EncodingHelper.detect_libgit2_binary?(data, cache_key: cache_key)
|
||||
def binary?(data)
|
||||
EncodingHelper.detect_libgit2_binary?(data)
|
||||
end
|
||||
|
||||
def size_could_be_lfs?(size)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ module Gitlab
|
|||
size: blob_data[:size],
|
||||
commit_id: blob_data[:revision],
|
||||
data: data,
|
||||
binary: Gitlab::Git::Blob.binary?(data, cache_key: blob_data[:oid])
|
||||
binary: Gitlab::Git::Blob.binary?(data)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ module Sidebars
|
|||
add_item(infrastructure_registry_menu_item)
|
||||
add_item(harbor_registry_menu_item)
|
||||
add_item(model_experiments_menu_item)
|
||||
add_item(model_registry_menu_item)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
@ -103,6 +104,20 @@ module Sidebars
|
|||
)
|
||||
end
|
||||
|
||||
def model_registry_menu_item
|
||||
unless can?(context.current_user, :read_model_registry, context.project)
|
||||
return ::Sidebars::NilMenuItem.new(item_id: :model_registry)
|
||||
end
|
||||
|
||||
::Sidebars::MenuItem.new(
|
||||
title: _('Model registry'),
|
||||
link: project_ml_models_path(context.project),
|
||||
super_sidebar_parent: Sidebars::Projects::SuperSidebarMenus::DeployMenu,
|
||||
active_routes: { controller: %w[projects/ml/models] },
|
||||
item_id: :model_registry
|
||||
)
|
||||
end
|
||||
|
||||
def packages_registry_disabled?
|
||||
!::Gitlab.config.packages.enabled ||
|
||||
!can?(context.current_user, :read_package, context.project&.packages_policy_subject)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ module Sidebars
|
|||
:releases,
|
||||
:feature_flags,
|
||||
:packages_registry,
|
||||
:container_registry
|
||||
:container_registry,
|
||||
:model_registry
|
||||
].each { |id| add_item(::Sidebars::NilMenuItem.new(item_id: id)) }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31196,6 +31196,9 @@ msgstr ""
|
|||
msgid "Model experiments"
|
||||
msgstr ""
|
||||
|
||||
msgid "Model registry"
|
||||
msgstr ""
|
||||
|
||||
msgid "ModelRegistry|Model registry"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ RSpec.describe 'Project navbar', :with_license, :js, feature_category: :groups_a
|
|||
|
||||
stub_config(registry: { enabled: false })
|
||||
stub_feature_flags(ml_experiment_tracking: false)
|
||||
stub_feature_flags(model_registry: false)
|
||||
insert_package_nav
|
||||
insert_infrastructure_registry_nav
|
||||
insert_infrastructure_google_cloud_nav
|
||||
|
|
@ -93,4 +94,16 @@ RSpec.describe 'Project navbar', :with_license, :js, feature_category: :groups_a
|
|||
|
||||
it_behaves_like 'verified navigation bar'
|
||||
end
|
||||
|
||||
context 'when model registry is available' do
|
||||
before do
|
||||
stub_feature_flags(model_registry: true)
|
||||
|
||||
insert_model_registry_nav(_('Package Registry'))
|
||||
|
||||
visit project_path(project)
|
||||
end
|
||||
|
||||
it_behaves_like 'verified navigation bar'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu, feature_catego
|
|||
before do
|
||||
stub_container_registry_config(enabled: registry_enabled)
|
||||
stub_config(packages: { enabled: packages_enabled })
|
||||
stub_feature_flags(ml_experiment_tracking: false)
|
||||
stub_feature_flags(ml_experiment_tracking: false, model_registry: false)
|
||||
end
|
||||
|
||||
context 'when Packages Registry is visible' do
|
||||
|
|
@ -195,5 +195,32 @@ RSpec.describe Sidebars::Projects::Menus::PackagesRegistriesMenu, feature_catego
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Model registry' do
|
||||
let(:item_id) { :model_registry }
|
||||
|
||||
before do
|
||||
allow(Ability).to receive(:allowed?).and_call_original
|
||||
allow(Ability).to receive(:allowed?)
|
||||
.with(user, :read_model_registry, project)
|
||||
.and_return(model_registry_enabled)
|
||||
end
|
||||
|
||||
context 'when user can read model registry' do
|
||||
let(:model_registry_enabled) { true }
|
||||
|
||||
it 'shows the menu item' do
|
||||
is_expected.not_to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user can not read model registry' do
|
||||
let(:model_registry_enabled) { false }
|
||||
|
||||
it 'does not show the menu item' do
|
||||
is_expected.to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ RSpec.describe Sidebars::Projects::SuperSidebarMenus::DeployMenu, feature_catego
|
|||
:releases,
|
||||
:feature_flags,
|
||||
:packages_registry,
|
||||
:container_registry
|
||||
:container_registry,
|
||||
:model_registry
|
||||
])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -124,6 +124,14 @@ module NavbarStructureHelper
|
|||
)
|
||||
end
|
||||
|
||||
def insert_model_registry_nav(within)
|
||||
insert_after_sub_nav_item(
|
||||
within,
|
||||
within: _('Deploy'),
|
||||
new_sub_nav_item_name: _('Model registry')
|
||||
)
|
||||
end
|
||||
|
||||
def project_analytics_sub_nav_item
|
||||
[
|
||||
_('Value stream analytics'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue