DEV: Relocate enable allowed PMs checkbox

DEV: Relocate enable allowed PMs checkbox

To avoid confusion move the enable allowed PMs checkbox to the same page that you add your allowed users.

Follow up to: 690f17bcbea17fc44d26b5e6962beb6a9023c140

diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/notifications.js b/app/assets/javascripts/discourse/app/controllers/preferences/notifications.js
index 4568619..f076d45 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/notifications.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/notifications.js
@@ -2,7 +2,6 @@ import I18n from "I18n";
 import Controller from "@ember/controller";
 import { NotificationLevels } from "discourse/lib/notification-levels";
 import { popupAjaxError } from "discourse/lib/ajax-error";
-import discourseComputed from "discourse-common/utils/decorators";
 
 export default Controller.extend({
   init() {
@@ -93,11 +92,6 @@ export default Controller.extend({
     this.isIOS = caps.isIOS;
   },
 
-  @discourseComputed("model.user_option.allow_private_messages")
-  disableAllowPmUsersSetting(allowPrivateMessages) {
-    return !allowPrivateMessages;
-  },
-
   actions: {
     save() {
       this.set("saved", false);
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/users.js b/app/assets/javascripts/discourse/app/controllers/preferences/users.js
index d16f196..b7bad14 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/users.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/users.js
@@ -3,6 +3,7 @@ import { alias, gte, or, and } from "@ember/object/computed";
 import { action, computed } from "@ember/object";
 import Controller from "@ember/controller";
 import { popupAjaxError } from "discourse/lib/ajax-error";
+import discourseComputed from "discourse-common/utils/decorators";
 
 export default Controller.extend({
   ignoredUsernames: alias("model.ignored_usernames"),
@@ -44,7 +45,8 @@ export default Controller.extend({
     this.saveAttrNames = [
       "muted_usernames",
       "ignored_usernames",
-      "allowed_pm_usernames"
+      "allowed_pm_usernames",
+      "enable_allowed_pm_users"
     ];
   },
 
@@ -58,6 +60,11 @@ export default Controller.extend({
     this.model.set("allowed_pm_usernames", usernames.uniq().join(","));
   },
 
+  @discourseComputed("model.user_option.allow_private_messages")
+  disableAllowPmUsersSetting(allowPrivateMessages) {
+    return !allowPrivateMessages;
+  },
+
   @action
   save() {
     this.set("saved", false);
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs b/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs
index 450ebde..9e079fd 100644
--- a/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs
+++ b/app/assets/javascripts/discourse/app/templates/preferences/notifications.hbs
@@ -61,15 +61,7 @@
           labelKey="user.allow_private_messages"
           checked=model.user_option.allow_private_messages}}
     </div>
-
-    <div class="controls">
-      {{preference-checkbox
-          labelKey="user.allow_private_messages_from_specific_users"
-          checked=model.user_option.enable_allowed_pm_users
-          disabled=disableAllowPmUsersSetting}}
-    </div>
   </div>
-
 {{/if}}
 
 {{plugin-outlet name="user-preferences-notifications" args=(hash model=model save=(action "save"))}}
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/users.hbs b/app/assets/javascripts/discourse/app/templates/preferences/users.hbs
index 91eb15d..aceb24a 100644
--- a/app/assets/javascripts/discourse/app/templates/preferences/users.hbs
+++ b/app/assets/javascripts/discourse/app/templates/preferences/users.hbs
@@ -25,22 +25,30 @@
   <div class="instructions">{{i18n "user.muted_users_instructions"}}</div>
 </div>
 
-{{#if allowPmUsersEnabled}}
+{{#if siteSettings.enable_personal_messages}}
   <div class="control-group user-allow-pm">
-    <div class="controls tracking-controls">
-      <label>
-        {{d-icon "far-envelope" class="icon"}}
-        <span>{{i18n "user.allowed_pm_users"}}</span>
-      </label>
-      {{user-chooser
-        value=allowedPmUsernames
-        onChange=(action "onChangeAllowedPmUsernames")
-        options=(hash
-          excludeCurrentUser=true
-        )
-      }}
+    <div class="controls">
+      {{preference-checkbox
+          labelKey="user.allow_private_messages_from_specific_users"
+          checked=model.user_option.enable_allowed_pm_users
+          disabled=disableAllowPmUsersSetting}}
     </div>
-    <div class="instructions">{{i18n "user.allowed_pm_users_instructions"}}</div>
+    {{#if allowPmUsersEnabled}}
+      <div class="controls tracking-controls">
+        <label>
+          {{d-icon "far-envelope" class="icon"}}
+          <span>{{i18n "user.allowed_pm_users"}}</span>
+        </label>
+        {{user-chooser
+          value=allowedPmUsernames
+          onChange=(action "onChangeAllowedPmUsernames")
+          options=(hash
+            excludeCurrentUser=true
+          )
+        }}
+      </div>
+      <div class="instructions">{{i18n "user.allowed_pm_users_instructions"}}</div>
+    {{/if}}
   </div>
 {{/if}}
 

GitHub sha: 30af3f24