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
Tatuya Kamada
gitlab-ce
Commits
074c9649
Commit
074c9649
authored
Oct 15, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add label type to group and project labels lists
parent
9cb12384
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
5 deletions
+52
-5
app/assets/stylesheets/pages/labels.scss
app/assets/stylesheets/pages/labels.scss
+15
-1
app/views/groups/labels/index.html.haml
app/views/groups/labels/index.html.haml
+1
-1
app/views/shared/_label_row.html.haml
app/views/shared/_label_row.html.haml
+2
-0
db/migrate/20161017125927_add_unique_index_to_labels.rb
db/migrate/20161017125927_add_unique_index_to_labels.rb
+32
-0
db/schema.rb
db/schema.rb
+2
-3
No files found.
app/assets/stylesheets/pages/labels.scss
View file @
074c9649
...
...
@@ -69,6 +69,20 @@
}
}
.label-type
{
display
:
block
;
margin-bottom
:
10px
;
margin-left
:
50px
;
@media
(
min-width
:
$screen-sm-min
)
{
display
:
inline-block
;
width
:
100px
;
margin-left
:
10px
;
margin-bottom
:
0
;
vertical-align
:
middle
;
}
}
.label-description
{
display
:
block
;
margin-bottom
:
10px
;
...
...
app/views/groups/labels/index.html.haml
View file @
074c9649
...
...
@@ -2,7 +2,7 @@
.top-area.adjust
.nav-text
Labels can be applied to issues and merge requests.
Labels can be applied to issues and merge requests.
Group labels are available for any project within the group.
.nav-controls
-
if
can?
(
current_user
,
:admin_label
,
@group
)
...
...
app/views/shared/_label_row.html.haml
View file @
074c9649
...
...
@@ -10,6 +10,8 @@
=
icon
(
'star'
)
%span
.label-name
=
link_to_label
(
label
,
subject:
@project
,
tooltip:
false
)
%span
.label-type
=
label
.
model_name
.
human
.
titleize
-
if
label
.
description
%span
.label-description
=
markdown_field
(
label
,
:description
)
db/migrate/20161017125927_add_unique_index_to_labels.rb
0 → 100644
View file @
074c9649
class
AddUniqueIndexToLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
true
DOWNTIME_REASON
=
'This migration removes duplicated labels.'
disable_ddl_transaction!
def
up
select_all
(
'SELECT title, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1'
).
each
do
|
label
|
label_title
=
quote_string
(
label
[
'title'
])
duplicated_ids
=
select_all
(
"SELECT id FROM labels WHERE title = '
#{
label_title
}
' ORDER BY id ASC"
).
map
{
|
label
|
label
[
'id'
]
}
label_id
=
duplicated_ids
.
first
duplicated_ids
.
delete
(
label_id
)
execute
(
"UPDATE label_links SET label_id =
#{
label_id
}
WHERE label_id IN(
#{
duplicated_ids
.
join
(
","
)
}
)"
)
execute
(
"DELETE FROM labels WHERE id IN(
#{
duplicated_ids
.
join
(
","
)
}
)"
)
end
remove_index
:labels
,
column: :project_id
if
index_exists?
(
:labels
,
:project_id
)
remove_index
:labels
,
column: :title
if
index_exists?
(
:labels
,
:title
)
add_concurrent_index
:labels
,
[
:group_id
,
:project_id
,
:title
],
unique:
true
end
def
down
remove_index
:labels
,
column:
[
:group_id
,
:project_id
,
:title
]
if
index_exists?
(
:labels
,
[
:group_id
,
:project_id
,
:title
],
unique:
true
)
add_concurrent_index
:labels
,
:project_id
add_concurrent_index
:labels
,
:title
end
end
db/schema.rb
View file @
074c9649
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20161017
095000
)
do
ActiveRecord
::
Schema
.
define
(
version:
20161017
125927
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -543,9 +543,8 @@ ActiveRecord::Schema.define(version: 20161017095000) do
t
.
integer
"group_id"
end
add_index
"labels"
,
[
"group_id"
,
"project_id"
,
"title"
],
name:
"index_labels_on_group_id_and_project_id_and_title"
,
unique:
true
,
using: :btree
add_index
"labels"
,
[
"group_id"
],
name:
"index_labels_on_group_id"
,
using: :btree
add_index
"labels"
,
[
"project_id"
],
name:
"index_labels_on_project_id"
,
using: :btree
add_index
"labels"
,
[
"title"
],
name:
"index_labels_on_title"
,
using: :btree
create_table
"lfs_objects"
,
force: :cascade
do
|
t
|
t
.
string
"oid"
,
null:
false
...
...
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