Commit 10d65e1b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add packages to navigation and policies [ci skip]

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 07c401cb
module Projects module Projects
module Packages module Packages
class PackagesController < ApplicationController class PackagesController < ApplicationController
before_action :authorize_admin_project! before_action :verify_packages_enabled!
before_action :authorize_read_packages!
before_action :authorize_admin_project!, only: [:destroy]
def index def index
@packages = project.packages.all.page(params[:page]) @packages = project.packages.all.page(params[:page])
...@@ -19,6 +21,12 @@ module Projects ...@@ -19,6 +21,12 @@ module Projects
redirect_to project_packages_path(@project), notice: _('Package was removed') redirect_to project_packages_path(@project), notice: _('Package was removed')
end end
private
def verify_packages_enabled!
render_404 unless Gitlab.config.packages.enabled
end
end end
end end
end end
...@@ -268,6 +268,10 @@ module ProjectsHelper ...@@ -268,6 +268,10 @@ module ProjectsHelper
nav_tabs << :container_registry nav_tabs << :container_registry
end end
if Gitlab.config.packages.enabled && can?(current_user, :read_packages, project)
nav_tabs << :packages
end
if project.builds_enabled? && can?(current_user, :read_pipeline, project) if project.builds_enabled? && can?(current_user, :read_pipeline, project)
nav_tabs << :pipelines nav_tabs << :pipelines
end end
......
...@@ -183,6 +183,7 @@ class ProjectPolicy < BasePolicy ...@@ -183,6 +183,7 @@ class ProjectPolicy < BasePolicy
enable :read_commit_status enable :read_commit_status
enable :read_build enable :read_build
enable :read_container_image enable :read_container_image
enable :read_packages
enable :read_pipeline enable :read_pipeline
enable :read_pipeline_schedule enable :read_pipeline_schedule
enable :read_environment enable :read_environment
......
...@@ -262,6 +262,19 @@ ...@@ -262,6 +262,19 @@
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Registry') = _('Registry')
- if project_nav_tab? :packages
= nav_link(controller: %w[projects/packages]) do
= link_to project_packages_path(@project) do
.nav-icon-container
= sprite_icon('disk')
%span.nav-item-name
= _('Packages')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: %w[projects/packages], html_options: { class: "fly-out-top-item" } ) do
= link_to project_packages_path(@project) do
%strong.fly-out-top-item-name
= _('Packages')
- if project_nav_tab? :wiki - if project_nav_tab? :wiki
= nav_link(controller: :wikis) do = nav_link(controller: :wikis) do
= link_to get_project_wiki_path(@project), class: 'shortcuts-wiki' do = link_to get_project_wiki_path(@project), class: 'shortcuts-wiki' do
......
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