diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/membership_actions.rb | 9 | ||||
-rw-r--r-- | app/controllers/dashboard/groups_controller.rb | 28 | ||||
-rw-r--r-- | app/controllers/projects/blob_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/projects/pipeline_schedules_controller.rb | 4 |
5 files changed, 41 insertions, 20 deletions
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index cefb9b4e766..8d07780f6c2 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -52,9 +52,14 @@ module MembershipActions "You left the \"#{membershipable.human_name}\" #{source_type}." end - redirect_path = member.request? ? member.source : [:dashboard, membershipable.class.to_s.tableize] + respond_to do |format| + format.html do + redirect_path = member.request? ? member.source : [:dashboard, membershipable.class.to_s.tableize] + redirect_to redirect_path, notice: notice + end - redirect_to redirect_path, notice: notice + format.json { render json: { notice: notice } } + end end protected diff --git a/app/controllers/dashboard/groups_controller.rb b/app/controllers/dashboard/groups_controller.rb index d03265e9f20..742157d113d 100644 --- a/app/controllers/dashboard/groups_controller.rb +++ b/app/controllers/dashboard/groups_controller.rb @@ -1,16 +1,30 @@ class Dashboard::GroupsController < Dashboard::ApplicationController def index - @group_members = current_user.group_members.includes(source: :route).joins(:group) - @group_members = @group_members.merge(Group.search(params[:filter_groups])) if params[:filter_groups].present? - @group_members = @group_members.merge(Group.sort(@sort = params[:sort])) - @group_members = @group_members.page(params[:page]) + @groups = + if params[:parent_id] && Group.supports_nested_groups? + parent = Group.find_by(id: params[:parent_id]) + + if can?(current_user, :read_group, parent) + GroupsFinder.new(current_user, parent: parent).execute + else + Group.none + end + else + current_user.groups + end + + @groups = @groups.search(params[:filter_groups]) if params[:filter_groups].present? + @groups = @groups.includes(:route) + @groups = @groups.sort(@sort = params[:sort]) + @groups = @groups.page(params[:page]) respond_to do |format| format.html format.json do - render json: { - html: view_to_html_string("dashboard/groups/_groups", locals: { group_members: @group_members }) - } + render json: GroupSerializer + .new(current_user: @current_user) + .with_pagination(request, response) + .represent(@groups) end end end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 7025c7a1de6..d8d14ea1fed 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -55,7 +55,7 @@ class Projects::BlobController < Projects::ApplicationController def edit if can_collaborate_with_project? - blob.load_all_data!(@repository) + blob.load_all_data! else redirect_to action: 'show' end @@ -74,7 +74,7 @@ class Projects::BlobController < Projects::ApplicationController def preview @content = params[:content] - @blob.load_all_data!(@repository) + @blob.load_all_data! diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true) diff_lines = diffy.diff.scan(/.*\n/)[2..-1] diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines) @@ -93,9 +93,11 @@ class Projects::BlobController < Projects::ApplicationController def diff apply_diff_view_cookie! - @form = UnfoldForm.new(params) - @lines = Gitlab::Highlight.highlight_lines(repository, @ref, @path) - @lines = @lines[@form.since - 1..@form.to - 1] + @blob.load_all_data! + @lines = Gitlab::Highlight.highlight(@blob.path, @blob.data, repository: @repository).lines + + @form = UnfoldForm.new(params) + @lines = @lines[@form.since - 1..@form.to - 1].map(&:html_safe) if @form.bottom? @match_line = '' @@ -111,7 +113,7 @@ class Projects::BlobController < Projects::ApplicationController private def blob - @blob ||= Blob.decorate(@repository.blob_at(@commit.id, @path), @project) + @blob ||= @repository.blob_at(@commit.id, @path) if @blob @blob diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index ac151839f61..1beac202efe 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -8,7 +8,7 @@ class Projects::LabelsController < Projects::ApplicationController before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update, :generate, :destroy, :remove_priority, :set_priorities] - before_action :authorize_admin_group!, only: [:promote] + before_action :authorize_admin_group_labels!, only: [:promote] respond_to :js, :html @@ -161,7 +161,7 @@ class Projects::LabelsController < Projects::ApplicationController return render_404 unless can?(current_user, :admin_label, @project) end - def authorize_admin_group! - return render_404 unless can?(current_user, :admin_group, @project.group) + def authorize_admin_group_labels! + return render_404 unless can?(current_user, :admin_label, @project.group) end end diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 2662a146968..ef4f083b98f 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -43,7 +43,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController if schedule.update(owner: current_user) redirect_to pipeline_schedules_path(@project) else - redirect_to pipeline_schedules_path(@project), alert: "Failed to change the owner" + redirect_to pipeline_schedules_path(@project), alert: _("Failed to change the owner") end end @@ -53,7 +53,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController else redirect_to pipeline_schedules_path(@project), status: 302, - alert: "Failed to remove the pipeline schedule" + alert: _("Failed to remove the pipeline schedule") end end |