diff options
Diffstat (limited to 'app/finders/ci')
-rw-r--r-- | app/finders/ci/freeze_periods_finder.rb | 16 | ||||
-rw-r--r-- | app/finders/ci/jobs_finder.rb | 11 | ||||
-rw-r--r-- | app/finders/ci/pipelines_finder.rb | 10 | ||||
-rw-r--r-- | app/finders/ci/runners_finder.rb | 17 |
4 files changed, 51 insertions, 3 deletions
diff --git a/app/finders/ci/freeze_periods_finder.rb b/app/finders/ci/freeze_periods_finder.rb new file mode 100644 index 00000000000..91df776abe6 --- /dev/null +++ b/app/finders/ci/freeze_periods_finder.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Ci + class FreezePeriodsFinder + def initialize(project, current_user = nil) + @project = project + @current_user = current_user + end + + def execute + return Ci::FreezePeriod.none unless Ability.allowed?(@current_user, :read_freeze_period, @project) + + @project.freeze_periods + end + end +end diff --git a/app/finders/ci/jobs_finder.rb b/app/finders/ci/jobs_finder.rb index 152eb271694..1627e41a02d 100644 --- a/app/finders/ci/jobs_finder.rb +++ b/app/finders/ci/jobs_finder.rb @@ -16,6 +16,7 @@ module Ci def execute builds = init_collection.order_id_desc + builds = filter_by_with_artifacts(builds) filter_by_scope(builds) rescue Gitlab::Access::AccessDeniedError type.none @@ -30,7 +31,7 @@ module Ci end def all_jobs - raise Gitlab::Access::AccessDeniedError unless current_user&.admin? + raise Gitlab::Access::AccessDeniedError unless current_user&.can_admin_all_resources? type.all end @@ -72,6 +73,14 @@ module Ci end end + def filter_by_with_artifacts(builds) + if params[:with_artifacts] + builds.with_erasable_artifacts + else + builds + end + end + def filter_by_statuses!(builds) unknown_statuses = params[:scope] - ::CommitStatus::AVAILABLE_STATUSES raise ArgumentError, 'Scope contains invalid value(s)' unless unknown_statuses.empty? diff --git a/app/finders/ci/pipelines_finder.rb b/app/finders/ci/pipelines_finder.rb index 712d5f8c6fb..4c47517299a 100644 --- a/app/finders/ci/pipelines_finder.rb +++ b/app/finders/ci/pipelines_finder.rb @@ -36,6 +36,7 @@ module Ci items = by_yaml_errors(items) items = by_updated_at(items) items = by_source(items) + items = by_name(items) sort_items(items) end @@ -152,6 +153,15 @@ module Ci items end + def by_name(items) + return items unless + Feature.enabled?(:pipeline_name, project) && + Feature.enabled?(:pipeline_name_search, project) && + params[:name].present? + + items.for_name(params[:name]) + end + # rubocop: disable CodeReuse/ActiveRecord def sort_items(items) order_by = if ALLOWED_INDEXED_COLUMNS.include?(params[:order_by]) diff --git a/app/finders/ci/runners_finder.rb b/app/finders/ci/runners_finder.rb index d0d98a59677..136d23939e2 100644 --- a/app/finders/ci/runners_finder.rb +++ b/app/finders/ci/runners_finder.rb @@ -10,6 +10,7 @@ module Ci def initialize(current_user:, params:) @params = params @group = params.delete(:group) + @project = params.delete(:project) @current_user = current_user end @@ -36,13 +37,19 @@ module Ci private def search! - @group ? group_runners : all_runners + if @project && Feature.enabled?(:on_demand_scans_runner_tags, @project) + project_runners + elsif @group + group_runners + else + all_runners + end @runners = @runners.search(@params[:search]) if @params[:search].present? end def all_runners - raise Gitlab::Access::AccessDeniedError unless @current_user&.admin? + raise Gitlab::Access::AccessDeniedError unless @current_user&.can_admin_all_resources? @runners = Ci::Runner.all end @@ -66,6 +73,12 @@ module Ci end end + def project_runners + raise Gitlab::Access::AccessDeniedError unless can?(@current_user, :admin_project, @project) + + @runners = ::Ci::Runner.owned_or_instance_wide(@project.id) + end + def filter_by_active! @runners = @runners.active(@params[:active]) if @params.include?(:active) end |