DEV: Make `discourse-common` an Ember addon. (#9578)

DEV: Make discourse-common an Ember addon. (#9578)

This is to help with the migration to Ember CLI. In the current running version of Discourse everything should be the same as before, just with a few extra files that are not used. However, using Ember CLI this can be installed as an Ember addon.

Co-Authored-By: Jarek Radosz jradosz@gmail.com

diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 81d5a2f..e848bdc 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -23,9 +23,6 @@ acc5cbdf8ecb9293a0fa9474ee73baf499c02428
 # Rename wizard from es6 -> js
 1ac02422011f89716ab27250d39b0e0212e03892
 
-# Rename discourse-common es6 -> js
-167503ca4824e37a2e93d74b3f50271556d0ba8e
-
 # Rename some root files
 11938d58d4b1bea1ff43306450da7b24f05db0a
 
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 86d34b4..489768d 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,4 +1,4 @@
-//= require_tree ./discourse-common
+//= require_tree ./discourse-common/addon
 //= require ./polyfills
 //= require_tree ./select-kit
 //= require ./discourse/app/app
diff --git a/app/assets/javascripts/discourse-common/addon/.gitkeep b/app/assets/javascripts/discourse-common/addon/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/.gitkeep
diff --git a/app/assets/javascripts/discourse-common/addon/config/environment.js b/app/assets/javascripts/discourse-common/addon/config/environment.js
new file mode 100644
index 0000000..18ce3cc
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/config/environment.js
@@ -0,0 +1,3 @@
+export const INPUT_DELAY = 250;
+
+export default { environment: Ember.testing ? "test" : "development" };
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/bound-i18n.js b/app/assets/javascripts/discourse-common/addon/helpers/bound-i18n.js
new file mode 100644
index 0000000..0d58d0f
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/bound-i18n.js
@@ -0,0 +1,3 @@
+import { htmlHelper } from "discourse-common/lib/helpers";
+
+export default htmlHelper((key, params) => I18n.t(key, params.hash));
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/component-for-collection.js b/app/assets/javascripts/discourse-common/addon/helpers/component-for-collection.js
new file mode 100644
index 0000000..384012a
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/component-for-collection.js
@@ -0,0 +1,8 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+
+registerUnbound(
+  "component-for-collection",
+  (collectionIdentifier, selectKit) => {
+    return selectKit.modifyComponentForCollection(collectionIdentifier);
+  }
+);
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/component-for-row.js b/app/assets/javascripts/discourse-common/addon/helpers/component-for-row.js
new file mode 100644
index 0000000..4f8ba12
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/component-for-row.js
@@ -0,0 +1,8 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+
+registerUnbound(
+  "component-for-row",
+  (collectionForIdentifier, item, selectKit) => {
+    return selectKit.modifyComponentForRow(collectionForIdentifier, item);
+  }
+);
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/d-icon.js b/app/assets/javascripts/discourse-common/addon/helpers/d-icon.js
new file mode 100644
index 0000000..454bb22
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/d-icon.js
@@ -0,0 +1,6 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+import { renderIcon } from "discourse-common/lib/icon-library";
+
+registerUnbound("d-icon", function(id, params) {
+  return new Handlebars.SafeString(renderIcon("string", id, params));
+});
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/fa-icon.js b/app/assets/javascripts/discourse-common/addon/helpers/fa-icon.js
new file mode 100644
index 0000000..1d657d0
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/fa-icon.js
@@ -0,0 +1,12 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+import { renderIcon } from "discourse-common/lib/icon-library";
+import deprecated from "discourse-common/lib/deprecated";
+
+export function iconHTML(id, params) {
+  return renderIcon("string", id, params);
+}
+
+registerUnbound("fa-icon", function(icon, params) {
+  deprecated("Use `{{d-icon}}` instead of `{{fa-icon}}");
+  return new Handlebars.SafeString(iconHTML(icon, params));
+});
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/get-url.js b/app/assets/javascripts/discourse-common/addon/helpers/get-url.js
new file mode 100644
index 0000000..e3847c4
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/get-url.js
@@ -0,0 +1,4 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+import getUrl from "discourse-common/lib/get-url";
+
+registerUnbound("get-url", value => getUrl(value));
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/html-safe.js b/app/assets/javascripts/discourse-common/addon/helpers/html-safe.js
new file mode 100644
index 0000000..dc6d5da
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/html-safe.js
@@ -0,0 +1,6 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+import { htmlSafe } from "@ember/template";
+
+registerUnbound("html-safe", function(string) {
+  return htmlSafe(string);
+});
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/i18n.js b/app/assets/javascripts/discourse-common/addon/helpers/i18n.js
new file mode 100644
index 0000000..902ed69
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/i18n.js
@@ -0,0 +1,6 @@
+import { registerUnbound } from "discourse-common/lib/helpers";
+
+registerUnbound("i18n", (key, params) => I18n.t(key, params));
+registerUnbound("i18n-yes-no", (value, params) =>
+  I18n.t(value ? "yes_value" : "no_value", params)
+);
diff --git a/app/assets/javascripts/discourse-common/addon/helpers/popular-themes.js b/app/assets/javascripts/discourse-common/addon/helpers/popular-themes.js
new file mode 100644
index 0000000..50d475e
--- /dev/null
+++ b/app/assets/javascripts/discourse-common/addon/helpers/popular-themes.js
@@ -0,0 +1,119 @@
+export const POPULAR_THEMES = [
+  {
+    name: "Graceful",
+    value: "https://github.com/discourse/graceful",
+    preview: "https://theme-creator.discourse.org/theme/awesomerobot/graceful",
+    description: "A light and graceful theme for Discourse.",
+    meta_url:
+      "https://meta.discourse.org/t/a-graceful-theme-for-discourse/93040"
+  },
+  {
+    name: "Material Design Theme",
+    value: "https://github.com/discourse/material-design-stock-theme",
+    preview: "https://newmaterial.trydiscourse.com",
+    description:
+      "Inspired by Material Design, this theme comes with several color palettes (incl. a dark one).",
+    meta_url: "https://meta.discourse.org/t/material-design-stock-theme/47142"
+  },
+  {
+    name: "Minima",
+    value: "https://github.com/discourse/minima",
+    preview: "https://theme-creator.discourse.org/theme/awesomerobot/minima",
+    description: "A minimal theme with reduced UI elements and focus on text.",
+    meta_url:
+      "https://meta.discourse.org/t/minima-a-minimal-theme-for-discourse/108178"
+  },
+  {
+    name: "Sam's Simple Theme",
+    value: "https://github.com/discourse/discourse-simple-theme",
+    preview: "https://theme-creator.discourse.org/theme/sam/simple",
+    description:
+      "Simplified front page design with classic colors and typography.",
+    meta_url:
+      "https://meta.discourse.org/t/sams-personal-minimal-topic-list-design/23552"
+  },
+  {
+    name: "Vincent",
+    value: "https://github.com/discourse/discourse-vincent-theme",
+    preview: "https://theme-creator.discourse.org/theme/awesomerobot/vincent",
+    description: "An elegant dark theme with a few color palettes.",
+    meta_url: "https://meta.discourse.org/t/discourse-vincent-theme/76662"
+  },
+  {
+    name: "Brand Header",

[... diff too long, it was truncated ...]

GitHub sha: cbb27241

This commit appears in #9578 which was merged by eviltrout.