DEV: Switch to new addComposerToolbarPopupMenuOption plugin API (#66)

Why this change?

`api.addToolbarPopupMenuOptionsCallback` has been deprecated in https://github.com/discourse/discourse/commit/913fd3a7b392b492f6344102577960a6eada00ce
This commit is contained in:
Alan Guo Xiang Tan
2023-10-23 08:08:36 +08:00
committed by GitHub
parent f076c50946
commit a6a86163a7
3 changed files with 26 additions and 27 deletions
@@ -1,30 +1,19 @@
import { apiInitializer } from "discourse/lib/api";
import SpreadsheetEditor from "../components/spreadsheet-editor";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
export default apiInitializer("0.11.1", (api) => {
api.modifyClass("controller:composer", {
pluginId: "discourse-table-builder",
modal: service(),
export default apiInitializer("1.15.0", (api) => {
const modal = api.container.lookup("service:modal");
@action
showTableBuilder() {
this.modal.show(SpreadsheetEditor, {
api.addComposerToolbarPopupMenuOption({
icon: "table",
label: themePrefix("discourse_table_builder.composer.button"),
action: (toolbarEvent) => {
modal.show(SpreadsheetEditor, {
model: {
toolbarEvent: this.toolbarEvent,
toolbarEvent,
tableTokens: null,
},
});
},
});
api.addToolbarPopupMenuOptionsCallback(() => {
return {
id: "table-builder",
action: "showTableBuilder",
icon: "table",
label: themePrefix("discourse_table_builder.composer.button"),
};
});
});