mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Support custom icon when adding custom link to sidebar via plugin API (#21760)
This commit is contained in:
parent
ae74d5b32e
commit
0bff95fcad
@ -1848,10 +1848,11 @@ class PluginApi {
|
||||
*
|
||||
* @param {(addCommunitySectionLinkCallback|Object)} arg - A callback function or an Object.
|
||||
* @param {string} arg.name - The name of the link. Needs to be dasherized and lowercase.
|
||||
* @param {string=} arg.route - The Ember route name to generate the href attribute for the link.
|
||||
* @param {string=} arg.href - The href attribute for the link.
|
||||
* @param {string} arg.title - The title attribute for the link.
|
||||
* @param {string} arg.text - The text to display for the link.
|
||||
* @param {string} [arg.route] - The Ember route name to generate the href attribute for the link.
|
||||
* @param {string} [arg.href] - The href attribute for the link.
|
||||
* @param {string} [arg.icon] - The FontAwesome icon to display for the link.
|
||||
* @param {Boolean} [secondary] - Determines whether the section link should be added to the main or secondary section in the "More..." links drawer.
|
||||
*/
|
||||
addCommunitySectionLink(arg, secondary) {
|
||||
@ -1904,7 +1905,7 @@ class PluginApi {
|
||||
* @param {Object} arg - An object
|
||||
* @param {string} arg.badgeTextFunction - Function used to generate the text for the badge displayed in the section link.
|
||||
* @param {string} arg.route - The Ember route name to generate the href attribute for the link.
|
||||
* @param {Object=} arg.routeQuery - Object representing the query params that should be appended to the route generated.
|
||||
* @param {Object} [arg.routeQuery] - Object representing the query params that should be appended to the route generated.
|
||||
* @param {shouldRegister} arg.shouldRegister - Function used to determine if the countable should be registered for the category.
|
||||
* @param {refreshCountFunction} arg.refreshCountFunction - Function used to calculate the value used to set the property for the count whenever the sidebar section link refreshes.
|
||||
* @param {prioritizeOverDefaults} args.prioritizeOverDefaults - Function used to determine whether the countable should be prioritized over the default countables of unread/new.
|
||||
|
@ -13,10 +13,11 @@ export let secondaryCustomSectionLinks = [];
|
||||
*
|
||||
* @param {(addSectionLinkCallback|Object)} args - A callback function or an Object.
|
||||
* @param {string} args.name - The name of the link. Needs to be dasherized and lowercase.
|
||||
* @param {string=} args.route - The Ember route name to generate the href attribute for the link.
|
||||
* @param {string=} args.href - The href attribute for the link.
|
||||
* @param {string=} args.title - The title attribute for the link.
|
||||
* @param {string} args.text - The text to display for the link.
|
||||
* @param {string} [args.route] - The Ember route name to generate the href attribute for the link.
|
||||
* @param {string} [args.href] - The href attribute for the link.
|
||||
* @param {string} [args.title] - The title attribute for the link.
|
||||
* @param {string} [args.icon] - The FontAwesome 5 icon to display for the link.
|
||||
* @param {Boolean} [secondary] - Determines whether the section link should be added to the main or secondary section in the "More..." links drawer.
|
||||
*/
|
||||
export function addSectionLink(args, secondary) {
|
||||
@ -65,6 +66,10 @@ export function addSectionLink(args, secondary) {
|
||||
get title() {
|
||||
return args.title;
|
||||
}
|
||||
|
||||
get prefixValue() {
|
||||
return args.icon || super.prefixValue;
|
||||
}
|
||||
};
|
||||
|
||||
links.push(klass);
|
||||
|
@ -1065,6 +1065,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||
route: "discovery.unread",
|
||||
text: "unread topics",
|
||||
title: "List of unread topics",
|
||||
icon: "wrench",
|
||||
});
|
||||
});
|
||||
|
||||
@ -1088,6 +1089,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||
"displays the right title for the link"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(
|
||||
".sidebar-section-link[data-link-name='unread'] .sidebar-section-link-prefix.icon .d-icon-wrench"
|
||||
),
|
||||
"displays the wrench icon for the link"
|
||||
);
|
||||
|
||||
await click(".sidebar-section-link[data-link-name='unread']");
|
||||
|
||||
assert.strictEqual(currentURL(), "/unread", "links to the right URL");
|
||||
@ -1154,6 +1162,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
||||
"displays the right title for the link"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(
|
||||
".sidebar-section-link[data-link-name='user-summary'] .sidebar-section-link-prefix.icon .d-icon-link"
|
||||
),
|
||||
"displays the link icon for the link"
|
||||
);
|
||||
|
||||
await click(".btn-sidebar-toggle");
|
||||
|
||||
assert.ok(teardownCalled, "section link teardown callback was called");
|
||||
|
Loading…
Reference in New Issue
Block a user