Browse Source

Move BBB button in composer options

Penar Musaraj 4 years ago
parent
commit
2b577fe81a
3 changed files with 30 additions and 20 deletions
  1. 28 18
      assets/javascripts/discourse/initializers/bbb.js.es6
  2. 1 1
      config/locales/client.en.yml
  3. 1 1
      plugin.rb

+ 28 - 18
assets/javascripts/discourse/initializers/bbb.js.es6

@@ -9,9 +9,9 @@ function launchBBB($elem, fullWindow) {
 
   ajax("/bbb/create.json", {
     type: "POST",
-    data: data
+    data: data,
   })
-    .then(res => {
+    .then((res) => {
       if (res.url) {
         if (fullWindow) {
           window.location.href = res.url;
@@ -43,7 +43,7 @@ function attachStatus($elem, helper) {
   const status = $elem.find(".bbb-status");
   const data = $elem.data();
 
-  ajax(`/bbb/status/${data.meetingID}.json`).then(res => {
+  ajax(`/bbb/status/${data.meetingID}.json`).then((res) => {
     if (res.avatars) {
       status.html(`<span>On the call: </span>`);
       res.avatars.forEach(function(avatar) {
@@ -72,26 +72,36 @@ export default {
   name: "insert-bbb",
 
   initialize() {
-    withPluginApi("0.8.31", api => {
+    withPluginApi("0.8.31", (api) => {
       const currentUser = api.getCurrentUser();
       const siteSettings = api.container.lookup("site-settings:main");
 
-      api.onToolbarCreate(toolbar => {
-        if (siteSettings.bbb_staff_only && !currentUser.staff) {
-          return;
-        }
+      api.decorateCooked(attachBBB, {
+        id: "discourse-bbb",
+      });
+
+      if (siteSettings.bbb_staff_only && !currentUser.staff) {
+        return;
+      }
 
-        toolbar.addButton({
-          title: "bbb.composer_title",
-          id: "insertBBB",
-          group: "insertions",
-          icon: "fab-bootstrap",
-          perform: e =>
-            showModal("insert-bbb").setProperties({ toolbarEvent: e })
-        });
+      api.modifyClass("controller:composer", {
+        actions: {
+          insertBBBModal() {
+            showModal("insert-bbb").setProperties({
+              toolbarEvent: this.get("toolbarEvent"),
+            });
+          },
+        },
       });
 
-      api.decorateCooked(attachBBB, { id: "discourse-bbb" });
+      api.addToolbarPopupMenuOptionsCallback((controller) => {
+        return {
+          id: "insert-bbb",
+          icon: "video",
+          action: "insertBBBModal",
+          label: "bbb.composer_title",
+        };
+      });
     });
-  }
+  },
 };

+ 1 - 1
config/locales/client.en.yml

@@ -1,7 +1,7 @@
 en:
   js:
     bbb:
-      composer_title: BigBlueButton Integration
+      composer_title: Add BigBlueButton room
       meetingID: Meeting ID
       button_text: Button label (optional)
       attendeePW: Attendee password

+ 1 - 1
plugin.rb

@@ -8,7 +8,7 @@
 
 enabled_site_setting :bbb_enabled
 register_asset "stylesheets/common/bbb.scss"
-register_svg_icon "fab-bootstrap"
+
 register_svg_icon "video"
 
 after_initialize do