2018-11-20 20:47:30 +05:30
|
|
|
<script>
|
2018-12-13 13:39:08 +05:30
|
|
|
import _ from 'underscore';
|
|
|
|
import CiIcon from '~/vue_shared/components/ci_icon.vue';
|
|
|
|
import { sprintf, __ } from '../../locale';
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
CiIcon,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
deploymentStatus: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-11-20 20:47:30 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
iconStatus: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
2018-11-20 20:47:30 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
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;
|
|
|
|
case 'out_of_date':
|
|
|
|
if (this.hasLastDeployment) {
|
2018-11-20 20:47:30 +05:30
|
|
|
environmentText = sprintf(
|
2018-12-13 13:39:08 +05:30
|
|
|
__(
|
|
|
|
'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}`),
|
|
|
|
},
|
2018-11-20 20:47:30 +05:30
|
|
|
false,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
} else {
|
2018-11-20 20:47:30 +05:30
|
|
|
environmentText = sprintf(
|
2018-12-13 13:39:08 +05:30
|
|
|
__('This job is an out-of-date deployment to %{environmentLink}.'),
|
2018-11-20 20:47:30 +05:30
|
|
|
{ environmentLink: this.environmentLink },
|
|
|
|
false,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'failed':
|
|
|
|
environmentText = sprintf(
|
|
|
|
__('The deployment of this job to %{environmentLink} did not succeed.'),
|
|
|
|
{ environmentLink: this.environmentLink },
|
2018-12-05 23:21:45 +05:30
|
|
|
false,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
break;
|
|
|
|
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;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return environmentText;
|
2018-12-05 23:21:45 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
environmentLink() {
|
|
|
|
if (this.hasEnvironment) {
|
2018-11-20 20:47:30 +05:30
|
|
|
return sprintf(
|
|
|
|
'%{startLink}%{name}%{endLink}',
|
|
|
|
{
|
2018-12-13 13:39:08 +05:30
|
|
|
startLink: `<a href="${
|
|
|
|
this.deploymentStatus.environment.environment_path
|
|
|
|
}" class="js-environment-link">`,
|
|
|
|
name: _.escape(this.deploymentStatus.environment.name),
|
2018-11-20 20:47:30 +05:30
|
|
|
endLink: '</a>',
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|
2018-12-13 13:39:08 +05:30
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
hasLastDeployment() {
|
|
|
|
return this.hasEnvironment && this.deploymentStatus.environment.last_deployment;
|
|
|
|
},
|
|
|
|
lastDeployment() {
|
|
|
|
return this.hasLastDeployment ? this.deploymentStatus.environment.last_deployment : {};
|
|
|
|
},
|
|
|
|
hasEnvironment() {
|
|
|
|
return !_.isEmpty(this.deploymentStatus.environment);
|
|
|
|
},
|
|
|
|
lastDeploymentPath() {
|
|
|
|
return !_.isEmpty(this.lastDeployment.deployable)
|
|
|
|
? this.lastDeployment.deployable.build_path
|
|
|
|
: '';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deploymentLink(name) {
|
|
|
|
return sprintf(
|
|
|
|
'%{startLink}%{name}%{endLink}',
|
|
|
|
{
|
|
|
|
startLink: `<a href="${this.lastDeploymentPath}" class="js-job-deployment-link">`,
|
|
|
|
name,
|
|
|
|
endLink: '</a>',
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
);
|
2018-11-20 20:47:30 +05:30
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
};
|
2018-11-20 20:47:30 +05:30
|
|
|
</script>
|
|
|
|
<template>
|
2019-02-13 22:33:31 +05:30
|
|
|
<div class="prepend-top-default append-bottom-default js-environment-container">
|
2018-11-20 20:47:30 +05:30
|
|
|
<div class="environment-information">
|
2019-02-13 22:33:31 +05:30
|
|
|
<ci-icon :status="iconStatus" />
|
|
|
|
<p class="inline append-bottom-0" v-html="environment"></p>
|
2018-11-20 20:47:30 +05:30
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|