UX: Use a different JIT message when there are no search results in the users directory (#27009)

This commit adds a different message to the users directory (`/u`) that's shown when there are no results for the search term instead of showing the one for when there are no users on the site yet.

Internal topic: t/126076.
This commit is contained in:
Osama Sayegh 2024-05-14 16:07:45 +03:00 committed by GitHub
parent 941d0f1cf5
commit 722d694305
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 7 deletions

View File

@ -80,13 +80,17 @@
<div class="empty-state">
<div class="empty-state-body">
<p>
{{i18n "directory.no_results.body"}}
{{#if this.currentUser.staff}}
{{html-safe
(i18n
"directory.no_results.extra_body" basePath=(base-path)
)
}}
{{#if this.name}}
{{i18n "directory.no_results_with_search"}}
{{else}}
{{i18n "directory.no_results.body"}}
{{#if this.currentUser.staff}}
{{html-safe
(i18n
"directory.no_results.extra_body" basePath=(base-path)
)
}}
{{/if}}
{{/if}}
</p>
</div>

View File

@ -9,6 +9,7 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
import I18n from "discourse-i18n";
acceptance("User Directory", function () {
test("Visit Page", async function (assert) {
@ -93,6 +94,46 @@ acceptance("User Directory", function () {
"list has been sorted"
);
});
test("Visit with no users", async function (assert) {
pretender.get("/directory_items", () => {
return response({
directory_items: [],
meta: {
last_updated_at: "2024-05-13T18:42:32.000Z",
total_rows_directory_items: 0,
},
});
});
await visit("/u");
assert
.dom(".empty-state-body")
.hasText(
I18n.t("directory.no_results.body"),
"a JIT message is shown when there are no users"
);
});
test("Visit with no search results", async function (assert) {
pretender.get("/directory_items", () => {
return response({
directory_items: [],
meta: {
last_updated_at: "2024-05-13T18:42:32.000Z",
total_rows_directory_items: 0,
},
});
});
await visit("/u?name=somenamethatdoesnotexist");
assert
.dom(".empty-state-body")
.hasText(
I18n.t("directory.no_results_with_search"),
"a different JIT message is used when there are no results for the search term"
);
});
});
acceptance("User directory - Editing columns", function (needs) {

View File

@ -768,6 +768,7 @@ en:
no_results:
body: "A list of community members showing their activity will be shown here. For now the list is empty because your community is still brand new!"
extra_body: "Admins and moderators can see and manage users in <a href='%{basePath}/admin/users/'>User Admin</a>."
no_results_with_search: "No results were found."
days_visited: "Visits"
days_visited_long: "Days Visited"
posts_read: "Read"