REFACTOR: Rename s to subscribe (#86)

REFACTOR: Rename s to subscribe (#86)

diff --git a/assets/javascripts/discourse/components/campaign-banner.js.es6 b/assets/javascripts/discourse/components/campaign-banner.js.es6
index a5dcbd6..6784aa6 100644
--- a/assets/javascripts/discourse/components/campaign-banner.js.es6
+++ b/assets/javascripts/discourse/components/campaign-banner.js.es6
@@ -119,7 +119,7 @@ export default Component.extend({
     const showOnRoute =
       currentRoute !== "discovery.s" &&
       !currentRoute.split(".")[0].includes("admin") &&
-      currentRoute.split(".")[0] !== "s";
+      currentRoute.split(".")[0] !== "subscribe";
 
     if (!this.site.show_campaign_banner) {
       return false;
diff --git a/assets/javascripts/discourse/controllers/s-index.js.es6 b/assets/javascripts/discourse/controllers/s-index.js.es6
deleted file mode 100644
index 6a5f0ca..0000000
--- a/assets/javascripts/discourse/controllers/s-index.js.es6
+++ /dev/null
@@ -1,10 +0,0 @@
-import Controller from "@ember/controller";
-import discourseComputed from "discourse-common/utils/decorators";
-import User from "discourse/models/user";
-
-export default Controller.extend({
-  @discourseComputed()
-  isLoggedIn() {
-    return User.current();
-  },
-});
diff --git a/assets/javascripts/discourse/controllers/s-show.js.es6 b/assets/javascripts/discourse/controllers/s-show.js.es6
deleted file mode 100644
index 45a91d5..0000000
--- a/assets/javascripts/discourse/controllers/s-show.js.es6
+++ /dev/null
@@ -1,131 +0,0 @@
-import Controller from "@ember/controller";
-import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
-import Transaction from "discourse/plugins/discourse-subscriptions/discourse/models/transaction";
-import I18n from "I18n";
-import { not } from "@ember/object/computed";
-import discourseComputed from "discourse-common/utils/decorators";
-
-export default Controller.extend({
-  selectedPlan: null,
-  promoCode: null,
-  isAnonymous: not("currentUser"),
-
-  init() {
-    this._super(...arguments);
-    this.set(
-      "stripe",
-      Stripe(this.siteSettings.discourse_subscriptions_public_key)
-    );
-    const elements = this.get("stripe").elements();
-
-    this.set("cardElement", elements.create("card", { hidePostalCode: true }));
-  },
-
-  alert(path) {
-    bootbox.alert(I18n.t(`discourse_subscriptions.${path}`));
-  },
-
-  @discourseComputed("model.product.repurchaseable", "model.product.subscribed")
-  canPurchase(repurchaseable, subscribed) {
-    if (!repurchaseable && subscribed) {
-      return false;
-    }
-
-    return true;
-  },
-
-  createSubscription(plan) {
-    return this.stripe.createToken(this.get("cardElement")).then((result) => {
-      if (result.error) {
-        this.set("loading", false);
-        return result;
-      } else {
-        const subscription = Subscription.create({
-          source: result.token.id,
-          plan: plan.get("id"),
-          promo: this.promoCode,
-        });
-
-        return subscription.save();
-      }
-    });
-  },
-
-  handleAuthentication(plan, transaction) {
-    return this.stripe
-      .confirmCardPayment(transaction.payment_intent.client_secret)
-      .then((result) => {
-        if (
-          result.paymentIntent &&
-          result.paymentIntent.status === "succeeded"
-        ) {
-          return result;
-        } else {
-          this.set("loading", false);
-          bootbox.alert(result.error.message || result.error);
-          return result;
-        }
-      });
-  },
-
-  _advanceSuccessfulTransaction(plan) {
-    this.alert("plans.success");
-    this.set("loading", false);
-
-    this.transitionToRoute(
-      plan.type === "recurring"
-        ? "user.billing.subscriptions"
-        : "user.billing.payments",
-      this.currentUser.username.toLowerCase()
-    );
-  },
-
-  actions: {
-    stripePaymentHandler() {
-      this.set("loading", true);
-      const plan = this.get("model.plans")
-        .filterBy("id", this.selectedPlan)
-        .get("firstObject");
-
-      if (!plan) {
-        this.alert("plans.validate.payment_options.required");
-        this.set("loading", false);
-        return;
-      }
-
-      let transaction = this.createSubscription(plan);
-
-      transaction
-        .then((result) => {
-          if (result.error) {
-            bootbox.alert(result.error.message || result.error);
-          } else if (
-            result.status === "incomplete" ||
-            result.status === "open"
-          ) {
-            const transactionId = result.id;
-            const planId = this.selectedPlan;
-            this.handleAuthentication(plan, result).then(
-              (authenticationResult) => {
-                if (authenticationResult && !authenticationResult.error) {
-                  return Transaction.finalize(transactionId, planId).then(
-                    () => {
-                      this._advanceSuccessfulTransaction(plan);
-                    }
-                  );
-                }
-              }
-            );
-          } else {
-            this._advanceSuccessfulTransaction(plan);
-          }
-        })
-        .catch((result) => {
-          bootbox.alert(
-            result.jqXHR.responseJSON.errors[0] || result.errorThrown
-          );
-          this.set("loading", false);
-        });
-    },
-  },
-});
diff --git a/assets/javascripts/discourse/controllers/s.js.es6 b/assets/javascripts/discourse/controllers/s.js.es6
deleted file mode 100644
index fa4ba1e..0000000
--- a/assets/javascripts/discourse/controllers/s.js.es6
+++ /dev/null
@@ -1,3 +0,0 @@
-import Controller from "@ember/controller";
-
-export default Controller.extend({});
diff --git a/assets/javascripts/discourse/controllers/subscribe-index.js.es6 b/assets/javascripts/discourse/controllers/subscribe-index.js.es6
new file mode 100644
index 0000000..6a5f0ca
--- /dev/null
+++ b/assets/javascripts/discourse/controllers/subscribe-index.js.es6
@@ -0,0 +1,10 @@
+import Controller from "@ember/controller";
+import discourseComputed from "discourse-common/utils/decorators";
+import User from "discourse/models/user";
+
+export default Controller.extend({
+  @discourseComputed()
+  isLoggedIn() {
+    return User.current();
+  },
+});
diff --git a/assets/javascripts/discourse/controllers/subscribe-show.js.es6 b/assets/javascripts/discourse/controllers/subscribe-show.js.es6
new file mode 100644
index 0000000..45a91d5
--- /dev/null
+++ b/assets/javascripts/discourse/controllers/subscribe-show.js.es6
@@ -0,0 +1,131 @@
+import Controller from "@ember/controller";
+import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
+import Transaction from "discourse/plugins/discourse-subscriptions/discourse/models/transaction";
+import I18n from "I18n";
+import { not } from "@ember/object/computed";
+import discourseComputed from "discourse-common/utils/decorators";
+
+export default Controller.extend({
+  selectedPlan: null,
+  promoCode: null,
+  isAnonymous: not("currentUser"),
+
+  init() {
+    this._super(...arguments);
+    this.set(
+      "stripe",
+      Stripe(this.siteSettings.discourse_subscriptions_public_key)
+    );
+    const elements = this.get("stripe").elements();
+
+    this.set("cardElement", elements.create("card", { hidePostalCode: true }));
+  },
+
+  alert(path) {
+    bootbox.alert(I18n.t(`discourse_subscriptions.${path}`));
+  },
+
+  @discourseComputed("model.product.repurchaseable", "model.product.subscribed")
+  canPurchase(repurchaseable, subscribed) {
+    if (!repurchaseable && subscribed) {
+      return false;
+    }
+
+    return true;
+  },
+
+  createSubscription(plan) {
+    return this.stripe.createToken(this.get("cardElement")).then((result) => {
+      if (result.error) {
+        this.set("loading", false);
+        return result;
+      } else {
+        const subscription = Subscription.create({
+          source: result.token.id,
+          plan: plan.get("id"),

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

GitHub sha: 5ead25feb6ff5c2d1fdc16de65a4a4fdfead9f3c

This commit appears in #86 which was approved by eviltrout. It was merged by justindirose.