summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2016-11-17 21:32:43 +0000
committerFilipa Lacerda <filipa@gitlab.com>2016-11-17 21:32:43 +0000
commita22f5161146d94f548d305f053531882f866a951 (patch)
tree56667d8ac72a6fe05d002c3e9927a137a998d11f
parentf9237abb66aa92825c17bc6864e16783c1e54450 (diff)
downloadgitlab-ce-a22f5161146d94f548d305f053531882f866a951.tar.gz
Adds helper to verify empty object
-rw-r--r--app/assets/javascripts/environments/components/environment_item.js.es621
1 files changed, 18 insertions, 3 deletions
diff --git a/app/assets/javascripts/environments/components/environment_item.js.es6 b/app/assets/javascripts/environments/components/environment_item.js.es6
index 871da5790ec..4358ce96a13 100644
--- a/app/assets/javascripts/environments/components/environment_item.js.es6
+++ b/app/assets/javascripts/environments/components/environment_item.js.es6
@@ -107,7 +107,8 @@
* @returns {Boolean}
*/
hasLastDeploymentKey() {
- if (this.model.last_deployment && this.model.last_deployment !== {}) {
+ if (this.model.last_deployment &&
+ !this.$options.isObjectEmpty(this.model.last_deployment)) {
return true;
}
return false;
@@ -326,8 +327,7 @@
* @returns {Boolean}
*/
deploymentHasUser() {
- if (this.model.last_deployment &&
- this.model.last_deployment.user) {
+ if (this.model.last_deployment && this.model.last_deployment.user) {
return true;
}
return false;
@@ -347,6 +347,21 @@
},
},
+ /**
+ * Helper to verify if certain given object are empty.
+ * Should be replaced by lodash _.isEmpty - https://lodash.com/docs/4.17.2#isEmpty
+ * @param {Object} object
+ * @returns {Bollean}
+ */
+ isObjectEmpty(object) {
+ for (const key in object) { // eslint-disable-line
+ if (hasOwnProperty.call(object, key)) {
+ return false;
+ }
+ }
+ return true;
+ },
+
template: `
<tr>
<td v-bind:class="{ 'children-row': isChildren}">