Commit 537da4b3 authored by Nick Kipling's avatar Nick Kipling Committed by Rémy Coutable

Adds PyPi to package list tabs

Updates the frontend to show the PyPi tab
Updated the projects API to accept new param
Updated tests
parent 7c61599f
......@@ -89,4 +89,8 @@ export const PACKAGE_REGISTRY_TABS = [
title: s__('PackageRegistry|NuGet'),
type: PackageType.NUGET,
},
{
title: s__('PackageRegistry|PyPi'),
type: PackageType.PYPI,
},
];
......@@ -3,6 +3,7 @@ export const PackageType = {
MAVEN: 'maven',
NPM: 'npm',
NUGET: 'nuget',
PYPI: 'pypi',
};
export const TrackingActions = {
......
---
title: Adds PyPi tab to the packages list page
merge_request: 30078
author:
type: added
......@@ -24,7 +24,7 @@ module API
desc: 'Return packages ordered by `created_at`, `name`, `version` or `type` fields.'
optional :sort, type: String, values: %w[asc desc], default: 'asc',
desc: 'Return packages sorted in `asc` or `desc` order.'
optional :package_type, type: String, values: %w[conan maven npm nuget],
optional :package_type, type: String, values: Packages::Package.package_types.keys,
desc: 'Return packages of a certain type'
optional :package_name, type: String,
desc: 'Return packages with this name'
......
......@@ -334,6 +334,73 @@ exports[`packages_list_app renders 1`] = `
</p>
</p>
<div
class="text-center"
>
<!---->
<!---->
</div>
</div>
</div>
</div>
</div>
</template>
</b-tab-stub>
<b-tab-stub
buttonid=""
tag="div"
title="PyPi"
titlelinkclass="gl-tab-nav-item"
>
<template>
<div>
<div
class="row empty-state"
>
<div
class="col-12"
>
<div
class="svg-250 svg-content"
>
<img
alt="There are no PyPi packages yet"
class=""
src="helpSvg"
/>
</div>
</div>
<div
class="col-12"
>
<div
class="text-content"
>
<h4
class="center"
style=""
>
There are no PyPi packages yet
</h4>
<p
class="center"
style=""
>
<p>
Learn how to
<a
href="helpUrl"
target="_blank"
>
publish and share your packages
</a>
with GitLab.
</p>
</p>
<div
class="text-center"
>
......
......@@ -129,31 +129,16 @@ describe API::GroupPackages do
it_behaves_like 'returns paginated packages'
end
context 'filtering on package_type' do
let_it_be(:package1) { create(:conan_package, project: project) }
let_it_be(:package2) { create(:maven_package, project: project) }
let_it_be(:package3) { create(:npm_package, project: project) }
let_it_be(:package4) { create(:nuget_package, project: project) }
context 'for each type' do
%w[conan maven npm nuget].each do |package_type|
it "returns #{package_type} packages" do
url = "/groups/#{group.id}/packages?package_type=#{package_type}"
get api(url)
expect(json_response.map { |package| package['package_type'] }).to eq([package_type])
end
end
end
it_behaves_like 'filters on each package_type', is_project: false
context 'does not accept non supported package_type value' do
let(:url) { "/groups/#{group.id}/packages?package_type=foo" }
include_context 'package filter context'
let(:url) { group_filter_url(:type, 'foo') }
it_behaves_like 'returning response status', :bad_request
end
end
end
context 'with packages feature disabled' do
before do
......
......@@ -95,26 +95,11 @@ describe API::ProjectPackages do
end
end
context 'filtering on package_type' do
let_it_be(:package1) { create(:conan_package, project: project) }
let_it_be(:package2) { create(:maven_package, project: project) }
let_it_be(:package3) { create(:npm_package, project: project) }
let_it_be(:package4) { create(:nuget_package, project: project) }
context 'for each type' do
%w[conan maven npm nuget].each do |package_type|
it "returns #{package_type} packages" do
url = package_filter_url(:type, package_type)
get api(url, user)
expect(json_response.length).to eq(1)
expect(json_response.map { |package| package['package_type'] }).to contain_exactly(package_type)
end
end
end
end
it_behaves_like 'filters on each package_type', is_project: true
context 'filtering on package_name' do
include_context 'package filter context'
it 'returns the named package' do
url = package_filter_url(:name, 'nuget')
get api(url, user)
......@@ -123,10 +108,6 @@ describe API::ProjectPackages do
expect(json_response.first['name']).to include(package2.name)
end
end
def package_filter_url(filter, param)
"/projects/#{project.id}/packages?package_#{filter}=#{param}"
end
end
context 'packages feature disabled' do
......
......@@ -142,6 +142,42 @@ RSpec.shared_examples 'background upload schedules a file migration' do
end
end
RSpec.shared_context 'package filter context' do
def package_filter_url(filter, param)
"/projects/#{project.id}/packages?package_#{filter}=#{param}"
end
def group_filter_url(filter, param)
"/groups/#{group.id}/packages?package_#{filter}=#{param}"
end
end
RSpec.shared_examples 'filters on each package_type' do |is_project: false|
include_context 'package filter context'
let_it_be(:package1) { create(:conan_package, project: project) }
let_it_be(:package2) { create(:maven_package, project: project) }
let_it_be(:package3) { create(:npm_package, project: project) }
let_it_be(:package4) { create(:nuget_package, project: project) }
let_it_be(:package5) { create(:pypi_package, project: project) }
let_it_be(:package6) { create(:composer_package, project: project) }
Packages::Package.package_types.keys.each do |package_type|
context "for package type #{package_type}" do
let(:url) { is_project ? package_filter_url(:type, package_type) : group_filter_url(:type, package_type) }
subject { get api(url, user) }
it "returns #{package_type} packages" do
subject
expect(json_response.length).to eq(1)
expect(json_response.map { |package| package['package_type'] }).to contain_exactly(package_type)
end
end
end
end
shared_examples 'package workhorse uploads' do
context 'without a workhorse header' do
let(:workhorse_token) { JWT.encode({ 'iss' => 'invalid header' }, Gitlab::Workhorse.secret, 'HS256') }
......
......@@ -14530,6 +14530,9 @@ msgstr ""
msgid "PackageRegistry|Published to the repository at %{timestamp}"
msgstr ""
msgid "PackageRegistry|PyPi"
msgstr ""
msgid "PackageRegistry|Registry Setup"
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