diff --git a/app/assets/javascripts/discourse/app/components/sidebar/api-sections.hbs b/app/assets/javascripts/discourse/app/components/sidebar/api-sections.hbs index 7ad30dda5b6..a431fc454bf 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/api-sections.hbs +++ b/app/assets/javascripts/discourse/app/components/sidebar/api-sections.hbs @@ -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}} diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js index 750c83fcd5d..c693a0ae921 100644 --- a/app/assets/javascripts/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js +++ b/app/assets/javascripts/discourse/app/lib/sidebar/base-custom-sidebar-section-link.js @@ -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 component. See https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/LinkTo?anchor=LinkTo. diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js index 848d7a7c872..c8443369ef1 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js @@ -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",