Commit 500e131f authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-07-17

parents 2497cd1e ddae884c
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
:cx="dotX" :cx="dotX"
:cy="dotY" :cy="dotY"
r="1.5" r="1.5"
tranform="translate(0 -1)" transform="translate(0 -1)"
/> />
</svg> </svg>
</div> </div>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# personal: boolean # personal: boolean
# search: string # search: string
# non_archived: boolean # non_archived: boolean
# archived: 'only' or boolean
# #
class ProjectsFinder < UnionFinder class ProjectsFinder < UnionFinder
include CustomAttributesFilter include CustomAttributesFilter
...@@ -130,7 +131,7 @@ class ProjectsFinder < UnionFinder ...@@ -130,7 +131,7 @@ class ProjectsFinder < UnionFinder
def by_archived(projects) def by_archived(projects)
if params[:non_archived] if params[:non_archived]
projects.non_archived projects.non_archived
elsif params.key?(:archived) # Back-compatibility with the places where `params[:archived]` can be set explicitly to `false` elsif params.key?(:archived)
if params[:archived] == 'only' if params[:archived] == 'only'
projects.archived projects.archived
elsif Gitlab::Utils.to_boolean(params[:archived]) elsif Gitlab::Utils.to_boolean(params[:archived])
......
...@@ -8,7 +8,7 @@ module SubmoduleHelper ...@@ -8,7 +8,7 @@ module SubmoduleHelper
url = repository.submodule_url_for(ref, submodule_item.path) url = repository.submodule_url_for(ref, submodule_item.path)
if url == '.' || url == './' if url == '.' || url == './'
url = File.join(Gitlab.config.gitlab.url, @project.full_path) url = File.join(Gitlab.config.gitlab.url, repository.project.full_path)
end end
if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z} if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z}
...@@ -31,7 +31,7 @@ module SubmoduleHelper ...@@ -31,7 +31,7 @@ module SubmoduleHelper
[namespace_project_path(namespace, project), [namespace_project_path(namespace, project),
namespace_project_tree_path(namespace, project, submodule_item.id)] namespace_project_tree_path(namespace, project, submodule_item.id)]
elsif relative_self_url?(url) elsif relative_self_url?(url)
relative_self_links(url, submodule_item.id) relative_self_links(url, submodule_item.id, repository.project)
elsif github_dot_com_url?(url) elsif github_dot_com_url?(url)
standard_links('github.com', namespace, project, submodule_item.id) standard_links('github.com', namespace, project, submodule_item.id)
elsif gitlab_dot_com_url?(url) elsif gitlab_dot_com_url?(url)
...@@ -73,7 +73,7 @@ module SubmoduleHelper ...@@ -73,7 +73,7 @@ module SubmoduleHelper
[base, [base, '/tree/', commit].join('')] [base, [base, '/tree/', commit].join('')]
end end
def relative_self_links(url, commit) def relative_self_links(url, commit, project)
url.rstrip! url.rstrip!
# Map relative links to a namespace and project # Map relative links to a namespace and project
# For example: # For example:
...@@ -85,7 +85,7 @@ module SubmoduleHelper ...@@ -85,7 +85,7 @@ module SubmoduleHelper
namespace = components.pop.gsub(/^\.\.$/, '') namespace = components.pop.gsub(/^\.\.$/, '')
if namespace.empty? if namespace.empty?
namespace = @project.namespace.full_path namespace = project.namespace.full_path
end end
begin begin
......
---
title: Fix typo in CSS transform property for Memory Graph component
merge_request: 20650
author:
type: fixed
---
title: Fix archived parameter for projects API
merge_request: 20566
author: Peter Marko
type: fixed
...@@ -151,7 +151,7 @@ POST /projects/:id/pipelines/:pipeline_id/retry ...@@ -151,7 +151,7 @@ POST /projects/:id/pipelines/:pipeline_id/retry
| `pipeline_id` | integer | yes | The ID of a pipeline | | `pipeline_id` | integer | yes | The ID of a pipeline |
``` ```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry" curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/retry"
``` ```
Response: Response:
...@@ -197,7 +197,7 @@ POST /projects/:id/pipelines/:pipeline_id/cancel ...@@ -197,7 +197,7 @@ POST /projects/:id/pipelines/:pipeline_id/cancel
| `pipeline_id` | integer | yes | The ID of a pipeline | | `pipeline_id` | integer | yes | The ID of a pipeline |
``` ```
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel" curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects/1/pipelines/46/cancel"
``` ```
Response: Response:
......
...@@ -35,6 +35,20 @@ GET /users ...@@ -35,6 +35,20 @@ GET /users
] ]
``` ```
You can also search for users by email or username with: `/users?search=John`
In addition, you can lookup users by username:
```
GET /users?username=:username
```
For example:
```
GET /users?username=jack_smith
```
In addition, you can filter users based on states eg. `blocked`, `active` In addition, you can filter users based on states eg. `blocked`, `active`
This works only to filter users who are `blocked` or `active`. This works only to filter users who are `blocked` or `active`.
It does not support `active=false` or `blocked=false`. It does not support `active=false` or `blocked=false`.
...@@ -128,21 +142,7 @@ GET /users ...@@ -128,21 +142,7 @@ GET /users
] ]
``` ```
You can search for users by email or username with: `/users?search=John` You can lookup users by external UID and provider:
In addition, you can lookup users by username:
```
GET /users?username=:username
```
For example:
```
GET /users?username=jack_smith
```
You can also lookup users by external UID and provider:
``` ```
GET /users?extern_uid=:extern_uid&provider=:provider GET /users?extern_uid=:extern_uid&provider=:provider
......
...@@ -398,7 +398,7 @@ module API ...@@ -398,7 +398,7 @@ module API
finder_params[:non_public] = true if params[:membership].present? finder_params[:non_public] = true if params[:membership].present?
finder_params[:starred] = true if params[:starred].present? finder_params[:starred] = true if params[:starred].present?
finder_params[:visibility_level] = Gitlab::VisibilityLevel.level_value(params[:visibility]) if params[:visibility] finder_params[:visibility_level] = Gitlab::VisibilityLevel.level_value(params[:visibility]) if params[:visibility]
finder_params[:archived] = params[:archived] finder_params[:archived] = archived_param unless params[:archived].nil?
finder_params[:search] = params[:search] if params[:search] finder_params[:search] = params[:search] if params[:search]
finder_params[:user] = params.delete(:user) if params[:user] finder_params[:user] = params.delete(:user) if params[:user]
finder_params[:custom_attributes] = params[:custom_attributes] if params[:custom_attributes] finder_params[:custom_attributes] = params[:custom_attributes] if params[:custom_attributes]
...@@ -535,5 +535,11 @@ module API ...@@ -535,5 +535,11 @@ module API
exception.status == 500 exception.status == 500
end end
def archived_param
return 'only' if params[:archived]
params[:archived]
end
end end
end end
...@@ -30,7 +30,7 @@ module API ...@@ -30,7 +30,7 @@ module API
end end
params :filter_params do params :filter_params do
optional :archived, type: Boolean, default: false, desc: 'Limit by archived status' optional :archived, type: Boolean, desc: 'Limit by archived status'
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values,
desc: 'Limit by visibility' desc: 'Limit by visibility'
optional :search, type: String, desc: 'Return list of projects matching the search criteria' optional :search, type: String, desc: 'Return list of projects matching the search criteria'
......
...@@ -92,11 +92,10 @@ describe SubmoduleHelper do ...@@ -92,11 +92,10 @@ describe SubmoduleHelper do
context 'in-repository submodule' do context 'in-repository submodule' do
let(:group) { create(:group, name: "Master Project", path: "master-project") } let(:group) { create(:group, name: "Master Project", path: "master-project") }
let(:project) { create(:project, group: group) } let(:project) { create(:project, group: group) }
before do
self.instance_variable_set(:@project, project)
end
it 'in-repository' do it 'in-repository' do
allow(repo).to receive(:project).and_return(project)
stub_url('./') stub_url('./')
expect(submodule_links(submodule_item)).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"]) expect(submodule_links(submodule_item)).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"])
end end
...@@ -167,32 +166,28 @@ describe SubmoduleHelper do ...@@ -167,32 +166,28 @@ describe SubmoduleHelper do
let(:project) { create(:project, group: group) } let(:project) { create(:project, group: group) }
let(:commit_id) { sample_commit[:id] } let(:commit_id) { sample_commit[:id] }
before do
self.instance_variable_set(:@project, project)
end
it 'one level down' do it 'one level down' do
result = relative_self_links('../test.git', commit_id) result = relative_self_links('../test.git', commit_id, project)
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
end end
it 'with trailing whitespace' do it 'with trailing whitespace' do
result = relative_self_links('../test.git ', commit_id) result = relative_self_links('../test.git ', commit_id, project)
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
end end
it 'two levels down' do it 'two levels down' do
result = relative_self_links('../../test.git', commit_id) result = relative_self_links('../../test.git', commit_id, project)
expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"]) expect(result).to eq(["/#{group.path}/test", "/#{group.path}/test/tree/#{commit_id}"])
end end
it 'one level down with namespace and repo' do it 'one level down with namespace and repo' do
result = relative_self_links('../foobar/test.git', commit_id) result = relative_self_links('../foobar/test.git', commit_id, project)
expect(result).to eq(["/foobar/test", "/foobar/test/tree/#{commit_id}"]) expect(result).to eq(["/foobar/test", "/foobar/test/tree/#{commit_id}"])
end end
it 'two levels down with namespace and repo' do it 'two levels down with namespace and repo' do
result = relative_self_links('../foobar/baz/test.git', commit_id) result = relative_self_links('../foobar/baz/test.git', commit_id, project)
expect(result).to eq(["/baz/test", "/baz/test/tree/#{commit_id}"]) expect(result).to eq(["/baz/test", "/baz/test/tree/#{commit_id}"])
end end
...@@ -201,7 +196,7 @@ describe SubmoduleHelper do ...@@ -201,7 +196,7 @@ describe SubmoduleHelper do
let(:project) { create(:project, namespace: user.namespace) } let(:project) { create(:project, namespace: user.namespace) }
it 'one level down with personal project' do it 'one level down with personal project' do
result = relative_self_links('../test.git', commit_id) result = relative_self_links('../test.git', commit_id, project)
expect(result).to eq(["/#{user.username}/test", "/#{user.username}/test/tree/#{commit_id}"]) expect(result).to eq(["/#{user.username}/test", "/#{user.username}/test/tree/#{commit_id}"])
end end
end end
......
...@@ -113,7 +113,7 @@ describe('MemoryGraph', () => { ...@@ -113,7 +113,7 @@ describe('MemoryGraph', () => {
const circleEl = el.querySelector('circle'); const circleEl = el.querySelector('circle');
expect(circleEl).toBeDefined(); expect(circleEl).toBeDefined();
expect(circleEl.getAttribute('r')).toBe('1.5'); expect(circleEl.getAttribute('r')).toBe('1.5');
expect(circleEl.getAttribute('tranform')).toBe('translate(0 -1)'); expect(circleEl.getAttribute('transform')).toBe('translate(0 -1)');
expect(circleEl.getAttribute('cx')).toBe(`${dotX}`); expect(circleEl.getAttribute('cx')).toBe(`${dotX}`);
expect(circleEl.getAttribute('cy')).toBe(`${dotY}`); expect(circleEl.getAttribute('cy')).toBe(`${dotY}`);
done(); done();
......
...@@ -237,6 +237,39 @@ describe API::Projects do ...@@ -237,6 +237,39 @@ describe API::Projects do
end end
end end
context 'and using archived' do
let!(:archived_project) { create(:project, creator_id: user.id, namespace: user.namespace, archived: true) }
it 'returns archived projects' do
get api('/projects?archived=true', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: true).size)
expect(json_response.map { |project| project['id'] }).to include(archived_project.id)
end
it 'returns non-archived projects' do
get api('/projects?archived=false', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: false).size)
expect(json_response.map { |project| project['id'] }).not_to include(archived_project.id)
end
it 'returns every project' do
get api('/projects', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |project| project['id'] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id))
end
end
context 'and using search' do context 'and using search' do
it_behaves_like 'projects response' do it_behaves_like 'projects response' do
let(:filter) { { search: project.name } } let(:filter) { { search: project.name } }
......
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