diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-05-10 16:17:31 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-05-10 16:17:31 +0000 |
commit | 269c0fe00715cf2ebf6e7e9f9f8fb6feef5d610d (patch) | |
tree | f203de27e62de24fb97bb78e6676a25fae607ba9 | |
parent | 1daa133c04532d80c524439fc5ef931daada6303 (diff) | |
download | gitlab-ce-269c0fe00715cf2ebf6e7e9f9f8fb6feef5d610d.tar.gz |
Replace old isObject for underscore methods
-rw-r--r-- | app/assets/javascripts/environments/components/environment_item.vue | 32 | ||||
-rw-r--r-- | app/assets/javascripts/gl_dropdown.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/type_utility.js | 17 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 1 | ||||
-rw-r--r-- | changelogs/unreleased/remove-old-isobject.yml | 4 | ||||
-rw-r--r-- | spec/javascripts/blob/create_branch_dropdown_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/blob/target_branch_dropdown_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/gl_dropdown_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/labels_issue_sidebar_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/project_title_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/search_autocomplete_spec.js | 1 |
11 files changed, 18 insertions, 47 deletions
diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index 0ffe9ea17fa..1f01629aa1b 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -1,5 +1,6 @@ <script> import Timeago from 'timeago.js'; +import _ from 'underscore'; import '../../lib/utils/text_utility'; import ActionsComponent from './environment_actions.vue'; import ExternalUrlComponent from './environment_external_url.vue'; @@ -59,7 +60,7 @@ export default { hasLastDeploymentKey() { if (this.model && this.model.last_deployment && - !this.$options.isObjectEmpty(this.model.last_deployment)) { + !_.isEmpty(this.model.last_deployment)) { return true; } return false; @@ -310,8 +311,8 @@ export default { */ deploymentHasUser() { return this.model && - !this.$options.isObjectEmpty(this.model.last_deployment) && - !this.$options.isObjectEmpty(this.model.last_deployment.user); + !_.isEmpty(this.model.last_deployment) && + !_.isEmpty(this.model.last_deployment.user); }, /** @@ -322,8 +323,8 @@ export default { */ deploymentUser() { if (this.model && - !this.$options.isObjectEmpty(this.model.last_deployment) && - !this.$options.isObjectEmpty(this.model.last_deployment.user)) { + !_.isEmpty(this.model.last_deployment) && + !_.isEmpty(this.model.last_deployment.user)) { return this.model.last_deployment.user; } return {}; @@ -338,8 +339,8 @@ export default { */ shouldRenderBuildName() { return !this.model.isFolder && - !this.$options.isObjectEmpty(this.model.last_deployment) && - !this.$options.isObjectEmpty(this.model.last_deployment.deployable); + !_.isEmpty(this.model.last_deployment) && + !_.isEmpty(this.model.last_deployment.deployable); }, /** @@ -380,7 +381,7 @@ export default { */ shouldRenderDeploymentID() { return !this.model.isFolder && - !this.$options.isObjectEmpty(this.model.last_deployment) && + !_.isEmpty(this.model.last_deployment) && this.model.last_deployment.iid !== undefined; }, @@ -410,21 +411,6 @@ export default { }, }, - /** - * 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; - }, - methods: { onClickFolder() { eventHub.$emit('toggleFolder', this.model, this.folderUrl); diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index 9666eeeb5ad..24c423dd01e 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -1,5 +1,6 @@ /* eslint-disable func-names, space-before-function-paren, no-var, one-var, one-var-declaration-per-line, prefer-rest-params, max-len, vars-on-top, wrap-iife, no-unused-vars, quotes, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, comma-dangle, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func, no-mixed-operators */ /* global fuzzaldrinPlus */ +import { isObject } from './lib/utils/type_utility'; var GitLabDropdown, GitLabDropdownFilter, GitLabDropdownRemote; @@ -93,7 +94,7 @@ GitLabDropdownFilter = (function() { // { prop: 'def' } // ] // } - if (gl.utils.isObject(data)) { + if (isObject(data)) { results = {}; for (key in data) { group = data[key]; @@ -396,7 +397,7 @@ GitLabDropdown = (function() { html = [this.noResults()]; } else { // Handle array groups - if (gl.utils.isObject(data)) { + if (isObject(data)) { html = []; for (name in data) { groupData = data[name]; diff --git a/app/assets/javascripts/lib/utils/type_utility.js b/app/assets/javascripts/lib/utils/type_utility.js index db62e0be324..be86f336bcd 100644 --- a/app/assets/javascripts/lib/utils/type_utility.js +++ b/app/assets/javascripts/lib/utils/type_utility.js @@ -1,15 +1,2 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, no-return-assign, max-len */ -(function() { - (function(w) { - var base; - if (w.gl == null) { - w.gl = {}; - } - if ((base = w.gl).utils == null) { - base.utils = {}; - } - return w.gl.utils.isObject = function(obj) { - return (obj != null) && (obj.constructor === Object); - }; - })(window); -}).call(window); +// eslint-disable-next-line import/prefer-default-export +export const isObject = obj => obj && obj.constructor === Object; diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index a07aa047293..30636f6afec 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -59,7 +59,6 @@ import './lib/utils/datetime_utility'; import './lib/utils/notify'; import './lib/utils/pretty_time'; import './lib/utils/text_utility'; -import './lib/utils/type_utility'; import './lib/utils/url_utility'; // u2f diff --git a/changelogs/unreleased/remove-old-isobject.yml b/changelogs/unreleased/remove-old-isobject.yml new file mode 100644 index 00000000000..67b18642253 --- /dev/null +++ b/changelogs/unreleased/remove-old-isobject.yml @@ -0,0 +1,4 @@ +--- +title: Remove unused code and uses underscore +merge_request: +author: diff --git a/spec/javascripts/blob/create_branch_dropdown_spec.js b/spec/javascripts/blob/create_branch_dropdown_spec.js index c1179e572ae..9f0d373cb81 100644 --- a/spec/javascripts/blob/create_branch_dropdown_spec.js +++ b/spec/javascripts/blob/create_branch_dropdown_spec.js @@ -1,5 +1,4 @@ require('~/gl_dropdown'); -require('~/lib/utils/type_utility'); require('~/blob/create_branch_dropdown'); require('~/blob/target_branch_dropdown'); diff --git a/spec/javascripts/blob/target_branch_dropdown_spec.js b/spec/javascripts/blob/target_branch_dropdown_spec.js index bb436978a0f..76ed3dc1a2d 100644 --- a/spec/javascripts/blob/target_branch_dropdown_spec.js +++ b/spec/javascripts/blob/target_branch_dropdown_spec.js @@ -1,5 +1,4 @@ require('~/gl_dropdown'); -require('~/lib/utils/type_utility'); require('~/blob/create_branch_dropdown'); require('~/blob/target_branch_dropdown'); diff --git a/spec/javascripts/gl_dropdown_spec.js b/spec/javascripts/gl_dropdown_spec.js index eb532dff5a1..8f90ed69e64 100644 --- a/spec/javascripts/gl_dropdown_spec.js +++ b/spec/javascripts/gl_dropdown_spec.js @@ -2,7 +2,6 @@ require('~/gl_dropdown'); require('~/lib/utils/common_utils'); -require('~/lib/utils/type_utility'); require('~/lib/utils/url_utility'); (() => { diff --git a/spec/javascripts/labels_issue_sidebar_spec.js b/spec/javascripts/labels_issue_sidebar_spec.js index 37e038c16da..53aba191b19 100644 --- a/spec/javascripts/labels_issue_sidebar_spec.js +++ b/spec/javascripts/labels_issue_sidebar_spec.js @@ -2,7 +2,6 @@ /* global IssuableContext */ /* global LabelsSelect */ -require('~/lib/utils/type_utility'); require('~/gl_dropdown'); require('select2'); require('vendor/jquery.nicescroll'); diff --git a/spec/javascripts/project_title_spec.js b/spec/javascripts/project_title_spec.js index 3a1d4e2440f..5c51e855401 100644 --- a/spec/javascripts/project_title_spec.js +++ b/spec/javascripts/project_title_spec.js @@ -2,7 +2,6 @@ /* global Project */ require('select2/select2.js'); -require('~/lib/utils/type_utility'); require('~/gl_dropdown'); require('~/api'); require('~/project_select'); diff --git a/spec/javascripts/search_autocomplete_spec.js b/spec/javascripts/search_autocomplete_spec.js index aaf058bd755..fa52a8a0dd2 100644 --- a/spec/javascripts/search_autocomplete_spec.js +++ b/spec/javascripts/search_autocomplete_spec.js @@ -3,7 +3,6 @@ require('~/gl_dropdown'); require('~/search_autocomplete'); require('~/lib/utils/common_utils'); -require('~/lib/utils/type_utility'); require('vendor/fuzzaldrin-plus'); (function() { |