Commit c4079d30 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '221259-move-packages-to-core-ui' into 'master'

Move package UI to core [RUN AS-IF-FOSS]

Closes #221259

See merge request gitlab-org/gitlab!36667
parents 2c1600a8 fb58018a
import Api from 'ee/api';
import Api from '~/api';
import createFlash from '~/flash';
import { FETCH_PACKAGE_VERSIONS_ERROR } from '../constants';
import * as types from './mutation_types';
......
import Api from 'ee/api';
import Api from '~/api';
import axios from '~/lib/utils/axios_utils';
import createFlash from '~/flash';
import * as types from './mutation_types';
......
import initPackageList from 'ee/packages/list/packages_list_app_bundle';
import initPackageList from '~/packages/list/packages_list_app_bundle';
document.addEventListener('DOMContentLoaded', () => {
if (document.getElementById('js-vue-packages-list')) {
......
import initPackageList from 'ee/packages/list/packages_list_app_bundle';
import initPackageList from '~/packages/list/packages_list_app_bundle';
document.addEventListener('DOMContentLoaded', () => {
if (document.getElementById('js-vue-packages-list')) {
......
import initPackageDetail from 'ee/packages/details/';
import initPackageDetail from '~/packages/details/';
document.addEventListener('DOMContentLoaded', initPackageDetail);
......@@ -11,8 +11,7 @@ module PackagesAccess
private
def verify_packages_enabled!
render_404 unless Gitlab.config.packages.enabled &&
project.feature_available?(:packages)
render_404 unless Gitlab.config.packages.enabled
end
def verify_read_package!
......
......@@ -7,7 +7,7 @@ module Groups
private
def verify_packages_enabled!
render_404 unless group.packages_feature_available?
render_404 unless group.packages_feature_enabled?
end
end
end
......@@ -392,6 +392,7 @@ class ProjectsController < Projects::ApplicationController
:initialize_with_readme,
:autoclose_referenced_issues,
:suggestion_commit_message,
:packages_enabled,
:service_desk_enabled,
project_feature_attributes: %i[
......
......@@ -28,6 +28,7 @@ module GroupsHelper
def group_packages_nav_link_paths
%w[
groups/packages#index
groups/container_registries#index
]
end
......@@ -157,6 +158,15 @@ module GroupsHelper
groups.to_json
end
def group_packages_nav?
group_packages_list_nav? ||
group_container_registry_nav?
end
def group_packages_list_nav?
@group.packages_feature_enabled?
end
private
def get_group_sidebar_links
......
# frozen_string_literal: true
module PackagesHelper
def package_sort_path(options = {})
"#{request.path}?#{options.to_param}"
end
def nuget_package_registry_url(project_id)
expose_url(api_v4_projects_packages_nuget_index_path(id: project_id, format: '.json'))
end
def package_registry_instance_url(registry_type)
expose_url("api/#{::API::API.version}/packages/#{registry_type}")
end
def package_registry_project_url(project_id, registry_type = :maven)
project_api_path = expose_path(api_v4_projects_path(id: project_id))
package_registry_project_path = "#{project_api_path}/packages/#{registry_type}"
expose_url(package_registry_project_path)
end
def package_from_presenter(package)
presenter = ::Packages::Detail::PackagePresenter.new(package)
presenter.detail_view.to_json
end
def pypi_registry_url(project_id)
full_url = expose_url(api_v4_projects_packages_pypi_simple_package_name_path({ id: project_id, package_name: '' }, true))
full_url.sub!('://', '://__token__:<your_personal_token>@')
end
def packages_coming_soon_enabled?(resource)
::Feature.enabled?(:packages_coming_soon, resource) && ::Gitlab.dev_env_or_com?
end
def packages_coming_soon_data(resource)
return unless packages_coming_soon_enabled?(resource)
{
project_path: ::Gitlab.com? ? 'gitlab-org/gitlab' : 'gitlab-org/gitlab-test',
suggested_contributions: help_page_path('user/packages/index', anchor: 'suggested-contributions')
}
end
def packages_list_data(type, resource)
{
resource_id: resource.id,
page_type: type,
empty_list_help_url: help_page_path('administration/packages/index'),
empty_list_illustration: image_path('illustrations/no-packages.svg'),
coming_soon_json: packages_coming_soon_data(resource).to_json
}
end
end
......@@ -429,9 +429,19 @@ module ProjectsHelper
apply_external_nav_tabs(nav_tabs, project)
nav_tabs += package_nav_tabs(project, current_user)
nav_tabs
end
def package_nav_tabs(project, current_user)
[].tap do |tabs|
if ::Gitlab.config.packages.enabled && can?(current_user, :read_package, project)
tabs << :packages
end
end
end
def apply_external_nav_tabs(nav_tabs, project)
nav_tabs << :external_issue_tracker if project.external_issue_tracker
nav_tabs << :external_wiki if project.external_wiki
......@@ -584,6 +594,7 @@ module ProjectsHelper
def project_permissions_settings(project)
feature = project.project_feature
{
packagesEnabled: !!project.packages_enabled,
visibilityLevel: project.visibility_level,
requestAccessEnabled: !!project.request_access_enabled,
issuesAccessLevel: feature.issues_access_level,
......@@ -604,6 +615,8 @@ module ProjectsHelper
def project_permissions_panel_data(project)
{
packagesAvailable: ::Gitlab.config.packages.enabled,
packagesHelpPath: help_page_path('user/packages/index'),
currentSettings: project_permissions_settings(project),
canDisableEmails: can_disable_emails?(project, current_user),
canChangeVisibilityLevel: can_change_visibility_level?(project, current_user),
......
......@@ -581,6 +581,47 @@ module SortingHelper
def sort_value_expire_date
'expired_asc'
end
def packages_sort_options_hash
{
sort_value_recently_created => sort_title_created_date,
sort_value_oldest_created => sort_title_created_date,
sort_value_name => sort_title_name,
sort_value_name_desc => sort_title_name,
sort_value_version_desc => sort_title_version,
sort_value_version_asc => sort_title_version,
sort_value_type_desc => sort_title_type,
sort_value_type_asc => sort_title_type,
sort_value_project_name_desc => sort_title_project_name,
sort_value_project_name_asc => sort_title_project_name
}
end
def packages_reverse_sort_order_hash
{
sort_value_recently_created => sort_value_oldest_created,
sort_value_oldest_created => sort_value_recently_created,
sort_value_name => sort_value_name_desc,
sort_value_name_desc => sort_value_name,
sort_value_version_desc => sort_value_version_asc,
sort_value_version_asc => sort_value_version_desc,
sort_value_type_desc => sort_value_type_asc,
sort_value_type_asc => sort_value_type_desc,
sort_value_project_name_desc => sort_value_project_name_asc,
sort_value_project_name_asc => sort_value_project_name_desc
}
end
def packages_sort_option_title(sort_value)
packages_sort_options_hash[sort_value] || sort_title_created_date
end
def packages_sort_direction_button(sort_value)
reverse_sort = packages_reverse_sort_order_hash[sort_value]
url = package_sort_path(sort: reverse_sort)
sort_direction_button(url, reverse_sort, sort_value)
end
end
SortingHelper.prepend_if_ee('::EE::SortingHelper')
......@@ -45,7 +45,7 @@ class Packages::PackageFile < ApplicationRecord
end
def download_path
Gitlab::Routing.url_helpers.download_project_package_file_path(project, self) if ::Gitlab.ee?
Gitlab::Routing.url_helpers.download_project_package_file_path(project, self)
end
def local?
......
- if group_container_registry_nav?
= nav_link(controller: 'groups/registry/repositories') do
= link_to group_container_registries_path(@group), title: _('Container Registry') do
- packages_link = group_packages_list_nav? ? group_packages_path(@group) : group_container_registries_path(@group)
- if group_packages_nav?
= nav_link(controller: ['groups/packages', 'groups/registry/repositories']) do
= link_to packages_link, title: _('Packages') do
.nav-icon-container
= sprite_icon('package')
%span.nav-item-name
= _('Packages & Registries')
%ul.sidebar-sub-level-items
= nav_link(controller: 'groups/registry/repositories', html_options: { class: "fly-out-top-item" } ) do
= link_to group_container_registries_path(@group), title: _('Container Registry') do
= nav_link(controller: [:packages, :repositories], html_options: { class: "fly-out-top-item" } ) do
= link_to packages_link, title: _('Packages & Registries') do
%strong.fly-out-top-item-name
= _('Packages & Registries')
%li.divider.fly-out-top-item
= nav_link(controller: 'groups/registry/repositories') do
= link_to group_container_registries_path(@group), title: _('Container Registry') do
%span= _('Container Registry')
- if group_packages_list_nav?
= nav_link(controller: 'groups/packages') do
= link_to group_packages_path(@group), title: _('Packages') do
%span= _('Package Registry')
- if group_container_registry_nav?
= nav_link(controller: 'groups/registry/repositories') do
= link_to group_container_registries_path(@group), title: _('Container Registry') do
%span= _('Container Registry')
- if project_nav_tab? :container_registry
= nav_link controller: :repositories do
= link_to project_container_registry_index_path(@project) do
- packages_link = project_nav_tab?(:packages) ? project_packages_path(@project) : project_container_registry_index_path(@project)
- if (project_nav_tab?(:packages) || project_nav_tab?(:container_registry))
= nav_link controller: [:packages, :repositories] do
= link_to packages_link, data: { qa_selector: 'packages_link' } do
.nav-icon-container
= sprite_icon('package')
%span.nav-item-name
= _('Packages & Registries')
%ul.sidebar-sub-level-items
= nav_link(controller: :repositories, html_options: { class: "fly-out-top-item" } ) do
= link_to project_container_registry_index_path(@project) do
= nav_link(controller: [:packages, :repositories], html_options: { class: "fly-out-top-item" } ) do
= link_to packages_link do
%strong.fly-out-top-item-name
= _('Packages & Registries')
%li.divider.fly-out-top-item
= nav_link controller: :repositories do
= link_to project_container_registry_index_path(@project), class: 'shortcuts-container-registry', title: _('Container Registry') do
%span= _('Container Registry')
- if project_nav_tab? :packages
= nav_link controller: :packages do
= link_to project_packages_path(@project), title: _('Package Registry') do
%span= _('Package Registry')
- if project_nav_tab? :container_registry
= nav_link controller: :repositories do
= link_to project_container_registry_index_path(@project), class: 'shortcuts-container-registry', title: _('Container Registry') do
%span= _('Container Registry')
---
title: Package feature moved to core
merge_request: 36667
author:
type: changed
......@@ -55,6 +55,8 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
post :toggle_subscription, on: :member
end
resources :packages, only: [:index]
resources :milestones, constraints: { id: %r{[^/]+} } do
member do
get :merge_requests
......
......@@ -30,6 +30,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :artifacts, only: [:index, :destroy]
resources :packages, only: [:index, :show, :destroy], module: :packages
resources :package_files, only: [], module: :packages do
member do
get :download
end
end
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
collection do
resources :artifacts, only: [] do
......
......@@ -39,7 +39,7 @@ module EE
adjourned_deletion_for_projects_and_groups: :deletion_adjourned_period,
required_ci_templates: :required_instance_ci_template,
disable_name_update_for_users: :updating_name_disabled_for_users,
packages: :npm_package_requests_forwarding,
package_forwarding: :npm_package_requests_forwarding,
default_branch_protection_restriction_in_groups: :group_owners_can_manage_default_branch_protection
}.each do |license_feature, attribute_name|
if License.feature_available?(license_feature)
......
......@@ -77,7 +77,6 @@ module EE
reset_approvals_on_push
ci_cd_only
use_custom_template
packages_enabled
require_password_to_approve
group_with_project_templates_id
]
......
......@@ -42,14 +42,9 @@ module EE
]
end
override :group_packages_nav?
def group_packages_nav?
group_packages_list_nav? ||
group_dependency_proxy_nav? ||
group_container_registry_nav?
end
def group_packages_list_nav?
@group.packages_feature_available?
super || group_dependency_proxy_nav?
end
def group_dependency_proxy_nav?
......
# frozen_string_literal: true
module EE
module PackagesHelper
def package_sort_path(options = {})
"#{request.path}?#{options.to_param}"
end
def nuget_package_registry_url(project_id)
expose_url(api_v4_projects_packages_nuget_index_path(id: project_id, format: '.json'))
end
def package_registry_instance_url(registry_type)
expose_url("api/#{::API::API.version}/packages/#{registry_type}")
end
def package_registry_project_url(project_id, registry_type = :maven)
project_api_path = expose_path(api_v4_projects_path(id: project_id))
package_registry_project_path = "#{project_api_path}/packages/#{registry_type}"
expose_url(package_registry_project_path)
end
def package_from_presenter(package)
presenter = ::Packages::Detail::PackagePresenter.new(package)
presenter.detail_view.to_json
end
def pypi_registry_url(project_id)
full_url = expose_url(api_v4_projects_packages_pypi_simple_package_name_path({ id: project_id, package_name: '' }, true))
full_url.sub!('://', '://__token__:<your_personal_token>@')
end
def packages_coming_soon_enabled?(resource)
::Feature.enabled?(:packages_coming_soon, resource) && ::Gitlab.dev_env_or_com?
end
def packages_coming_soon_data(resource)
return unless packages_coming_soon_enabled?(resource)
{
project_path: ::Gitlab.com? ? 'gitlab-org/gitlab' : 'gitlab-org/gitlab-test',
suggested_contributions: help_page_path('user/packages/index', anchor: 'suggested-contributions')
}
end
def packages_list_data(type, resource)
{
resource_id: resource.id,
page_type: type,
empty_list_help_url: help_page_path('administration/packages/index'),
empty_list_illustration: image_path('illustrations/no-packages.svg'),
coming_soon_json: packages_coming_soon_data(resource).to_json
}
end
end
end
......@@ -31,12 +31,6 @@ module EE
nav_tabs += get_project_security_nav_tabs(project, current_user)
if ::Gitlab.config.packages.enabled &&
project.feature_available?(:packages) &&
can?(current_user, :read_package, project)
nav_tabs << :packages
end
if can?(current_user, :read_code_review_analytics, project)
nav_tabs << :code_review
end
......@@ -63,21 +57,6 @@ module EE
tab_ability_map
end
override :project_permissions_settings
def project_permissions_settings(project)
super.merge(
packagesEnabled: !!project.packages_enabled
)
end
override :project_permissions_panel_data
def project_permissions_panel_data(project)
super.merge(
packagesAvailable: ::Gitlab.config.packages.enabled && project.feature_available?(:packages),
packagesHelpPath: help_page_path('user/packages/index')
)
end
override :default_url_to_repo
def default_url_to_repo(project = @project)
case default_clone_protocol
......
......@@ -64,47 +64,6 @@ module EE
end
end
def packages_sort_options_hash
{
sort_value_recently_created => sort_title_created_date,
sort_value_oldest_created => sort_title_created_date,
sort_value_name => sort_title_name,
sort_value_name_desc => sort_title_name,
sort_value_version_desc => sort_title_version,
sort_value_version_asc => sort_title_version,
sort_value_type_desc => sort_title_type,
sort_value_type_asc => sort_title_type,
sort_value_project_name_desc => sort_title_project_name,
sort_value_project_name_asc => sort_title_project_name
}
end
def packages_reverse_sort_order_hash
{
sort_value_recently_created => sort_value_oldest_created,
sort_value_oldest_created => sort_value_recently_created,
sort_value_name => sort_value_name_desc,
sort_value_name_desc => sort_value_name,
sort_value_version_desc => sort_value_version_asc,
sort_value_version_asc => sort_value_version_desc,
sort_value_type_desc => sort_value_type_asc,
sort_value_type_asc => sort_value_type_desc,
sort_value_project_name_desc => sort_value_project_name_asc,
sort_value_project_name_asc => sort_value_project_name_desc
}
end
def packages_sort_option_title(sort_value)
packages_sort_options_hash[sort_value] || sort_title_created_date
end
def packages_sort_direction_button(sort_value)
reverse_sort = packages_reverse_sort_order_hash[sort_value]
url = package_sort_path(sort: reverse_sort)
sort_direction_button(url, reverse_sort, sort_value)
end
# Creates a button with the opposite ordering for the current field in UI.
def sort_order_button(sort)
opposite_sorting_param = epics_ordering_options_hash[sort] || epics_ordering_options_hash.key(sort)
......
......@@ -303,10 +303,6 @@ module EE
end
end
def packages_feature_available?
packages_feature_enabled? && feature_available?(:packages)
end
def dependency_proxy_feature_available?
::Gitlab.config.dependency_proxy.enabled && feature_available?(:dependency_proxy)
end
......
......@@ -94,7 +94,7 @@ class License < ApplicationRecord
object_storage
operations_dashboard
opsgenie_integration
packages
package_forwarding
pages_size_limit
productivity_analytics
project_aliases
......
- packages_link = project_nav_tab?(:packages) ? project_packages_path(@project) : project_container_registry_index_path(@project)
- if (project_nav_tab?(:packages) || project_nav_tab?(:container_registry))
= nav_link controller: [:packages, :repositories] do
= link_to packages_link, data: { qa_selector: 'packages_link' } do
.nav-icon-container
= sprite_icon('package')
%span.nav-item-name
= _('Packages & Registries')
%ul.sidebar-sub-level-items
= nav_link(controller: [:packages, :repositories], html_options: { class: "fly-out-top-item" } ) do
= link_to packages_link do
%strong.fly-out-top-item-name
= _('Packages & Registries')
%li.divider.fly-out-top-item
- if project_nav_tab? :packages
= nav_link controller: :packages do
= link_to project_packages_path(@project), title: _('Package Registry') do
%span= _('Package Registry')
- if project_nav_tab? :container_registry
= nav_link controller: :repositories do
= link_to project_container_registry_index_path(@project), class: 'shortcuts-container-registry', title: _('Container Registry') do
%span= _('Container Registry')
......@@ -176,7 +176,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resource :roadmap, only: [:show], controller: 'roadmap'
resource :dependency_proxy, only: [:show, :update]
resources :packages, only: [:index]
post '/restore' => '/groups#restore', as: :restore
end
......
......@@ -15,13 +15,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :requirements, only: [:index]
end
resources :packages, only: [:index, :show, :destroy], module: :packages
resources :package_files, only: [], module: :packages do
member do
get :download
end
end
resources :feature_flags, param: :iid do
resources :feature_flag_issues, only: [:index, :create, :destroy], as: 'issues', path: 'issues'
end
......
......@@ -18,7 +18,7 @@ module EE
expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) }
expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) }
expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:packages) }
expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:package_forwarding) }
expose :group_owners_can_manage_default_branch_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_branch_protection_restriction_in_groups) }
expose :maintenance_mode, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) }
expose :maintenance_mode_message, if: ->(_instance, _opts) { ::Gitlab::Geo.license_allows? && ::Feature.enabled?(:maintenance_mode) }
......
......@@ -24,7 +24,6 @@ module EE
expose :mirror_overwrites_diverged_branches, if: ->(project, _) { project.mirror? }
expose :external_authorization_classification_label,
if: ->(_, _) { License.feature_available?(:external_authorization_service_api_management) }
expose :packages_enabled, if: ->(project, _) { project.feature_available?(:packages) }
expose :marked_for_deletion_at, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :marked_for_deletion_on, if: ->(project, _) { project.feature_available?(:adjourned_deletion_for_projects_and_groups) } do |project, _|
project.marked_for_deletion_at
......
......@@ -32,7 +32,6 @@ module EE
optional :only_mirror_protected_branches, type: Grape::API::Boolean, desc: 'Only mirror protected branches'
optional :mirror_overwrites_diverged_branches, type: Grape::API::Boolean, desc: 'Pull mirror overwrites diverged branches'
optional :import_url, type: String, desc: 'URL from which the project is imported'
optional :packages_enabled, type: Grape::API::Boolean, desc: 'Enable project packages feature'
optional :fallback_approvals_required, type: Integer, desc: 'Overall approvals required when no rule is present'
end
end
......@@ -50,7 +49,6 @@ module EE
:approvals_before_merge,
:external_authorization_classification_label,
:import_url,
:packages_enabled,
:fallback_approvals_required
]
end
......
......@@ -39,7 +39,7 @@ module EE
attrs = attrs.except(*EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes)
end
unless License.feature_available?(:packages)
unless License.feature_available?(:package_forwarding)
attrs = attrs.except(:npm_package_requests_forwarding)
end
......
......@@ -120,7 +120,7 @@ RSpec.describe Admin::ApplicationSettingsController do
context 'updating npm packages request forwarding setting' do
let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages }
let(:feature) { :package_forwarding }
it_behaves_like 'settings for licensed features'
end
......
......@@ -17,6 +17,8 @@ RSpec.describe 'Group navbar' do
stub_feature_flags(group_iterations: false)
stub_feature_flags(group_wiki: false)
sign_in(user)
insert_package_nav(_('Kubernetes'))
end
context 'when productivity analytics is available' do
......@@ -148,20 +150,10 @@ RSpec.describe 'Group navbar' do
context 'when packages are available' do
before do
stub_config(packages: { enabled: true }, registry: { enabled: false })
stub_licensed_features(packages: true)
insert_after_nav_item(
_('Kubernetes'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
visit group_path(group)
end
it_behaves_like 'verified navigation bar'
context 'when container registry is available' do
before do
stub_config(registry: { enabled: true })
......
......@@ -11,6 +11,8 @@ RSpec.describe 'Project navbar' do
let_it_be(:project) { create(:project, :repository) }
before do
insert_package_nav(_('Operations'))
project.add_maintainer(user)
sign_in(user)
end
......@@ -56,21 +58,10 @@ RSpec.describe 'Project navbar' do
context 'when packages are available' do
before do
stub_config(packages: { enabled: true }, registry: { enabled: false })
stub_licensed_features(packages: true)
insert_after_nav_item(
_('Operations'),
new_nav_item: {
nav_item: _('Packages & Registries'),
nav_sub_items: [_('Package Registry')]
}
)
visit project_path(project)
end
it_behaves_like 'verified navigation bar'
context 'when container registry is available' do
before do
stub_config(registry: { enabled: true })
......
......@@ -142,24 +142,6 @@ RSpec.describe API::Projects do
end
end
describe 'packages_enabled attribute' do
it 'is exposed when the feature is available' do
stub_licensed_features(packages: true)
get api("/projects/#{project.id}", user)
expect(json_response).to have_key 'packages_enabled'
end
it 'is not exposed when the feature is not available' do
stub_licensed_features(packages: false)
get api("/projects/#{project.id}", user)
expect(json_response).not_to have_key 'packages_enabled'
end
end
describe 'compliance_frameworks attribute' do
context 'when compliance_framework feature is available' do
context 'when project has a compliance framework' do
......@@ -810,40 +792,6 @@ RSpec.describe API::Projects do
end
end
describe 'updating packages_enabled attribute' do
it 'is enabled by default' do
expect(project.packages_enabled).to be true
end
context 'packages feature is allowed by license' do
before do
stub_licensed_features(packages: true)
end
it 'disables project packages feature' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages_enabled).to be false
expect(json_response['packages_enabled']).to eq(false)
end
end
context 'packages feature is not allowed by license' do
before do
stub_licensed_features(packages: false)
end
it 'disables project packages feature but does not return packages_enabled attribute' do
put(api("/projects/#{project.id}", user), params: { packages_enabled: false })
expect(response).to have_gitlab_http_status(:ok)
expect(project.reload.packages_enabled).to be false
expect(json_response['packages_enabled']).to be_nil
end
end
end
describe 'updating approvals_before_merge attribute' do
context 'when authenticated as project owner' do
it 'updates approvals_before_merge' do
......
......@@ -186,7 +186,7 @@ RSpec.describe API::Settings, 'EE Settings' do
context 'updating npm packages request forwarding' do
let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages }
let(:feature) { :package_forwarding }
it_behaves_like 'settings for licensed features'
end
......
......@@ -10,7 +10,6 @@ RSpec.describe Groups::TransferService, '#execute' do
let(:transfer_service) { described_class.new(group, user) }
before do
stub_licensed_features(packages: true)
group.add_owner(user)
new_group&.add_owner(user)
end
......
......@@ -10,7 +10,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
assign(:repository, project.repository)
allow(view).to receive(:current_ref).and_return('master')
stub_licensed_features(tracing: true, packages: true)
stub_licensed_features(tracing: true)
end
describe 'issue boards' do
......@@ -221,96 +221,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe 'Packages' do
let(:user) { create(:user) }
let_it_be(:package_menu_name) { 'Packages & Registries' }
let_it_be(:package_entry_name) { 'Package Registry' }
before do
project.team.add_developer(user)
sign_in(user)
stub_container_registry_config(enabled: true)
end
context 'when packages is enabled' do
it 'packages link is visible' do
render
expect(rendered).to have_link(package_menu_name, href: project_packages_path(project))
end
it 'packages list link is visible' do
render
expect(rendered).to have_link(package_entry_name, href: project_packages_path(project))
end
it 'container registry link is visible' do
render
expect(rendered).to have_link('Container Registry', href: project_container_registry_index_path(project))
end
end
context 'when packages are disabled' do
before do
stub_licensed_features(packages: false)
end
it 'packages list link is not visible' do
render
expect(rendered).not_to have_link(package_entry_name, href: project_packages_path(project))
end
it 'top level packages link links to container registry' do
render
expect(rendered).to have_link(package_menu_name, href: project_container_registry_index_path(project))
end
it 'packages top level and container registry links are visible' do
render
expect(rendered).to have_link(package_menu_name, href: project_container_registry_index_path(project))
expect(rendered).to have_link('Container Registry', href: project_container_registry_index_path(project))
end
end
context 'when container registry is disabled' do
before do
stub_container_registry_config(enabled: false)
end
it 'packages top level and list link are visible' do
render
expect(rendered).to have_link(package_menu_name, href: project_packages_path(project))
expect(rendered).to have_link(package_entry_name, href: project_packages_path(project))
end
it 'container registry link is not visible' do
render
expect(rendered).not_to have_link('Container Registry', href: project_container_registry_index_path(project))
end
end
context 'when both packages and container registry are disabled' do
before do
stub_licensed_features(packages: false)
stub_container_registry_config(enabled: false)
end
it 'packages top level item is not visible' do
render
expect(rendered).not_to have_link(package_menu_name, href: project_packages_path(project))
end
end
end
describe 'Settings > Operations' do
it 'is not visible when no valid license' do
allow(view).to receive(:can?).and_return(true)
......
......@@ -13,9 +13,7 @@ module API
expose :_links do
expose :web_path do |package|
if ::Gitlab.ee?
::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end
::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end
expose :delete_api_path, if: can_destroy(:package, &:project) do |package|
......
......@@ -35,6 +35,7 @@ module API
end
end
expose :packages_enabled
expose :empty_repo?, as: :empty_repo
expose :archived?, as: :archived
expose :visibility
......
......@@ -61,6 +61,7 @@ module API
optional :auto_devops_deploy_strategy, type: String, values: %w(continuous manual timed_incremental), desc: 'Auto Deploy strategy'
optional :autoclose_referenced_issues, type: Boolean, desc: 'Flag indication if referenced issues auto-closing is enabled'
optional :repository_storage, type: String, desc: 'Which storage shard the repository is on. Available only to admins'
optional :packages_enabled, type: Boolean, desc: 'Enable project packages feature'
end
params :optional_project_params_ee do
......@@ -137,6 +138,7 @@ module API
:suggestion_commit_message,
:repository_storage,
:compliance_framework_setting,
:packages_enabled,
:service_desk_enabled,
# TODO: remove in API v5, replaced by *_access_level
......
......@@ -277,6 +277,11 @@ module QA
autoload :Show, 'qa/page/project/job/show'
end
module Packages
autoload :Index, 'qa/page/project/packages/index'
autoload :Show, 'qa/page/project/packages/show'
end
module Settings
autoload :Advanced, 'qa/page/project/settings/advanced'
autoload :Main, 'qa/page/project/settings/main'
......@@ -315,6 +320,7 @@ module QA
autoload :Repository, 'qa/page/project/sub_menus/repository'
autoload :Settings, 'qa/page/project/sub_menus/settings'
autoload :Project, 'qa/page/project/sub_menus/project'
autoload :Packages, 'qa/page/project/sub_menus/packages'
end
module Issue
......
......@@ -101,7 +101,6 @@ module QA
autoload :Menu, 'qa/ee/page/project/menu'
module SubMenus
autoload :Packages, 'qa/ee/page/project/sub_menus/packages'
autoload :SecurityCompliance, 'qa/ee/page/project/sub_menus/security_compliance'
autoload :Repository, 'qa/ee/page/project/sub_menus/repository'
autoload :Settings, 'qa/ee/page/project/sub_menus/settings'
......@@ -140,11 +139,6 @@ module QA
end
end
module Packages
autoload :Index, 'qa/ee/page/project/packages/index'
autoload :Show, 'qa/ee/page/project/packages/show'
end
module Pipeline
autoload :Show, 'qa/ee/page/project/pipeline/show'
end
......
......@@ -13,7 +13,6 @@ module QA
base.class_eval do
prepend QA::Page::Project::SubMenus::Common
prepend SubMenus::SecurityCompliance
prepend SubMenus::Packages
prepend SubMenus::Project
prepend SubMenus::Repository
prepend SubMenus::Settings
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Packages
class Index < QA::Page::Base
view 'ee/app/views/projects/packages/packages/_legacy_package_list.html.haml' do
element :package_row
element :package_link
end
def click_package(name)
click_element(:package_link, text: name)
end
def has_package?(name)
has_element?(:package_link, text: name)
end
def has_no_package?(name)
has_no_element?(:package_link, text: name)
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Packages
class Show < QA::Page::Base
view 'ee/app/assets/javascripts/packages/details/components/app.vue' do
element :delete_button
element :delete_modal_button
element :package_information_content
end
def has_package_info?(name, version)
has_element?(:package_information_content, text: /#{name}.*#{version}/)
end
def click_delete
click_element(:delete_button)
wait_for_animated_element(:delete_modal_button)
click_element(:delete_modal_button)
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module SubMenus
module Packages
extend QA::Page::PageConcern
def self.prepended(base)
base.class_eval do
view 'ee/app/views/layouts/nav/sidebar/_project_packages_link.html.haml' do
element :packages_link
end
end
end
def click_packages_link
within_sidebar do
click_element :packages_link
end
end
end
end
end
end
end
end
......@@ -11,6 +11,7 @@ module QA
include SubMenus::Operations
include SubMenus::Repository
include SubMenus::Settings
include SubMenus::Packages
view 'app/views/layouts/nav/sidebar/_project.html.haml' do
element :activity_link
......
# frozen_string_literal: true
module QA
module Page
module Project
module Packages
class Index < QA::Page::Base
view 'app/views/projects/packages/packages/_legacy_package_list.html.haml' do
element :package_row
element :package_link
end
def click_package(name)
click_element(:package_link, text: name)
end
def has_package?(name)
has_element?(:package_link, text: name)
end
def has_no_package?(name)
has_no_element?(:package_link, text: name)
end
end
end
end
end
end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment