mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 10:47:31 +08:00
FEATURE: Ignoring users from the preferences page in a cleaner way (#7289)
* FEATURE: Ignoring users from the preferences page in a cleaner way
This commit is contained in:
parent
6f5d7f987e
commit
d8ff94ecaa
|
@ -0,0 +1,9 @@
|
|||
export default Ember.Component.extend({
|
||||
tagName: "div",
|
||||
items: null,
|
||||
actions: {
|
||||
removeIgnoredUser(item) {
|
||||
this.get("onRemoveIgnoredUser")(item);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,29 @@
|
|||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
item: null,
|
||||
actions: {
|
||||
removeIgnoredUser(item) {
|
||||
this.set("saved", false);
|
||||
this.get("items").removeObject(item);
|
||||
User.findByUsername(item).then(user => {
|
||||
user
|
||||
.updateNotificationLevel("normal")
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("saved", true));
|
||||
});
|
||||
},
|
||||
newIgnoredUser() {
|
||||
const modal = showModal("ignore-duration-with-username", {
|
||||
model: this.get("model")
|
||||
});
|
||||
modal.setProperties({
|
||||
onUserIgnored: username => {
|
||||
this.get("items").addObject(username);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,31 @@
|
|||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
loading: false,
|
||||
ignoredUntil: null,
|
||||
ignoredUsername: null,
|
||||
actions: {
|
||||
ignore() {
|
||||
if (!this.get("ignoredUntil") || !this.get("ignoredUsername")) {
|
||||
this.flash(
|
||||
I18n.t("user.user_notifications.ignore_duration_time_frame_required"),
|
||||
"alert-error"
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.set("loading", true);
|
||||
User.findByUsername(this.get("ignoredUsername")).then(user => {
|
||||
user
|
||||
.updateNotificationLevel("ignore", this.get("ignoredUntil"))
|
||||
.then(() => {
|
||||
this.onUserIgnored(this.get("ignoredUsername"));
|
||||
this.send("closeModal");
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("loading", false));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
<div class="ignored-user-list-item">
|
||||
<span class="ignored-user-name">{{item}}</span>
|
||||
{{d-button class="remove-ignored-user no-text btn-icon" action=(action "removeIgnoredUser" item) icon="times"}}
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<div class="ignored-list">
|
||||
{{#each items as |item|}}
|
||||
{{ignored-user-list-item item=item onRemoveIgnoredUser=(action "removeIgnoredUser")}}
|
||||
{{else}}
|
||||
{{i18n 'user.user_notifications.ignore_no_users'}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="instructions">{{i18n 'user.ignored_users_instructions'}}</div>
|
||||
<div>{{#d-button action=(action "newIgnoredUser") class="btn-default" icon="plus"}}{{i18n 'user.user_notifications.add_ignored_user'}}{{/d-button}}</div>
|
|
@ -0,0 +1,25 @@
|
|||
{{#d-modal-body title="user.user_notifications.ignore_duration_title" autoFocus="false"}}
|
||||
<div class="controls tracking-controls">
|
||||
<label>{{d-icon "eye-slash" class="icon"}} {{i18n "user.user_notifications.ignore_duration_username"}}</label>
|
||||
{{user-selector excludeCurrentUser=true
|
||||
single="true"
|
||||
usernames=ignoredUsername
|
||||
class="user-selector"}}
|
||||
</div>
|
||||
{{future-date-input
|
||||
label="user.user_notifications.ignore_duration_when"
|
||||
input=ignoredUntil
|
||||
includeWeekend=true
|
||||
includeDateTime=false
|
||||
includeMidFuture=true
|
||||
includeFarFuture=false}}
|
||||
<p>{{i18n "user.user_notifications.ignore_duration_note"}}</p>
|
||||
{{/d-modal-body}}
|
||||
|
||||
<div class="modal-footer">
|
||||
{{d-button class="btn-primary"
|
||||
disabled=saveDisabled
|
||||
label="user.user_notifications.ignore_duration_save"
|
||||
action=(action "ignore")}}
|
||||
{{conditional-loading-spinner size="small" condition=loading}}
|
||||
</div>
|
|
@ -1,27 +1,16 @@
|
|||
<label class="control-label">{{i18n 'user.users'}}</label>
|
||||
<div class="control-group">
|
||||
<div class="controls tracking-controls">
|
||||
<label>{{d-icon "d-muted" class="``icon"}} {{i18n 'user.muted_users'}}</label>
|
||||
<label>
|
||||
{{d-icon "d-muted" class="icon"}}
|
||||
<span>{{i18n 'user.muted_users'}}</span>
|
||||
</label>
|
||||
{{user-selector excludeCurrentUser=true usernames=model.muted_usernames class="user-selector"}}
|
||||
</div>
|
||||
<div class="instructions">{{i18n 'user.muted_users_instructions'}}</div>
|
||||
|
||||
{{#if ignoredEnabled}}
|
||||
<div class="controls tracking-controls">
|
||||
<label>{{d-icon "eye-slash" class="icon"}} {{i18n 'user.ignored_users'}}</label>
|
||||
{{user-selector excludeCurrentUser=true
|
||||
usernames=model.ignored_usernames
|
||||
onChangeCallback=(action "ignoredUsernamesChanged")
|
||||
class="user-selector"}}
|
||||
</div>
|
||||
<div class="instructions">{{i18n 'user.ignored_users_instructions'}}</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{plugin-outlet name="user-preferences-notifications" args=(hash model=model save=(action "save"))}}
|
||||
|
||||
<br/>
|
||||
|
||||
{{plugin-outlet name="user-custom-controls" args=(hash model=model)}}
|
||||
|
||||
<div class="control-group save-button">
|
||||
|
@ -29,3 +18,12 @@
|
|||
{{partial 'user/preferences/save-button'}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if ignoredEnabled}}
|
||||
<div class="control-group">
|
||||
<div class="controls tracking-controls">
|
||||
<label>{{d-icon "eye-slash" class="icon"}} {{i18n 'user.ignored_users'}}</label>
|
||||
{{ignored-user-list model=model items=model.ignored_usernames saving=saved}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
.ignored-list {
|
||||
overflow: auto;
|
||||
max-height: 150px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
min-height: 30px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ignored-user-list-item {
|
||||
border: 1px solid #e9e9e9;
|
||||
border-radius: 0.25em;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.remove-ignored-user {
|
||||
display: flex;
|
||||
flex: 1 0 0px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0 0.25em 0.25em 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ignored-user-name {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
|
@ -739,12 +739,15 @@ en:
|
|||
private_messages: "Messages"
|
||||
user_notifications:
|
||||
ignore_duration_title: "Ignore Timer"
|
||||
ignore_duration_username: "Username"
|
||||
ignore_duration_when: "Duration:"
|
||||
ignore_duration_save: "Ignore"
|
||||
ignore_duration_note: "Please note that all ignores are automatically removed after the ignore duration expires."
|
||||
ignore_duration_time_frame_required: "Please select a time frame"
|
||||
ignore_no_users: "You have no ignored users."
|
||||
ignore_option: "Ignored"
|
||||
ignore_option_title: "You will not receive notifications related to this user and all of their topics and replies will be hidden."
|
||||
add_ignored_user: "Add..."
|
||||
mute_option: "Muted"
|
||||
mute_option_title: "You will not receive any notifications related to this user."
|
||||
normal_option: "Normal"
|
||||
|
|
Loading…
Reference in New Issue
Block a user