DEV: Upgrades to Ember 3.10 (#7871)

DEV: Upgrades to Ember 3.10 (#7871)

Co-Authored-By: majakomel maja.komel@gmail.com

diff --git a/Gemfile b/Gemfile
index f1420c3..6a621c4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -51,7 +51,7 @@ gem 'onebox', '1.9.2'
 gem 'http_accept_language', '~>2.0.5', require: false
 
 gem 'ember-rails', '0.18.5'
-gem 'discourse-ember-source', '~> 3.8.0'
+gem 'discourse-ember-source', '~> 3.10.0'
 gem 'ember-handlebars-template', '0.8.0'
 gem 'barber'
 
diff --git a/Gemfile.lock b/Gemfile.lock
index 61885cc..898e8b7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -91,7 +91,7 @@ GEM
     debug_inspector (0.0.3)
     diff-lcs (1.3)
     diffy (3.3.0)
-    discourse-ember-source (3.8.0.1)
+    discourse-ember-source (3.10.0.1)
     discourse_image_optim (0.26.2)
       exifr (~> 1.2, >= 1.2.2)
       fspath (~> 3.0)
@@ -438,7 +438,7 @@ DEPENDENCIES
   colored2
   cppjieba_rb
   diffy
-  discourse-ember-source (~> 3.8.0)
+  discourse-ember-source (~> 3.10.0)
   discourse_image_optim
   email_reply_trimmer (~> 0.1)
   ember-handlebars-template (= 0.8.0)
diff --git a/app/assets/javascripts/admin/components/ace-editor.js.es6 b/app/assets/javascripts/admin/components/ace-editor.js.es6
index ff3203f..8fd9089 100644
--- a/app/assets/javascripts/admin/components/ace-editor.js.es6
+++ b/app/assets/javascripts/admin/components/ace-editor.js.es6
@@ -75,7 +75,7 @@ export default Ember.Component.extend({
         if (!this.element || this.isDestroying || this.isDestroyed) {
           return;
         }
-        const editor = loadedAce.edit(this.$(".ace")[0]);
+        const editor = loadedAce.edit(this.element.querySelector(".ace"));
 
         editor.setTheme("ace/theme/chrome");
         editor.setShowPrintMargin(false);
@@ -89,7 +89,7 @@ export default Ember.Component.extend({
         editor.$blockScrolling = Infinity;
         editor.renderer.setScrollMargin(10, 10);
 
-        this.$().data("editor", editor);
+        this.element.setAttribute("data-editor", editor);
         this._editor = editor;
         this.changeDisabledState();
 
diff --git a/app/assets/javascripts/admin/components/admin-backups-logs.js.es6 b/app/assets/javascripts/admin/components/admin-backups-logs.js.es6
index 56f9032..5112564 100644
--- a/app/assets/javascripts/admin/components/admin-backups-logs.js.es6
+++ b/app/assets/javascripts/admin/components/admin-backups-logs.js.es6
@@ -18,8 +18,8 @@ export default Ember.Component.extend(
     },
 
     _scrollDown() {
-      const $div = this.$()[0];
-      $div.scrollTop = $div.scrollHeight;
+      const div = this.element;
+      div.scrollTop = div.scrollHeight;
     },
 
     @on("init")
diff --git a/app/assets/javascripts/admin/components/admin-graph.js.es6 b/app/assets/javascripts/admin/components/admin-graph.js.es6
index 5ef3840..5949d51 100644
--- a/app/assets/javascripts/admin/components/admin-graph.js.es6
+++ b/app/assets/javascripts/admin/components/admin-graph.js.es6
@@ -5,7 +5,7 @@ export default Ember.Component.extend({
   type: "line",
 
   refreshChart() {
-    const ctx = this.$()[0].getContext("2d");
+    const ctx = this.element.getContext("2d");
     const model = this.model;
     const rawData = this.get("model.data");
 
diff --git a/app/assets/javascripts/admin/components/admin-report-chart.js.es6 b/app/assets/javascripts/admin/components/admin-report-chart.js.es6
index b4ced4e..80d35c4 100644
--- a/app/assets/javascripts/admin/components/admin-report-chart.js.es6
+++ b/app/assets/javascripts/admin/components/admin-report-chart.js.es6
@@ -35,14 +35,17 @@ export default Ember.Component.extend({
 
   _scheduleChartRendering() {
     Ember.run.schedule("afterRender", () => {
-      this._renderChart(this.model, this.$(".chart-canvas"));
+      this._renderChart(
+        this.model,
+        this.element && this.element.querySelector(".chart-canvas")
+      );
     });
   },
 
-  _renderChart(model, $chartCanvas) {
-    if (!$chartCanvas || !$chartCanvas.length) return;
+  _renderChart(model, chartCanvas) {
+    if (!chartCanvas) return;
 
-    const context = $chartCanvas[0].getContext("2d");
+    const context = chartCanvas.getContext("2d");
     const chartData = Ember.makeArray(
       model.get("chartData") || model.get("data")
     );
diff --git a/app/assets/javascripts/admin/components/admin-report-stacked-chart.js.es6 b/app/assets/javascripts/admin/components/admin-report-stacked-chart.js.es6
index a70f698..ce0dfd9 100644
--- a/app/assets/javascripts/admin/components/admin-report-stacked-chart.js.es6
+++ b/app/assets/javascripts/admin/components/admin-report-stacked-chart.js.es6
@@ -33,14 +33,17 @@ export default Ember.Component.extend({
 
   _scheduleChartRendering() {
     Ember.run.schedule("afterRender", () => {
-      this._renderChart(this.model, this.$(".chart-canvas"));
+      this._renderChart(
+        this.model,
+        this.element.querySelector(".chart-canvas")
+      );
     });
   },
 
-  _renderChart(model, $chartCanvas) {
-    if (!$chartCanvas || !$chartCanvas.length) return;
+  _renderChart(model, chartCanvas) {
+    if (!chartCanvas) return;
 
-    const context = $chartCanvas[0].getContext("2d");
+    const context = chartCanvas.getContext("2d");
 
     const chartData = Ember.makeArray(
       model.get("chartData") || model.get("data")
diff --git a/app/assets/javascripts/admin/components/color-input.js.es6 b/app/assets/javascripts/admin/components/color-input.js.es6
index e57a8ef..17783cd 100644
--- a/app/assets/javascripts/admin/components/color-input.js.es6
+++ b/app/assets/javascripts/admin/components/color-input.js.es6
@@ -11,10 +11,10 @@ export default Ember.Component.extend({
   classNames: ["color-picker"],
   hexValueChanged: function() {
     var hex = this.hexValue;
-    let $text = this.$("input.hex-input");
+    let text = this.element.querySelector("input.hex-input");
 
     if (this.valid) {
-      $text.attr(
+      text.setAttribute(
         "style",
         "color: " +
           (this.brightnessValue > 125 ? "black" : "white") +
@@ -24,10 +24,12 @@ export default Ember.Component.extend({
       );
 
       if (this.pickerLoaded) {
-        this.$(".picker").spectrum({ color: "#" + this.hexValue });
+        $(this.element.querySelector(".picker")).spectrum({
+          color: "#" + this.hexValue
+        });
       }
     } else {
-      $text.attr("style", "");
+      text.setAttribute("style", "");
     }
   }.observes("hexValue", "brightnessValue", "valid"),
 
@@ -35,7 +37,7 @@ export default Ember.Component.extend({
     loadScript("/javascripts/spectrum.js").then(() => {
       loadCSS("/javascripts/spectrum.css").then(() => {
         Ember.run.schedule("afterRender", () => {
-          this.$(".picker")
+          $(this.element.querySelector(".picker"))
             .spectrum({ color: "#" + this.hexValue })
             .on("change.spectrum", (me, color) => {
               this.set("hexValue", color.toHexString().replace("#", ""));
diff --git a/app/assets/javascripts/admin/components/embeddable-host.js.es6 b/app/assets/javascripts/admin/components/embeddable-host.js.es6
index 34d46ac..7639312 100644
--- a/app/assets/javascripts/admin/components/embeddable-host.js.es6
+++ b/app/assets/javascripts/admin/components/embeddable-host.js.es6
@@ -14,7 +14,7 @@ export default Ember.Component.extend(bufferedProperty("host"), {
   @observes("editing")
   _focusOnInput() {
     Ember.run.schedule("afterRender", () => {
-      this.$(".host-name").focus();
+      this.element.querySelector(".host-name").focus();
     });
   },
 
diff --git a/app/assets/javascripts/admin/components/highlighted-code.js.es6 b/app/assets/javascripts/admin/components/highlighted-code.js.es6
index 62cf58f..9f99c09 100644
--- a/app/assets/javascripts/admin/components/highlighted-code.js.es6
+++ b/app/assets/javascripts/admin/components/highlighted-code.js.es6
@@ -5,6 +5,6 @@ export default Ember.Component.extend({
   @on("didInsertElement")
   @observes("code")
   _refresh: function() {
-    highlightSyntax(this.$());
+    highlightSyntax($(this.element));
   }
 });

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

GitHub sha: b3eb6797

1 Like