From 5c6e96720bb450458252204a2e40755373fe0707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 16 Jan 2025 17:58:43 +0100 Subject: [PATCH] New "user-preferences-tracking-topics" plugin outlet (#30821) Adds the "user-preferences-tracking-topics" plugin outlet to allow the `discourse-assign` plugin to add a new "notification level when assigned" user preference. There's also a new `customAttrNames` tracked property that allows plugins to add new user option to be saved from this screen / plugin outlet. Also changed the text used for the "notification level when replying" to match the one that is used for the "notification level when assigned" in https://github.com/discourse/discourse-assign/pull/626. ## BEFORE image ## AFTER Screenshot 2025-01-16 at 16 11 26 DEV: remove unused topic-tracking component --- .../user-preferences/topic-tracking.hbs | 36 ------------------- .../app/controllers/preferences/tracking.js | 18 ++++++---- .../app/templates/preferences/tracking.hbs | 7 +++- config/locales/client.en.yml | 6 +++- 4 files changed, 22 insertions(+), 45 deletions(-) delete mode 100644 app/assets/javascripts/discourse/app/components/user-preferences/topic-tracking.hbs diff --git a/app/assets/javascripts/discourse/app/components/user-preferences/topic-tracking.hbs b/app/assets/javascripts/discourse/app/components/user-preferences/topic-tracking.hbs deleted file mode 100644 index 7fcc1ae5a52..00000000000 --- a/app/assets/javascripts/discourse/app/components/user-preferences/topic-tracking.hbs +++ /dev/null @@ -1,36 +0,0 @@ -
-
- - -
- -
- - -
- -
- - -
-
\ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/tracking.js b/app/assets/javascripts/discourse/app/controllers/preferences/tracking.js index acc176f58e2..1e89a02517e 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/tracking.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/tracking.js @@ -10,6 +10,7 @@ export default class extends Controller { @service currentUser; @service siteSettings; @tracked saved = false; + @tracked customAttrNames = []; likeNotificationFrequencies = [ { name: i18n("user.like_notification_frequency.always"), value: 0 }, @@ -53,15 +54,15 @@ export default class extends Controller { notificationLevelsForReplying = [ { - name: i18n("topic.notifications.watching.title"), + name: i18n("user.notification_level_when_replying.watch_topic"), value: NotificationLevels.WATCHING, }, { - name: i18n("topic.notifications.tracking.title"), + name: i18n("user.notification_level_when_replying.track_topic"), value: NotificationLevels.TRACKING, }, { - name: i18n("topic.notifications.regular.title"), + name: i18n("user.notification_level_when_replying.do_nothing"), value: NotificationLevels.REGULAR, }, ]; @@ -154,7 +155,8 @@ export default class extends Controller { @computed( "siteSettings.tagging_enabled", - "siteSettings.mute_all_categories_by_default" + "siteSettings.mute_all_categories_by_default", + "customAttrNames" ) get saveAttrNames() { const attrs = [ @@ -180,6 +182,10 @@ export default class extends Controller { ); } + if (this.customAttrNames?.length > 0) { + attrs.push(...this.customAttrNames); + } + return attrs; } @@ -189,9 +195,7 @@ export default class extends Controller { return this.model .save(this.saveAttrNames) - .then(() => { - this.saved = true; - }) + .then(() => (this.saved = true)) .catch(popupAjaxError); } } diff --git a/app/assets/javascripts/discourse/app/templates/preferences/tracking.hbs b/app/assets/javascripts/discourse/app/templates/preferences/tracking.hbs index 49700bff811..05281b1ea62 100644 --- a/app/assets/javascripts/discourse/app/templates/preferences/tracking.hbs +++ b/app/assets/javascripts/discourse/app/templates/preferences/tracking.hbs @@ -39,7 +39,7 @@ class="controls controls-dropdown" data-setting-name="user-notification-level-when-replying" > - + + +