DEV: Upgrade to Ember 3.

DEV: Upgrade to Ember 3.

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
index 88a9221..c90d46c 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
@@ -24,13 +24,13 @@
                   <p class="text-danger">{{i18n passphraseStatus}}</p>
                 {{/if}}
 
-                {{d-button class="btn-primary" icon="exchange" action="changeEncrypt" disabled=(or passphraseStatus inProgress) label="encrypt.preferences.change"}}
-                {{d-button action="hidePassphraseInput" disabled=inProgress label="cancel"}}
+                {{d-button class="btn-primary" icon="exchange" action=(action "changeEncrypt") disabled=(or passphraseStatus inProgress) label="encrypt.preferences.change"}}
+                {{d-button action=(action "hidePassphraseInput") disabled=inProgress label="cancel"}}
               </form>
             {{else}}
-              {{d-button icon="exchange" action="showPassphraseInput" label="encrypt.preferences.change" id="change"}}
-              {{d-button icon="times" action="deactivateEncrypt" label="encrypt.preferences.deactivate" id="deactivate"}}
-              {{d-button icon="file-export" action="export" label="encrypt.export.title"}}
+              {{d-button icon="exchange" action=(action "showPassphraseInput") label="encrypt.preferences.change" id="change"}}
+              {{d-button icon="times" action=(action "deactivateEncrypt") label="encrypt.preferences.deactivate" id="deactivate"}}
+              {{d-button icon="file-export" action=(action "export") label="encrypt.export.title"}}
             {{/if}}
           {{else}}
             <form>
@@ -40,7 +40,7 @@
                 <label for="">{{i18n "encrypt.preferences.passphrase_label"}}</label>
                 {{input type="password" value=passphrase id="passphrase" autocomplete="current-password" disabled=inProgress}}
               </p>
-              <p>{{d-button class="btn-primary" icon="unlock" action="activateEncrypt" disabled=inProgress label="encrypt.preferences.activate"}}</p>
+              <p>{{d-button class="btn-primary" icon="unlock" action=(action "activateEncrypt") disabled=inProgress label="encrypt.preferences.activate"}}</p>
             </form>
           {{/if}}
         {{else}}
@@ -60,12 +60,12 @@
                 <p class="text-danger">{{i18n passphraseStatus}}</p>
               {{/if}}
               <p>
-                {{d-button class="btn-primary" icon="lock" action="enableEncrypt" disabled=(or passphraseStatus inProgress) label="encrypt.preferences.enable"}}
-                {{d-button action="hidePassphraseInput" disabled=inProgress label="cancel"}}
+                {{d-button class="btn-primary" icon="lock" action=(action "enableEncrypt") disabled=(or passphraseStatus inProgress) label="encrypt.preferences.enable"}}
+                {{d-button action=(action "hidePassphraseInput") disabled=inProgress label="cancel"}}
               </p>
             </form>
           {{else}}
-            {{d-button icon="lock" action="showPassphraseInput" label="encrypt.preferences.enable"}}
+            {{d-button icon="lock" action=(action "showPassphraseInput") label="encrypt.preferences.enable"}}
           {{/if}}
         {{/if}}
       {{else}}
diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
index 5cd86bf..c161c7a 100644
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
@@ -49,17 +49,6 @@ export default {
         isEncryptActive: false,
         // TOOD: Check out if there is a way to define functions like this in
         //       the `export default` scope.
-        passphraseStatus: function() {
-          const passphrase = component.get("passphrase");
-          const passphrase2 = component.get("passphrase2");
-          if (!passphrase) {
-            return "encrypt.preferences.passphrase_enter";
-          } else if (passphrase.length < 15) {
-            return "encrypt.preferences.passphrase_insecure";
-          } else if (passphrase !== passphrase2) {
-            return "encrypt.preferences.passphrase_mismatch";
-          }
-        }.property("passphrase", "passphrase2"),
         willDestroyElement() {
           this._super(...arguments);
           this.appEvents.off(
@@ -69,6 +58,21 @@ export default {
           );
         }
       });
+      Ember.defineProperty(
+        component,
+        "passphraseStatus",
+        Ember.computed("passphrase", "passphrase2", function() {
+          const passphrase = component.get("passphrase");
+          const passphrase2 = component.get("passphrase2");
+          if (!passphrase) {
+            return "encrypt.preferences.passphrase_enter";
+          } else if (passphrase.length < 15) {
+            return "encrypt.preferences.passphrase_insecure";
+          } else if (passphrase !== passphrase2) {
+            return "encrypt.preferences.passphrase_mismatch";
+          }
+        })
+      );
     } else {
       component.setProperties({
         model: args.model,
diff --git a/assets/javascripts/discourse/templates/modal/activate-encrypt.hbs b/assets/javascripts/discourse/templates/modal/activate-encrypt.hbs
index ae9d5d0..9e29ce2 100644
--- a/assets/javascripts/discourse/templates/modal/activate-encrypt.hbs
+++ b/assets/javascripts/discourse/templates/modal/activate-encrypt.hbs
@@ -10,6 +10,6 @@
 {{/d-modal-body}}
 
 <div class="modal-footer">
-  {{d-button class="btn btn-primary" icon="unlock" label="encrypt.preferences.activate" action="activate"}}
+  {{d-button class="btn btn-primary" icon="unlock" label="encrypt.preferences.activate" action=(action "activate")}}
   {{d-modal-cancel close=(action "closeModal")}}
 </div>
diff --git a/assets/javascripts/discourse/templates/modal/export-keypair.hbs b/assets/javascripts/discourse/templates/modal/export-keypair.hbs
index 5764bc3..b30135b 100644
--- a/assets/javascripts/discourse/templates/modal/export-keypair.hbs
+++ b/assets/javascripts/discourse/templates/modal/export-keypair.hbs
@@ -14,12 +14,12 @@
 {{/d-modal-body}}
 
 <div class="modal-footer">
-  {{d-button class="btn btn-primary" icon="file-export" label="encrypt.export.title" action="export"}}
+  {{d-button class="btn btn-primary" icon="file-export" label="encrypt.export.title" action=(action "export")}}
   {{#if exported}}
     {{#if copied}}
-      {{d-button class="btn" icon="clipboard" label="admin.customize.copied_to_clipboard" action="copy"}}
+      {{d-button class="btn" icon="clipboard" label="admin.customize.copied_to_clipboard" action=(action "copy")}}
     {{else}}
-      {{d-button class="btn" icon="clipboard" label="admin.customize.copy_to_clipboard" action="copy"}}
+      {{d-button class="btn" icon="clipboard" label="admin.customize.copy_to_clipboard" action=(action "copy")}}
     {{/if}}
   {{/if}}
   {{d-modal-cancel close=(action "closeModal")}}

GitHub sha: feb0e39b

1 Like