ソースを参照

DEV: Switch to new `addComposerToolbarPopupMenuOption` plugin API (#4)

Why this change?

`api.addToolbarPopupMenuOptionsCallback` has been deprecated in https://github.com/discourse/discourse/commit/913fd3a7b392b492f6344102577960a6eada00ce
Alan Guo Xiang Tan 1 年間 前
コミット
d78b5c4c30

+ 1 - 0
.discourse-compatibility

@@ -1,2 +1,3 @@
+< 3.2.0.beta2: 91aedef56a80b313a365ed3c814bbd0cca8695bd
 3.1.999: 86b488188c9beca0478b41ff50ca91a48df1d421
 

+ 8 - 17
assets/javascripts/discourse/initializers/bbb.js.es6

@@ -75,7 +75,7 @@ export default {
   name: "insert-bbb",
 
   initialize() {
-    withPluginApi("0.8.31", (api) => {
+    withPluginApi("1.15.0", (api) => {
       const currentUser = api.getCurrentUser();
       const siteSettings = api.container.lookup("site-settings:main");
 
@@ -87,24 +87,15 @@ export default {
         !siteSettings.bbb_staff_only ||
         (siteSettings.bbb_staff_only && currentUser && currentUser.staff)
       ) {
-        api.modifyClass("controller:composer", {
-          actions: {
-            insertBBBModal() {
-              showModal("insert-bbb").setProperties({
-                toolbarEvent: this.get("toolbarEvent"),
-              });
-            },
+        api.addComposerToolbarPopupMenuOption({
+          icon: "video",
+          label: "bbb.composer_title",
+          action: (toolbarEvent) => {
+            showModal("insert-bbb").setProperties({
+              toolbarEvent,
+            });
           },
         });
-
-        api.addToolbarPopupMenuOptionsCallback((controller) => {
-          return {
-            id: "insert-bbb",
-            icon: "video",
-            action: "insertBBBModal",
-            label: "bbb.composer_title",
-          };
-        });
       }
     });
   },