Admin Panel/Settings/Accounts: Hide system messages of all users.

Thanks to bbyszio, r4nc0r and xet7 !

Related #3345
This commit is contained in:
Lauri Ojansivu 2021-03-26 10:05:28 +02:00
parent 5f53f8cc01
commit a249ffc805
4 changed files with 43 additions and 7 deletions

View file

@ -122,6 +122,8 @@ template(name='email')
template(name='accountSettings')
ul#account-setting.setting-detail
li
button.js-all-hide-system-messages.primary {{_ 'hide-system-messages-of-all-users'}}
li.accounts-form
.title {{_ 'accounts-allowEmailChange'}}
.form-group.flex
@ -129,23 +131,18 @@ template(name='accountSettings')
span {{_ 'yes'}}
input.wekan-form-control#accounts-allowEmailChange(type="radio" name="allowEmailChange" value="false" checked="{{#unless allowEmailChange}}checked{{/unless}}")
span {{_ 'no'}}
li
li.accounts-form
.title {{_ 'accounts-allowUserNameChange'}}
.form-group.flex
input.wekan-form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="true" checked="{{#if allowUserNameChange}}checked{{/if}}")
span {{_ 'yes'}}
input.wekan-form-control#accounts-allowUserNameChange(type="radio" name="allowUserNameChange" value="false" checked="{{#unless allowUserNameChange}}checked{{/unless}}")
span {{_ 'no'}}
li
li.accounts-form
.title {{_ 'accounts-allowUserDelete'}}
.form-group.flex
input.wekan-form-control#accounts-allowUserDelete(type="radio" name="allowUserDelete" value="true" checked="{{#if allowUserDelete}}checked{{/if}}")
span {{_ 'yes'}}
input.wekan-form-control#accounts-allowUserDelete(type="radio" name="allowUserDelete" value="false" checked="{{#unless allowUserDelete}}checked{{/unless}}")
span {{_ 'no'}}
li
button.js-accounts-save.primary {{_ 'save'}}
template(name='announcementSettings')

View file

@ -274,7 +274,6 @@ BlazeComponent.extendComponent({
$set: { booleanValue: allowUserDelete },
});
},
allowEmailChange() {
return AccountSettings.findOne('accounts-allowEmailChange').booleanValue;
},
@ -284,12 +283,31 @@ BlazeComponent.extendComponent({
allowUserDelete() {
return AccountSettings.findOne('accounts-allowUserDelete').booleanValue;
},
allHideSystemMessages() {
Meteor.call('setAllUsersHideSystemMessages', (err, ret) => {
if (!err && ret) {
if (ret === true) {
const message = `${TAPi18n.__(
'now-system-messages-of-all-users-are-hidden',
)}`;
alert(message);
}
} else {
const reason = err.reason || '';
const message = `${TAPi18n.__(err.error)}\n${reason}`;
alert(message);
}
});
},
events() {
return [
{
'click button.js-accounts-save': this.saveAccountsChange,
},
{
'click button.js-all-hide-system-messages': this.allHideSystemMessages,
},
];
},
}).register('accountSettings');

View file

@ -982,5 +982,7 @@
"title-alphabetically": "Title (Alphabetically)",
"created-at-newest-first": "Created At (Newest First)",
"created-at-oldest-first": "Created At (Oldest First)",
"links-heading": "Links"
"links-heading": "Links",
"hide-system-messages-of-all-users": "Hide system messages of all users",
"now-system-messages-of-all-users-are-hidden": "Now system messages of all users are hidden"
}

View file

@ -797,6 +797,25 @@ Meteor.methods({
if (Meteor.isServer) {
Meteor.methods({
setAllUsersHideSystemMessages() {
if (Meteor.user() && Meteor.user().isAdmin) {
// If setting is missing, add it
Users.update(
{ 'profile.hiddenSystemMessages': { $exists: false } },
{ $set: { 'profile.hiddenSystemMessages': true } },
{ multi: true },
);
// If setting is false, set it to true
Users.update(
{ 'profile.hiddenSystemMessages': false },
{ $set: { 'profile.hiddenSystemMessages': true } },
{ multi: true },
);
return true;
} else {
return false;
}
},
setCreateUser(
fullname,
username,