Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey @NhienLam,
I've taken a closer look into doing what you need for upvote/downvote. Firstly, I think its better to use
api.addPostMenuButton()
instead. Take a look at this draft PR and see how I've added that in. After this, you can then see that I've added an action. These are calls to methods where you can handle what will happen on a click.A good example of a plugin doing this functionality is discourse-solved. Take a look at their codebase to see how they've implemented action calls.
Take a look at this file in their repo:
https://github.com/discourse/discourse-solved/blob/HEAD/assets/javascripts/discourse/initializers/extend-for-solved-button.js.es6
See how they have
api.addPostMenuButton()
with the action set to "acceptAnswer".This action is calling the widgetAction on line 174.
I think you can mimic this approach for your plugin. Take a look, I think it'll be helpful.
Also another relevant article here:
https://meta.discourse.org/t/add-additional-button-post-menu/149439