Steps for creating custom small-actions to use in plugin?

I’m working on some domain-specific plugins for our forum and we would like to create custom small actions similar to these:

In particular I just need to be able to put notices like these on the topic but being able to customize the icon and the text.

Can anyone walk me through the constructs/modules/templates/etc I would need to hook into to accomplish this on the back-end and front-end, or could you point me to an existing plugin that currently implements this?

Thank you!

3 Likes

discourse-assign is probably the best example of this:

https://github.com/discourse/discourse-assign/blob/master/lib/topic_assigner.rb#L207-L217

And then some stuff to add the icon / content

https://github.com/discourse/discourse-assign/blob/master/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6#L158-L169

11 Likes

Thanks, this helped out a lot.

What would be the best way to go about making the small action display richer text?

Current:
image

What I want: (I achieved this by manually inserting the cooked class into the div with class small-action-desc)

image

I skimmed through the source code about post transformers but could not find anything related to this


EDIT: ended up just adding this as .scss

.custom-message {
    ins {
        background-color: dark-light-choose(
            $success-low,
            scale-color($success, $lightness: -60%)
        );
    }
    del {
        background-color: dark-light-choose(
            $danger-low,
            scale-color($danger, $lightness: -60%)
        );
    }
}
5 Likes