2016-06-13 18:21:14 +08:00
|
|
|
import { withPluginApi } from 'discourse/lib/plugin-api';
|
|
|
|
import showModal from 'discourse/lib/show-modal';
|
|
|
|
|
|
|
|
function initializePollUIBuilder(api) {
|
2016-07-07 15:52:56 +08:00
|
|
|
const siteSettings = api.container.lookup('site-settings:main');
|
|
|
|
|
|
|
|
if (!siteSettings.poll_enabled && (api.getCurrentUser() && !api.getCurrentUser().staff)) return;
|
|
|
|
|
2017-06-14 03:52:08 +08:00
|
|
|
api.modifyClass('controller:composer', {
|
2016-06-13 18:21:14 +08:00
|
|
|
actions: {
|
|
|
|
showPollBuilder() {
|
|
|
|
showModal("poll-ui-builder").set("toolbarEvent", this.get("toolbarEvent"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(function() {
|
|
|
|
return {
|
|
|
|
action: 'showPollBuilder',
|
|
|
|
icon: 'bar-chart-o',
|
|
|
|
label: 'poll.ui_builder.title'
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "add-poll-ui-builder",
|
|
|
|
|
|
|
|
initialize() {
|
2017-06-14 03:52:08 +08:00
|
|
|
withPluginApi('0.8.7', initializePollUIBuilder);
|
2016-06-13 18:21:14 +08:00
|
|
|
}
|
|
|
|
};
|