diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2016-11-17 21:46:41 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2016-11-17 21:46:41 +0000 |
commit | 92cff96f86597f86614116436d4b11d8a325032a (patch) | |
tree | ac2ff67c2e9a8b8cd2d87a969efdab357933a480 | |
parent | a22f5161146d94f548d305f053531882f866a951 (diff) | |
download | gitlab-ce-92cff96f86597f86614116436d4b11d8a325032a.tar.gz |
Improvements after review
-rw-r--r-- | app/assets/javascripts/environments/components/environment_item.js.es6 | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/app/assets/javascripts/environments/components/environment_item.js.es6 b/app/assets/javascripts/environments/components/environment_item.js.es6 index 4358ce96a13..9241b5472a7 100644 --- a/app/assets/javascripts/environments/components/environment_item.js.es6 +++ b/app/assets/javascripts/environments/components/environment_item.js.es6 @@ -208,8 +208,7 @@ * @returns {Object|Undefined} */ commitRef() { - if (this.model.last_deployment && - this.model.last_deployment.ref) { + if (this.model.last_deployment && this.model.last_deployment.ref) { return this.model.last_deployment.ref; } return undefined; @@ -327,10 +326,8 @@ * @returns {Boolean} */ deploymentHasUser() { - if (this.model.last_deployment && this.model.last_deployment.user) { - return true; - } - return false; + return !this.$options.isObjectEmpty(this.model.last_deployment) && + !this.$options.isObjectEmpty(this.model.last_deployment.user); }, /** @@ -340,11 +337,38 @@ * @returns {Object} */ deploymentUser() { - if (this.model.last_deployment && this.model.last_deployment.user) { + if (!this.$options.isObjectEmpty(this.model.last_deployment) && + !this.$options.isObjectEmpty(this.model.last_deployment.user)) { return this.model.last_deployment.user; } return {}; }, + + /** + * Verifies if the build name column should be rendered by verifing + * if all the information needed is present + * and if the environment is not a folder. + * + * @returns {Boolean} + */ + shouldRenderBuildName() { + return !this.isFolder && + !this.$options.isObjectEmpty(this.model.last_deployment) && + !this.$options.isObjectEmpty(this.model.last_deployment.deployable); + }, + + /** + * Verifies if deplyment internal ID should be rendered by verifing + * if all the information needed is present + * and if the environment is not a folder. + * + * @returns {Boolean} + */ + shouldRenderDeploymentID() { + return !this.isFolder && + !this.$options.isObjectEmpty(this.model.last_deployment) && + this.model.last_deployment.iid !== undefined; + }, }, /** @@ -385,7 +409,7 @@ <td class="deployment-column"> <span - v-if="!isFolder && model.last_deployment && model.last_deployment.iid" + v-if="shouldRenderDeploymentID" v-html="deploymentInternalId"> </span> @@ -401,7 +425,7 @@ </td> <td> - <a v-if="!isFolder && model.last_deployment && model.last_deployment.deployable" + <a v-if="shouldRenderBuildName" class="build-link" :href="model.last_deployment.deployable.build_path" v-html="buildName"> @@ -434,25 +458,29 @@ <td class="hidden-xs"> <div v-if="!isFolder"> - <div v-if="hasManualActions && canCreateDeployment" class="inline js-manual-actions-container"> + <div v-if="hasManualActions && canCreateDeployment" + class="inline js-manual-actions-container"> <actions-component :actions="manualActions"> </actions-component> </div> - <div v-if="model.external_url && canReadEnvironment" class="inline js-external-url-container"> + <div v-if="model.external_url && canReadEnvironment" + class="inline js-external-url-container"> <external-url-component :external_url="model.external_url"> </external_url-component> </div> - <div v-if="isStoppable && canCreateDeployment" class="inline js-stop-component-container"> + <div v-if="isStoppable && canCreateDeployment" + class="inline js-stop-component-container"> <stop-component :stop_url="model.environment_path"> </stop-component> </div> - <div v-if="canRetry && canCreateDeployment" class="inline js-rollback-component-container"> + <div v-if="canRetry && canCreateDeployment" + class="inline js-rollback-component-container"> <rollback-component :is_last_deployment="isLastDeployment" :retry_url="retryUrl"> |