diff --git a/app/assets/javascripts/angular-new/issues/issues_controller.js.coffee b/app/assets/javascripts/angular-new/issues/issues_controller.js.coffee index b4949d80d..76830cda7 100644 --- a/app/assets/javascripts/angular-new/issues/issues_controller.js.coffee +++ b/app/assets/javascripts/angular-new/issues/issues_controller.js.coffee @@ -91,7 +91,6 @@ IssuesController = (dataservice, $http, $location, Issue, $rootScope) -> vm.filter.status_open = true setSortClass() - getIssues() init(dataservice) true diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index d23e3551e..b0d99df32 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -9,57 +9,59 @@ class Projects::IssuesController < Projects::BaseController layout false, only: [:update, :search_collaborators] - def index(status = 200) + def index params[:kind] ||= 'issues' params[:filter] ||= 'all' params[:sort] ||= :updated - respond_to do |format| - format.html {} - format.json do - if params[:kind] == 'pull_requests' - all_issues = @project.issues.joins(:pull_request) - else - all_issues = @project.issues.without_pull_requests - end - - @all_issues = all_issues - if current_user - @created_issues = all_issues.where(user_id: current_user) - @assigned_issues = all_issues.where(assignee_id: current_user) - end - - case params[:filter] - when 'created' - @issues = @created_issues - when 'assigned' - @issues = @assigned_issues - else - @issues = all_issues - end - - if params[:labels].is_a?(Array) && params[:labels].present? - @issues = @issues.joins(:labels).where(labels: {name: params[:labels]}) - else - params[:labels] = [] - end - - @opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged - - params[:status] = params[:status] == 'closed' ? :closed : :open - @issues = @issues.send( params[:status] == :closed ? :closed_or_merged : :not_closed_or_merged ) - - params[:direction] = params[:direction] == 'asc' ? :asc : :desc - if params[:sort] == 'submitted' - @issues = @issues.order(created_at: params[:direction]) - else - @issues = @issues.order(updated_at: params[:direction]) - end - - @issues = @issues.includes(:assignee, :user, :pull_request).uniq - .paginate(page: current_page) - end + if params[:kind] == 'pull_requests' + all_issues = @project.issues.joins(:pull_request) + else + all_issues = @project.issues.without_pull_requests end + + @all_issues = all_issues + if current_user + @created_issues = all_issues.where(user_id: current_user) + @assigned_issues = all_issues.where(assignee_id: current_user) + end + + case params[:filter] + when 'created' + @issues = @created_issues + when 'assigned' + @issues = @assigned_issues + else + @issues = all_issues + end + + if params[:labels].is_a?(Array) && params[:labels].present? + @issues = @issues.joins(:labels).where(labels: {name: params[:labels]}) + else + params[:labels] = [] + end + + @opened_issues, @closed_issues = @issues.not_closed_or_merged, @issues.closed_or_merged + + params[:status] = params[:status] == 'closed' ? :closed : :open + @issues = @issues.send( params[:status] == :closed ? :closed_or_merged : :not_closed_or_merged ) + + params[:direction] = params[:direction] == 'asc' ? :asc : :desc + if params[:sort] == 'submitted' + @issues = @issues.order(created_at: params[:direction]) + else + @issues = @issues.order(updated_at: params[:direction]) + end + + @issues = @issues.includes(:assignee, :user, :pull_request).uniq + .paginate(page: current_page) + + render 'index' + end + + def pull_requests + params[:kind] = 'pull_requests' + index end def new diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 0ec5a95b2..59be9d0a2 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -95,12 +95,6 @@ class Projects::PullRequestsController < Projects::BaseController end end - def index(status = 200) - params[:kind] = 'pull_requests' - params[:filter] ||= 'all' - params[:sort] ||= :updated - end - def autocomplete_to_project items = [] term = params[:term].to_s.strip.downcase diff --git a/app/views/projects/base/_submenu.html.haml b/app/views/projects/base/_submenu.html.haml index c425e9909..32cc85a78 100644 --- a/app/views/projects/base/_submenu.html.haml +++ b/app/views/projects/base/_submenu.html.haml @@ -29,9 +29,9 @@ = link_to t('project_menu.builds'), project_build_lists_path(@project) - if @project.has_issues - %li{ class: ('active' if contr == :issues) } + %li{ class: ('active' if contr == :issues && act == :index) } = link_to t('project_menu.tracker', count: @opened_issues_count), project_issues_path(@project) - %li{ class: ('active' if contr == :pull_requests) } + %li{ class: ('active' if contr == :issues && act == :pull_requests) } =link_to t('project_menu.pull_requests', count: @opened_pull_requests_count), project_pull_requests_path(@project) - if @project.has_wiki %li{ class: ('active' if contr == :wiki) } diff --git a/app/views/projects/issues/_index.html.slim b/app/views/projects/issues/_index.html.slim deleted file mode 100644 index 05e61b8eb..000000000 --- a/app/views/projects/issues/_index.html.slim +++ /dev/null @@ -1,28 +0,0 @@ -- render 'submenu' - -.container ng-controller = 'IssuesController as issuesCtrl' ng-cloak = true - .row - .col-md-3.col-sm-4.offset20 - == render 'projects/issues/index_sidebar', project: @project - .col-md-9.col-sm-8.offset20 - tabset.boffset10 - tab[ heading = "#{t "layout.issues.statuses.open"} ({{issuesCtrl.filter.opened_count}})" - active = 'issuesCtrl.filter.status_open' - ng-click = "issuesCtrl.setIssuesStatus('open')" ] - tab[ heading = "#{t "layout.issues.statuses.closed"} ({{issuesCtrl.filter.closed_count}})" - active = 'issuesCtrl.filter.status_closed' - ng-click = "issuesCtrl.setIssuesStatus('closed')" ] - - .pull-right.boffset10 - button.btn.btn-default.roffset5[ type = 'button' - ng-click = "issuesCtrl.setIssuesSort('updated')" ] - span.fa ng-class = "issuesCtrl.updated_class" - => t('layout.issues.sort.updated') - button.btn.btn-default[ type = 'button' - ng-click = "issuesCtrl.setIssuesSort('submitted')" ] - span.fa ng-class = "issuesCtrl.submitted_class" - => t('layout.issues.sort.submitted') - == render 'projects/issues/issues_table' - -- content_for :additional_scripts do - == render 'projects/issues/init_service.js.erb' \ No newline at end of file diff --git a/app/views/projects/issues/_init_service.js.erb b/app/views/projects/issues/_init_service.js.erb index 8684e8666..40bd49a76 100644 --- a/app/views/projects/issues/_init_service.js.erb +++ b/app/views/projects/issues/_init_service.js.erb @@ -1,9 +1,12 @@ diff --git a/app/views/projects/issues/index.html.slim b/app/views/projects/issues/index.html.slim index 715e59f40..ad73542f4 100644 --- a/app/views/projects/issues/index.html.slim +++ b/app/views/projects/issues/index.html.slim @@ -1,2 +1,29 @@ -- set_meta_tags title: [title_object(@project), t('.title')] -== render 'index' +- set_meta_tags title: [title_object(@project), t("projects.#{params[:kind]}.title")] +- render 'submenu' + +.container ng-controller = 'IssuesController as issuesCtrl' ng-cloak = true + .row + .col-md-3.col-sm-4.offset20 + == render 'index_sidebar', project: @project + .col-md-9.col-sm-8.offset20 + tabset.boffset10 + tab[ heading = "#{t "layout.issues.statuses.open"} ({{issuesCtrl.filter.opened_count}})" + active = 'issuesCtrl.filter.status_open' + ng-click = "issuesCtrl.setIssuesStatus('open')" ] + tab[ heading = "#{t "layout.issues.statuses.closed"} ({{issuesCtrl.filter.closed_count}})" + active = 'issuesCtrl.filter.status_closed' + ng-click = "issuesCtrl.setIssuesStatus('closed')" ] + + .pull-right.boffset10 + button.btn.btn-default.roffset5[ type = 'button' + ng-click = "issuesCtrl.setIssuesSort('updated')" ] + span.fa ng-class = "issuesCtrl.updated_class" + => t('layout.issues.sort.updated') + button.btn.btn-default[ type = 'button' + ng-click = "issuesCtrl.setIssuesSort('submitted')" ] + span.fa ng-class = "issuesCtrl.submitted_class" + => t('layout.issues.sort.submitted') + == render 'issues_table' + +- content_for :additional_scripts do + == render 'init_service.js.erb' diff --git a/app/views/projects/pull_requests/index.html.slim b/app/views/projects/pull_requests/index.html.slim deleted file mode 100644 index d896c6b09..000000000 --- a/app/views/projects/pull_requests/index.html.slim +++ /dev/null @@ -1,2 +0,0 @@ -- set_meta_tags title: [title_object(@project), t('.title')] -== render 'projects/issues/index' diff --git a/config/routes.rb b/config/routes.rb index af366004a..8416506b8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -327,6 +327,8 @@ Rosa::Application.routes.draw do get :search_collaborators end end + get 'pull_requests' => 'issues#pull_requests', as: :pull_requests + post "/labels/:label_id" => "issues#destroy_label", as: :issues_delete_label post "/labels/:label_id/update" => "issues#update_label", as: :issues_update_label @@ -337,7 +339,7 @@ Rosa::Application.routes.draw do get :find, on: :collection end resources :hooks, except: :show - resources :pull_requests, except: :destroy do + resources :pull_requests, except: [:index, :destroy] do get :autocomplete_to_project, on: :collection put :merge, on: :member end