diff options
| author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 12:24:19 +0000 |
|---|---|---|
| committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-28 12:24:19 +0000 |
| commit | 72cb3bee798655c2d370dfedf3c04665aaa43aa3 (patch) | |
| tree | 4f57c272abd6067ed3dfdf38bca9220b3ea13bf5 /app/controllers/projects | |
| parent | 70c1d0352e39c3c04caaa3082c3ffb4ad5c29b32 (diff) | |
| download | gitlab-ce-72cb3bee798655c2d370dfedf3c04665aaa43aa3.tar.gz | |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects')
| -rw-r--r-- | app/controllers/projects/pipelines_controller.rb | 31 | ||||
| -rw-r--r-- | app/controllers/projects/settings/repository_controller.rb | 17 |
2 files changed, 19 insertions, 29 deletions
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 30f582f90a5..39ebcd60e9a 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -265,29 +265,34 @@ class Projects::PipelinesController < Projects::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def pipeline - @pipeline ||= if params[:id].blank? && params[:latest] - latest_pipeline - else - project - .all_pipelines - .includes(builds: :tags, user: :status) - .find(params[:id]) - .present(current_user: current_user) - end + return @pipeline if defined?(@pipeline) + + pipelines = + if find_latest_pipeline? + project.latest_pipelines(params['ref']) + else + project.all_pipelines.id_in(params[:id]) + end + + @pipeline = pipelines + .includes(builds: :tags, user: :status) + .take + &.present(current_user: current_user) + + @pipeline || not_found end # rubocop: enable CodeReuse/ActiveRecord def set_pipeline_path - @pipeline_path ||= if params[:id].blank? && params[:latest] + @pipeline_path ||= if find_latest_pipeline? latest_project_pipelines_path(@project, params['ref']) else project_pipeline_path(@project, @pipeline) end end - def latest_pipeline - @project.latest_pipeline(params['ref']) - &.present(current_user: current_user) + def find_latest_pipeline? + params[:id].blank? && params[:latest] end def disable_query_limiting diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index 5adfab55bf4..a6f4e2fcd73 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -122,21 +122,6 @@ module Projects ] end - def access_levels_options - { - create_access_levels: levels_for_dropdown, - push_access_levels: levels_for_dropdown, - merge_access_levels: levels_for_dropdown - } - end - - def levels_for_dropdown - roles = ProtectedRef::AccessLevel.human_access_levels.map do |id, text| - { id: id, text: text, before_divider: true } - end - { roles: roles } - end - def protectable_tags_for_dropdown { open_tags: ProtectableDropdown.new(@project, :tags).hash } end @@ -154,7 +139,7 @@ module Projects def load_gon_index gon.push(protectable_tags_for_dropdown) gon.push(protectable_branches_for_dropdown) - gon.push(access_levels_options) + gon.push(helpers.protected_access_levels_for_dropdowns) gon.push(current_project_id: project.id) if project end end |
