...
 
Commits (9)
......@@ -130,7 +130,7 @@ export const isInViewport = (el, offset = {}) => {
rect.top >= (top || 0) &&
rect.left >= (left || 0) &&
rect.bottom <= window.innerHeight &&
rect.right <= window.innerWidth
parseInt(rect.right, 10) <= window.innerWidth
);
};
......
......@@ -275,6 +275,7 @@ class User < ApplicationRecord
scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :by_username, -> (usernames) { iwhere(username: Array(usernames).map(&:to_s)) }
scope :for_todos, -> (todos) { where(id: todos.select(:user_id)) }
scope :with_emails, -> { preload(:emails) }
# Limits the users to those that have TODOs, optionally in the given state.
#
......
---
title: 'API: Expose milestone progress'
merge_request: 25173
title: 'API: Indicate if label is a project label'
merge_request: 25219
author: Robert Schilling
type: added
......@@ -42,7 +42,6 @@ Example Response:
"due_date": "2013-11-29",
"start_date": "2013-11-10",
"state": "active",
"percentage_complete" : 66,
"updated_at": "2013-10-02T09:24:18Z",
"created_at": "2013-10-02T09:24:18Z"
}
......
......@@ -30,7 +30,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"subscribed": false,
"priority": 10
"priority": 10,
"is_project_label": true
},
{
"id" : 4,
......@@ -42,7 +43,8 @@ Example response:
"closed_issues_count": 5,
"open_merge_requests_count": 0,
"subscribed": false,
"priority": null
"priority": null,
"is_project_label": true
},
{
"id" : 7,
......@@ -54,7 +56,8 @@ Example response:
"closed_issues_count": 3,
"open_merge_requests_count": 1,
"subscribed": false,
"priority": null
"priority": null,
"is_project_label": true
},
{
"id" : 8,
......@@ -66,7 +69,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 2,
"subscribed": false,
"priority": null
"priority": null,
"is_project_label": false
},
{
"id" : 9,
......@@ -78,7 +82,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"subscribed": true,
"priority": null
"priority": null,
"is_project_label": true
}
]
```
......@@ -116,7 +121,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 0,
"subscribed": false,
"priority": null
"priority": null,
"is_project_label": true
}
```
......@@ -173,7 +179,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 2,
"subscribed": false,
"priority": null
"priority": null,
"is_project_label": true
}
```
......@@ -209,7 +216,8 @@ Example response:
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"subscribed": true,
"priority": null
"priority": null,
"is_project_label": true
}
```
......
......@@ -39,7 +39,6 @@ Example Response:
"due_date": "2013-11-29",
"start_date": "2013-11-10",
"state": "active",
"percentage_complete" : 66,
"updated_at": "2013-10-02T09:24:18Z",
"created_at": "2013-10-02T09:24:18Z"
}
......
......@@ -502,9 +502,6 @@ module API
expose :state, :created_at, :updated_at
expose :due_date
expose :start_date
expose :percentage_complete do |milestone, options|
milestone.percent_complete(options[:current_user])
end
expose :web_url do |milestone, _options|
Gitlab::UrlBuilder.build(milestone)
......@@ -1035,6 +1032,9 @@ module API
expose :priority do |label, options|
label.priority(options[:parent])
end
expose :is_project_label do |label, options|
label.is_a?(::ProjectLabel)
end
end
class List < Grape::Entity
......
......@@ -35,19 +35,19 @@ module API
milestones = filter_by_iid(milestones, params[:iids]) if params[:iids].present?
milestones = filter_by_search(milestones, params[:search]) if params[:search]
present paginate(milestones), with: Entities::Milestone, current_user: current_user
present paginate(milestones), with: Entities::Milestone
end
def get_milestone_for(parent)
milestone = parent.milestones.find(params[:milestone_id])
present milestone, with: Entities::Milestone, current_user: current_user
present milestone, with: Entities::Milestone
end
def create_milestone_for(parent)
milestone = ::Milestones::CreateService.new(parent, current_user, declared_params).execute
if milestone.valid?
present milestone, with: Entities::Milestone, current_user: current_user
present milestone, with: Entities::Milestone
else
render_api_error!("Failed to create milestone #{milestone.errors.messages}", 400)
end
......@@ -60,7 +60,7 @@ module API
milestone = ::Milestones::UpdateService.new(parent, current_user, milestone_params).execute(milestone)
if milestone.valid?
present milestone, with: Entities::Milestone, current_user: current_user
present milestone, with: Entities::Milestone
else
render_api_error!("Failed to update milestone #{milestone.errors.messages}", 400)
end
......
......@@ -8,7 +8,6 @@
"title": { "type": "string" },
"description": { "type": ["string", "null"] },
"state": { "type": "string" },
"percentage_complete": { "type": "integer" },
"created_at": { "type": "date" },
"updated_at": { "type": "date" },
"start_date": { "type": "date" },
......
......@@ -855,6 +855,7 @@ describe('common_utils', () => {
});
it('returns true when provided `el` is in viewport', () => {
el.setAttribute('style', `position: absolute; right: ${window.innerWidth + 0.2};`);
document.body.appendChild(el);
expect(commonUtils.isInViewport(el)).toBe(true);
......
......@@ -22,7 +22,7 @@ describe API::Labels do
expected_keys = %w(
id name color text_color description
open_issues_count closed_issues_count open_merge_requests_count
subscribed priority
subscribed priority is_project_label
)
get api("/projects/#{project.id}/labels", user)
......@@ -47,6 +47,7 @@ describe API::Labels do
expect(label1_response['description']).to be_nil
expect(label1_response['priority']).to be_nil
expect(label1_response['subscribed']).to be_falsey
expect(label1_response['is_project_label']).to be_truthy
expect(group_label_response['open_issues_count']).to eq(1)
expect(group_label_response['closed_issues_count']).to eq(0)
......@@ -57,6 +58,7 @@ describe API::Labels do
expect(group_label_response['description']).to be_nil
expect(group_label_response['priority']).to be_nil
expect(group_label_response['subscribed']).to be_falsey
expect(group_label_response['is_project_label']).to be_falsey
expect(priority_label_response['open_issues_count']).to eq(0)
expect(priority_label_response['closed_issues_count']).to eq(0)
......@@ -67,6 +69,7 @@ describe API::Labels do
expect(priority_label_response['description']).to be_nil
expect(priority_label_response['priority']).to eq(3)
expect(priority_label_response['subscribed']).to be_falsey
expect(priority_label_response['is_project_label']).to be_truthy
end
end
......
......@@ -8,17 +8,12 @@ shared_examples_for 'group and project milestones' do |route_definition|
describe "GET #{route_definition}" do
it 'returns milestones list' do
create(:issue, project: project, milestone: milestone)
create(:closed_issue, project: project, milestone: milestone)
create(:closed_issue, project: project, milestone: milestone)
get api(route, 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.first['title']).to eq(milestone.title)
expect(json_response.first['percentage_complete']).to eq(66)
end
it 'returns a 401 error if user not authenticated' do
......