summaryrefslogtreecommitdiff
path: root/app/controllers/groups/milestones_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/groups/milestones_controller.rb')
-rw-r--r--app/controllers/groups/milestones_controller.rb71
1 files changed, 16 insertions, 55 deletions
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index 8cfbd293597..df3fb6b67c2 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -6,17 +6,17 @@ class Groups::MilestonesController < Groups::ApplicationController
before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy]
before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy]
before_action do
- push_frontend_feature_flag(:burnup_charts)
+ push_frontend_feature_flag(:burnup_charts, @group)
end
def index
respond_to do |format|
format.html do
- @milestone_states = Milestone.states_count(group_projects_with_access, [group])
- @milestones = Kaminari.paginate_array(milestones).page(params[:page])
+ @milestone_states = Milestone.states_count(group_projects_with_access.without_order, [group])
+ @milestones = milestones.page(params[:page])
end
format.json do
- render json: milestones.map { |m| m.for_display.slice(:id, :title, :name) }
+ render json: milestones.to_json(only: [:id, :title], methods: :name)
end
end
end
@@ -29,7 +29,7 @@ class Groups::MilestonesController < Groups::ApplicationController
@milestone = Milestones::CreateService.new(group, current_user, milestone_params).execute
if @milestone.persisted?
- redirect_to milestone_path
+ redirect_to milestone_path(@milestone)
else
render "new"
end
@@ -39,23 +39,15 @@ class Groups::MilestonesController < Groups::ApplicationController
end
def edit
- render_404 if @milestone.legacy_group_milestone?
end
def update
- # Keep this compatible with legacy group milestones where we have to update
- # all projects milestones states at once.
- milestones, update_params = get_milestones_for_update
- milestones.each do |milestone|
- Milestones::UpdateService.new(milestone.resource_parent, current_user, update_params).execute(milestone)
- end
+ Milestones::UpdateService.new(@milestone.parent, current_user, milestone_params).execute(@milestone)
- redirect_to milestone_path
+ redirect_to milestone_path(@milestone)
end
def destroy
- return render_404 if @milestone.legacy_group_milestone?
-
Milestones::DestroyService.new(group, current_user).execute(@milestone)
respond_to do |format|
@@ -66,14 +58,6 @@ class Groups::MilestonesController < Groups::ApplicationController
private
- def get_milestones_for_update
- if @milestone.legacy_group_milestone?
- [@milestone.milestones, legacy_milestone_params]
- else
- [[@milestone], milestone_params]
- end
- end
-
def authorize_admin_milestones!
return render_404 unless can?(current_user, :admin_milestone, group)
end
@@ -82,27 +66,21 @@ class Groups::MilestonesController < Groups::ApplicationController
params.require(:milestone).permit(:title, :description, :start_date, :due_date, :state_event)
end
- def legacy_milestone_params
- params.require(:milestone).permit(:state_event)
+ def milestones
+ MilestonesFinder.new(search_params).execute
end
- def milestone_path
- if @milestone.legacy_group_milestone?
- group_milestone_path(group, @milestone.safe_title, title: @milestone.title)
- else
- group_milestone_path(group, @milestone.iid)
- end
+ def milestone
+ @milestone = group.milestones.find_by_iid(params[:id])
+
+ render_404 unless @milestone
end
- def milestones
- milestones = MilestonesFinder.new(search_params).execute
+ def search_params
+ groups = request.format.json? ? group_ids(include_ancestors: true) : group_ids
@sort = params[:sort] || 'due_date_asc'
- MilestoneArray.sort(milestones + legacy_milestones, @sort)
- end
-
- def legacy_milestones
- GroupMilestone.build_collection(group, group_projects_with_access, params)
+ params.permit(:state, :search_title).merge(sort: @sort, group_ids: groups, project_ids: group_projects_with_access)
end
def group_projects_with_access
@@ -116,23 +94,6 @@ class Groups::MilestonesController < Groups::ApplicationController
group.self_and_descendants.public_or_visible_to_user(current_user).select(:id)
end
end
-
- def milestone
- @milestone =
- if params[:title]
- GroupMilestone.build(group, group_projects_with_access, params[:title])
- else
- group.milestones.find_by_iid(params[:id])
- end
-
- render_404 unless @milestone
- end
-
- def search_params
- groups = request.format.json? ? group_ids(include_ancestors: true) : group_ids
-
- params.permit(:state, :search_title).merge(group_ids: groups)
- end
end
Groups::MilestonesController.prepend_if_ee('EE::Groups::MilestonesController')