diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 15:15:39 +0300 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 15:15:39 +0300 |
| commit | 593df8e69a81a3ab0a4755db74dc282c00e02ef5 (patch) | |
| tree | cdbec00afa3289a9fe4065a8c7ba56e5c82a365f /app | |
| parent | cc331684593143cba773b0160222865eeb86b134 (diff) | |
| download | gitlab-ce-593df8e69a81a3ab0a4755db74dc282c00e02ef5.tar.gz | |
Improve labels
* allow developers to manage labels
* add ability to remove label
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/sections/issues.scss | 2 | ||||
| -rw-r--r-- | app/assets/stylesheets/sections/labels.scss | 4 | ||||
| -rw-r--r-- | app/controllers/projects/labels_controller.rb | 13 | ||||
| -rw-r--r-- | app/helpers/labels_helper.rb | 2 | ||||
| -rw-r--r-- | app/models/ability.rb | 2 | ||||
| -rw-r--r-- | app/models/label.rb | 5 | ||||
| -rw-r--r-- | app/views/projects/labels/_label.html.haml | 8 |
7 files changed, 28 insertions, 8 deletions
diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index f637d66f1bc..a7fa715d2e0 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -94,7 +94,7 @@ } } -.issue-show-labels .label { +.issue-show-labels .color-label { padding: 6px 10px; } diff --git a/app/assets/stylesheets/sections/labels.scss b/app/assets/stylesheets/sections/labels.scss index 96f32d78f5c..d1590e42fcb 100644 --- a/app/assets/stylesheets/sections/labels.scss +++ b/app/assets/stylesheets/sections/labels.scss @@ -15,3 +15,7 @@ font-size: 14px; } } + +.color-label { + padding: 3px 4px; +} diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 4d0723a26df..14194b3963c 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,18 +1,17 @@ class Projects::LabelsController < Projects::ApplicationController before_filter :module_enabled - before_filter :label, only: [:edit, :update] + before_filter :label, only: [:edit, :update, :destroy] before_filter :authorize_labels! - before_filter :authorize_admin_labels!, only: [:edit, :update, :new, :create, :destroy] + before_filter :authorize_admin_labels!, except: [:index] respond_to :js, :html def index - @labels = @project.labels + @labels = @project.labels.order('title ASC').page(params[:page]).per(20) end def new @label = @project.labels.new - end def create @@ -48,6 +47,12 @@ class Projects::LabelsController < Projects::ApplicationController end end + def destroy + @label.destroy + + redirect_to project_labels_path(@project), notice: 'Label was removed' + end + protected def module_enabled diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index b4082d625f3..17c87f5c762 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -13,7 +13,7 @@ module LabelsHelper text_color = "#FFF" end - content_tag :span, class: 'label', style: "background:#{label_color};color:#{text_color}" do + content_tag :span, class: 'label color-label', style: "background:#{label_color};color:#{text_color}" do label.name end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 09a652ecaad..f1d57de63bb 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -142,6 +142,7 @@ class Ability :write_wiki, :modify_issue, :admin_issue, + :admin_label, :push_code ] end @@ -164,7 +165,6 @@ class Ability :modify_merge_request, :admin_issue, :admin_milestone, - :admin_label, :admin_project_snippet, :admin_team_member, :admin_merge_request, diff --git a/app/models/label.rb b/app/models/label.rb index ea1daa6a204..5d6e5e91a0c 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -1,6 +1,7 @@ class Label < ActiveRecord::Base belongs_to :project has_many :label_links, dependent: :destroy + has_many :issues, through: :label_links, source: :target, source_type: 'Issue' validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true validates :project, presence: true @@ -11,4 +12,8 @@ class Label < ActiveRecord::Base def name title end + + def open_issues_count + issues.opened.count + end end diff --git a/app/views/projects/labels/_label.html.haml b/app/views/projects/labels/_label.html.haml index 59bf31314e7..488f86a3ce1 100644 --- a/app/views/projects/labels/_label.html.haml +++ b/app/views/projects/labels/_label.html.haml @@ -1,4 +1,10 @@ %li = render_colored_label(label) .pull-right - = link_to 'Edit', edit_project_label_path(@project, label), class: 'btn' + %strong.append-right-20 + = link_to project_issues_path(@project, label_name: label.name) do + = pluralize label.open_issues_count, 'open issue' + + - if can? current_user, :admin_label, @project + = link_to 'Edit', edit_project_label_path(@project, label), class: 'btn' + = link_to 'Remove', project_label_path(@project, label), class: 'btn btn-remove', method: :delete, data: {confirm: "Remove this label? Are you sure?"} |
