I've been trying to develop my own extension but I'm completely stuck at trying to get the settings Modal to appear. I tried just my code which didn't work. I then tried to see if another extension would work (I used flagrow/terms for testing) which worked fine even when I re-compiled the JS sources. I then tried modifying the other extensions source which still worked. However when I changed the extension key (from flagrow-terms
to my-extension
) the settings modal no longer worked. Any help would be appreciated.
src/admin/index.js
import app from 'flarum/app';
import MySettingsModal from './components/MySettingsModal';
app.initializers.add('my-extension', app => {
app.extensionSettings['my-extension'] = () => app.modal.show(new MySettingsModal());
});
src/admin/components/MySettingsModal.js
import app from 'flarum/app';
import SettingsModal from 'flarum/components/SettingsModal';
const settingsPrefix = 'my-extension.';
const translationPrefix = 'my-extension.admin.settings.';
export default class MySettingsModal extends SettingsModal {
title() {
return app.translator.trans(translationPrefix + 'title');
}
form() {
return [
m('.Form-group', [
m('label', app.translator.trans(translationPrefix + 'api_key_label')),
m('input[type=text].FormControl', {
bidi: this.setting(settingsPrefix + 'api_key'),
placeholder: 'API Key',
}),
]),
];
}
}