* docs: restore generated plugin SDK reference pages Reimplements the Hugo-era plugingodocs/pluginjsdocs/pluginmanifestdocs shortcode pipeline natively in Docusaurus, so the server plugin SDK, web app plugin SDK, and manifest reference pages render full generated content again instead of "Generated content (migrating)" placeholders. Two new Go generators (gen-plugin-godocs, gen-plugin-manifest-docs) and one Node generator (gen-plugin-jsdocs.mjs) read server/public/plugin, server/public/model, and webapp/channels/src/plugins/registry.ts directly from this monorepo and emit gitignored JSON consumed by new PluginGoDocs/PluginGoExample/PluginJsDocs/PluginManifestDocs React components, wired into prestart/prebuild alongside the existing sidebar/OpenAPI generators. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: remove migration plan doc from this PR Was a handoff/status doc for the implementing agent, not meant to ship as part of the change itself. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: make plugin-godocs/manifest-docs builds atomic build:plugin-godocs and build:plugin-manifest-docs redirected straight into data/plugin-*.json, which doesn't exist on a clean checkout (the redirection itself would fail before the generator ever ran) and, on a subsequent failed run, would truncate a previously-good JSON file before failing. Create data/ up front, write to a .tmp file, and only mv it into place once the generator exits successfully. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: fix review findings in plugin doc generators gen-plugin-manifest-docs: - jsonFieldName now excludes unexported fields (matching encoding/json) and falls back to the Go field name when there's no tag or the tag's name component is empty (e.g. json:",omitempty"), instead of dropping the field entirely. - exprTypeDocs's SelectorExpr case now resolves a qualified type only when its package qualifier actually points at the model package (checked against the declaring file's imports), instead of matching any x.Sel identifier by name alone regardless of which package it qualifies. gen-plugin-godocs: - The example-code loop now falls back to example.Code when example.Play is nil (go/doc leaves Play nil when it can't synthesize a whole runnable program), and propagates printer.Fprint errors instead of discarding them. No output change for the current server/public/plugin or server/public/model content — verified via a full regen. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: drop legacy-repo comment references, align jsdocs generator parser Remove "port of the old mattermost-developer-documentation Hugo shortcode" comments from the plugin doc generators/components now that they're fully native to this monorepo, and switch gen-plugin-jsdocs.mjs from the TypeScript compiler API to @typescript-eslint/typescript-estree to match the old script's parser/shape, while keeping the more robust reArg-declared-parameter-name and node-scoped comment-attachment logic. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: bump plugin doc generators' go.mod to go 1.26 go 1.23 was arbitrarily low; align with a current Go version. go run auto-downloads a matching toolchain on older local installs, so this doesn't reintroduce a dependency on server/public/go.mod's version. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: handle RestElement in gen-plugin-jsdocs parameter extraction paramNamesFromPattern silently dropped rest parameters/destructured rest members (e.g. (a, ...rest) or {a, ...rest}), since RestElement matched none of its type checks. No effect on today's registry.ts output (no rest patterns currently used there), but keeps the extraction correct if one is ever introduced. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: simplify plugin doc generators README note Co-authored-by: Cursor <cursoragent@cursor.com> * docs: check stdout write errors in plugin doc generators os.Stdout.Write's return errors were discarded, so a failed/partial write (e.g. broken pipe, disk full) would still exit 0. Combined with the npm scripts' > file.tmp && mv pattern, a truncated write could be treated as a successful generation. Fatal on either write failing. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: flatten Server/Webapp plugin SDK reference sidebar nesting server/server-reference.md and webapp/webapp-reference.md were the only file in their respective folders, so the sidebar generator (which only collapses a folder into a single entry when it has an index.md) rendered them as a "Server" > "Server plugin SDK reference" category with one child instead of one flat entry, unlike every sibling reference folder (rest-api/index.md, bot-accounts/index.md, etc.). Rename both to index.md to match that convention, and update the ~20 cross-referencing links (many with #anchor fragments) that pointed at the old /reference/server/server-reference and /reference/webapp/webapp- reference paths. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
5.9 KiB
title, sidebar_position
| title | sidebar_position |
|---|---|
| Best practices | 0 |
Design best practices
Actions that apply to specific Channels
-
Recommendation: Have your plugin register the actions to the channel header. This makes it quickly accessible for users and the actions apply on the channel they're viewing.
-
Example: Zoom meeting posts to a channel
You can additionally register a slash command on the server-side to take channel-specific actions.
Actions that apply to specific messages
-
Recommendation: Have your plugin register a post dropdown menu component with some text, icon and an action function. This adds your action to the "More Actions" post menu dropdown for easy discovery.
-
Examples: Create or attach to Jira issue from a message; copy a message to another channel; report an inappropriate message
-
Sample code: mattermost/mattermost-plugin-todo/webapp/src/index.js
Actions related to files or images
-
Recommendation: Have your plugin register a file upload method with some text, icon and an action function. This adds your new action to the file upload menu.
-
Examples: File sharing from OneDrive or GDrive; Draw plugin for sketches
Actions that apply to specific teams
-
Recommendation: Have your plugin register left sidebar header component with some text, icon and an action function. This adds your action above your team's channels in the sidebar.
-
Examples: Trello kanban board plugin, GitHub Plugin
Quick links or status summaries of workflows
-
Recommendation: Have your plugin register a bottom team sidebar component. This adds icons to the lower left corner of the UI.
-
Examples: GitHub sidebar links with summary of outstanding reviews or unread messages; ServiceNow incident status summary
Global actions that can be taken anywhere in the server and not directly related to teams, channels or users
-
Recommendation: Have your plugin register main menu action with some text, icon for mobile, and an action function. This adds your action to the Main Menu. You can additionally register a slash command on the server-side.
-
Examples: Share feedback plugin in Main Menu; /jira slash commands for quick actions
Actions that apply to specific users
-
Recommendation: Have your plugin register a popover user actions component. This adds your action button to the user profile popover.
-
Examples: Report User plugin; Display extra information about the user from an LDAP server
Extra information on a user profile
-
Recommendation: Have your plugin register a popover user attribute component. This adds your custom attributes to the user profile popover.
-
Examples: Custom User Attributes plugin
Actions related to emoji and GIFs
- Recommendation: Have your plugin add a component to the emoji picker. This is not yet supported, but some work had previously started with the issue currently opened as Help Wanted.
- Examples: Bitmoji plugin; GIFs via Giphy or Gfycat
Set up the plugin to properly communicate with the Mattermost Server
Use the Mattermost Server's SiteURL in your web app plugin
In order to make sure your plugin has full compatibility with your Mattermost server, you should use the server's configured SiteURL in each API call you send to the server from the webapp. Here's an example of how to compute the SiteURL:
export const getPluginServerRoute = (state) => {
const config = getConfig(state);
let basePath = '';
if (config && config.SiteURL) {
basePath = new URL(config.SiteURL).pathname;
if (basePath && basePath[basePath.length - 1] === '/') {
basePath = basePath.substr(0, basePath.length - 1);
}
}
return basePath + '/plugins/' + PluginId;
};
Include the server's CSRF token in your web app plugin's requests
The Mattermost server can be configured to require a CSRF token to be present in HTTP requests sent from the webapp. In order to include the token in each request, you can use the mattermost-redux library's Client4.getOptions function to add the token to your fetch request. Here's an example of how to include the CSRF token.
const response = await fetch(url, Client4.getOptions(options));








