UX: Move encrypted preferences to Security tab (#100)

UX: Move encrypted preferences to Security tab (#100)

diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
deleted file mode 100644
index 0908674..0000000
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.hbs
+++ /dev/null
@@ -1,79 +0,0 @@
-{{#if canEnableEncrypt}}
-  <div class="control-group pref-title">
-    <label class="control-label">{{i18n "encrypt.title"}}</label>
-    {{#if isIE11}}
-      <div class="alert alert-error">
-        <p>{{i18n "encrypt.preferences.ie11"}}</p>
-      </div>
-    {{else if isInsecureContext}}
-      <div class="alert alert-error">
-        <p>{{i18n "encrypt.preferences.insecure_context"}}</p>
-      </div>
-    {{else}}
-      <div class="controls">
-        {{#if isCurrentUser}}
-          {{#if isEncryptEnabled}}
-            {{#if isEncryptActive}}
-              <p>{{i18n "encrypt.preferences.status_enabled"}}</p>
-              {{d-button icon="times" action=(action "deactivateEncrypt") label="encrypt.preferences.deactivate" id="deactivate"}}
-              {{d-button icon="plus" action=(action "generatePaperKey" true) label="encrypt.generate_paper_key.title_device"}}
-              {{d-button icon="ticket-alt" action=(action "generatePaperKey") label="encrypt.generate_paper_key.title"}}
-              {{encrypt-preferences-dropdown onChange=(action "selectEncryptPreferencesDropdownAction")}}
-            {{else}}
-              <form>
-                <p>{{i18n "encrypt.preferences.status_enabled_but_inactive"}}</p>
-
-                {{#if importIdentity}}
-                  {{html-safe (i18n "encrypt.preferences.notice_import")}}
-                  {{textarea class="imported-key-pair" value=identity placeholder=identityPlaceholder}}
-                {{else}}
-                  {{html-safe (i18n "encrypt.preferences.notice_active")}}
-                  <p>
-                    <label for="password">{{i18n "encrypt.preferences.paper_key_label"}}</label>
-                    {{input
-                      type="password"
-                      value=passphrase
-                      placeholder=(i18n "encrypt.preferences.paper_key_placeholder")
-                      id="passphrase"
-                      autocomplete="current-password"
-                      disabled=inProgress}}
-                  </p>
-                {{/if}}
-
-                <p>
-                  {{d-button class="btn-primary"
-                             icon="unlock"
-                             action=(action "activateEncrypt")
-                             type="submit"
-                             disabled=inProgress
-                             label="encrypt.preferences.activate"
-                  }}
-                  {{encrypt-enable-dropdown isEncryptEnabled=isEncryptEnabled
-                                            importIdentity=importIdentity
-                                            onChange=(action "selectEncryptEnableDropdownAction")}}
-                </p>
-              </form>
-            {{/if}}
-          {{else}}
-            <p>{{i18n "encrypt.preferences.status_disabled"}}</p>
-            {{#if importIdentity}}
-              {{html-safe (i18n "encrypt.preferences.notice_import")}}
-              {{textarea class="imported-key-pair" value=identity placeholder=identityPlaceholder}}
-            {{/if}}
-            {{d-button class="btn-primary" icon="lock" action=(action "enableEncrypt") disabled=inProgress label="encrypt.preferences.enable"}}
-            {{encrypt-enable-dropdown isEncryptEnabled=isEncryptEnabled
-                                      importIdentity=importIdentity
-                                      onChange=(action "selectEncryptEnableDropdownAction")}}
-          {{/if}}
-        {{else}}
-          {{#if isEncryptEnabled}}
-            <p>{{i18n "encrypt.preferences.status_enabled_other"}}</p>
-            <p><a href {{action "selectEncryptEnableDropdownAction" "reset"}} class="text-danger">{{i18n "encrypt.reset.title"}}</a></p>
-          {{else}}
-            <p>{{i18n "encrypt.preferences.status_disabled_other"}}</p>
-          {{/if}}
-        {{/if}}
-      </div>
-    {{/if}}
-  </div>
-{{/if}}
diff --git a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6 b/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
deleted file mode 100644
index 0ed7744..0000000
--- a/assets/javascripts/discourse/connectors/user-preferences-account/encrypt.js.es6
+++ /dev/null
@@ -1,181 +0,0 @@
-import showModal from "discourse/lib/show-modal";
-import User from "discourse/models/user";
-import {
-  deleteDb,
-  saveDbIdentity,
-} from "discourse/plugins/discourse-encrypt/lib/database";
-import {
-  ENCRYPT_ACTIVE,
-  ENCRYPT_DISABLED,
-  activateEncrypt,
-  canEnableEncrypt,
-  enableEncrypt,
-  getEncryptionStatus,
-} from "discourse/plugins/discourse-encrypt/lib/discourse";
-import {
-  getPackedPlaceholder,
-  unpackIdentity,
-} from "discourse/plugins/discourse-encrypt/lib/pack";
-import { importIdentity } from "discourse/plugins/discourse-encrypt/lib/protocol";
-import I18n from "I18n";
-
-export default {
-  setupComponent(args, component) {
-    const currentUser = User.current();
-    const isCurrentUser = args.model.id === currentUser.id;
-
-    component.setProperties({
-      /** crypto.subtle is only available in secure contexts. */
-      isInsecureContext: !window.isSecureContext,
-      /** Not all algorithms are available in IE11. */
-      isIE11: this.capabilities.isIE11,
-      /** Whether current user is the same as model user. */
-      isCurrentUser,
-      /** Whether plugin is enabled for current user. */
-      canEnableEncrypt: canEnableEncrypt(args.model, component.siteSettings),
-      /** Whether the encryption is enabled or not. */
-      isEncryptEnabled: !!args.model.encrypt_public,
-    });
-
-    if (isCurrentUser) {
-      const status = getEncryptionStatus(args.model, component.siteSettings);
-      component.setProperties({
-        /** Value of passphrase input.
-         *  It should stay in memory for as little time as possible.
-         *  Clear it often.
-         */
-        passphrase: "",
-        /** Whether it is an import operation. */
-        importIdentity: false,
-        /** Key to be imported .*/
-        identity: "",
-        identityPlaceholder: getPackedPlaceholder(),
-        /** Whether any operation (AJAX request, key generation, etc.) is
-         *  in progress. */
-        inProgress: false,
-        /** Whether the encryption is enabled or not. */
-        isEncryptEnabled: status !== ENCRYPT_DISABLED,
-        /** Whether the encryption is active on this device. */
-        isEncryptActive: status === ENCRYPT_ACTIVE,
-        /** Listens for encryption status updates. */
-        listener() {
-          const newStatus = getEncryptionStatus(
-            args.model,
-            component.siteSettings
-          );
-          component.setProperties({
-            isEncryptEnabled: newStatus !== ENCRYPT_DISABLED,
-            isEncryptActive: newStatus === ENCRYPT_ACTIVE,
-          });
-        },
-        didInsertElement() {
-          this._super(...arguments);
-          this.appEvents.on("encrypt:status-changed", this, this.listener);
-        },
-        willDestroyElement() {
-          this._super(...arguments);
-          this.appEvents.off("encrypt:status-changed", this, this.listener);
-        },
-      });
-    }
-  },
-
-  actions: {
-    enableEncrypt() {
-      this.set("inProgress", true);
-
-      return enableEncrypt(this.model, this.importIdentity && this.identity)
-        .then(() => {
-          this.appEvents.trigger("encrypt:status-changed");
-        })
-        .catch(() =>
-          bootbox.alert(I18n.t("encrypt.preferences.key_pair_invalid"))
-        )
-        .finally(() => {
-          this.setProperties({
-            passphrase: "",

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

GitHub sha: 5158ab02

This commit appears in #100 which was approved by CvX. It was merged by nbianca.