DEV: allows to use routeAction from components/widgets (#9267)

DEV: allows to use routeAction from components/widgets (#9267)

ATM this is only usable as a helper in templates.

diff --git a/app/assets/javascripts/discourse/helpers/route-action.js b/app/assets/javascripts/discourse/helpers/route-action.js
index 4e01049..1de9229 100644
--- a/app/assets/javascripts/discourse/helpers/route-action.js
+++ b/app/assets/javascripts/discourse/helpers/route-action.js
@@ -32,29 +32,32 @@ function getRouteWithAction(router, actionName) {
   return { action, handler };
 }
 
+export function routeAction(actionName, router, ...params) {
+  assert("[ember-route-action-helper] Unable to lookup router", router);
+
+  runInDebug(() => {
+    let { handler } = getRouteWithAction(router, actionName);
+    assert(
+      `[ember-route-action-helper] Unable to find action ${actionName}`,
+      handler
+    );
+  });
+
+  return function(...invocationArgs) {
+    let { action, handler } = getRouteWithAction(router, actionName);
+    let args = params.concat(invocationArgs);
+    return run.join(handler, action, ...args);
+  };
+}
+
 export default Helper.extend({
-  router: computed(function() {
-    return getOwner(this).lookup("router:main");
-  }).readOnly(),
+  router: computed({
+    get() {
+      return getOwner(this).lookup("router:main");
+    }
+  }),
 
   compute([actionName, ...params]) {
-    let router = get(this, "router");
-    assert("[ember-route-action-helper] Unable to lookup router", router);
-
-    runInDebug(() => {
-      let { handler } = getRouteWithAction(router, actionName);
-      assert(
-        `[ember-route-action-helper] Unable to find action ${actionName}`,
-        handler
-      );
-    });
-
-    let routeAction = function(...invocationArgs) {
-      let { action, handler } = getRouteWithAction(router, actionName);
-      let args = params.concat(invocationArgs);
-      return run.join(handler, action, ...args);
-    };
-
-    return routeAction;
+    return routeAction(actionName, get(this, "router"), ...params);
   }
 });

GitHub sha: 7d7c5641

This commit appears in #9267 which was approved by eviltrout. It was merged by jjaffeux.