The past 15 hours for me have been a nightmare of reading existing plugins and source code just to get extremely basic functionality to write my first plugin. I need help.
Specifically, I need help just getting a new button in the admin panel for each post (the button in the bottom left). The most I’ve gotten done is putting the button in the same element as the widget…
But notice the bullet point. This is because what I’ve created isn’t going in the ul as it should be. I have no clue how to fix this.
(the div is my option).
I did that with this code:
import { withPluginApi } from 'discourse/lib/plugin-api';
import showModal from "discourse/lib/show-modal";
export default {
name: 'tl-post-lock',
initialize() {
withPluginApi('0.8.24', function(api) {
const user = api.getCurrentUser()
if(user.trust_level >= api.container.lookup('site-settings:main').tl_lock_minimum) {
// User is allowed to see the button
api.decorateWidget('topic-admin-menu:after', (decorator) => {
// Adds the button to the admin menu
return decorator.attach('admin-menu-button', {
icon: 'ban',
fullLabel: 'tl_post_lock.button_label',
action: 'actionTlLock'
})
})
}
})
}
}
After this, there’s no way to get it to actually click. After the decorateWidget block, if I write any form of this:
I get the following completely unhelpful error with a line and character that doesn’t even EXIST.
Along with a bunch of other spam.
I’m losing my sanity. How do I just add a button to the bottom left admin panel so I can run code when I click on it?