diff options
author | Fatih Acet <acetfatih@gmail.com> | 2016-09-01 21:52:12 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-09-01 21:52:12 +0000 |
commit | 0b4b3833935777880d5ddf6d6fb404a0a6bc44c9 (patch) | |
tree | 3486944bfbc8898aabac6f252a7ad973c1181959 | |
parent | f90c6a24b469cb1fe939f6e8fba5a835c62e477f (diff) | |
parent | f43a0470bd52132c2853582c51637a736dcce5e8 (diff) | |
download | gitlab-ce-0b4b3833935777880d5ddf6d6fb404a0a6bc44c9.tar.gz |
Merge branch 'users-es6' into 'master'
Front End - Rewrote ES5 `user.js` to ES6 `user.js.es6`
## What does this MR do?
This MR removes the `users.js` file in `app/assets/javascripts/users.js` and replaces it with ES6.
* It also adds the file extension `.es6` so that the sprockets babel gem can transpile it to ES5.
* The new file is: `users.js.es6` in `app/assets/javascripts/`
* Replaced `new User` with `new gl.User` in `app/views/users/show.html.haml`
## Are there points in the code the reviewer needs to double check?
I followed the AirBnb guide, but if there are any mistakes let me know!
## Why was this MR needed?
Because the entire coffee script codebase was transferred over to ES5 with a plan to move everything over to ES6 :smile:
## What are the relevant issue numbers?
#20098
## Screenshots (if relevant)
## Does this MR meet the acceptance criteria?
- Tests
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5676
-rw-r--r-- | app/assets/javascripts/user.js | 29 | ||||
-rw-r--r-- | app/assets/javascripts/user.js.es6 | 34 | ||||
-rw-r--r-- | app/views/users/show.html.haml | 2 |
3 files changed, 35 insertions, 30 deletions
diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js deleted file mode 100644 index 6c4d88cf407..00000000000 --- a/app/assets/javascripts/user.js +++ /dev/null @@ -1,29 +0,0 @@ -(function() { - this.User = (function() { - function User(opts) { - this.opts = opts; - $('.profile-groups-avatars').tooltip({ - "placement": "top" - }); - this.initTabs(); - $('.hide-project-limit-message').on('click', function(e) { - $.cookie('hide_project_limit_message', 'false', { - path: gon.relative_url_root || '/' - }); - $(this).parents('.project-limit-message').remove(); - return e.preventDefault(); - }); - } - - User.prototype.initTabs = function() { - return new UserTabs({ - parentEl: '.user-profile', - action: this.opts.action - }); - }; - - return User; - - })(); - -}).call(this); diff --git a/app/assets/javascripts/user.js.es6 b/app/assets/javascripts/user.js.es6 new file mode 100644 index 00000000000..6889d3a7491 --- /dev/null +++ b/app/assets/javascripts/user.js.es6 @@ -0,0 +1,34 @@ +(global => { + global.User = class { + constructor(opts) { + this.opts = opts; + this.placeProfileAvatarsToTop(); + this.initTabs(); + this.hideProjectLimitMessage(); + } + + placeProfileAvatarsToTop() { + $('.profile-groups-avatars').tooltip({ + placement: 'top' + }); + } + + initTabs() { + return new UserTabs({ + parentEl: '.user-profile', + action: this.opts.action + }); + } + + hideProjectLimitMessage() { + $('.hide-project-limit-message').on('click', e => { + e.preventDefault(); + const path = gon.relative_url_root || '/'; + $.cookie('hide_project_limit_message', 'false', { + path: path + }); + $(this).parents('.project-limit-message').remove(); + }); + } + } +})(window.gl || (window.gl = {})); diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c7f39868e71..9a052abe40a 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -123,6 +123,6 @@ :javascript var userProfile; - userProfile = new User({ + userProfile = new gl.User({ action: "#{controller.action_name}" }); |