DEV: Export openNewCategoryModal from discovery-categories (#9501)

DEV: Export openNewCategoryModal from discovery-categories (#9501)

diff --git a/app/assets/javascripts/discourse/routes/discovery-categories.js b/app/assets/javascripts/discourse/routes/discovery-categories.js
index 451d9cc..2770a80 100644
--- a/app/assets/javascripts/discourse/routes/discovery-categories.js
+++ b/app/assets/javascripts/discourse/routes/discovery-categories.js
@@ -110,22 +110,7 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
     },
 
     createCategory() {
-      const groups = this.site.groups,
-        everyoneName = groups.findBy("id", 0).name;
-
-      const model = this.store.createRecord("category", {
-        color: "0088CC",
-        text_color: "FFFFFF",
-        group_permissions: [{ group_name: everyoneName, permission_type: 1 }],
-        available_groups: groups.map(g => g.name),
-        allow_badges: true,
-        topic_featured_link_allowed: true,
-        custom_fields: {},
-        search_priority: searchPriorities.normal
-      });
-
-      showModal("edit-category", { model });
-      this.controllerFor("edit-category").set("selectedTab", "general");
+      openNewCategoryModal(this);
     },
 
     reorderCategories() {
@@ -148,4 +133,22 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, {
   }
 });
 
+export function openNewCategoryModal(context) {
+  const groups = context.site.groups,
+    everyoneName = groups.findBy("id", 0).name;
+
+  const model = context.store.createRecord("category", {
+    color: "0088CC",
+    text_color: "FFFFFF",
+    group_permissions: [{ group_name: everyoneName, permission_type: 1 }],
+    available_groups: groups.map(g => g.name),
+    allow_badges: true,
+    topic_featured_link_allowed: true,
+    custom_fields: {},
+    search_priority: searchPriorities.normal
+  });
+
+  showModal("edit-category", { model }).set("selectedTab", "general");
+}
+
 export default DiscoveryCategoriesRoute;

GitHub sha: 04fb37c7

This commit appears in #9501 which was approved by eviltrout. It was merged by markvanlan.