diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js
index fa3d98c4ba5..71a6210d912 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.js
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js
@@ -53,7 +53,10 @@ import { addPluginOutletDecorator } from "discourse/components/plugin-connector"
import { addPluginReviewableParam } from "discourse/components/reviewable-item";
import { addPopupMenuOptionsCallback } from "discourse/controllers/composer";
import { addPostClassesCallback } from "discourse/widgets/post";
-import { addPostSmallActionIcon } from "discourse/widgets/post-small-action";
+import {
+ addGroupPostSmallActionCode,
+ addPostSmallActionIcon,
+} from "discourse/widgets/post-small-action";
import { addQuickAccessProfileItem } from "discourse/widgets/quick-access-profile";
import { addTagsHtmlCallback } from "discourse/lib/render-tags";
import { addToolbarCallback } from "discourse/components/d-editor";
@@ -81,7 +84,7 @@ import { addSearchResultsCallback } from "discourse/lib/search";
import { addSearchSuggestion } from "discourse/widgets/search-menu-results";
// If you add any methods to the API ensure you bump up this number
-const PLUGIN_API_VERSION = "0.12.1";
+const PLUGIN_API_VERSION = "0.12.2";
class PluginApi {
constructor(version, container) {
@@ -715,6 +718,17 @@ class PluginApi {
addPostSmallActionIcon(key, icon);
}
+ /**
+ * Register a small action code to be used for small post actions containing a link to a group
+ *
+ * ```javascript
+ * api.addGroupPostSmallActionCode('group_assigned');
+ * ```
+ **/
+ addGroupPostSmallActionCode(actionCode) {
+ addGroupPostSmallActionCode(actionCode);
+ }
+
/**
* Register an additional query param with topic discovery,
* this allows for filters on the topic list
diff --git a/app/assets/javascripts/discourse/app/widgets/post-small-action.js b/app/assets/javascripts/discourse/app/widgets/post-small-action.js
index 76075500193..7331ce4f061 100644
--- a/app/assets/javascripts/discourse/app/widgets/post-small-action.js
+++ b/app/assets/javascripts/discourse/app/widgets/post-small-action.js
@@ -16,7 +16,7 @@ export function actionDescriptionHtml(actionCode, createdAt, username) {
let who = "";
if (username) {
- if (actionCode === "invited_group" || actionCode === "removed_group") {
+ if (groupActionCodes.includes(actionCode)) {
who = `@${username}`;
} else {
who = `@${username}`;
@@ -34,6 +34,8 @@ export function actionDescription(actionCode, createdAt, username) {
});
}
+const groupActionCodes = ["invited_group", "removed_group"];
+
const icons = {
"closed.enabled": "lock",
"closed.disabled": "unlock-alt",
@@ -64,6 +66,10 @@ export function addPostSmallActionIcon(key, icon) {
icons[key] = icon;
}
+export function addGroupPostSmallActionCode(actionCode) {
+ groupActionCodes.push(actionCode);
+}
+
export default createWidget("post-small-action", {
buildKey: (attrs) => `post-small-act-${attrs.id}`,
tagName: "div.small-action.onscreen-post",