diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-09-06 13:18:53 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-09-06 13:18:53 +0100 |
commit | 0e1404d441b0db532046d50dcbaf754ff4d3a77e (patch) | |
tree | 87a5b482c31e846d5e799291aa9852a008732c2a /app/controllers/projects/issues_controller.rb | |
parent | fa0f9d60e2be51261f4f58c25d75229ba996659d (diff) | |
parent | ba302454e1191f28453929df80e13c4dd418f8c7 (diff) | |
download | gitlab-ce-collapsable-pipeline-settings.tar.gz |
Merge branch 'master' into collapsable-pipeline-settingscollapsable-pipeline-settings
* master: (260 commits)
Enable auto-retry in GitLab CI/CD pipeline
Clean up new navigation templates
Wait for gitaly to boot during tests
Update 'Visibility of pipelines'
refactored code
Fix note resolution specs
Add author and MR to changelog
Tidy up projects API specs
Resolve outdated diff discussions on push
Fix migration
change collapse to resolve and comments to discussions
add unit tests for new collapse_outdated_diff_comments toggle
Add functionality to collapse outdated diff comments regardless of discussion resolution
refactor code based on feedback
fix spec failures
Use flexbox for prometheus graph row grouping instead of bootstrap classes
Fix wrong API status codes
small refactor
Hide admin link from default search results for non-admins
Make search dropdowns consistent
...
Diffstat (limited to 'app/controllers/projects/issues_controller.rb')
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 349b19f72e2..dc9e6f71152 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -15,7 +15,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action :authorize_create_issue!, only: [:new, :create] # Allow modify issue - before_action :authorize_update_issue!, only: [:edit, :update] + before_action :authorize_update_issue!, only: [:edit, :update, :move] # Allow create a new branch and empty WIP merge request from current issue before_action :authorize_create_merge_request!, only: [:create_merge_request] @@ -27,10 +27,9 @@ class Projects::IssuesController < Projects::ApplicationController @issues = issues_collection @issues = @issues.page(params[:page]) @issuable_meta_data = issuable_meta_data(@issues, @collection_type) + @total_pages = issues_page_count(@issues) - if @issues.out_of_range? && @issues.total_pages != 0 - return redirect_to url_for(params.merge(page: @issues.total_pages, only_path: true)) - end + return if redirect_out_of_range(@issues, @total_pages) if params[:label_name].present? @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute @@ -142,25 +141,33 @@ class Projects::IssuesController < Projects::ApplicationController @issue = Issues::UpdateService.new(project, current_user, update_params).execute(issue) + respond_to do |format| + format.html do + recaptcha_check_with_fallback { render :edit } + end + + format.json do + render_issue_json + end + end + + rescue ActiveRecord::StaleObjectError + render_conflict_response + end + + def move + params.require(:move_to_project_id) + if params[:move_to_project_id].to_i > 0 new_project = Project.find(params[:move_to_project_id]) return render_404 unless issue.can_move?(current_user, new_project) - move_service = Issues::MoveService.new(project, current_user) - @issue = move_service.execute(@issue, new_project) + @issue = Issues::UpdateService.new(project, current_user, target_project: new_project).execute(issue) end respond_to do |format| - format.html do - recaptcha_check_with_fallback { render :edit } - end - format.json do - if @issue.valid? - render json: serializer.represent(@issue) - else - render json: { errors: @issue.errors.full_messages }, status: :unprocessable_entity - end + render_issue_json end end @@ -271,6 +278,14 @@ class Projects::IssuesController < Projects::ApplicationController return render_404 unless @project.feature_available?(:issues, current_user) end + def render_issue_json + if @issue.valid? + render json: serializer.represent(@issue) + else + render json: { errors: @issue.errors.full_messages }, status: :unprocessable_entity + end + end + def issue_params params.require(:issue).permit(*issue_params_attributes) end |