diff options
Diffstat (limited to 'app/controllers/dashboard')
-rw-r--r-- | app/controllers/dashboard/milestones_controller.rb | 32 | ||||
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 10 |
2 files changed, 14 insertions, 28 deletions
diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb index d34a07324da..14f9a026688 100644 --- a/app/controllers/dashboard/milestones_controller.rb +++ b/app/controllers/dashboard/milestones_controller.rb @@ -1,48 +1,32 @@ # frozen_string_literal: true class Dashboard::MilestonesController < Dashboard::ApplicationController - include MilestoneActions - before_action :projects before_action :groups, only: :index - before_action :milestone, only: [:show, :merge_requests, :participants, :labels] def index respond_to do |format| format.html do - @milestone_states = Milestone.states_count(@projects.select(:id), @groups.select(:id)) - @milestones = Kaminari.paginate_array(milestones).page(params[:page]) + @milestone_states = Milestone.states_count(@projects.select(:id), groups.select(:id)) + @milestones = milestones.page(params[:page]) end format.json do - render json: milestones + render json: milestones.to_json(only: [:id, :title], methods: :name) end end end - def show - end - private - def group_milestones - DashboardGroupMilestone.build_collection(groups, params) - end - - # See [#39545](https://gitlab.com/gitlab-org/gitlab-foss/issues/39545) for info about the deprecation of dynamic milestones - def dynamic_milestones - DashboardMilestone.build_collection(@projects, params) - end - def milestones - @milestones = group_milestones + dynamic_milestones - end - - def milestone - @milestone = DashboardMilestone.build(@projects, params[:title]) - render_404 unless @milestone + MilestonesFinder.new(search_params).execute end def groups @groups ||= GroupsFinder.new(current_user, all_available: false).execute end + + def search_params + params.permit(:state, :search_title).merge(group_ids: groups, project_ids: projects) + end end diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index ebee8e9094e..8a8064b24c2 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -17,7 +17,9 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def destroy - TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user) + todo = current_user.todos.find(params[:id]) + + TodoService.new.resolve_todo(todo, current_user, resolved_by_action: :mark_done) respond_to do |format| format.html do @@ -31,7 +33,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def destroy_all - updated_ids = TodoService.new.mark_todos_as_done(@todos, current_user) + updated_ids = TodoService.new.resolve_todos(@todos, current_user, resolved_by_action: :mark_all_done) respond_to do |format| format.html { redirect_to dashboard_todos_path, status: :found, notice: _('Everything on your to-do list is marked as done.') } @@ -41,13 +43,13 @@ class Dashboard::TodosController < Dashboard::ApplicationController end def restore - TodoService.new.mark_todos_as_pending_by_ids(params[:id], current_user) + TodoService.new.restore_todo(current_user.todos.find(params[:id]), current_user) render json: todos_counts end def bulk_restore - TodoService.new.mark_todos_as_pending_by_ids(params[:ids], current_user) + TodoService.new.restore_todos(current_user.todos.for_ids(params[:ids]), current_user) render json: todos_counts end |