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

<img width="375" alt="image"
src="https://github.com/user-attachments/assets/178ba47e-f783-46d2-adae-28afec49b259"
/>

## AFTER

<img width="363" alt="Screenshot 2025-01-16 at 16 11 26"
src="https://github.com/user-attachments/assets/215e9f86-62f7-48ea-b665-72cbf28abd21"
/>

DEV: remove unused topic-tracking component
This commit is contained in:
Régis Hanol 2025-01-16 17:58:43 +01:00 committed by GitHub
parent 892d02fda1
commit 5c6e96720b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 45 deletions

View File

@ -1,36 +0,0 @@
<div class="user-preferences_tracking-topics-controls">
<div class="controls controls-dropdown">
<label>{{i18n "user.new_topic_duration.label"}}</label>
<ComboBox
@valueProperty="value"
@content={{@considerNewTopicOptions}}
@value={{@model.user_option.new_topic_duration_minutes}}
@onChange={{fn (mut @model.user_option.new_topic_duration_minutes)}}
class="duration"
/>
</div>
<div class="controls controls-dropdown">
<label>{{i18n "user.auto_track_topics"}}</label>
<ComboBox
@valueProperty="value"
@content={{@autoTrackDurations}}
@value={{@model.user_option.auto_track_topics_after_msecs}}
@onChange={{action
(mut @model.user_option.auto_track_topics_after_msecs)
}}
/>
</div>
<div class="controls controls-dropdown">
<label>{{i18n "user.notification_level_when_replying"}}</label>
<ComboBox
@valueProperty="value"
@content={{@notificationLevelsForReplying}}
@value={{@model.user_option.notification_level_when_replying}}
@onChange={{action
(mut @model.user_option.notification_level_when_replying)
}}
/>
</div>
</div>

View File

@ -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);
}
}

View File

@ -39,7 +39,7 @@
class="controls controls-dropdown"
data-setting-name="user-notification-level-when-replying"
>
<label>{{i18n "user.notification_level_when_replying"}}</label>
<label>{{i18n "user.notification_level_when_replying.label"}}</label>
<ComboBox
@valueProperty="value"
@content={{this.notificationLevelsForReplying}}
@ -50,6 +50,11 @@
/>
</div>
<PluginOutlet
@name="user-preferences-tracking-topics"
@outletArgs={{hash model=this.model customAttrNames=this.customAttrNames}}
/>
<PreferenceCheckbox
@labelKey="user.topics_unread_when_closed"
@checked={{this.model.user_option.topics_unread_when_closed}}

View File

@ -1925,7 +1925,11 @@ en:
after_5_minutes: "after 5 minutes"
after_10_minutes: "after 10 minutes"
notification_level_when_replying: "When I post in a topic, set that topic to"
notification_level_when_replying:
label: "When posting"
watch_topic: "Watch topic"
track_topic: "Track topic"
do_nothing: "Do nothing"
topics_unread_when_closed: "Consider topics unread when they are closed"
invited: