Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget approach #6

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Widget approach #6

wants to merge 8 commits into from

Conversation

keegangeorge
Copy link
Contributor

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

@seanyap
Copy link
Contributor

seanyap commented Aug 6, 2021

@rykwong Is this @NhienLam's branch that you said you'll merge into your branch?

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.

3 participants