FEATURE: Scheduled group email credential problem check (#15396)

This commit adds a check that runs regularly as per
2d68e5d942 which tests the
credentials of groups with SMTP or IMAP enabled. If any issues
are found with those credentials a high priority problem is added to the
admin dashboard.

This commit also formats the admin dashboard differently if
there are high priority problems, bringing them to the top of
the list and highlighting them.

The problem will be cleared if the issue is fixed before the next
problem check, or if the group's settings are updated with a valid
credential.
This commit is contained in:
Martin Brennan
2022-01-04 10:14:33 +10:00
committed by GitHub
parent 8a26ea23f6
commit 20fe5eceb8
11 changed files with 223 additions and 14 deletions

View File

@@ -13,9 +13,14 @@ export default Controller.extend({
exceptionController: controller("exception"),
showVersionChecks: setting("version_checks"),
@discourseComputed("problems.length")
foundProblems(problemsLength) {
return this.currentUser.get("admin") && (problemsLength || 0) > 0;
@discourseComputed(
"lowPriorityProblems.length",
"highPriorityProblems.length"
)
foundProblems(lowPriorityProblemsLength, highPriorityProblemsLength) {
const problemsLength =
lowPriorityProblemsLength + highPriorityProblemsLength;
return this.currentUser.admin && problemsLength > 0;
},
visibleTabs: computed("siteSettings.dashboard_visible_tabs", function () {
@@ -92,7 +97,16 @@ export default Controller.extend({
});
AdminDashboard.fetchProblems()
.then((model) => this.set("problems", model.problems))
.then((model) => {
this.set(
"highPriorityProblems",
model.problems.filterBy("priority", "high")
);
this.set(
"lowPriorityProblems",
model.problems.filterBy("priority", "low")
);
})
.finally(() => this.set("loadingProblems", false));
},

View File

@@ -1,17 +1,34 @@
{{#if foundProblems}}
<div class="section dashboard-problems">
<div class="section-title">
<h2>
{{d-icon "heart"}}
{{i18n "admin.dashboard.problems_found"}}
</h2>
{{#if highPriorityProblems.length}}
<h2>
{{d-icon "exclamation-triangle"}}
{{i18n "admin.dashboard.critical_problems_found"}}
</h2>
{{else}}
<h2>
{{d-icon "heart"}}
{{i18n "admin.dashboard.problems_found"}}
</h2>
{{/if}}
</div>
<div class="section-body">
{{#conditional-loading-section isLoading=loadingProblems}}
<div class="problem-messages">
{{#if highPriorityProblems.length}}
<div class="problem-messages priority-high">
<ul>
{{#each highPriorityProblems as |problem|}}
<li class={{concat "dashboard-problem " "priority-" problem.priority}}>{{html-safe problem.message}}</li>
{{/each}}
</ul>
</div>
{{/if}}
<div class="problem-messages priority-low">
<ul>
{{#each problems as |problem|}}
{{#each lowPriorityProblems as |problem|}}
<li class={{concat "dashboard-problem " "priority-" problem.priority}}>{{html-safe problem.message}}</li>
{{/each}}
</ul>

View File

@@ -11,7 +11,8 @@
{{dashboard-problems
loadingProblems=loadingProblems
foundProblems=foundProblems
problems=problems
lowPriorityProblems=lowPriorityProblems
highPriorityProblems=highPriorityProblems
problemsTimestamp=problemsTimestamp
refreshProblems=(action "refreshProblems")
}}