mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 05:50:14 +08:00
FEATURE: allow adding small action codes dedicated to groups (#14109)
Plugin API is allowing to add small action codes dedicated to groups. This will be used by assign-plugin when topic is assigned or unassigned from group.
This commit is contained in:
parent
c74f116a48
commit
d41aa5e9f5
|
@ -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
|
||||
|
|
|
@ -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 = `<a class="mention-group" href="/g/${username}">@${username}</a>`;
|
||||
} else {
|
||||
who = `<a class="mention" href="${userPath(username)}">@${username}</a>`;
|
||||
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue
Block a user