mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: Plugin API function to add items to quick access profile (#10182)
This commit is contained in:

committed by
GitHub

parent
d09a953f53
commit
81fe8a50d4
@ -56,6 +56,7 @@ import { addExtraIconRenderer } from "discourse/helpers/category-link";
|
||||
import { queryRegistry } from "discourse/widgets/widget";
|
||||
import Composer from "discourse/models/composer";
|
||||
import { on } from "@ember/object/evented";
|
||||
import { addQuickAccessProfileItem } from "discourse/widgets/quick-access-profile";
|
||||
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
|
||||
|
||||
// If you add any methods to the API ensure you bump up this number
|
||||
@ -1157,6 +1158,22 @@ class PluginApi {
|
||||
addToHeaderIcons(icon) {
|
||||
addToHeaderIcons(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item to the quick access profile panel, before "Log Out".
|
||||
*
|
||||
* ```
|
||||
* api.addQuickAccessProfileItem({
|
||||
* icon: "pencil-alt",
|
||||
* href: "/somewhere",
|
||||
* content: I18n.t("user.somewhere")
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
**/
|
||||
addQuickAccessProfileItem(item) {
|
||||
addQuickAccessProfileItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
let _pluginv01;
|
||||
|
@ -3,6 +3,12 @@ import QuickAccessPanel from "discourse/widgets/quick-access-panel";
|
||||
import { createWidgetFrom } from "discourse/widgets/widget";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
const _extraItems = [];
|
||||
|
||||
export function addQuickAccessProfileItem(item) {
|
||||
_extraItems.push(item);
|
||||
}
|
||||
|
||||
createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
||||
tagName: "div.quick-access-panel.quick-access-profile",
|
||||
|
||||
@ -22,10 +28,12 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
||||
},
|
||||
|
||||
_getItems() {
|
||||
const items = this._getDefaultItems();
|
||||
let items = this._getDefaultItems();
|
||||
if (this._showToggleAnonymousButton()) {
|
||||
items.push(this._toggleAnonymousButton());
|
||||
}
|
||||
items = items.concat(_extraItems);
|
||||
|
||||
if (this.attrs.showLogoutButton) {
|
||||
items.push(this._logOutButton());
|
||||
}
|
||||
|
Reference in New Issue
Block a user