Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5aff8b41
Commit
5aff8b41
authored
Mar 29, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `Personal pipelines quota` for user profile
parent
63305cfe
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
215 additions
and
42 deletions
+215
-42
app/assets/stylesheets/pages/groups.scss
app/assets/stylesheets/pages/groups.scss
+8
-0
app/controllers/profiles/pipeline_quota_controller.rb
app/controllers/profiles/pipeline_quota_controller.rb
+6
-0
app/helpers/ee/namespace_helper.rb
app/helpers/ee/namespace_helper.rb
+47
-0
app/views/groups/pipeline_quota/index.html.haml
app/views/groups/pipeline_quota/index.html.haml
+2
-41
app/views/layouts/nav/_profile.html.haml
app/views/layouts/nav/_profile.html.haml
+4
-0
app/views/namespaces/_shared_runner_status.html.haml
app/views/namespaces/_shared_runner_status.html.haml
+1
-1
app/views/namespaces/pipelines_quota/_list.haml
app/views/namespaces/pipelines_quota/_list.haml
+44
-0
app/views/profiles/pipeline_quota/index.haml
app/views/profiles/pipeline_quota/index.haml
+14
-0
config/routes/profile.rb
config/routes/profile.rb
+4
-0
config/routes/user.rb
config/routes/user.rb
+1
-0
spec/features/profiles/pipeline_quota_spec.rb
spec/features/profiles/pipeline_quota_spec.rb
+84
-0
No files found.
app/assets/stylesheets/pages/groups.scss
View file @
5aff8b41
...
@@ -117,6 +117,14 @@
...
@@ -117,6 +117,14 @@
}
}
}
}
.user-settings-pipeline-quota
{
margin-top
:
$gl-padding
;
.pipeline-quota
{
border-top
:
none
;
}
}
table
.pipeline-project-metrics
tr
td
{
table
.pipeline-project-metrics
tr
td
{
padding
:
$gl-padding
;
padding
:
$gl-padding
;
}
}
...
...
app/controllers/profiles/pipeline_quota_controller.rb
0 → 100644
View file @
5aff8b41
class
Profiles::PipelineQuotaController
<
Profiles
::
ApplicationController
def
index
@namespace
=
current_user
.
namespace
@projects
=
@namespace
.
projects
.
with_shared_runners_limit_enabled
.
page
(
params
[
:page
])
end
end
app/helpers/ee/
groups
_helper.rb
→
app/helpers/ee/
namespace
_helper.rb
View file @
5aff8b41
module
EE
module
EE
module
Groups
Helper
module
Namespace
Helper
def
group_shared_runner_limits_quota
(
group
)
def
namespace_shared_runner_limits_quota
(
namespace
)
used
=
group
.
shared_runners_minutes
.
to_i
used
=
namespace
.
shared_runners_minutes
.
to_i
if
group
.
shared_runners_minutes_limit_enabled?
if
namespace
.
shared_runners_minutes_limit_enabled?
limit
=
group
.
actual_shared_runners_minutes_limit
limit
=
namespace
.
actual_shared_runners_minutes_limit
status
=
group
.
shared_runners_minutes_used?
?
'over_quota'
:
'under_quota'
status
=
namespace
.
shared_runners_minutes_used?
?
'over_quota'
:
'under_quota'
else
else
limit
=
'Unlimited'
limit
=
'Unlimited'
status
=
'disabled'
status
=
'disabled'
...
@@ -16,14 +16,14 @@ module EE
...
@@ -16,14 +16,14 @@ module EE
end
end
end
end
def
group_shared_runner_limits_percent_used
(
group
)
def
namespace_shared_runner_limits_percent_used
(
namespace
)
return
0
unless
group
.
shared_runners_minutes_limit_enabled?
return
0
unless
namespace
.
shared_runners_minutes_limit_enabled?
100
*
group
.
shared_runners_minutes
.
to_i
/
group
.
actual_shared_runners_minutes_limit
100
*
namespace
.
shared_runners_minutes
.
to_i
/
namespace
.
actual_shared_runners_minutes_limit
end
end
def
group_shared_runner_limits_progress_bar
(
group
)
def
namespace_shared_runner_limits_progress_bar
(
namespace
)
percent
=
[
group_shared_runner_limits_percent_used
(
group
),
100
].
min
percent
=
[
namespace_shared_runner_limits_percent_used
(
namespace
),
100
].
min
status
=
status
=
if
percent
==
100
if
percent
==
100
...
...
app/views/groups/pipeline_quota/index.html.haml
View file @
5aff8b41
...
@@ -9,44 +9,5 @@
...
@@ -9,44 +9,5 @@
%strong
=
@group
.
name
%strong
=
@group
.
name
group
group
.pipeline-quota.container-fluid
=
render
"namespaces/pipelines_quota/list"
,
.row
locals:
{
namespace:
@group
,
projects:
@projects
}
.col-sm-6
%strong
-
last_reset
=
@group
.
shared_runners_seconds_last_reset
-
if
last_reset
Usage since
=
last_reset
.
strftime
(
'%b %d, %Y'
)
-
else
Current period usage
%div
=
group_shared_runner_limits_quota
(
@group
)
minutes
.col-sm-6.right
-
if
@group
.
shared_runners_minutes_limit_enabled?
#{
group_shared_runner_limits_percent_used
(
@group
)
}
% used
-
else
Unlimited
=
group_shared_runner_limits_progress_bar
(
@group
)
%table
.table.pipeline-project-metrics
%thead
%tr
%th
Project
%th
Minutes
%tbody
-
@projects
.
each
do
|
project
|
%tr
%td
.avatar-container.s20.hidden-xs
=
project_icon
(
project
,
alt:
''
,
class:
'avatar project-avatar s20'
)
%strong
=
link_to
project
.
name
,
project
%td
=
project
.
shared_runners_minutes
-
if
@projects
.
blank?
%tr
%td
{
colspan:
2
}
.nothing-here-block
This group has no projects which use shared runners
=
paginate
@projects
,
theme:
"gitlab"
app/views/layouts/nav/_profile.html.haml
View file @
5aff8b41
...
@@ -51,3 +51,7 @@
...
@@ -51,3 +51,7 @@
=
link_to
audit_log_profile_path
,
title:
'Authentication log'
do
=
link_to
audit_log_profile_path
,
title:
'Authentication log'
do
%span
%span
Authentication log
Authentication log
=
nav_link
(
path:
'profiles#pipeline_quota'
)
do
=
link_to
profile_pipeline_quota_path
,
title:
'Pipeline quota'
do
%span
Pipeline quota
app/views/namespaces/_shared_runner_status.html.haml
View file @
5aff8b41
...
@@ -3,5 +3,5 @@
...
@@ -3,5 +3,5 @@
%li
%li
%span
.light
Pipeline minutes quota:
%span
.light
Pipeline minutes quota:
%strong
%strong
=
group
_shared_runner_limits_quota
(
namespace
)
=
namespace
_shared_runner_limits_quota
(
namespace
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"shared-runners-build-minutes-quota"
),
target:
'_blank'
=
link_to
icon
(
'question-circle'
),
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"shared-runners-build-minutes-quota"
),
target:
'_blank'
app/views/namespaces/pipelines_quota/_list.haml
0 → 100644
View file @
5aff8b41
-
namespace
=
locals
.
fetch
(
:namespace
)
-
projects
=
locals
.
fetch
(
:projects
)
.pipeline-quota.container-fluid
.row
.col-sm-6
%strong
-
last_reset
=
namespace
.
shared_runners_seconds_last_reset
-
if
last_reset
Usage since
=
last_reset
.
strftime
(
'%b %d, %Y'
)
-
else
Current period usage
%div
=
namespace_shared_runner_limits_quota
(
namespace
)
minutes
.col-sm-6.right
-
if
namespace
.
shared_runners_minutes_limit_enabled?
#{
namespace_shared_runner_limits_percent_used
(
namespace
)
}
% used
-
else
Unlimited
=
namespace_shared_runner_limits_progress_bar
(
namespace
)
%table
.table.pipeline-project-metrics
%thead
%tr
%th
Project
%th
Minutes
%tbody
-
projects
.
each
do
|
project
|
%tr
%td
.avatar-container.s20.hidden-xs
=
project_icon
(
project
,
alt:
''
,
class:
'avatar project-avatar s20'
)
%strong
=
link_to
project
.
name
,
project
%td
=
project
.
shared_runners_minutes
-
if
projects
.
blank?
%tr
%td
{
colspan:
2
}
.nothing-here-block
This group has no projects which use shared runners
=
paginate
projects
,
theme:
"gitlab"
app/views/profiles/pipeline_quota/index.haml
0 → 100644
View file @
5aff8b41
-
page_title
'Personal pipelines quota'
=
render
'profiles/head'
.user-settings-pipeline-quota.row
.profile-settings-sidebar.col-lg-3
%h4
Personal pipelines quota
=
link_to
icon
(
'question-circle'
),
help_page_path
(
"user/admin_area/settings/continuous_integration"
,
anchor:
"shared-runners-build-minutes-quota"
),
target:
'_blank'
%p
.light
Monthly build minutes usage across shared Runners
.col-lg-9
=
render
"namespaces/pipelines_quota/list"
,
locals:
{
namespace:
@namespace
,
projects:
@projects
}
config/routes/profile.rb
View file @
5aff8b41
...
@@ -47,5 +47,9 @@ resource :profile, only: [:show, :update] do
...
@@ -47,5 +47,9 @@ resource :profile, only: [:show, :update] do
end
end
resources
:u2f_registrations
,
only:
[
:destroy
]
resources
:u2f_registrations
,
only:
[
:destroy
]
## EE-specific
resources
:pipeline_quota
,
only:
[
:index
]
## EE-specific
end
end
end
end
config/routes/user.rb
View file @
5aff8b41
...
@@ -31,6 +31,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
...
@@ -31,6 +31,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get
:contributed
,
as: :contributed_projects
get
:contributed
,
as: :contributed_projects
get
:snippets
get
:snippets
get
:exists
get
:exists
get
:pipelines_quota
get
'/'
,
to:
redirect
(
'/%{username}'
),
as:
nil
get
'/'
,
to:
redirect
(
'/%{username}'
),
as:
nil
end
end
...
...
spec/features/profiles/pipeline_quota_spec.rb
0 → 100644
View file @
5aff8b41
require
'spec_helper'
feature
'Profile > Pipeline Quota'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:empty_project
,
namespace:
namespace
,
shared_runners_enabled:
true
)
}
before
do
login_with
(
user
)
end
it
'is linked within the profile page'
do
visit
profile_path
page
.
within
(
'.layout-nav'
)
do
expect
(
page
).
to
have_selector
(
:link_or_button
,
'Pipeline quota'
)
end
end
context
'with no quota'
do
let
(
:namespace
)
{
create
(
:namespace
,
:with_build_minutes
,
owner:
user
)
}
it
'shows correct group quota info'
do
visit
profile_pipeline_quota_path
page
.
within
(
'.pipeline-quota'
)
do
expect
(
page
).
to
have_content
(
"400 / Unlimited minutes"
)
expect
(
page
).
to
have_selector
(
'.progress-bar-success'
)
end
end
end
context
'with no projects using shared runners'
do
let
(
:namespace
)
{
create
(
:namespace
,
:with_not_used_build_minutes_limit
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:empty_project
,
namespace:
namespace
,
shared_runners_enabled:
false
)
}
it
'shows correct group quota info'
do
visit
profile_pipeline_quota_path
page
.
within
(
'.pipeline-quota'
)
do
expect
(
page
).
to
have_content
(
"300 / Unlimited minutes"
)
expect
(
page
).
to
have_selector
(
'.progress-bar-success'
)
end
page
.
within
(
'.pipeline-project-metrics'
)
do
expect
(
page
).
to
have_content
(
'This group has no projects which use shared runners'
)
end
end
end
context
'minutes under quota'
do
let
(
:namespace
)
{
create
(
:namespace
,
:with_not_used_build_minutes_limit
,
owner:
user
)
}
it
'shows correct group quota info'
do
visit
profile_pipeline_quota_path
page
.
within
(
'.pipeline-quota'
)
do
expect
(
page
).
to
have_content
(
"300 / 500 minutes"
)
expect
(
page
).
to
have_content
(
"60% used"
)
expect
(
page
).
to
have_selector
(
'.progress-bar-success'
)
end
end
end
context
'minutes over quota'
do
let
(
:namespace
)
{
create
(
:namespace
,
:with_used_build_minutes_limit
,
owner:
user
)
}
let!
(
:other_project
)
{
create
(
:empty_project
,
namespace:
namespace
,
shared_runners_enabled:
false
)
}
it
'shows correct group quota and projects info'
do
visit
profile_pipeline_quota_path
page
.
within
(
'.pipeline-quota'
)
do
expect
(
page
).
to
have_content
(
"1000 / 500 minutes"
)
expect
(
page
).
to
have_content
(
"200% used"
)
expect
(
page
).
to
have_selector
(
'.progress-bar-danger'
)
end
page
.
within
(
'.pipeline-project-metrics'
)
do
expect
(
page
).
to
have_content
(
project
.
name
)
expect
(
page
).
not_to
have_content
(
other_project
.
name
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment