diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-16 18:37:17 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-10-17 14:36:40 +0900 |
commit | dbd223c4d17253c544a5eeebbbf35a6571221c64 (patch) | |
tree | bf88c857f3a75d8538f51eb17c2e5ee6c5aa8726 | |
parent | fa13105707c2890421ff971db84ba5575a55442f (diff) | |
download | gitlab-ce-dbd223c4d17253c544a5eeebbbf35a6571221c64.tar.gz |
Fix deployment status facility
-rw-r--r-- | app/serializers/build_details_entity.rb | 8 | ||||
-rw-r--r-- | app/serializers/detailed_status_entity.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/canceled.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/common.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/created.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/failed.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/manual.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/pending.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/running.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/scheduled.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/skipped.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/deployment/success.rb | 8 |
12 files changed, 26 insertions, 20 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 7144617d3b7..0c2b0dfacf4 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -9,9 +9,7 @@ class BuildDetailsEntity < JobEntity expose :runner, using: RunnerEntity expose :pipeline, using: PipelineEntity - expose :deployment_status, with: DetailedStatusEntity do |build| - build.last_deployment.detailed_status - end + expose :deployment_status, with: DetailedStatusEntity # expose :deployment_status, if: -> (*) { build.starts_environment? } do # expose :deployment_status, as: :status @@ -113,4 +111,8 @@ class BuildDetailsEntity < JobEntity def can_admin_build? can?(request.current_user, :admin_build, project) end + + def deployment_status + build.last_deployment.detailed_status(current_user) + end end diff --git a/app/serializers/detailed_status_entity.rb b/app/serializers/detailed_status_entity.rb index 76cebc4bb9a..cf66a8cadd7 100644 --- a/app/serializers/detailed_status_entity.rb +++ b/app/serializers/detailed_status_entity.rb @@ -33,7 +33,7 @@ class DetailedStatusEntity < Grape::Entity expose :action_button_title, as: :button_title end - expose :deployment_status, if: -> (status, _) { status.has_deployment? } do + expose :deployment, if: -> (status, _) { status.has_deployment? } do expose :environment_text expose :environment_path expose :deployment_path diff --git a/lib/gitlab/ci/status/deployment/canceled.rb b/lib/gitlab/ci/status/deployment/canceled.rb index d0693ae1a9c..21dc5191a5e 100644 --- a/lib/gitlab/ci/status/deployment/canceled.rb +++ b/lib/gitlab/ci/status/deployment/canceled.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Canceled < Status::Extended def environment_text - "This job was canceled to deploy to %{environmentLink}." + "This job was canceled to deploy to %{environment_path}." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/common.rb b/lib/gitlab/ci/status/deployment/common.rb index a31acf490d1..07944117f75 100644 --- a/lib/gitlab/ci/status/deployment/common.rb +++ b/lib/gitlab/ci/status/deployment/common.rb @@ -8,13 +8,17 @@ module Gitlab end def details_path - project_deployment_path(subject.project, subject) + project_job_path(subject.project, subject.deployable) end def environment_path project_environment_path(subject.project, subject.environment) end + def deployment_path + project_job_path(subject.project, subject.deployable) + end + def has_deployment? true end diff --git a/lib/gitlab/ci/status/deployment/created.rb b/lib/gitlab/ci/status/deployment/created.rb index 84611d6de62..31634022710 100644 --- a/lib/gitlab/ci/status/deployment/created.rb +++ b/lib/gitlab/ci/status/deployment/created.rb @@ -5,14 +5,14 @@ module Gitlab class Created < Status::Extended def environment_text if subject.environment.deployments.any? - "This job will deploy to %{environmentLink} and overwrite the %{deploymentLink}." + "This job will deploy to %{environment_path} and overwrite the %{deployment_path}." else - "This job will deploy to %{environmentLink}." + "This job will deploy to %{environment_path}." end end - def deployment_link - project_deployment_path(subject.project, subject.environment.last_successful_deployment) + def deployment_path + project_job_path(subject.project, subject.environment.last_successful_deployment.deployable) end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/failed.rb b/lib/gitlab/ci/status/deployment/failed.rb index 7218a961c73..38af2a36c02 100644 --- a/lib/gitlab/ci/status/deployment/failed.rb +++ b/lib/gitlab/ci/status/deployment/failed.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Failed < Status::Extended def environment_text - "The deployment of this job to %{environmentLink} did not succeed." + "The deployment of this job to %{environment_path} did not succeed." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/manual.rb b/lib/gitlab/ci/status/deployment/manual.rb index 0ee2a53e404..cc871685a6d 100644 --- a/lib/gitlab/ci/status/deployment/manual.rb +++ b/lib/gitlab/ci/status/deployment/manual.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Manual < Status::Extended def environment_text - "Please trigger the build to deploy to %{environmentLink}." + "Please trigger the build to deploy to %{environment_path}." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/pending.rb b/lib/gitlab/ci/status/deployment/pending.rb index 6b6baddbccb..d0f2588c9e5 100644 --- a/lib/gitlab/ci/status/deployment/pending.rb +++ b/lib/gitlab/ci/status/deployment/pending.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Pending < Status::Extended def environment_text - "This job deploys to %{environmentLink} soon." + "This job deploys to %{environment_path} soon." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/running.rb b/lib/gitlab/ci/status/deployment/running.rb index 1b9368c1b62..3a95710c740 100644 --- a/lib/gitlab/ci/status/deployment/running.rb +++ b/lib/gitlab/ci/status/deployment/running.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Running < Status::Extended def environment_text - "This job is deploying to %{environmentLink}." + "This job is deploying to %{environment_path}." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/scheduled.rb b/lib/gitlab/ci/status/deployment/scheduled.rb index 9c718c930cb..311b8dcd4ee 100644 --- a/lib/gitlab/ci/status/deployment/scheduled.rb +++ b/lib/gitlab/ci/status/deployment/scheduled.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Scheduled < Status::Extended def environment_text - "This job is scheduled to deploy to %{environmentLink}." + "This job is scheduled to deploy to %{environment_path}." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/skipped.rb b/lib/gitlab/ci/status/deployment/skipped.rb index b610a26c491..928879194dd 100644 --- a/lib/gitlab/ci/status/deployment/skipped.rb +++ b/lib/gitlab/ci/status/deployment/skipped.rb @@ -4,7 +4,7 @@ module Gitlab module Deployment class Skipped < Status::Extended def environment_text - "This job was skipped and did not deploy to %{environmentLink}." + "This job was skipped and did not deploy to %{environment_path}." end def self.matches?(deployment, user) diff --git a/lib/gitlab/ci/status/deployment/success.rb b/lib/gitlab/ci/status/deployment/success.rb index 2f9229147cb..2fe3193515e 100644 --- a/lib/gitlab/ci/status/deployment/success.rb +++ b/lib/gitlab/ci/status/deployment/success.rb @@ -5,14 +5,14 @@ module Gitlab class Success < Status::Extended def environment_text if subject.last? - "This job is the most recent deployment to %{environmentLink}." + "This job is the most recent deployment to %{environment_path}." else - "This job is an out-of-date deployment to %{environmentLink}. View the most recent deployment %{deploymentLink}." + "This job is an out-of-date deployment to %{environment_path}. View the most recent deployment %{deployment_path}." end end - def deploymentLink - project_deployment_path(subject.project, subject.environment.last_successful_deployment) + def deployment_path + project_job_path(subject.project, subject.environment.last_successful_deployment.deployable) end def self.matches?(deployment, user) |