diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/labels.scss | 2 | ||||
-rw-r--r-- | app/controllers/admin/labels_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/concerns/issues_action.rb | 2 | ||||
-rw-r--r-- | app/controllers/concerns/merge_requests_action.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 2 | ||||
-rw-r--r-- | app/finders/issuable_finder.rb | 20 | ||||
-rw-r--r-- | app/models/label.rb | 15 | ||||
-rw-r--r-- | app/views/admin/labels/_form.html.haml | 4 | ||||
-rw-r--r-- | app/views/admin/labels/_label.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/labels/_form.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/labels/_label.html.haml | 3 | ||||
-rw-r--r-- | app/views/shared/_label_row.html.haml | 4 | ||||
-rw-r--r-- | app/views/shared/issuable/_filter.html.haml | 4 | ||||
-rw-r--r-- | db/migrate/20160217100506_add_description_to_label.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 5 |
18 files changed, 70 insertions, 19 deletions
diff --git a/CHANGELOG b/CHANGELOG index 11a88588be6..8a95909eee9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -73,6 +73,8 @@ v 8.5.0 (unreleased) - Make it possible to erase a build (trace, artifacts) using UI and API - Ability to revert changes from a Merge Request or Commit - Emoji comment on diffs are not award emoji + - Add label description (Nuttanart Pornprasitsakul) + - Show label row when filtering issues or merge requests by label (Nuttanart Pornprasitsakul) v 8.4.4 - Update omniauth-saml gem to 1.4.2 diff --git a/app/assets/stylesheets/pages/labels.scss b/app/assets/stylesheets/pages/labels.scss index d1590e42fcb..1c78aafdb87 100644 --- a/app/assets/stylesheets/pages/labels.scss +++ b/app/assets/stylesheets/pages/labels.scss @@ -9,7 +9,7 @@ } } -.manage-labels-list { +.label-row { .label { padding: 9px; font-size: 14px; diff --git a/app/controllers/admin/labels_controller.rb b/app/controllers/admin/labels_controller.rb index 3b070e65d0d..d79ce2b10fe 100644 --- a/app/controllers/admin/labels_controller.rb +++ b/app/controllers/admin/labels_controller.rb @@ -53,6 +53,6 @@ class Admin::LabelsController < Admin::ApplicationController end def label_params - params[:label].permit(:title, :color) + params[:label].permit(:title, :description, :color) end end diff --git a/app/controllers/concerns/issues_action.rb b/app/controllers/concerns/issues_action.rb index effd4721949..5b098628557 100644 --- a/app/controllers/concerns/issues_action.rb +++ b/app/controllers/concerns/issues_action.rb @@ -6,6 +6,8 @@ module IssuesAction @issues = @issues.page(params[:page]).per(ApplicationController::PER_PAGE) @issues = @issues.preload(:author, :project) + @label = @issuable_finder.labels.first + respond_to do |format| format.html format.atom { render layout: false } diff --git a/app/controllers/concerns/merge_requests_action.rb b/app/controllers/concerns/merge_requests_action.rb index f7a25111db9..f6de696e84d 100644 --- a/app/controllers/concerns/merge_requests_action.rb +++ b/app/controllers/concerns/merge_requests_action.rb @@ -5,5 +5,7 @@ module MergeRequestsAction @merge_requests = get_merge_requests_collection @merge_requests = @merge_requests.page(params[:page]).per(ApplicationController::PER_PAGE) @merge_requests = @merge_requests.preload(:author, :target_project) + + @label = @issuable_finder.labels.first end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 68244883803..67faa1e4437 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -32,6 +32,7 @@ class Projects::IssuesController < Projects::ApplicationController end @issues = @issues.page(params[:page]).per(PER_PAGE) + @label = @project.labels.find_by(title: params[:label_name]) respond_to do |format| format.html diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 86d6e3e0f6b..ecac3c395ec 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -69,7 +69,7 @@ class Projects::LabelsController < Projects::ApplicationController end def label_params - params.require(:label).permit(:title, :color) + params.require(:label).permit(:title, :description, :color) end def label diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 9d588c370aa..86b8e7bdf2e 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -34,6 +34,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE) @merge_requests = @merge_requests.preload(:target_project) + @label = @project.labels.find_by(title: params[:label_name]) + respond_to do |format| format.html format.json do diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 0a4192e6bac..f7240edd618 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -119,6 +119,20 @@ class IssuableFinder labels? && params[:label_name] == Label::None.title end + def labels + return @labels if defined?(@labels) + + if labels? && !filter_by_no_label? + @labels = Label.where(title: label_names) + + if projects + @labels = @labels.where(project: projects) + end + else + @labels = Label.none + end + end + def assignee? params[:assignee_id].present? end @@ -253,8 +267,6 @@ class IssuableFinder joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{klass.name}' AND label_links.target_id = #{klass.table_name}.id"). where(label_links: { id: nil }) else - label_names = params[:label_name].split(",") - items = items.joins(:labels).where(labels: { title: label_names }) if projects @@ -266,6 +278,10 @@ class IssuableFinder items end + def label_names + params[:label_name].split(',') + end + def current_user_related? params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me' end diff --git a/app/models/label.rb b/app/models/label.rb index f93ce7e1c89..07a1db4abe5 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -2,13 +2,14 @@ # # Table name: labels # -# id :integer not null, primary key -# title :string(255) -# color :string(255) -# project_id :integer -# created_at :datetime -# updated_at :datetime -# template :boolean default(FALSE) +# id :integer not null, primary key +# title :string(255) +# color :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# template :boolean default(FALSE) +# description :string(255) # class Label < ActiveRecord::Base diff --git a/app/views/admin/labels/_form.html.haml b/app/views/admin/labels/_form.html.haml index eaa94ed9e36..8c6b389bf15 100644 --- a/app/views/admin/labels/_form.html.haml +++ b/app/views/admin/labels/_form.html.haml @@ -12,6 +12,10 @@ .col-sm-10 = f.text_field :title, class: "form-control", required: true .form-group + = f.label :description, class: 'control-label' + .col-sm-10 + = f.text_field :description, class: "form-control js-quick-submit" + .form-group = f.label :color, "Background color", class: 'control-label' .col-sm-10 .input-group diff --git a/app/views/admin/labels/_label.html.haml b/app/views/admin/labels/_label.html.haml index e3ccbf6c3a8..5736a301910 100644 --- a/app/views/admin/labels/_label.html.haml +++ b/app/views/admin/labels/_label.html.haml @@ -1,5 +1,7 @@ %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 'Delete', admin_label_path(label), class: 'btn btn-sm btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Delete this label? Are you sure?"} + .label-row + = render_colored_label(label) + = markdown(label.description, pipeline: :single_line) + .pull-right + = link_to 'Edit', edit_admin_label_path(label), class: 'btn btn-sm' + = link_to 'Delete', admin_label_path(label), class: 'btn btn-sm btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Delete this label? Are you sure?"} diff --git a/app/views/projects/labels/_form.html.haml b/app/views/projects/labels/_form.html.haml index 5ce2a7b985d..d63d3a3ec20 100644 --- a/app/views/projects/labels/_form.html.haml +++ b/app/views/projects/labels/_form.html.haml @@ -12,6 +12,10 @@ .col-sm-10 = f.text_field :title, class: "form-control js-quick-submit", required: true, autofocus: true .form-group + = f.label :description, class: 'control-label' + .col-sm-10 + = f.text_field :description, class: "form-control js-quick-submit" + .form-group = f.label :color, "Background color", class: 'control-label' .col-sm-10 .input-group diff --git a/app/views/projects/labels/_label.html.haml b/app/views/projects/labels/_label.html.haml index b70a9fc9fe5..5b35acc66c0 100644 --- a/app/views/projects/labels/_label.html.haml +++ b/app/views/projects/labels/_label.html.haml @@ -1,5 +1,6 @@ %li{id: dom_id(label)} - = link_to_label(label) + = render "shared/label_row", label: label + .pull-right %strong.append-right-20 = link_to_label(label) do diff --git a/app/views/shared/_label_row.html.haml b/app/views/shared/_label_row.html.haml new file mode 100644 index 00000000000..8134b15d245 --- /dev/null +++ b/app/views/shared/_label_row.html.haml @@ -0,0 +1,4 @@ +%span.label-row + = link_to_label(label) + %span.prepend-left-10 + = markdown(label.description, pipeline: :single_line) diff --git a/app/views/shared/issuable/_filter.html.haml b/app/views/shared/issuable/_filter.html.haml index b7e350d27af..e55159d996b 100644 --- a/app/views/shared/issuable/_filter.html.haml +++ b/app/views/shared/issuable/_filter.html.haml @@ -41,6 +41,10 @@ .filter-item.inline = button_tag "Update issues", class: "btn update_selected_issues btn-save" +- if @label + .gray-content-block.second-block + = render "shared/label_row", label: @label + :javascript new UsersSelect(); $('form.filter-form').on('submit', function (event) { diff --git a/db/migrate/20160217100506_add_description_to_label.rb b/db/migrate/20160217100506_add_description_to_label.rb new file mode 100644 index 00000000000..eed6d1f236a --- /dev/null +++ b/db/migrate/20160217100506_add_description_to_label.rb @@ -0,0 +1,5 @@ +class AddDescriptionToLabel < ActiveRecord::Migration + def change + add_column :labels, :description, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 344c384b6d0..af5bac63b42 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160209130428) do +ActiveRecord::Schema.define(version: 20160217100506) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -445,7 +445,8 @@ ActiveRecord::Schema.define(version: 20160209130428) do t.integer "project_id" t.datetime "created_at" t.datetime "updated_at" - t.boolean "template", default: false + t.boolean "template", default: false + t.string "description" end add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree |