mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:02:46 +08:00
DEV: migrate ignored-user-list to gjs (#27800)
I removed the `this.saving` behavior part as it's not really useful and was not working as expected anyways.
This commit is contained in:
parent
ea822de9e2
commit
8cc1d9771b
|
@ -0,0 +1,65 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import User from "discourse/models/user";
|
||||
import i18n from "discourse-common/helpers/i18n";
|
||||
import IgnoredUserListItem from "./ignored-user-list-item";
|
||||
import IgnoreDurationModal from "./modal/ignore-duration-with-username";
|
||||
|
||||
export default class IgnoredUserList extends Component {
|
||||
@service modal;
|
||||
|
||||
@action
|
||||
async removeIgnoredUser(item) {
|
||||
this.args.items.removeObject(item);
|
||||
|
||||
try {
|
||||
const user = await User.findByUsername(item);
|
||||
await user.updateNotificationLevel({
|
||||
level: "normal",
|
||||
actingUser: this.args.model,
|
||||
});
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
newIgnoredUser() {
|
||||
this.modal.show(IgnoreDurationModal, {
|
||||
model: {
|
||||
actingUser: this.args.model,
|
||||
ignoredUsername: null,
|
||||
onUserIgnored: (username) => {
|
||||
this.args.items.addObject(username);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="ignored-list">
|
||||
{{#each @items as |item|}}
|
||||
<IgnoredUserListItem
|
||||
@item={{item}}
|
||||
@onRemoveIgnoredUser={{this.removeIgnoredUser}}
|
||||
/>
|
||||
{{else}}
|
||||
{{i18n "user.user_notifications.ignore_no_users"}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class="instructions">{{i18n "user.ignored_users_instructions"}}</div>
|
||||
<div>
|
||||
<DButton
|
||||
@action={{this.newIgnoredUser}}
|
||||
@icon="plus"
|
||||
@label="user.user_notifications.add_ignored_user"
|
||||
class="btn-default"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
<div class="ignored-list">
|
||||
{{#each this.items as |item|}}
|
||||
<IgnoredUserListItem
|
||||
@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><DButton
|
||||
@action={{action "newIgnoredUser"}}
|
||||
@icon="plus"
|
||||
@label="user.user_notifications.add_ignored_user"
|
||||
class="btn-default"
|
||||
/></div>
|
|
@ -1,36 +0,0 @@
|
|||
import Component from "@ember/component";
|
||||
import { service } from "@ember/service";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import User from "discourse/models/user";
|
||||
import IgnoreDurationModal from "./modal/ignore-duration-with-username";
|
||||
|
||||
export default Component.extend({
|
||||
modal: service(),
|
||||
item: null,
|
||||
actions: {
|
||||
removeIgnoredUser(item) {
|
||||
this.set("saved", false);
|
||||
this.items.removeObject(item);
|
||||
User.findByUsername(item).then((user) => {
|
||||
user
|
||||
.updateNotificationLevel({
|
||||
level: "normal",
|
||||
actingUser: this.model,
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set("saved", true));
|
||||
});
|
||||
},
|
||||
newIgnoredUser() {
|
||||
this.modal.show(IgnoreDurationModal, {
|
||||
model: {
|
||||
actingUser: this.model,
|
||||
ignoredUsername: null,
|
||||
onUserIgnored: (username) => {
|
||||
this.items.addObject(username);
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -8,7 +8,6 @@
|
|||
<IgnoredUserList
|
||||
@model={{this.model}}
|
||||
@items={{this.model.ignored_usernames}}
|
||||
@saving={{this.saved}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user