diff options
-rw-r--r-- | app/assets/javascripts/environments/components/environment_item.js.es6 | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/assets/javascripts/environments/components/environment_item.js.es6 b/app/assets/javascripts/environments/components/environment_item.js.es6 index a3ba3c762d7..c842b9e418f 100644 --- a/app/assets/javascripts/environments/components/environment_item.js.es6 +++ b/app/assets/javascripts/environments/components/environment_item.js.es6 @@ -23,6 +23,7 @@ window.gl = window.gl || {}; window.gl.environmentsList = window.gl.environmentsList || {}; + window.gl.environmentsList.timeagoInstance = new timeago(); // eslint-disable-line gl.environmentsList.EnvironmentItem = Vue.component('environment-item', { @@ -147,10 +148,15 @@ this.model.last_deployment.deployable; }, + /** + * Verifies if the date to be shown is present. + * + * @returns {Boolean|Undefined} + */ canShowDate() { return this.model.last_deployment && this.model.last_deployment.deployable && - this.model.last_deployment.deployable.created_at; + this.model.last_deployment.deployable !== undefined; }, /** @@ -159,9 +165,9 @@ * @returns {String} */ createdDate() { - const timeagoInstance = new timeago(); // eslint-disable-line - - return timeagoInstance.format(this.model.last_deployment.deployable.created_at); + return window.gl.environmentsList.timeagoInstance.format( + this.model.last_deployment.deployable.created_at + ); }, /** |