diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-19 17:21:39 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:24 -0200 |
commit | 398ab263fd08a5d9d7b19c5b3d06f33814a474eb (patch) | |
tree | 5a7249f72bdec65e87abb597f22a68afa9fb9f74 /app/controllers | |
parent | d5a595b59702489c0b1026a0951157b8cfd3d65c (diff) | |
download | gitlab-ce-398ab263fd08a5d9d7b19c5b3d06f33814a474eb.tar.gz |
Allow users to apply group labels on Issues/MRs
Diffstat (limited to 'app/controllers')
4 files changed, 15 insertions, 6 deletions
diff --git a/app/controllers/dashboard/labels_controller.rb b/app/controllers/dashboard/labels_controller.rb index 2a88350a4ca..797f8503b2d 100644 --- a/app/controllers/dashboard/labels_controller.rb +++ b/app/controllers/dashboard/labels_controller.rb @@ -1,6 +1,9 @@ class Dashboard::LabelsController < Dashboard::ApplicationController def index - labels = Label.where(project_id: projects).select(:id, :title, :color).uniq(:title) + labels = LabelsFinder.new(current_user, project_id: projects) + .execute + .select(:id, :title, :color) + .uniq(:title) respond_to do |format| format.json { render json: labels } diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 96041b07647..d85bc85092f 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -25,8 +25,7 @@ class Projects::IssuesController < Projects::ApplicationController def index @issues = issues_collection @issues = @issues.page(params[:page]) - - @labels = @project.labels.where(title: params[:label_name]) + @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute if params[:label_name].presence respond_to do |format| format.html @@ -45,11 +44,15 @@ class Projects::IssuesController < Projects::ApplicationController assignee_id: "" ) - @issue = @noteable = @project.issues.new(issue_params) + @issue = @noteable = @project.issues.new(issue_params) + @labels = LabelsFinder.new(current_user, project_id: @project.id).execute + respond_with(@issue) end def edit + @labels = LabelsFinder.new(current_user, project_id: @project.id).execute + respond_with(@issue) end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index a6626df4826..35224f965bf 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -17,7 +17,7 @@ class Projects::LabelsController < Projects::ApplicationController respond_to do |format| format.html format.json do - render json: @project.labels + render json: LabelsFinder.new(current_user, project_id: @project.id).execute end end end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 04386258c19..c8970155497 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -40,7 +40,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController @merge_requests = @merge_requests.page(params[:page]) @merge_requests = @merge_requests.preload(:target_project) - @labels = @project.labels.where(title: params[:label_name]) + @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute if params[:label_name].presence respond_to do |format| format.html @@ -263,6 +263,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController @source_project = @merge_request.source_project @target_project = @merge_request.target_project @target_branches = @merge_request.target_project.repository.branch_names + @labels = LabelsFinder.new(current_user, project_id: @project.id).execute end def update @@ -575,6 +576,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController @note_counts = Note.where(commit_id: @commits.map(&:id)). group(:commit_id).count + @labels = LabelsFinder.new(current_user, project_id: @project.id).execute + define_pipelines_vars end |