UX: moves create event button to toolbar popup menu

UX: moves create event button to toolbar popup menu

diff --git a/assets/javascripts/initializers/add-event-ui-builder.js.es6 b/assets/javascripts/initializers/add-event-ui-builder.js.es6
index bc21ac3..f47aaad 100644
--- a/assets/javascripts/initializers/add-event-ui-builder.js.es6
+++ b/assets/javascripts/initializers/add-event-ui-builder.js.es6
@@ -4,42 +4,43 @@ import showModal from "discourse/lib/show-modal";
 function initializeEventBuilder(api) {
   const currentUser = api.getCurrentUser();
 
-  api.onToolbarCreate(toolbar => {
-    if (
-      !currentUser ||
-      !currentUser.can_create_discourse_post_event ||
-      !toolbar.context.outletArgs
-    ) {
+  api.addToolbarPopupMenuOptionsCallback(composerController => {
+    if (!currentUser || !currentUser.can_create_discourse_post_event) {
       return;
     }
 
-    const composer = toolbar.context.outletArgs.composer;
+    const composerModel = composerController.model;
     if (
-      !composer.replyingToTopic &&
-      (composer.topicFirstPost ||
-        (composer.editingPost &&
-          composer.post &&
-          composer.post.post_number === 1))
+      composerModel &&
+      !composerModel.replyingToTopic &&
+      (composerModel.topicFirstPost ||
+        (composerModel.editingPost &&
+          composerModel.post &&
+          composerModel.post.post_number === 1))
     ) {
-      toolbar.addButton({
-        title: "discourse_post_event.builder_modal.attach",
+      return {
+        label: "discourse_post_event.builder_modal.attach",
         id: "insertEvent",
         group: "insertions",
         icon: "calendar-day",
-        perform: toolbarEvent => {
-          const eventModel = toolbar.context.store.createRecord(
-            "discourse-post-event-event"
-          );
-          eventModel.setProperties({
-            status: "public"
-          });
+        action: "insertEvent"
+      };
+    }
+  });
+
+  api.modifyClass("controller:composer", {
+    actions: {
+      insertEvent() {
+        const eventModel = this.store.createRecord(
+          "discourse-post-event-event"
+        );
+        eventModel.set("status", "public");
 
-          showModal("discourse-post-event-builder").setProperties({
-            toolbarEvent,
-            model: { eventModel }
-          });
-        }
-      });
+        showModal("discourse-post-event-builder").setProperties({
+          toolbarEvent: this.toolbarEvent,
+          model: { eventModel }
+        });
+      }
     }
   });
 }

GitHub sha: 4065f4ba