FEATURE: allow sidebar section api to create external links (#22609)

* FEATURE: allow sidebar section api to create external links

Right now, sidebar API allows creating sections with internal links. It should be extended to allow creating links to external URLs as well.

* FIX: after rebase
This commit is contained in:
Krzysztof Kotlarek 2023-07-20 11:07:18 +10:00 committed by GitHub
parent b105c6c510
commit 117f6d92a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 3 deletions

View File

@ -17,6 +17,7 @@
@route={{link.route}}
@model={{link.model}}
@models={{link.models}}
@href={{link.href}}
@title={{link.title}}
@contentCSSClass={{link.contentCSSClass}}
@prefixColor={{link.prefixColor}}

View File

@ -19,9 +19,12 @@ export default class BaseCustomSidebarSectionLink {
/**
* @returns {string} The Ember route which the section link should link to.
*/
get route() {
this._notImplemented();
}
get route() {}
/**
* @returns {string} URL to external website which the section link should link to.
*/
get href() {}
/**
* @returns {Object} `model` argument for the <LinkTo> component. See https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/LinkTo?anchor=LinkTo.

View File

@ -206,6 +206,28 @@ acceptance("Sidebar - Plugin API", function (needs) {
return "hover button title attribute";
}
})(),
new (class extends BaseCustomSidebarSectionLink {
get name() {
return "homepage";
}
get classNames() {
return "my-class-name";
}
get href() {
return "https://www.discourse.org";
}
get title() {
return "Homepage";
}
get text() {
return "Homepage";
}
})(),
];
}
};
@ -349,6 +371,18 @@ acceptance("Sidebar - Plugin API", function (needs) {
"uses correct prefix image url"
);
assert.strictEqual(
links[3].title,
"Homepage",
"displays external link with correct title attribute"
);
assert.strictEqual(
links[3].href,
"https://www.discourse.org/",
"displays external link with correct href attribute"
);
assert.strictEqual(
query(".sidebar-section-link-hover button").title,
"hover button title attribute",