DEV: Plugin API function to add items to quick access profile (#10182)

DEV: Plugin API function to add items to quick access profile (#10182)

diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js
index 879eeac..a157f01 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.js
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js
@@ -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;
diff --git a/app/assets/javascripts/discourse/app/widgets/quick-access-profile.js b/app/assets/javascripts/discourse/app/widgets/quick-access-profile.js
index bbdd5dd..f1c209c 100644
--- a/app/assets/javascripts/discourse/app/widgets/quick-access-profile.js
+++ b/app/assets/javascripts/discourse/app/widgets/quick-access-profile.js
@@ -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());
     }

GitHub sha: 81fe8a50

This commit appears in #10182 which was approved by eviltrout. It was merged by markvanlan.