DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808)

approved

#1

DEV: upgrades from Ember 2.13 to Ember 3.5.1 (#6808)

Co-Authored-By: Bianca Nenciu nbianca@users.noreply.github.com Co-Authored-By: David Taylor david@taylorhq.com

diff --git a/Gemfile b/Gemfile
index d715161..345d8e7 100644
--- a/Gemfile
+++ b/Gemfile
@@ -41,8 +41,8 @@ gem 'onebox', '1.8.76'
 gem 'http_accept_language', '~>2.0.5', require: false
 
 gem 'ember-rails', '0.18.5'
-gem 'ember-source', '2.13.3'
-gem 'ember-handlebars-template', '0.7.5'
+gem 'discourse-ember-source', '~> 3.5.1'
+gem 'ember-handlebars-template', '0.8.0'
 gem 'barber'
 
 # message bus 2.2.0 should be very stable
diff --git a/Gemfile.lock b/Gemfile.lock
index f51e645..26d066b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -83,7 +83,7 @@ GEM
       open4 (~> 1.3)
     coderay (1.1.2)
     colored2 (3.1.2)
-    concurrent-ruby (1.1.3)
+    concurrent-ruby (1.1.4)
     connection_pool (2.2.2)
     cork (0.3.0)
       colored2 (~> 3.1)
@@ -105,6 +105,7 @@ GEM
       terminal-table (~> 1)
     debug_inspector (0.0.3)
     diff-lcs (1.3)
+    discourse-ember-source (3.5.1.3)
     discourse_image_optim (0.26.2)
       exifr (~> 1.2, >= 1.2.2)
       fspath (~> 3.0)
@@ -114,9 +115,9 @@ GEM
     email_reply_trimmer (0.1.12)
     ember-data-source (3.0.2)
       ember-source (>= 2, < 3.0)
-    ember-handlebars-template (0.7.5)
+    ember-handlebars-template (0.8.0)
       barber (>= 0.11.0)
-      sprockets (>= 3.3, < 4)
+      sprockets (>= 3.3, < 4.1)
     ember-rails (0.18.5)
       active_model_serializers
       ember-data-source (>= 1.0.0.beta.5)
@@ -124,7 +125,7 @@ GEM
       ember-source (>= 1.1.0)
       jquery-rails (>= 1.0.17)
       railties (>= 3.1)
-    ember-source (2.13.3)
+    ember-source (2.18.2)
     erubi (1.7.1)
     excon (0.62.0)
     execjs (2.7.0)
@@ -462,11 +463,11 @@ DEPENDENCIES
   colored2
   cppjieba_rb
   danger
+  discourse-ember-source (~> 3.5.1)
   discourse_image_optim
   email_reply_trimmer (~> 0.1)
-  ember-handlebars-template (= 0.7.5)
+  ember-handlebars-template (= 0.8.0)
   ember-rails (= 0.18.5)
-  ember-source (= 2.13.3)
   excon
   execjs
   fabrication
diff --git a/app/assets/javascripts/admin/components/admin-user-field-item.js.es6 b/app/assets/javascripts/admin/components/admin-user-field-item.js.es6
index 64e95ce..bdb22e2 100644
--- a/app/assets/javascripts/admin/components/admin-user-field-item.js.es6
+++ b/app/assets/javascripts/admin/components/admin-user-field-item.js.es6
@@ -83,26 +83,14 @@ export default Ember.Component.extend(bufferedProperty("userField"), {
         .catch(popupAjaxError);
     },
 
-    moveUp() {
-      this.sendAction("moveUpAction", this.get("userField"));
-    },
-
-    moveDown() {
-      this.sendAction("moveDownAction", this.get("userField"));
-    },
-
     edit() {
       this.set("editing", true);
     },
 
-    destroy() {
-      this.sendAction("destroyAction", this.get("userField"));
-    },
-
     cancel() {
       const id = this.get("userField.id");
       if (Ember.isEmpty(id)) {
-        this.sendAction("destroyAction", this.get("userField"));
+        this.destroyAction(this.get("userField"));
       } else {
         this.rollbackBuffer();
         this.set("editing", false);
diff --git a/app/assets/javascripts/admin/components/admin-watched-word.js.es6 b/app/assets/javascripts/admin/components/admin-watched-word.js.es6
index d1283e8..53f7a8a 100644
--- a/app/assets/javascripts/admin/components/admin-watched-word.js.es6
+++ b/app/assets/javascripts/admin/components/admin-watched-word.js.es6
@@ -14,7 +14,7 @@ export default Ember.Component.extend(
       this.get("word")
         .destroy()
         .then(() => {
-          this.sendAction("action", this.get("word"));
+          this.action(this.get("word"));
         })
         .catch(e => {
           bootbox.alert(
diff --git a/app/assets/javascripts/admin/components/embeddable-host.js.es6 b/app/assets/javascripts/admin/components/embeddable-host.js.es6
index 7264d42..8dda74d 100644
--- a/app/assets/javascripts/admin/components/embeddable-host.js.es6
+++ b/app/assets/javascripts/admin/components/embeddable-host.js.es6
@@ -61,7 +61,7 @@ export default Ember.Component.extend(bufferedProperty("host"), {
           this.get("host")
             .destroyRecord()
             .then(() => {
-              this.sendAction("deleteHost", this.get("host"));
+              this.deleteHost(this.get("host"));
             });
         }
       });
@@ -70,7 +70,7 @@ export default Ember.Component.extend(bufferedProperty("host"), {
     cancel() {
       const host = this.get("host");
       if (host.get("isNew")) {
-        this.sendAction("deleteHost", host);
+        this.deleteHost(host);
       } else {
         this.rollbackBuffer();
         this.set("editToggled", false);
diff --git a/app/assets/javascripts/admin/components/inline-edit-checkbox.js.es6 b/app/assets/javascripts/admin/components/inline-edit-checkbox.js.es6
index f14ba62..fb93625 100644
--- a/app/assets/javascripts/admin/components/inline-edit-checkbox.js.es6
+++ b/app/assets/javascripts/admin/components/inline-edit-checkbox.js.es6
@@ -4,13 +4,17 @@ import {
 } from "ember-addons/ember-computed-decorators";
 
 export default Ember.Component.extend({
+  classNames: ["inline-edit"],
+
+  checked: null,
+  checkedInternal: null,
+
   init() {
-    this._super();
+    this._super(...arguments);
+
     this.set("checkedInternal", this.get("checked"));
   },
 
-  classNames: ["inline-edit"],
-
   @observes("checked")
   checkedChanged() {
     this.set("checkedInternal", this.get("checked"));
@@ -33,7 +37,7 @@ export default Ember.Component.extend({
 
     finished() {
       this.set("checked", this.get("checkedInternal"));
-      this.sendAction();
+      this.action();
     }
   }
 });
diff --git a/app/assets/javascripts/admin/components/permalink-form.js.es6 b/app/assets/javascripts/admin/components/permalink-form.js.es6
index 969840a..0bd547c 100644
--- a/app/assets/javascripts/admin/components/permalink-form.js.es6
+++ b/app/assets/javascripts/admin/components/permalink-form.js.es6
@@ -33,7 +33,7 @@ export default Ember.Component.extend({
             self.set("url", "");
             self.set("permalink_type_value", "");
             self.set("formSubmitted", false);
-            self.sendAction("action", Permalink.create(result.permalink));
+            self.action(Permalink.create(result.permalink));
             Em.run.schedule("afterRender", function() {
               self.$(".permalink-url").focus();
             });
diff --git a/app/assets/javascripts/admin/components/resumable-upload.js.es6 b/app/assets/javascripts/admin/components/resumable-upload.js.es6
index 4a8545b..0073047 100644
--- a/app/assets/javascripts/admin/components/resumable-upload.js.es6
+++ b/app/assets/javascripts/admin/components/resumable-upload.js.es6
@@ -8,8 +8,8 @@ import { bufferedRender } from "discourse-common/lib/buffered-render";
 
     {{resumable-upload
         target="/admin/backups/upload"
-        success="successAction"
-        error="errorAction"
+        success=(action "successAction")
+        error=(action "errorAction")
         uploadText="UPLOAD"
     }}
 **/
@@ -100,7 +100,7 @@ export default Ember.Component.extend(
           // mark as not uploading anymore
           self._reset();
           // fire an event to allow the parent route to reload its model
-          self.sendAction("success", file.fileName);
+          self.success(file.fileName);
         });
       });
 
@@ -109,7 +109,7 @@ export default Ember.Component.extend(
           // mark as not uploading anymore
           self._reset();
           // fire an event to allow the parent route to display the error message
-          self.sendAction("error", file.fileName, message);
+          self.error(file.fileName, message);
         });
       });
     }.on("init"),
diff --git a/app/assets/javascripts/admin/components/save-controls.js.es6 b/app/assets/javascripts/admin/components/save-controls.js.es6
index 51adbaf..cade010 100644
--- a/app/assets/javascripts/admin/components/save-controls.js.es6
+++ b/app/assets/javascripts/admin/components/save-controls.js.es6
@@ -8,11 +8,5 @@ export default Ember.Component.extend({

[... diff too long, it was truncated ...]

GitHub sha: f9648de8


#2

#3

@jjaffeux do you remember why this change was required? It caused issues with our social registration popups (they were relying on the didTransition event bubbling up to the ApplicationRoute). I’ve fixed that to use a less brittle method, but I wonder if other things might break as well :thinking:


#4

It was propagating the event keyboard since ember3 and filling the search input with /

I didnt have this usecase in mind, can think of a better fix maybe.


#5

For this case I’ve switched to using router.on('didTransition'), which seems cleaner anyway. But in general I notice that @ZogStriP made a very specific change a number of years ago, so there might be other things that rely on it :thinking:.


#6

Theres a big work coming on router for ember 3.6/3.7 maybe we can wait we start this to reconsider this issue too.