Skip to content

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

Extensibility points for poster name

Robin Ward645c32758a2c
diff --git a/app/assets/javascripts/discourse/widgets/poster-name.js.es6 b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
index 363f769101f..51cfbcf2fe9 100644
--- a/app/assets/javascripts/discourse/widgets/poster-name.js.es6
+++ b/app/assets/javascripts/discourse/widgets/poster-name.js.es6
@@ -10,6 +10,11 @@ function sanitizeName(name){
export default createWidget('poster-name', {
tagName: 'div.names.trigger-user-card',
+ settings: {
+ showNameAndGroup: true,
+ showGlyph: true
+ },
+
// TODO: Allow extensibility
posterGlyph(attrs) {
if (attrs.moderator) {
@@ -41,10 +46,18 @@ export default createWidget('poster-name', {
classNames.push(primaryGroupName);
}
const nameContents = [ this.userLink(attrs, nameFirst ? name : username) ];
- const glyph = this.posterGlyph(attrs);
- if (glyph) { nameContents.push(glyph); }
+
+ if (this.settings.showGlyph) {
+ const glyph = this.posterGlyph(attrs);
+ if (glyph) { nameContents.push(glyph); }
+ }
const contents = [h('span', { className: classNames.join(' ') }, nameContents)];
+
+ if (!this.settings.showNameAndGroup) {
+ return contents;
+ }
+
if (name && this.siteSettings.display_name_on_posts && sanitizeName(name) !== sanitizeName(username)) {
contents.push(h('span.second.' + (nameFirst ? "username" : "full-name"),
this.userLink(attrs, nameFirst ? username : name)));