Skip to content

Add inline action button sample with mm_blocks_actions#211

Open
sbishel wants to merge 4 commits into
masterfrom
action_buttons
Open

Add inline action button sample with mm_blocks_actions#211
sbishel wants to merge 4 commits into
masterfrom
action_buttons

Conversation

@sbishel

@sbishel sbishel commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Add /inline_action slash command that posts a markdown issue-tracker table whose mmaction://triage?... links open a per-row triage dialog.
  • Demonstrates the mm_blocks_actions post prop (with required type: "external") and per-click parameters carried in the link query string (id, title, priority, assignee) merged into the upstream URL by MergeQueryIntoURL. Static fields (project) still come through request.Context.
  • Adds a /inline_action/triage HTTP handler that opens a follow-up dialog populated from those query params and the static context.

Ticket Link

Fixes https://mattermost.atlassian.net/browse/MM-68387

Test plan

  • /inline_action posts the 5-row issue table.
  • Clicking "Triage" on each row opens a dialog whose intro text shows that row's id / title / priority / assignee plus the static project=Demo Project.
  • Submitting the triage dialog posts the standard "Dialog Submitted" message back to the channel.

Requires mattermost/mattermost#36219 to test.

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request adds an inline action feature to the Mattermost demo plugin. Users can invoke /demo_plugin inline_action to post a markdown table with an action button; clicking the button triggers an HTTP endpoint that opens an interactive triage dialog for issue management.

Changes

Inline Action Workflow

Layer / File(s) Summary
Command trigger registration and dispatcher wiring
server/command_hooks.go
Adds inline_action command constant, registers it with Mattermost command API with autocomplete and label, and routes the trigger in the ExecuteCommand dispatcher.
Command handler with action button
server/command_hooks.go
Implements executeCommandInlineAction to build a markdown issue table post with mm_blocks_actions containing an external triage action pointing to the plugin's HTTP endpoint; logs and returns ephemeral error if post creation fails.
HTTP inline action triage endpoint
server/http_hooks.go
Registers /inline_action/triage route and implements handleInlineActionTriage to parse triage metadata (id, title, priority, assignee, project), build an interactive dialog request, and open it via Mattermost API; includes formatJSON helper for indented JSON output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an inline action button sample that demonstrates the mm_blocks_actions feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly relates to the changeset, detailing the addition of an /inline_action slash command with markdown table posting and triage dialog functionality, matching the file changes in command_hooks.go and http_hooks.go.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch action_buttons

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/http_hooks.go`:
- Around line 517-525: The intro always prefixes assignee with '@', producing
"`@unassigned`"; change to build a display value that only prepends '@' for real
assignees. Create a local assigneeDisplay (or similar) based on assignee (e.g.,
if assignee == "unassigned" or empty then assigneeDisplay = "unassigned" else
assigneeDisplay = "@"+assignee) and use that in the fmt.Sprintf that builds
intro (referencing assignee, assigneeDisplay, and the existing fmt.Sprintf call
that builds intro using issueID, project, title, priority).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4cd24d6-f7ce-4326-be60-a3c0f70bf03a

📥 Commits

Reviewing files that changed from the base of the PR and between e9d7e1f and 47b0c4f.

📒 Files selected for processing (2)
  • server/command_hooks.go
  • server/http_hooks.go

Comment thread server/http_hooks.go Outdated
Per coderabbit review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant