diff options
-rw-r--r-- | changelogs/unreleased/refactoring-entities-file-22.yml | 5 | ||||
-rw-r--r-- | lib/api/entities.rb | 41 | ||||
-rw-r--r-- | lib/api/entities/pipeline.rb | 17 | ||||
-rw-r--r-- | lib/api/entities/pipeline_schedule.rb | 12 | ||||
-rw-r--r-- | lib/api/entities/pipeline_schedule_details.rb | 10 | ||||
-rw-r--r-- | lib/api/entities/trigger.rb | 15 | ||||
-rw-r--r-- | lib/api/entities/variable.rb | 12 | ||||
-rw-r--r-- | locale/gitlab.pot | 37 |
8 files changed, 91 insertions, 58 deletions
diff --git a/changelogs/unreleased/refactoring-entities-file-22.yml b/changelogs/unreleased/refactoring-entities-file-22.yml new file mode 100644 index 00000000000..08ae350d35d --- /dev/null +++ b/changelogs/unreleased/refactoring-entities-file-22.yml @@ -0,0 +1,5 @@ +--- +title: Separate entities into own class files +merge_request: 24950 +author: Rajendra Kadam +type: added diff --git a/lib/api/entities.rb b/lib/api/entities.rb index c0970b4cd6c..479d662f3f5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -128,47 +128,6 @@ module API projects_relation + projects_relation.map(&:forked_from_project).compact end end - - class Trigger < Grape::Entity - include ::API::Helpers::Presentable - - expose :id - expose :token - expose :description - expose :created_at, :updated_at, :last_used - expose :owner, using: Entities::UserBasic - end - - class Variable < Grape::Entity - expose :variable_type, :key, :value - expose :protected?, as: :protected, if: -> (entity, _) { entity.respond_to?(:protected?) } - expose :masked?, as: :masked, if: -> (entity, _) { entity.respond_to?(:masked?) } - expose :environment_scope, if: -> (entity, _) { entity.respond_to?(:environment_scope) } - end - - class Pipeline < PipelineBasic - expose :before_sha, :tag, :yaml_errors - - expose :user, with: Entities::UserBasic - expose :created_at, :updated_at, :started_at, :finished_at, :committed_at - expose :duration - expose :coverage - expose :detailed_status, using: DetailedStatusEntity do |pipeline, options| - pipeline.detailed_status(options[:current_user]) - end - end - - class PipelineSchedule < Grape::Entity - expose :id - expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active - expose :created_at, :updated_at - expose :owner, using: Entities::UserBasic - end - - class PipelineScheduleDetails < PipelineSchedule - expose :last_pipeline, using: Entities::PipelineBasic - expose :variables, using: Entities::Variable - end end end diff --git a/lib/api/entities/pipeline.rb b/lib/api/entities/pipeline.rb new file mode 100644 index 00000000000..778efbe4bcc --- /dev/null +++ b/lib/api/entities/pipeline.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module API + module Entities + class Pipeline < Entities::PipelineBasic + expose :before_sha, :tag, :yaml_errors + + expose :user, with: Entities::UserBasic + expose :created_at, :updated_at, :started_at, :finished_at, :committed_at + expose :duration + expose :coverage + expose :detailed_status, using: DetailedStatusEntity do |pipeline, options| + pipeline.detailed_status(options[:current_user]) + end + end + end +end diff --git a/lib/api/entities/pipeline_schedule.rb b/lib/api/entities/pipeline_schedule.rb new file mode 100644 index 00000000000..a72fe3f3141 --- /dev/null +++ b/lib/api/entities/pipeline_schedule.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class PipelineSchedule < Grape::Entity + expose :id + expose :description, :ref, :cron, :cron_timezone, :next_run_at, :active + expose :created_at, :updated_at + expose :owner, using: Entities::UserBasic + end + end +end diff --git a/lib/api/entities/pipeline_schedule_details.rb b/lib/api/entities/pipeline_schedule_details.rb new file mode 100644 index 00000000000..5e54489a0f9 --- /dev/null +++ b/lib/api/entities/pipeline_schedule_details.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module API + module Entities + class PipelineScheduleDetails < Entities::PipelineSchedule + expose :last_pipeline, using: Entities::PipelineBasic + expose :variables, using: Entities::Variable + end + end +end diff --git a/lib/api/entities/trigger.rb b/lib/api/entities/trigger.rb new file mode 100644 index 00000000000..6a9f772fc6b --- /dev/null +++ b/lib/api/entities/trigger.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module API + module Entities + class Trigger < Grape::Entity + include ::API::Helpers::Presentable + + expose :id + expose :token + expose :description + expose :created_at, :updated_at, :last_used + expose :owner, using: Entities::UserBasic + end + end +end diff --git a/lib/api/entities/variable.rb b/lib/api/entities/variable.rb new file mode 100644 index 00000000000..6705df30b2e --- /dev/null +++ b/lib/api/entities/variable.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module API + module Entities + class Variable < Grape::Entity + expose :variable_type, :key, :value + expose :protected?, as: :protected, if: -> (entity, _) { entity.respond_to?(:protected?) } + expose :masked?, as: :masked, if: -> (entity, _) { entity.respond_to?(:masked?) } + expose :environment_scope, if: -> (entity, _) { entity.respond_to?(:environment_scope) } + end + end +end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index b429e0d99d5..074c74e41cb 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -11244,31 +11244,19 @@ msgstr "" msgid "LicenseCompliance|Add licenses manually to approve or blacklist" msgstr "" -msgid "LicenseCompliance|Approve" +msgid "LicenseCompliance|Allow" msgstr "" -msgid "LicenseCompliance|Approve license" +msgid "LicenseCompliance|Allowed" msgstr "" -msgid "LicenseCompliance|Approve license?" -msgstr "" - -msgid "LicenseCompliance|Approved" -msgstr "" - -msgid "LicenseCompliance|Blacklist" -msgstr "" - -msgid "LicenseCompliance|Blacklist license" -msgstr "" - -msgid "LicenseCompliance|Blacklist license?" +msgid "LicenseCompliance|Cancel" msgstr "" -msgid "LicenseCompliance|Blacklisted" +msgid "LicenseCompliance|Denied" msgstr "" -msgid "LicenseCompliance|Cancel" +msgid "LicenseCompliance|Deny" msgstr "" msgid "LicenseCompliance|Here you can approve or blacklist licenses for this project. Using %{ci} or %{license} will allow you to see if there are any unmanaged licenses and approve or blacklist them in merge request." @@ -11312,6 +11300,9 @@ msgstr "" msgid "LicenseCompliance|License name" msgstr "" +msgid "LicenseCompliance|License review" +msgstr "" + msgid "LicenseCompliance|Packages" msgstr "" @@ -11357,6 +11348,9 @@ msgstr "" msgid "Licenses|Components" msgstr "" +msgid "Licenses|Detected in Project" +msgstr "" + msgid "Licenses|Displays licenses detected in the project, based on the %{linkStart}latest pipeline%{linkEnd} scan" msgstr "" @@ -11372,6 +11366,15 @@ msgstr "" msgid "Licenses|Name" msgstr "" +msgid "Licenses|Policies" +msgstr "" + +msgid "Licenses|Policy" +msgstr "" + +msgid "Licenses|Specified policies in this project" +msgstr "" + msgid "Licenses|The license list details information about the licenses used within your project." msgstr "" |