Commit adf209e6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add UI for maven packages feature

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 087673ac
......@@ -262,6 +262,19 @@
%strong.fly-out-top-item-name
= _('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
= nav_link(controller: :wikis) do
= link_to get_project_wiki_path(@project), class: 'shortcuts-wiki' do
......
......@@ -310,6 +310,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
scope '-' do
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
collection do
post :cancel_all
......
......@@ -125,6 +125,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.
- [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]**
- [Maven packages repository](maven_packages.md): Enable Maven packages repository within GitLab.
### Repository settings
......
# GitLab private Maven repository administration
> **Notes:**
- [Introduced][ee-5811] in GitLab 11.3.
- This document is about the admin guide. To 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
**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
- [Syntax highlighting](highlighting.md): An alternative to customize
your code blocks, overriding GitLab's default choice of language
- [Badges](badges.md): Badges for the project overview
- [Maven packages](maven_packages.md): Your private Maven repository in GitLab
### Project's integrations
......
module Projects
module Packages
class PackagesController < ApplicationController
before_action :verify_packages_enabled!
before_action :authorize_read_package!
before_action :authorize_admin_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
super + %w(path_locks)
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
def default_url_to_repo(project = @project)
case default_clone_protocol
......
- page_title "Packages"
- can_admin_package = can?(current_user, :admin_package, @project)
- if @packages.any?
%table.table
%thead
%tr
%th= _('Name')
%th= _('Version')
%th= _('Type')
%th= _('Created')
%th
%tbody
- @packages.each do |package|
%tr
%td
= link_to package.name, project_package_path(@project, package)
%td
= package.version
%td
= _('Maven package')
%td
= time_ago_with_tooltip(package.created_at)
%td
- if can_admin_package
= 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
.detail-page-header-body
%strong
= @package.version
.detail-page-header-actions
- if can?(current_user, :admin_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-md-6
.card
.card-header
= _('Package info:')
%ul.content-list
%li
%span.light
= _('Name:')
%strong
= @package.name
%li
%span.light
= _('Version:')
%strong
= @package.version
%li
%span.light
= _('Created on:')
%strong
= @package.created_at.to_s(:medium)
- if @maven_metadatum
.card
.card-header
= _('Maven Package info:')
%ul.content-list
%li
%span.light
= _('Group ID:')
%strong
= @maven_metadatum.app_group
%li
%span.light
= _('Artifact ID:')
%strong
= @maven_metadatum.app_name
.col-md-6
.card
.card-header
= _('Package files:')
%ul.content-list
- @package_files.each do |package_file|
%li
= package_file.file.identifier
.text-muted
= _('Added')
= time_ago_with_tooltip(package_file.created_at)
require 'spec_helper'
describe 'Packages' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:package) { create(:maven_package, project: project) }
before do
sign_in(user)
project.add_developer(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
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
......@@ -423,6 +423,9 @@ msgstr ""
msgid "Add users to group"
msgstr ""
msgid "Added"
msgstr ""
msgid "Additional text"
msgstr ""
......@@ -735,6 +738,9 @@ msgstr ""
msgid "Are you sure?"
msgstr ""
msgid "Artifact ID:"
msgstr ""
msgid "Artifacts"
msgstr ""
......@@ -2433,6 +2439,9 @@ msgstr ""
msgid "Delete"
msgstr ""
msgid "Delete Package"
msgstr ""
msgid "Delete Snippet"
msgstr ""
......@@ -3622,6 +3631,9 @@ msgstr ""
msgid "Group ID"
msgstr ""
msgid "Group ID:"
msgstr ""
msgid "Group Runners"
msgstr ""
......@@ -4410,6 +4422,12 @@ msgstr ""
msgid "Markdown enabled"
msgstr ""
msgid "Maven Package info:"
msgstr ""
msgid "Maven package"
msgstr ""
msgid "Maximum git storage failures"
msgstr ""
......@@ -4856,6 +4874,9 @@ msgstr ""
msgid "No other labels with such name or description"
msgstr ""
msgid "No packages stored for this project."
msgstr ""
msgid "No prioritised labels with such name or description"
msgstr ""
......@@ -5104,6 +5125,18 @@ msgstr ""
msgid "Owner"
msgstr ""
msgid "Package files:"
msgstr ""
msgid "Package info:"
msgstr ""
msgid "Package was removed"
msgstr ""
msgid "Packages"
msgstr ""
msgid "Pages"
msgstr ""
......@@ -7434,6 +7467,9 @@ msgstr ""
msgid "Twitter"
msgstr ""
msgid "Type"
msgstr ""
msgid "Unable to load the diff. %{button_try_again}"
msgstr ""
......@@ -7596,6 +7632,12 @@ msgstr ""
msgid "Verified"
msgstr ""
msgid "Version"
msgstr ""
msgid "Version:"
msgstr ""
msgid "View epics list"
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