summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-09-20 00:09:57 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-19 14:58:24 -0200
commitbdb7bf4b5188ffd68e54cbf671ba9ce1a4ffb1d1 (patch)
tree3f53930ff56ab0cfeceb0ab3af75fe9b75fefebd /app/controllers
parentbf9d928b45516e716b0f7f099361ca03aa1454f8 (diff)
downloadgitlab-ce-bdb7bf4b5188ffd68e54cbf671ba9ce1a4ffb1d1.tar.gz
List group labels on project labels page
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/groups/labels_controller.rb20
-rw-r--r--app/controllers/projects/application_controller.rb4
-rw-r--r--app/controllers/projects/issues_controller.rb4
-rw-r--r--app/controllers/projects/labels_controller.rb11
-rw-r--r--app/controllers/projects/merge_requests_controller.rb2
5 files changed, 34 insertions, 7 deletions
diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb
index 449298f51a8..0ec2fcda0ef 100644
--- a/app/controllers/groups/labels_controller.rb
+++ b/app/controllers/groups/labels_controller.rb
@@ -3,6 +3,7 @@ class Groups::LabelsController < Groups::ApplicationController
before_action :label, only: [:edit, :update, :destroy, :toggle_subscription]
before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :destroy]
+ before_action :save_previous_label_path, only: [:edit]
respond_to :html
@@ -25,11 +26,12 @@ class Groups::LabelsController < Groups::ApplicationController
end
def edit
+ @previous_labels_path = previous_labels_path
end
def update
if @label.update_attributes(label_params)
- redirect_to group_labels_path(@group)
+ redirect_back_or_group_labels_path
else
render :edit
end
@@ -64,4 +66,20 @@ class Groups::LabelsController < Groups::ApplicationController
def label_params
params.require(:label).permit(:title, :description, :color)
end
+
+ def redirect_back_or_group_labels_path(options = {})
+ redirect_to previous_labels_path, options
+ end
+
+ def previous_labels_path
+ session.fetch(:previous_labels_path, fallback_path)
+ end
+
+ def fallback_path
+ group_labels_path(@group)
+ end
+
+ def save_previous_label_path
+ session[:previous_labels_path] = URI(request.referer || '').path
+ end
end
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index b2ff36f6538..5daf4311cc8 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -44,6 +44,10 @@ class Projects::ApplicationController < ApplicationController
@project
end
+ def project_labels
+ @project_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
+ end
+
def repository
@repository ||= project.repository
end
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 4f6d7ca80df..1558426e1a4 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -48,13 +48,13 @@ class Projects::IssuesController < Projects::ApplicationController
)
@issue = @noteable = @project.issues.new(issue_params)
- @labels = LabelsFinder.new(current_user, project_id: @project.id).execute
+ @labels = project_labels
respond_with(@issue)
end
def edit
- @labels = LabelsFinder.new(current_user, project_id: @project.id).execute
+ @labels = project_labels
respond_with(@issue)
end
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 35224f965bf..3db3c091da6 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -11,13 +11,15 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to :js, :html
def index
+ @project_labels = project_labels
+ @prioritized_labels = project_labels.prioritized
+ @group_labels = @project.group.labels.unprioritized if @project.group.present?
@labels = @project.labels.unprioritized.page(params[:page])
- @prioritized_labels = @project.labels.prioritized
respond_to do |format|
format.html
format.json do
- render json: LabelsFinder.new(current_user, project_id: @project.id).execute
+ render json: @project_labels
end
end
end
@@ -68,6 +70,7 @@ class Projects::LabelsController < Projects::ApplicationController
def destroy
@label.destroy
+ @project_labels = project_labels
respond_to do |format|
format.html do
@@ -80,6 +83,8 @@ class Projects::LabelsController < Projects::ApplicationController
def remove_priority
respond_to do |format|
+ label = project_labels.find(params[:id])
+
if label.update_attribute(:priority, nil)
format.json { render json: label }
else
@@ -92,7 +97,7 @@ class Projects::LabelsController < Projects::ApplicationController
def set_priorities
Label.transaction do
params[:label_ids].each_with_index do |label_id, index|
- label = @project.labels.find_by_id(label_id)
+ label = project_labels.find_by_id(label_id)
label.update_attribute(:priority, index) if label
end
end
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index c8970155497..291c3f64914 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -263,7 +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
+ @labels = project_labels
end
def update