Skip to content

A platform for community discussion. Free, open, simple.

FIX: Admin search labels doubled up with parent label (#33308)

Martin Brennan00942ddffd5f
diff --git a/app/assets/javascripts/admin/addon/services/admin-search-data-source.js b/app/assets/javascripts/admin/addon/services/admin-search-data-source.js
index cfcc454d9be..180adee880d 100644
--- a/app/assets/javascripts/admin/addon/services/admin-search-data-source.js
+++ b/app/assets/javascripts/admin/addon/services/admin-search-data-source.js
@@ -72,13 +72,12 @@ export class PageLinkFormatter {
let label;
if (this.parentLabel) {
+ label = `${this.parentLabel} ${SEPARATOR} ${linkLabel}`;
+ } else {
label = sectionLabel;
- if (sectionLabel) {
- label += ` ${SEPARATOR} `;
+ if (sectionLabel !== linkLabel) {
+ label = label + (sectionLabel ? ` ${SEPARATOR} ` : "") + linkLabel;
}
- label += `${this.parentLabel} ${SEPARATOR} ${linkLabel}`;
- } else {
- label = sectionLabel + (sectionLabel ? ` ${SEPARATOR} ` : "") + linkLabel;
}
let keywords = this.link.keywords
@@ -338,7 +337,7 @@ export default class AdminSearchDataSource extends Service {
return filteredResults.sort((a, b) => b.score - a.score);
}
- #addPageLink(navMapSection, link, parentLabel = "") {
+ #addPageLink(navMapSection, link, parentLabel = null) {
const formattedPageLink = new PageLinkFormatter(
this.router,
navMapSection,
diff --git a/app/assets/javascripts/discourse/tests/unit/services/admin-search-data-source-test.js b/app/assets/javascripts/discourse/tests/unit/services/admin-search-data-source-test.js
index 590a78ca9ea..a987f7b03e5 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/admin-search-data-source-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/admin-search-data-source-test.js
@@ -117,6 +117,49 @@ module("Unit | Service | AdminSearchDataSource", function (hooks) {
);
});
+ test("buildMap - labels are correct for top-level, second-level, and third-level nav", async function (assert) {
+ await this.subject.buildMap();
+
+ const firstPage = this.subject.pageDataSourceItems.find(
+ (page) => page.url === "/admin"
+ );
+
+ assert.notStrictEqual(firstPage, undefined, "top-level page exists");
+ assert.strictEqual(
+ firstPage.label,
+ i18n("admin.dashboard.title"),
+ "top-level label is correct e.g. Dashboard"
+ );
+
+ const secondPage = this.subject.pageDataSourceItems.find(
+ (page) => page.url === "/admin/config/flags"
+ );
+
+ assert.notStrictEqual(secondPage, undefined, "second-level page exists");
+ assert.strictEqual(
+ secondPage.label,
+ i18n("admin.config_sections.community.title") +
+ " > " +
+ i18n("admin.config.flags.title"),
+ "second-level label is correct e.g. Community > Flags"
+ );
+
+ const thirdPage = this.subject.pageDataSourceItems.find(
+ (page) => page.url === "/admin/backups/logs"
+ );
+
+ assert.notStrictEqual(thirdPage, undefined, "third-level page exists");
+ assert.strictEqual(
+ thirdPage.label,
+ i18n("admin.config_sections.advanced.title") +
+ " > " +
+ i18n("admin.config.backups.title") +
+ " > " +
+ i18n("admin.config.backups.sub_pages.logs.title"),
+ "third-level label is correct e.g. Advanced > Backups > Logs"
+ );
+ });
+
test("search - returns empty array if the search term is too small", async function (assert) {
await this.subject.buildMap();
assert.deepEqual(this.subject.search("a"), []);
@@ -219,7 +262,7 @@ module(
this.router,
navMapSection,
link,
- i18n("admin.config.backups.title")
+ i18n(navMapSection.label) + " > " + i18n("admin.config.backups.title")
);
assert.deepEqual(
formatter.format().label,
@@ -228,7 +271,7 @@ module(
i18n("admin.config.backups.title") +
" > " +
i18n(link.label),
- "link uses the section label, parent label, and link label for sub-pages"
+ "link uses the parent label and link label for sub-pages, since the section label is already included in the parent label"
);
link = {
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js
index 25edf9efb08..a19a37e03e1 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-admin-plugin-configuration-nav.js
@@ -15,6 +15,7 @@ export default {
{
label: "chat.incoming_webhooks.title",
route: "adminPlugins.show.discourse-chat-incoming-webhooks",
+ description: "chat.incoming_webhooks.header_description",
},
]);
diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.yml
index 86655f2167d..5b2c31da255 100644
--- a/plugins/chat/config/locales/client.en.yml
+++ b/plugins/chat/config/locales/client.en.yml
@@ -554,6 +554,7 @@ en:
select_emoji: "Choose Emoji"
system: "system"
title: "Incoming webhooks"
+ header_description: "Incoming webhooks can be used by external systems to post messages into a designated chat channel as a bot user"
url: "URL"
url_instructions: "This URL contains a secret value - keep it safe."
username: "Username"