mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FEATURE: addUserMenuGlyph extensibility point
This commit is contained in:
parent
b20b568039
commit
8c8de1c2d4
@ -15,9 +15,10 @@ import { extraConnectorClass } from 'discourse/lib/plugin-connectors';
|
|||||||
import { addPostSmallActionIcon } from 'discourse/widgets/post-small-action';
|
import { addPostSmallActionIcon } from 'discourse/widgets/post-small-action';
|
||||||
import { addDiscoveryQueryParam } from 'discourse/controllers/discovery-sortable';
|
import { addDiscoveryQueryParam } from 'discourse/controllers/discovery-sortable';
|
||||||
import { addTagsHtmlCallback } from 'discourse/lib/render-tags';
|
import { addTagsHtmlCallback } from 'discourse/lib/render-tags';
|
||||||
|
import { addUserMenuGlyph } from 'discourse/widgets/user-menu';
|
||||||
|
|
||||||
// If you add any methods to the API ensure you bump up this number
|
// If you add any methods to the API ensure you bump up this number
|
||||||
const PLUGIN_API_VERSION = '0.8.2';
|
const PLUGIN_API_VERSION = '0.8.3';
|
||||||
|
|
||||||
class PluginApi {
|
class PluginApi {
|
||||||
constructor(version, container) {
|
constructor(version, container) {
|
||||||
@ -399,10 +400,30 @@ class PluginApi {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
|
* api.addTagsHtmlCallback(callback);
|
||||||
|
*
|
||||||
**/
|
**/
|
||||||
addTagsHtmlCallback(callback) {
|
addTagsHtmlCallback(callback) {
|
||||||
addTagsHtmlCallback(callback);
|
addTagsHtmlCallback(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a glyph to user menu after bookmarks
|
||||||
|
* WARNING: there is limited space there
|
||||||
|
*
|
||||||
|
* example:
|
||||||
|
*
|
||||||
|
* api.addUserMenuGlyph({
|
||||||
|
* label: 'awesome.label',
|
||||||
|
* className: 'my-class',
|
||||||
|
* icon: 'my-icon',
|
||||||
|
* href: `/some/path`
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
addUserMenuGlyph(glyph) {
|
||||||
|
addUserMenuGlyph(glyph);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let _pluginv01;
|
let _pluginv01;
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import { createWidget } from 'discourse/widgets/widget';
|
import { createWidget } from 'discourse/widgets/widget';
|
||||||
import { h } from 'virtual-dom';
|
import { h } from 'virtual-dom';
|
||||||
|
|
||||||
|
let extraGlyphs;
|
||||||
|
|
||||||
|
export function addUserMenuGlyph(glyph) {
|
||||||
|
extraGlyphs = extraGlyphs || [];
|
||||||
|
extraGlyphs.push(glyph);
|
||||||
|
}
|
||||||
|
|
||||||
createWidget('user-menu-links', {
|
createWidget('user-menu-links', {
|
||||||
tagName: 'div.menu-links-header',
|
tagName: 'div.menu-links-header',
|
||||||
|
|
||||||
@ -13,10 +20,18 @@ createWidget('user-menu-links', {
|
|||||||
isAnon;
|
isAnon;
|
||||||
|
|
||||||
const path = attrs.path;
|
const path = attrs.path;
|
||||||
const glyphs = [{ label: 'user.bookmarks',
|
const glyphs = [];
|
||||||
|
|
||||||
|
if (extraGlyphs) {
|
||||||
|
// yes glyphs.push(...extraGlyphs) is nicer, but pulling in
|
||||||
|
// _toConsumableArray seems totally uneeded here
|
||||||
|
glyphs.push.apply(glyphs, extraGlyphs);
|
||||||
|
}
|
||||||
|
|
||||||
|
glyphs.push({ label: 'user.bookmarks',
|
||||||
className: 'user-bookmarks-link',
|
className: 'user-bookmarks-link',
|
||||||
icon: 'bookmark',
|
icon: 'bookmark',
|
||||||
href: `${path}/activity/bookmarks` }];
|
href: `${path}/activity/bookmarks` });
|
||||||
|
|
||||||
if (siteSettings.enable_private_messages) {
|
if (siteSettings.enable_private_messages) {
|
||||||
glyphs.push({ label: 'user.private_messages',
|
glyphs.push({ label: 'user.private_messages',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user