summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-10-17 16:43:37 +0900
committerShinya Maeda <shinya@gitlab.com>2018-10-17 16:43:37 +0900
commit0dd023ee5a8956425c2c61c905a90feed09914f2 (patch)
tree660279a0686d3d604c6d4f497cd5f0a5cbc2277b
parentf75bcdc5ca871dc89bd18b218d6c79d59ec50b38 (diff)
downloadgitlab-ce-0dd023ee5a8956425c2c61c905a90feed09914f2.tar.gz
Remove unnecessary status entiry. Create texts for environment_text for both pipeline and job
-rw-r--r--lib/gitlab/ci/status/deployment/canceled.rb6
-rw-r--r--lib/gitlab/ci/status/deployment/common.rb39
-rw-r--r--lib/gitlab/ci/status/deployment/created.rb10
-rw-r--r--lib/gitlab/ci/status/deployment/factory.rb4
-rw-r--r--lib/gitlab/ci/status/deployment/failed.rb6
-rw-r--r--lib/gitlab/ci/status/deployment/manual.rb17
-rw-r--r--lib/gitlab/ci/status/deployment/pending.rb17
-rw-r--r--lib/gitlab/ci/status/deployment/running.rb6
-rw-r--r--lib/gitlab/ci/status/deployment/scheduled.rb17
-rw-r--r--lib/gitlab/ci/status/deployment/skipped.rb17
-rw-r--r--lib/gitlab/ci/status/deployment/success.rb10
11 files changed, 69 insertions, 80 deletions
diff --git a/lib/gitlab/ci/status/deployment/canceled.rb b/lib/gitlab/ci/status/deployment/canceled.rb
index 21dc5191a5e..d9509a4764e 100644
--- a/lib/gitlab/ci/status/deployment/canceled.rb
+++ b/lib/gitlab/ci/status/deployment/canceled.rb
@@ -3,7 +3,11 @@ module Gitlab
module Status
module Deployment
class Canceled < Status::Extended
- def environment_text
+ def environment_text_for_pipeline
+ "Canceled to deploy to %{environment_path}."
+ end
+
+ def environment_text_for_job
"This job was canceled to deploy to %{environment_path}."
end
diff --git a/lib/gitlab/ci/status/deployment/common.rb b/lib/gitlab/ci/status/deployment/common.rb
index 07944117f75..a552592c02c 100644
--- a/lib/gitlab/ci/status/deployment/common.rb
+++ b/lib/gitlab/ci/status/deployment/common.rb
@@ -4,13 +4,18 @@ module Gitlab
module Deployment
module Common
def has_details?
- can?(user, :read_deployment, subject)
+ can?(current_user, :read_environment, environment) &&
+ can?(user, :read_deployment, subject)
end
def details_path
project_job_path(subject.project, subject.deployable)
end
+ def environment_name
+ environment.name
+ end
+
def environment_path
project_environment_path(subject.project, subject.environment)
end
@@ -19,8 +24,36 @@ module Gitlab
project_job_path(subject.project, subject.deployable)
end
- def has_deployment?
- true
+ def external_url
+ subject.environment.external_url
+ end
+
+ def stop_url
+ if can?(current_user, :stop_environment, environment)
+ stop_project_environment_path(project, environment)
+ end
+ end
+
+ def metrics_url
+ if environment.has_metrics?
+ metrics_project_environment_deployment_path(project, environment, subject)
+ end
+ end
+
+ def metrics_monitoring_url
+ environment_metrics_path(environment)
+ end
+
+ def deployed_at
+ subject.deployed_at
+ end
+
+ def deployed_at_formatted
+ subject.deployed_at_formatted
+ end
+
+ def environment
+ subject.environment
end
end
end
diff --git a/lib/gitlab/ci/status/deployment/created.rb b/lib/gitlab/ci/status/deployment/created.rb
index 01a74b3b71d..05aa4b840ca 100644
--- a/lib/gitlab/ci/status/deployment/created.rb
+++ b/lib/gitlab/ci/status/deployment/created.rb
@@ -3,7 +3,15 @@ module Gitlab
module Status
module Deployment
class Created < Status::Extended
- def environment_text
+ def environment_text_for_pipeline
+ if subject.environment.deployments.any?
+ "Will deploy to %{environment_path} and overwrite the %{deployment_path}."
+ else
+ "Will deploy to %{environment_path}."
+ end
+ end
+
+ def environment_text_for_job
if subject.environment.deployments.any?
"This job will deploy to %{environment_path} and overwrite the %{deployment_path}."
else
diff --git a/lib/gitlab/ci/status/deployment/factory.rb b/lib/gitlab/ci/status/deployment/factory.rb
index 0b5ceaed986..feeac8a833c 100644
--- a/lib/gitlab/ci/status/deployment/factory.rb
+++ b/lib/gitlab/ci/status/deployment/factory.rb
@@ -7,11 +7,7 @@ module Gitlab
[[Status::Deployment::Canceled,
Status::Deployment::Created,
Status::Deployment::Failed,
- Status::Deployment::Manual,
- Status::Deployment::Pending,
Status::Deployment::Running,
- Status::Deployment::Scheduled,
- Status::Deployment::Skipped,
Status::Deployment::Success]]
end
diff --git a/lib/gitlab/ci/status/deployment/failed.rb b/lib/gitlab/ci/status/deployment/failed.rb
index 38af2a36c02..d77ce56c310 100644
--- a/lib/gitlab/ci/status/deployment/failed.rb
+++ b/lib/gitlab/ci/status/deployment/failed.rb
@@ -3,7 +3,11 @@ module Gitlab
module Status
module Deployment
class Failed < Status::Extended
- def environment_text
+ def environment_text_for_pipeline
+ "Failed to deploy to %{environment_path}."
+ end
+
+ def environment_text_for_job
"The deployment of this job to %{environment_path} did not succeed."
end
diff --git a/lib/gitlab/ci/status/deployment/manual.rb b/lib/gitlab/ci/status/deployment/manual.rb
deleted file mode 100644
index cc871685a6d..00000000000
--- a/lib/gitlab/ci/status/deployment/manual.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Gitlab
- module Ci
- module Status
- module Deployment
- class Manual < Status::Extended
- def environment_text
- "Please trigger the build to deploy to %{environment_path}."
- end
-
- def self.matches?(deployment, user)
- deployment.manual?
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/status/deployment/pending.rb b/lib/gitlab/ci/status/deployment/pending.rb
deleted file mode 100644
index d0f2588c9e5..00000000000
--- a/lib/gitlab/ci/status/deployment/pending.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Gitlab
- module Ci
- module Status
- module Deployment
- class Pending < Status::Extended
- def environment_text
- "This job deploys to %{environment_path} soon."
- end
-
- def self.matches?(deployment, user)
- deployment.pending?
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/status/deployment/running.rb b/lib/gitlab/ci/status/deployment/running.rb
index 3a95710c740..d210d610cf9 100644
--- a/lib/gitlab/ci/status/deployment/running.rb
+++ b/lib/gitlab/ci/status/deployment/running.rb
@@ -3,7 +3,11 @@ module Gitlab
module Status
module Deployment
class Running < Status::Extended
- def environment_text
+ def environment_text_for_pipeline
+ "Deploying to %{environment_path}."
+ end
+
+ def environment_text_for_job
"This job is deploying to %{environment_path}."
end
diff --git a/lib/gitlab/ci/status/deployment/scheduled.rb b/lib/gitlab/ci/status/deployment/scheduled.rb
deleted file mode 100644
index 311b8dcd4ee..00000000000
--- a/lib/gitlab/ci/status/deployment/scheduled.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Gitlab
- module Ci
- module Status
- module Deployment
- class Scheduled < Status::Extended
- def environment_text
- "This job is scheduled to deploy to %{environment_path}."
- end
-
- def self.matches?(deployment, user)
- deployment.scheduled?
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/status/deployment/skipped.rb b/lib/gitlab/ci/status/deployment/skipped.rb
deleted file mode 100644
index 928879194dd..00000000000
--- a/lib/gitlab/ci/status/deployment/skipped.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-module Gitlab
- module Ci
- module Status
- module Deployment
- class Skipped < Status::Extended
- def environment_text
- "This job was skipped and did not deploy to %{environment_path}."
- end
-
- def self.matches?(deployment, user)
- deployment.skipped?
- end
- end
- end
- end
- end
-end
diff --git a/lib/gitlab/ci/status/deployment/success.rb b/lib/gitlab/ci/status/deployment/success.rb
index 8f487872dde..8b2ad6b8e5b 100644
--- a/lib/gitlab/ci/status/deployment/success.rb
+++ b/lib/gitlab/ci/status/deployment/success.rb
@@ -3,7 +3,15 @@ module Gitlab
module Status
module Deployment
class Success < Status::Extended
- def environment_text
+ def environment_text_for_pipeline
+ if subject.last?
+ "Successfully deployed to %{environment_path}."
+ else
+ "Outdated deployment to %{environment_path}. View the most recent deployment %{deployment_path}."
+ end
+ end
+
+ def environment_text_for_job
if subject.last?
"This job is the most recent deployment to %{environment_path}."
else