Commit 1c5192ed authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dz-add-ui-to-packages' into 'master'

Add UI for maven packages feature

See merge request gitlab-org/gitlab-ee!6781
parents f5e65d42 e3c31a14
...@@ -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/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/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
......
...@@ -310,6 +310,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -310,6 +310,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
scope '-' do scope '-' do
get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive' get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
## EE-specific
resources :packages, only: [:index, :show, :destroy], module: :packages
## EE-specific
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
collection do collection do
post :cancel_all post :cancel_all
......
...@@ -124,6 +124,7 @@ created in snippets, wikis, and repos. ...@@ -124,6 +124,7 @@ created in snippets, wikis, and repos.
- [Default labels](../user/admin_area/labels.html): Create labels that will be automatically added to every new project. - [Default labels](../user/admin_area/labels.html): Create labels that will be automatically added to every new project.
- [Restrict the use of public or internal projects](../public_access/public_access.md#restricting-the-use-of-public-or-internal-projects): Restrict the use of visibility levels for users when they create a project or a snippet. - [Restrict the use of public or internal projects](../public_access/public_access.md#restricting-the-use-of-public-or-internal-projects): Restrict the use of visibility levels for users when they create a project or a snippet.
- [Custom project templates](../user/admin_area/custom_project_templates.md): Configure a set of projects to be used as custom templates when creating a new project. **[PREMIUM ONLY]** - [Custom project templates](../user/admin_area/custom_project_templates.md): Configure a set of projects to be used as custom templates when creating a new project. **[PREMIUM ONLY]**
- [Maven packages repository](maven_packages.md): Enable Maven packages repository within GitLab.
### Repository settings ### Repository settings
......
# GitLab private Maven repository administration
> **Notes:**
- [Introduced][ee-5811] in GitLab 11.3.
- This document is about the admin guide. Learn how to use GitLab Maven
repository from [user documentation](../user/project/maven_packages.md).
When enabled, every project in GitLab will have its own space to store Maven packages.
## Enable the Maven repository
**Omnibus GitLab installations**
# TODO: Update this section once https://gitlab.com/gitlab-org/gitlab-ee/issues/7253 is resolved
**Installations from source**
If you have installed GitLab from source:
1. After the installation is complete, you will have to configure the `packages`
section in `gitlab.yml` in order to enable it.
The contents of `gitlab.yml` are:
```
packages:
enabled: true
```
where:
| Parameter | Description |
| --------- | ----------- |
| `enabled` | `true` or `false`. Enables the packages repository in GitLab. By default this is `false`. |
[ee-5811]: https://gitlab.com/gitlab-org/gitlab-ee/issues/5811
...@@ -86,6 +86,7 @@ website with GitLab Pages ...@@ -86,6 +86,7 @@ website with GitLab Pages
- [Syntax highlighting](highlighting.md): An alternative to customize - [Syntax highlighting](highlighting.md): An alternative to customize
your code blocks, overriding GitLab's default choice of language your code blocks, overriding GitLab's default choice of language
- [Badges](badges.md): Badges for the project overview - [Badges](badges.md): Badges for the project overview
- [Maven packages](maven_packages.md): Your private Maven repository in GitLab
### Project's integrations ### Project's integrations
......
module Projects
module Packages
class PackagesController < ApplicationController
before_action :verify_packages_enabled!
before_action :authorize_read_package!
before_action :authorize_destroy_package!, only: [:destroy]
def index
@packages = project.packages.all.page(params[:page])
end
def show
@package = project.packages.find(params[:id])
@package_files = @package.package_files.recent
@maven_metadatum = @package.maven_metadatum
end
def destroy
@package = project.packages.find(params[:id])
@package.destroy
redirect_to project_packages_path(@project), status: 302, notice: _('Package was removed')
end
private
def verify_packages_enabled!
render_404 unless Gitlab.config.packages.enabled
end
end
end
end
...@@ -17,6 +17,17 @@ module EE ...@@ -17,6 +17,17 @@ module EE
super + %w(path_locks) super + %w(path_locks)
end end
override :get_project_nav_tabs
def get_project_nav_tabs(project, current_user)
nav_tabs = super
if ::Gitlab.config.packages.enabled && can?(current_user, :read_package, project)
nav_tabs << :packages
end
nav_tabs
end
override :default_url_to_repo override :default_url_to_repo
def default_url_to_repo(project = @project) def default_url_to_repo(project = @project)
case default_clone_protocol case default_clone_protocol
......
...@@ -6,6 +6,8 @@ class Packages::PackageFile < ActiveRecord::Base ...@@ -6,6 +6,8 @@ class Packages::PackageFile < ActiveRecord::Base
validates :file, presence: true validates :file, presence: true
validates :file_name, presence: true validates :file_name, presence: true
scope :recent, -> { order(id: :desc) }
mount_uploader :file, Packages::PackageFileUploader mount_uploader :file, Packages::PackageFileUploader
after_save :update_file_store, if: :file_changed? after_save :update_file_store, if: :file_changed?
......
...@@ -114,6 +114,7 @@ module EE ...@@ -114,6 +114,7 @@ module EE
enable :push_code_to_protected_branches enable :push_code_to_protected_branches
enable :admin_path_locks enable :admin_path_locks
enable :update_approvers enable :update_approvers
enable :destroy_package
end end
rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy
......
- page_title _("Packages")
- can_destroy_package = can?(current_user, :destroy_package, @project)
- if @packages.any?
.table-holder
.gl-responsive-table-row.table-row-header{ role: 'row' }
.table-section.section-30{ role: 'rowheader' }
= _('Name')
.table-section.section-20{ role: 'rowheader' }
= _('Version')
.table-section.section-20{ role: 'rowheader' }
= _('Type')
.table-section.section-20{ role: 'rowheader' }
= _('Created')
.table-section.section-10{ role: 'rowheader' }
- @packages.each do |package|
.gl-responsive-table-row
.table-section.section-30
.table-mobile-header{ role: "rowheader" }= _("Name")
.table-mobile-content.flex-truncate-parent
= link_to package.name, project_package_path(@project, package), class: 'flex-truncate-child'
.table-section.section-20
.table-mobile-header{ role: "rowheader" }= _("Version")
.table-mobile-content
= package.version
.table-section.section-20
.table-mobile-header{ role: "rowheader" }= _("Type")
.table-mobile-content
= _('Maven package')
.table-section.section-20
.table-mobile-header{ role: "rowheader" }= _("Created")
.table-mobile-content
= time_ago_with_tooltip(package.created_at)
.table-section.section-10
.table-mobile-header{ role: "rowheader" }
.table-mobile-content
- if can_destroy_package
.pull-right
= link_to project_package_path(@project, package), method: :delete, data: { confirm: _("Are you sure?") }, class: "btn btn-grouped btn-inverted btn-remove", title: _('Delete Package') do
= icon('trash')
= paginate @packages, theme: "gitlab"
- else
.nothing-here-block
= _('No packages stored for this project.')
- add_to_breadcrumbs _("Packages"), project_packages_path(@project)
- add_to_breadcrumbs @package.name, project_packages_path(@project)
- breadcrumb_title @package.version
- page_title _("Packages")
.detail-page-header.d-flex.justify-content-between
%strong
= @package.version
- if can?(current_user, :destroy_package, @project)
= link_to project_package_path(@project, @package), method: :delete, data: { confirm: _("Are you sure?") }, class: "btn btn-grouped btn-inverted btn-remove", title: _('Delete Package') do
= _('Delete')
.row.prepend-top-default
.col-sm-6
.card
.card-header
%strong= _('Package information')
%ul.content-list
%li
%span.text-secondary
= _('Name')
%span.pull-right
= @package.name
%li
%span.text-secondary
= _('Version')
%span.pull-right
= @package.version
%li
%span.text-secondary
= _('Created on')
%span.pull-right
= @package.created_at.to_s(:medium)
.col-sm-6
- if @maven_metadatum
.card
.card-header
%strong= _('Maven Metadata')
%ul.content-list
%li
%span.text-secondary
= _('Group ID')
%span.pull-right
= @maven_metadatum.app_group
%li
%span.text-secondary
= _('Artifact ID')
%span.pull-right
= @maven_metadatum.app_name
%li
%span.text-secondary
= _('Version')
%span.pull-right
= @maven_metadatum.app_version
%table.table
%thead
%tr
%th
= _('Name')
%th
= _('Size')
%th
.pull-right
= _('Created')
%tbody
- @package_files.each do |package_file|
%tr
%td
= icon('file-o fw')
= package_file.file.identifier
%td
= number_to_human_size(package_file.size, precision: 2)
%td
.pull-right
= time_ago_with_tooltip(package_file.created_at)
---
title: Add UI for GitLab private Maven repository feature
merge_request: 6781
author:
type: added
require 'spec_helper'
describe 'Packages' do
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
sign_in(user)
project.add_master(user)
end
context 'when there are no packages' do
it 'shows no packages message' do
visit_project_packages
expect(page).to have_content 'No packages stored for this project.'
end
end
context 'when there are packages' do
let!(:package) { create(:maven_package, project: project) }
before do
package
visit_project_packages
end
it 'shows list of packages' do
expect(page).to have_content(package.name)
expect(page).to have_content(package.version)
end
it 'shows a single package' do
click_on package.name
expect(page).to have_content(package.name)
expect(page).to have_content(package.version)
package.package_files.each do |package_file|
expect(page).to have_content(package_file.file_name)
end
end
it 'removes package' do
click_link 'Delete Package'
expect(page).to have_content 'Package was removed'
expect(page).not_to have_content(package.name)
end
end
def visit_project_packages
visit project_packages_path(project)
end
end
...@@ -735,6 +735,9 @@ msgstr "" ...@@ -735,6 +735,9 @@ msgstr ""
msgid "Are you sure?" msgid "Are you sure?"
msgstr "" msgstr ""
msgid "Artifact ID"
msgstr ""
msgid "Artifacts" msgid "Artifacts"
msgstr "" msgstr ""
...@@ -2319,6 +2322,9 @@ msgstr "" ...@@ -2319,6 +2322,9 @@ msgstr ""
msgid "Created by me" msgid "Created by me"
msgstr "" msgstr ""
msgid "Created on"
msgstr ""
msgid "Created on:" msgid "Created on:"
msgstr "" msgstr ""
...@@ -2433,6 +2439,9 @@ msgstr "" ...@@ -2433,6 +2439,9 @@ msgstr ""
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
msgid "Delete Package"
msgstr ""
msgid "Delete Snippet" msgid "Delete Snippet"
msgstr "" msgstr ""
...@@ -4452,6 +4461,12 @@ msgstr "" ...@@ -4452,6 +4461,12 @@ msgstr ""
msgid "Markdown enabled" msgid "Markdown enabled"
msgstr "" msgstr ""
msgid "Maven Metadata"
msgstr ""
msgid "Maven package"
msgstr ""
msgid "Maximum git storage failures" msgid "Maximum git storage failures"
msgstr "" msgstr ""
...@@ -4901,6 +4916,9 @@ msgstr "" ...@@ -4901,6 +4916,9 @@ msgstr ""
msgid "No other labels with such name or description" msgid "No other labels with such name or description"
msgstr "" msgstr ""
msgid "No packages stored for this project."
msgstr ""
msgid "No prioritised labels with such name or description" msgid "No prioritised labels with such name or description"
msgstr "" msgstr ""
...@@ -5149,6 +5167,15 @@ msgstr "" ...@@ -5149,6 +5167,15 @@ msgstr ""
msgid "Owner" msgid "Owner"
msgstr "" msgstr ""
msgid "Package information"
msgstr ""
msgid "Package was removed"
msgstr ""
msgid "Packages"
msgstr ""
msgid "Pages" msgid "Pages"
msgstr "" msgstr ""
...@@ -6501,6 +6528,9 @@ msgstr "" ...@@ -6501,6 +6528,9 @@ msgstr ""
msgid "Sign-up restrictions" msgid "Sign-up restrictions"
msgstr "" msgstr ""
msgid "Size"
msgstr ""
msgid "Size and domain settings for static websites" msgid "Size and domain settings for static websites"
msgstr "" msgstr ""
...@@ -7512,6 +7542,9 @@ msgstr "" ...@@ -7512,6 +7542,9 @@ msgstr ""
msgid "Twitter" msgid "Twitter"
msgstr "" msgstr ""
msgid "Type"
msgstr ""
msgid "Unable to load the diff. %{button_try_again}" msgid "Unable to load the diff. %{button_try_again}"
msgstr "" msgstr ""
...@@ -7674,6 +7707,9 @@ msgstr "" ...@@ -7674,6 +7707,9 @@ msgstr ""
msgid "Verified" msgid "Verified"
msgstr "" msgstr ""
msgid "Version"
msgstr ""
msgid "View epics list" msgid "View epics list"
msgstr "" msgstr ""
......
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