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:
parent
b105c6c510
commit
117f6d92a8
|
@ -17,6 +17,7 @@
|
||||||
@route={{link.route}}
|
@route={{link.route}}
|
||||||
@model={{link.model}}
|
@model={{link.model}}
|
||||||
@models={{link.models}}
|
@models={{link.models}}
|
||||||
|
@href={{link.href}}
|
||||||
@title={{link.title}}
|
@title={{link.title}}
|
||||||
@contentCSSClass={{link.contentCSSClass}}
|
@contentCSSClass={{link.contentCSSClass}}
|
||||||
@prefixColor={{link.prefixColor}}
|
@prefixColor={{link.prefixColor}}
|
||||||
|
|
|
@ -19,9 +19,12 @@ export default class BaseCustomSidebarSectionLink {
|
||||||
/**
|
/**
|
||||||
* @returns {string} The Ember route which the section link should link to.
|
* @returns {string} The Ember route which the section link should link to.
|
||||||
*/
|
*/
|
||||||
get route() {
|
get route() {}
|
||||||
this._notImplemented();
|
|
||||||
}
|
/**
|
||||||
|
* @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.
|
* @returns {Object} `model` argument for the <LinkTo> component. See https://api.emberjs.com/ember/release/classes/Ember.Templates.components/methods/LinkTo?anchor=LinkTo.
|
||||||
|
|
|
@ -206,6 +206,28 @@ acceptance("Sidebar - Plugin API", function (needs) {
|
||||||
return "hover button title attribute";
|
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"
|
"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(
|
assert.strictEqual(
|
||||||
query(".sidebar-section-link-hover button").title,
|
query(".sidebar-section-link-hover button").title,
|
||||||
"hover button title attribute",
|
"hover button title attribute",
|
||||||
|
|
Loading…
Reference in New Issue