Closed Bug 1467975 Opened 6 years ago Closed 6 years ago

Convert lodash .each() to native ES6 JS

Categories

(Tree Management :: Treeherder: Frontend, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: vykuntamsrinivas, Assigned: vykuntamsrinivas)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36



Actual results:

we are using 
// Underscore/Lodash
_.each([1, 2, 3], function (value, index) {
  console.log(value)
})


Expected results:

we are going to use 
// Native
[1, 2, 3].forEach(function (value, index) {
  console.log(value)
})
Blocks: 1466494
Hi! Thank you for working on this :-)

Note that _.each() also supports Objects as well as arrays, so some of the current uses will need to be replaced by Object.entries() rather than Array.prototype.forEach():
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
Assignee: nobody → vykuntamsrinivas
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P3
(In reply to Ed Morley [:emorley] from comment #1)
> Hi! Thank you for working on this :-)
> 
> Note that _.each() also supports Objects as well as arrays, so some of the
> current uses will need to be replaced by Object.entries() rather than
> Array.prototype.forEach():
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
> Global_Objects/Object/entries

Thanks for help emorley. Can you please help me join #treeherder IRC? is there new #name for treeherder?
 I fixed in almost all places except 2 files. They are resultsets_store.js and pinboard.js. I can not invoke break point for both files. Can you please tell which part of UI render these files.
Flags: needinfo?(cdawson)
srinivas:  ``resultsets_store.js`` is what holds all the main job data, so that file is used all the time.  It will depend on which action you're doing.  ``pinboard.js`` recently changed and I don't think it contains any ``_.each`` functions any longer so you won't need to deal with that one.

I don't see your PR yet, so please let me know which function in ``resultsets_store.js`` you're trying to debug.  If it's ``addRunnableJobs`` then you get to that with the drop-down at the header of each push that says "add new jobs".
Flags: needinfo?(cdawson)
Hi emorley:
 I committed my changes and trying to push to detail-panel-fixes  brach in sourcetree. but i am getting the below error.

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/detail-panel-fixes:refs/heads/detail-panel-fixes 
Pushing to https://github.com/mozilla/treeherder
remote: Permission to mozilla/treeherder.git denied to git-srinivas.
fatal: unable to access 'https://github.com/mozilla/treeherder/': The requested URL returned error: 403
Completed with errors, see above
Flags: needinfo?(emorley)
Hi! It looks like git is pushing to our copy of the repository (for which you won't have permissions), rather than your fork of it. See:
https://guides.github.com/activities/forking/
https://help.github.com/articles/fork-a-repo/
Flags: needinfo?(emorley)
Attachment #8986828 - Flags: review?(cdawson)
Just back from PTO and had a couple higher priority things than this.  I will do my very best to review this tomorrow.
Comment on attachment 8986828 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3699

Feedback in PR.  Thanks!
Flags: needinfo?(cdawson)
Attachment #8986828 - Flags: review?(cdawson)
Cancelling needinfo until the PR is updated. After updating it please comment in the PR (or here) so we know to take another look :-)
Flags: needinfo?(cdawson)
Hi camd, I fixed the review changes suggested. Please check :)
Flags: needinfo?(cdawson)
Flags: needinfo?(emorley)
Flags: needinfo?(emorley)
Attachment #8986828 - Flags: review?(cdawson)
Left comments in the PR.  Needs a rebase.  Otherwise, the code looks good.
Flags: needinfo?(cdawson)
Comment on attachment 8986828 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3699

Thanks for the PR!
Attachment #8986828 - Flags: review?(cdawson) → review+
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
(In reply to Cameron Dawson [:camd] from comment #14)
> Comment on attachment 8986828 [details] [review]
> Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3699
> 
> Thanks for the PR!
Welcome :camd :)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: