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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
57d00130
Commit
57d00130
authored
Sep 03, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CRUD for admin labels
parent
28219ea9
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
275 additions
and
39 deletions
+275
-39
app/controllers/admin/labels_controller.rb
app/controllers/admin/labels_controller.rb
+59
-0
app/models/label.rb
app/models/label.rb
+7
-1
app/views/admin/labels/_form.html.haml
app/views/admin/labels/_form.html.haml
+35
-0
app/views/admin/labels/_label.html.haml
app/views/admin/labels/_label.html.haml
+5
-0
app/views/admin/labels/destroy.js.haml
app/views/admin/labels/destroy.js.haml
+2
-0
app/views/admin/labels/edit.html.haml
app/views/admin/labels/edit.html.haml
+9
-0
app/views/admin/labels/index.html.haml
app/views/admin/labels/index.html.haml
+16
-0
app/views/admin/labels/new.html.haml
app/views/admin/labels/new.html.haml
+7
-0
app/views/layouts/nav/_admin.html.haml
app/views/layouts/nav/_admin.html.haml
+6
-0
config/routes.rb
config/routes.rb
+2
-0
db/migrate/20150902001023_add_template_to_label.rb
db/migrate/20150902001023_add_template_to_label.rb
+5
-0
db/schema.rb
db/schema.rb
+122
-38
No files found.
app/controllers/admin/labels_controller.rb
0 → 100644
View file @
57d00130
class
Admin::LabelsController
<
Admin
::
ApplicationController
before_action
:set_label
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
def
index
@labels
=
Label
.
templates
.
page
(
params
[
:page
]).
per
(
PER_PAGE
)
end
def
show
end
def
new
@label
=
Label
.
new
end
def
edit
end
def
create
@label
=
Label
.
new
(
label_params
)
@label
.
template
=
true
if
@label
.
save
redirect_to
admin_labels_url
,
notice:
"Label was created"
else
render
:new
end
end
def
update
if
@label
.
update
(
label_params
)
redirect_to
admin_labels_path
,
notice:
'label was successfully updated.'
else
render
:edit
end
end
def
destroy
@label
.
destroy
@labels
=
Label
.
templates
respond_to
do
|
format
|
format
.
html
do
redirect_to
(
admin_labels_path
,
notice:
'Label was removed'
)
end
format
.
js
end
end
private
def
set_label
@label
=
Label
.
find
(
params
[
:id
])
end
def
label_params
params
[
:label
].
permit
(
:title
,
:color
)
end
end
app/models/label.rb
View file @
57d00130
...
@@ -24,7 +24,7 @@ class Label < ActiveRecord::Base
...
@@ -24,7 +24,7 @@ class Label < ActiveRecord::Base
validates
:color
,
validates
:color
,
format:
{
with:
/\A#[0-9A-Fa-f]{6}\Z/
},
format:
{
with:
/\A#[0-9A-Fa-f]{6}\Z/
},
allow_blank:
false
allow_blank:
false
validates
:project
,
presence:
true
validates
:project
,
presence:
true
,
unless:
Proc
.
new
{
|
service
|
service
.
template?
}
# Don't allow '?', '&', and ',' for label titles
# Don't allow '?', '&', and ',' for label titles
validates
:title
,
validates
:title
,
...
@@ -34,6 +34,8 @@ class Label < ActiveRecord::Base
...
@@ -34,6 +34,8 @@ class Label < ActiveRecord::Base
default_scope
{
order
(
title: :asc
)
}
default_scope
{
order
(
title: :asc
)
}
scope
:templates
,
->
{
where
(
template:
true
)
}
alias_attribute
:name
,
:title
alias_attribute
:name
,
:title
def
self
.
reference_prefix
def
self
.
reference_prefix
...
@@ -78,4 +80,8 @@ class Label < ActiveRecord::Base
...
@@ -78,4 +80,8 @@ class Label < ActiveRecord::Base
def
open_issues_count
def
open_issues_count
issues
.
opened
.
count
issues
.
opened
.
count
end
end
def
template?
template
end
end
end
app/views/admin/labels/_form.html.haml
0 → 100644
View file @
57d00130
=
form_for
[
:admin
,
@label
],
html:
{
class:
'form-horizontal label-form js-requires-input'
}
do
|
f
|
-
if
@label
.
errors
.
any?
.row
.col-sm-offset-2.col-sm-10
.alert.alert-danger
-
@label
.
errors
.
full_messages
.
each
do
|
msg
|
%span
=
msg
%br
.form-group
=
f
.
label
:title
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:title
,
class:
"form-control"
,
required:
true
.form-group
=
f
.
label
:color
,
"Background Color"
,
class:
'control-label'
.col-sm-10
.input-group
.input-group-addon.label-color-preview
=
f
.
color_field
:color
,
class:
"form-control"
.help-block
Choose any color.
%br
Or you can choose one of suggested colors below
.suggest-colors
-
suggested_colors
.
each
do
|
color
|
=
link_to
'#'
,
style:
"background-color:
#{
color
}
"
,
data:
{
color:
color
}
do
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-save js-save-button'
=
link_to
"Cancel"
,
admin_labels_path
,
class:
'btn btn-cancel'
:coffeescript
new Labels
app/views/admin/labels/_label.html.haml
0 → 100644
View file @
57d00130
%li
{
id:
dom_id
(
label
)}
=
render_colored_label
(
label
)
.pull-right
=
link_to
'Edit'
,
edit_admin_label_path
(
label
),
class:
'btn btn-sm'
=
link_to
'Remove'
,
admin_label_path
(
label
),
class:
'btn btn-sm btn-remove remove-row'
,
method: :delete
,
remote:
true
,
data:
{
confirm:
"Remove this label? Are you sure?"
}
app/views/admin/labels/destroy.js.haml
0 → 100644
View file @
57d00130
-
if
@labels
.
size
==
0
$('.labels').load(document.URL + ' .light-well').hide().fadeIn(1000)
app/views/admin/labels/edit.html.haml
0 → 100644
View file @
57d00130
-
page_title
"Edit"
,
@label
.
name
,
"Labels"
%h3
Edit label
%span
.light
#{
@label
.
name
}
.back-link
=
link_to
admin_labels_path
do
←
To labels list
%hr
=
render
'form'
app/views/admin/labels/index.html.haml
0 → 100644
View file @
57d00130
-
page_title
"Labels"
=
link_to
new_admin_label_path
,
class:
"pull-right btn btn-new"
do
New label
%h3
.page-title
Labels
%hr
.labels
-
if
@labels
.
present?
%ul
.bordered-list.manage-labels-list
=
render
@labels
=
paginate
@labels
,
theme:
'gitlab'
-
else
.light-well
.nothing-here-block
There are no any labels yet
\ No newline at end of file
app/views/admin/labels/new.html.haml
0 → 100644
View file @
57d00130
-
page_title
"New Label"
%h3
New label
.back-link
=
link_to
admin_labels_path
do
←
To labels list
%hr
=
render
'form'
app/views/layouts/nav/_admin.html.haml
View file @
57d00130
...
@@ -57,6 +57,12 @@
...
@@ -57,6 +57,12 @@
%span
%span
Service Templates
Service Templates
=
nav_link
(
controller: :labels
)
do
=
link_to
admin_labels_path
,
title:
'Labels'
,
data:
{
placement:
'right'
}
do
=
icon
(
'tags fw'
)
%span
Labels
=
nav_link
(
controller: :abuse_reports
)
do
=
nav_link
(
controller: :abuse_reports
)
do
=
link_to
admin_abuse_reports_path
,
title:
"Abuse reports"
do
=
link_to
admin_abuse_reports_path
,
title:
"Abuse reports"
do
=
icon
(
'exclamation-circle fw'
)
=
icon
(
'exclamation-circle fw'
)
...
...
config/routes.rb
View file @
57d00130
...
@@ -201,6 +201,8 @@ Gitlab::Application.routes.draw do
...
@@ -201,6 +201,8 @@ Gitlab::Application.routes.draw do
resources
:services
resources
:services
end
end
resources
:labels
root
to:
'dashboard#index'
root
to:
'dashboard#index'
end
end
...
...
db/migrate/20150902001023_add_template_to_label.rb
0 → 100644
View file @
57d00130
class
AddTemplateToLabel
<
ActiveRecord
::
Migration
def
change
add_column
:labels
,
:template
,
:boolean
,
default:
false
end
end
\ No newline at end of file
db/schema.rb
View file @
57d00130
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20150
824002011
)
do
ActiveRecord
::
Schema
.
define
(
version:
20150
902001023
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -24,6 +24,17 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -24,6 +24,17 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
end
end
create_table
"appearances"
,
force:
true
do
|
t
|
t
.
string
"title"
t
.
text
"description"
t
.
string
"logo"
t
.
integer
"updated_by"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"dark_logo"
t
.
string
"light_logo"
end
create_table
"application_settings"
,
force:
true
do
|
t
|
create_table
"application_settings"
,
force:
true
do
|
t
|
t
.
integer
"default_projects_limit"
t
.
integer
"default_projects_limit"
t
.
boolean
"signup_enabled"
t
.
boolean
"signup_enabled"
...
@@ -36,17 +47,36 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -36,17 +47,36 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
integer
"default_branch_protection"
,
default:
2
t
.
integer
"default_branch_protection"
,
default:
2
t
.
boolean
"twitter_sharing_enabled"
,
default:
true
t
.
boolean
"twitter_sharing_enabled"
,
default:
true
t
.
text
"restricted_visibility_levels"
t
.
text
"restricted_visibility_levels"
t
.
boolean
"version_check_enabled"
,
default:
true
t
.
integer
"max_attachment_size"
,
default:
10
,
null:
false
t
.
integer
"max_attachment_size"
,
default:
10
,
null:
false
t
.
integer
"default_project_visibility"
t
.
integer
"default_project_visibility"
t
.
integer
"default_snippet_visibility"
t
.
integer
"default_snippet_visibility"
t
.
text
"restricted_signup_domains"
t
.
text
"restricted_signup_domains"
t
.
boolean
"version_check_enabled"
,
default:
true
t
.
boolean
"user_oauth_applications"
,
default:
true
t
.
boolean
"user_oauth_applications"
,
default:
true
t
.
string
"after_sign_out_path"
t
.
string
"after_sign_out_path"
t
.
integer
"session_expire_delay"
,
default:
10080
,
null:
false
t
.
integer
"session_expire_delay"
,
default:
10080
,
null:
false
t
.
text
"help_text"
t
.
text
"import_sources"
t
.
text
"import_sources"
end
end
create_table
"approvals"
,
force:
true
do
|
t
|
t
.
integer
"merge_request_id"
,
null:
false
t
.
integer
"user_id"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"approvers"
,
force:
true
do
|
t
|
t
.
integer
"target_id"
,
null:
false
t
.
string
"target_type"
t
.
integer
"user_id"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
add_index
"approvers"
,
[
"target_id"
,
"target_type"
],
name:
"index_approvers_on_target_id_and_target_type"
,
using: :btree
add_index
"approvers"
,
[
"user_id"
],
name:
"index_approvers_on_user_id"
,
using: :btree
create_table
"audit_events"
,
force:
true
do
|
t
|
create_table
"audit_events"
,
force:
true
do
|
t
|
t
.
integer
"author_id"
,
null:
false
t
.
integer
"author_id"
,
null:
false
t
.
string
"type"
,
null:
false
t
.
string
"type"
,
null:
false
...
@@ -119,6 +149,28 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -119,6 +149,28 @@ ActiveRecord::Schema.define(version: 20150824002011) do
add_index
"forked_project_links"
,
[
"forked_to_project_id"
],
name:
"index_forked_project_links_on_forked_to_project_id"
,
unique:
true
,
using: :btree
add_index
"forked_project_links"
,
[
"forked_to_project_id"
],
name:
"index_forked_project_links_on_forked_to_project_id"
,
unique:
true
,
using: :btree
create_table
"git_hooks"
,
force:
true
do
|
t
|
t
.
string
"force_push_regex"
t
.
string
"delete_branch_regex"
t
.
string
"commit_message_regex"
t
.
boolean
"deny_delete_tag"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"author_email_regex"
t
.
boolean
"member_check"
,
default:
false
,
null:
false
t
.
string
"file_name_regex"
t
.
boolean
"is_sample"
,
default:
false
t
.
integer
"max_file_size"
,
default:
0
end
create_table
"historical_data"
,
force:
true
do
|
t
|
t
.
date
"date"
,
null:
false
t
.
integer
"active_user_count"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"identities"
,
force:
true
do
|
t
|
create_table
"identities"
,
force:
true
do
|
t
|
t
.
string
"extern_uid"
t
.
string
"extern_uid"
t
.
string
"provider"
t
.
string
"provider"
...
@@ -186,10 +238,26 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -186,10 +238,26 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
boolean
"template"
,
default:
false
end
end
add_index
"labels"
,
[
"project_id"
],
name:
"index_labels_on_project_id"
,
using: :btree
add_index
"labels"
,
[
"project_id"
],
name:
"index_labels_on_project_id"
,
using: :btree
create_table
"ldap_group_links"
,
force:
true
do
|
t
|
t
.
string
"cn"
,
null:
false
t
.
integer
"group_access"
,
null:
false
t
.
integer
"group_id"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
string
"provider"
end
create_table
"licenses"
,
force:
true
do
|
t
|
t
.
text
"data"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
end
create_table
"members"
,
force:
true
do
|
t
|
create_table
"members"
,
force:
true
do
|
t
|
t
.
integer
"access_level"
,
null:
false
t
.
integer
"access_level"
,
null:
false
t
.
integer
"source_id"
,
null:
false
t
.
integer
"source_id"
,
null:
false
...
@@ -279,6 +347,7 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -279,6 +347,7 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
string
"type"
t
.
string
"type"
t
.
string
"description"
,
default:
""
,
null:
false
t
.
string
"description"
,
default:
""
,
null:
false
t
.
string
"avatar"
t
.
string
"avatar"
t
.
boolean
"membership_lock"
,
default:
false
end
end
add_index
"namespaces"
,
[
"created_at"
,
"id"
],
name:
"index_namespaces_on_created_at_and_id"
,
using: :btree
add_index
"namespaces"
,
[
"created_at"
,
"id"
],
name:
"index_namespaces_on_created_at_and_id"
,
using: :btree
...
@@ -356,6 +425,14 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -356,6 +425,14 @@ ActiveRecord::Schema.define(version: 20150824002011) do
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"owner_id"
,
"owner_type"
],
name:
"index_oauth_applications_on_owner_id_and_owner_type"
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
add_index
"oauth_applications"
,
[
"uid"
],
name:
"index_oauth_applications_on_uid"
,
unique:
true
,
using: :btree
create_table
"project_group_links"
,
force:
true
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"group_id"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
integer
"group_access"
,
default:
30
,
null:
false
end
create_table
"project_import_data"
,
force:
true
do
|
t
|
create_table
"project_import_data"
,
force:
true
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
text
"data"
t
.
text
"data"
...
@@ -386,6 +463,11 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -386,6 +463,11 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
string
"import_type"
t
.
string
"import_type"
t
.
string
"import_source"
t
.
string
"import_source"
t
.
text
"merge_requests_template"
t
.
boolean
"merge_requests_rebase_enabled"
,
default:
false
t
.
boolean
"merge_requests_rebase_default"
,
default:
true
t
.
integer
"approvals_before_merge"
,
default:
0
,
null:
false
t
.
boolean
"reset_approvals_on_push"
,
default:
true
t
.
integer
"commit_count"
,
default:
0
t
.
integer
"commit_count"
,
default:
0
end
end
...
@@ -530,13 +612,14 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -530,13 +612,14 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
boolean
"hide_no_password"
,
default:
false
t
.
boolean
"hide_no_password"
,
default:
false
t
.
boolean
"password_automatically_set"
,
default:
false
t
.
boolean
"password_automatically_set"
,
default:
false
t
.
string
"location"
t
.
string
"location"
t
.
string
"public_email"
,
default:
""
,
null:
false
t
.
string
"encrypted_otp_secret"
t
.
string
"encrypted_otp_secret"
t
.
string
"encrypted_otp_secret_iv"
t
.
string
"encrypted_otp_secret_iv"
t
.
string
"encrypted_otp_secret_salt"
t
.
string
"encrypted_otp_secret_salt"
t
.
boolean
"otp_required_for_login"
,
default:
false
,
null:
false
t
.
boolean
"otp_required_for_login"
,
default:
false
,
null:
false
t
.
text
"otp_backup_codes"
t
.
text
"otp_backup_codes"
t
.
string
"public_email"
,
default:
""
,
null:
false
t
.
integer
"dashboard"
,
default:
0
t
.
integer
"dashboard"
,
default:
0
t
.
datetime
"admin_email_unsubscribed_at"
t
.
integer
"project_view"
,
default:
0
t
.
integer
"project_view"
,
default:
0
end
end
...
@@ -573,6 +656,7 @@ ActiveRecord::Schema.define(version: 20150824002011) do
...
@@ -573,6 +656,7 @@ ActiveRecord::Schema.define(version: 20150824002011) do
t
.
boolean
"merge_requests_events"
,
default:
false
,
null:
false
t
.
boolean
"merge_requests_events"
,
default:
false
,
null:
false
t
.
boolean
"tag_push_events"
,
default:
false
t
.
boolean
"tag_push_events"
,
default:
false
t
.
boolean
"note_events"
,
default:
false
,
null:
false
t
.
boolean
"note_events"
,
default:
false
,
null:
false
t
.
integer
"group_id"
t
.
boolean
"enable_ssl_verification"
,
default:
false
t
.
boolean
"enable_ssl_verification"
,
default:
false
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