summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/jobs
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-15 21:06:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-15 21:06:25 +0000
commit0ff031c7f4e2c7fe1b671b30fef569eb3fbea942 (patch)
tree0493e9faf4bb9d69c06226901cea12f22714a92a /app/assets/javascripts/jobs
parent7b8ec6e718331dd1f8330f08f49f01ba2c20b84c (diff)
downloadgitlab-ce-0ff031c7f4e2c7fe1b671b30fef569eb3fbea942.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jobs')
-rw-r--r--app/assets/javascripts/jobs/components/environments_block.vue151
1 files changed, 90 insertions, 61 deletions
diff --git a/app/assets/javascripts/jobs/components/environments_block.vue b/app/assets/javascripts/jobs/components/environments_block.vue
index 8cda7dac51f..163849d3c40 100644
--- a/app/assets/javascripts/jobs/components/environments_block.vue
+++ b/app/assets/javascripts/jobs/components/environments_block.vue
@@ -19,69 +19,18 @@ export default {
},
computed: {
environment() {
- let environmentText;
switch (this.deploymentStatus.status) {
case 'last':
- environmentText = sprintf(
- __('This job is the most recent deployment to %{link}.'),
- { link: this.environmentLink },
- false,
- );
- break;
+ return this.lastEnvironmentMessage();
case 'out_of_date':
- if (this.hasLastDeployment) {
- environmentText = sprintf(
- __(
- 'This job is an out-of-date deployment to %{environmentLink}. View the most recent deployment %{deploymentLink}.',
- ),
- {
- environmentLink: this.environmentLink,
- deploymentLink: this.deploymentLink(`#${this.lastDeployment.iid}`),
- },
- false,
- );
- } else {
- environmentText = sprintf(
- __('This job is an out-of-date deployment to %{environmentLink}.'),
- { environmentLink: this.environmentLink },
- false,
- );
- }
-
- break;
+ return this.outOfDateEnvironmentMessage();
case 'failed':
- environmentText = sprintf(
- __('The deployment of this job to %{environmentLink} did not succeed.'),
- { environmentLink: this.environmentLink },
- false,
- );
- break;
+ return this.failedEnvironmentMessage();
case 'creating':
- if (this.hasLastDeployment) {
- environmentText = sprintf(
- __(
- 'This job is creating a deployment to %{environmentLink} and will overwrite the %{deploymentLink}.',
- ),
- {
- environmentLink: this.environmentLink,
- deploymentLink: this.deploymentLink(__('latest deployment')),
- },
- false,
- );
- } else {
- environmentText = sprintf(
- __('This job is creating a deployment to %{environmentLink}.'),
- { environmentLink: this.environmentLink },
- false,
- );
- }
- break;
+ return this.creatingEnvironmentMessage();
default:
- break;
+ return '';
}
- return environmentText && this.hasCluster
- ? `${environmentText} ${this.clusterText}`
- : environmentText;
},
environmentLink() {
if (this.hasEnvironment) {
@@ -137,11 +86,6 @@ export default {
false,
);
},
- clusterText() {
- return this.hasCluster
- ? sprintf(__('Cluster %{cluster} was used.'), { cluster: this.clusterNameOrLink }, false)
- : '';
- },
},
methods: {
deploymentLink(name) {
@@ -155,6 +99,91 @@ export default {
false,
);
},
+ failedEnvironmentMessage() {
+ const { environmentLink } = this;
+
+ return sprintf(
+ __('The deployment of this job to %{environmentLink} did not succeed.'),
+ { environmentLink },
+ false,
+ );
+ },
+ lastEnvironmentMessage() {
+ const { environmentLink, clusterNameOrLink, hasCluster } = this;
+
+ const message = hasCluster
+ ? __('This job is deployed to %{environmentLink} using cluster %{clusterNameOrLink}.')
+ : __('This job is deployed to %{environmentLink}.');
+
+ return sprintf(message, { environmentLink, clusterNameOrLink }, false);
+ },
+ outOfDateEnvironmentMessage() {
+ const { hasLastDeployment, hasCluster, environmentLink, clusterNameOrLink } = this;
+
+ if (hasLastDeployment) {
+ const message = hasCluster
+ ? __(
+ 'This job is an out-of-date deployment to %{environmentLink} using cluster %{clusterNameOrLink}. View the %{deploymentLink}.',
+ )
+ : __(
+ 'This job is an out-of-date deployment to %{environmentLink}. View the %{deploymentLink}.',
+ );
+
+ return sprintf(
+ message,
+ {
+ environmentLink,
+ clusterNameOrLink,
+ deploymentLink: this.deploymentLink(__('most recent deployment')),
+ },
+ false,
+ );
+ }
+
+ const message = hasCluster
+ ? __(
+ 'This job is an out-of-date deployment to %{environmentLink} using cluster %{clusterNameOrLink}.',
+ )
+ : __('This job is an out-of-date deployment to %{environmentLink}.');
+
+ return sprintf(
+ message,
+ {
+ environmentLink,
+ clusterNameOrLink,
+ },
+ false,
+ );
+ },
+ creatingEnvironmentMessage() {
+ const { hasLastDeployment, hasCluster, environmentLink, clusterNameOrLink } = this;
+
+ if (hasLastDeployment) {
+ const message = hasCluster
+ ? __(
+ 'This job is creating a deployment to %{environmentLink} using cluster %{clusterNameOrLink}. This will overwrite the %{deploymentLink}.',
+ )
+ : __(
+ 'This job is creating a deployment to %{environmentLink}. This will overwrite the %{deploymentLink}.',
+ );
+
+ return sprintf(
+ message,
+ {
+ environmentLink,
+ clusterNameOrLink,
+ deploymentLink: this.deploymentLink(__('latest deployment')),
+ },
+ false,
+ );
+ }
+
+ return sprintf(
+ __('This job is creating a deployment to %{environmentLink}.'),
+ { environmentLink },
+ false,
+ );
+ },
},
};
</script>