DEV: Update to new prettier standards

This commit is contained in:
Justin DiRose
2020-09-16 09:53:50 -05:00
parent d60c5b6d54
commit 7e753d45bd
45 changed files with 1741 additions and 141 deletions
@@ -8,5 +8,5 @@ export default Button.extend({
this.classNameBindings = this.classNameBindings.concat(
"selected:btn-primary"
);
}
},
});
@@ -10,6 +10,6 @@ export default Component.extend({
actions: {
clickPlan(plan) {
this.set("selectedPlan", plan.id);
}
}
},
},
});
@@ -18,6 +18,6 @@ export default Component.extend({
planClick() {
this.clickPlan(this.plan);
return false;
}
}
},
},
});
@@ -13,5 +13,5 @@ export default Component.extend({
@discourseComputed()
isLoggedIn() {
return User.current();
}
},
});
@@ -5,5 +5,5 @@ export default Component.extend({
this._super(...arguments);
this.cardElement.mount("#card-element");
},
didDestroyElement() {}
didDestroyElement() {},
});
@@ -14,6 +14,6 @@ export default Controller.extend({
}
this.set("order", order);
}
}
},
},
});
@@ -7,6 +7,6 @@ export default Controller.extend({
return DiscourseURL.redirectTo(
`/admin/plugins/discourse-subscriptions/plans/${id}`
);
}
}
},
},
});
@@ -15,6 +15,6 @@ export default Controller.extend({
this.transitionToRoute("adminPlugins.discourse-subscriptions.plans");
})
.catch(popupAjaxError);
}
}
},
},
});
@@ -19,7 +19,7 @@ export default Controller.extend({
{ id: "GBP", name: "GBP" },
{ id: "USD", name: "USD" },
{ id: "INR", name: "INR" },
{ id: "BRL", name: "BRL" }
{ id: "BRL", name: "BRL" },
];
},
@@ -29,7 +29,7 @@ export default Controller.extend({
{ id: "day", name: "day" },
{ id: "week", name: "week" },
{ id: "month", name: "month" },
{ id: "year", name: "year" }
{ id: "year", name: "year" },
];
},
@@ -60,14 +60,14 @@ export default Controller.extend({
// TODO: set default group name beforehand
if (this.get("model.plan.metadata.group_name") === undefined) {
this.set("model.plan.metadata", {
group_name: this.get("model.groups.firstObject.name")
group_name: this.get("model.groups.firstObject.name"),
});
}
this.get("model.plan")
.save()
.then(() => this.redirect(this.productId))
.catch(data =>
.catch((data) =>
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
);
},
@@ -76,9 +76,9 @@ export default Controller.extend({
this.get("model.plan")
.update()
.then(() => this.redirect(this.productId))
.catch(data =>
.catch((data) =>
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
);
}
}
},
},
});
@@ -10,7 +10,7 @@ export default Controller.extend({
createProduct() {
this.get("model.product")
.save()
.then(product => {
.then((product) => {
this.transitionToRoute(
"adminPlugins.discourse-subscriptions.products.show",
product.id
@@ -28,6 +28,6 @@ export default Controller.extend({
);
})
.catch(popupAjaxError);
}
}
},
},
});
@@ -23,16 +23,16 @@ export default Controller.extend({
},
createSubscription(plan) {
return this.stripe.createToken(this.get("cardElement")).then(result => {
return this.stripe.createToken(this.get("cardElement")).then((result) => {
if (result.error) {
return result;
} else {
const customer = Customer.create({ source: result.token.id });
return customer.save().then(c => {
return customer.save().then((c) => {
const subscription = Subscription.create({
customer: c.id,
plan: plan.get("id")
plan: plan.get("id"),
});
return subscription.save();
@@ -44,7 +44,7 @@ export default Controller.extend({
handleAuthentication(plan, transaction) {
return this.stripe
.confirmCardPayment(transaction.payment_intent.client_secret)
.then(result => {
.then((result) => {
if (
result.paymentIntent &&
result.paymentIntent.status === "succeeded"
@@ -86,7 +86,7 @@ export default Controller.extend({
let transaction = this.createSubscription(plan);
transaction
.then(result => {
.then((result) => {
if (result.error) {
bootbox.alert(result.error.message || result.error);
} else if (
@@ -96,7 +96,7 @@ export default Controller.extend({
const transactionId = result.id;
const planId = this.selectedPlan;
this.handleAuthentication(plan, result).then(
authenticationResult => {
(authenticationResult) => {
if (authenticationResult && !authenticationResult.error) {
return Transaction.finalize(transactionId, planId).then(
() => {
@@ -110,10 +110,10 @@ export default Controller.extend({
this._advanceSuccessfulTransaction(plan);
}
})
.catch(result => {
.catch((result) => {
bootbox.alert(result.errorThrown);
this.set("loading", false);
});
}
}
},
},
});
@@ -3,12 +3,12 @@ export default {
path: "/plugins",
map() {
this.route("discourse-subscriptions", function() {
this.route("discourse-subscriptions", function () {
this.route("dashboard");
this.route("products", function() {
this.route("show", { path: "/:product-id" }, function() {
this.route("plans", function() {
this.route("products", function () {
this.route("show", { path: "/:product-id" }, function () {
this.route("plans", function () {
this.route("show", { path: "/:plan-id" });
});
});
@@ -16,5 +16,5 @@ export default {
this.route("subscriptions");
});
}
},
};
@@ -2,9 +2,9 @@ export default {
resource: "user",
path: "users/:username",
map() {
this.route("billing", function() {
this.route("billing", function () {
this.route("payments");
this.route("subscriptions");
});
}
},
};
@@ -1,6 +1,6 @@
import Helper from "@ember/component/helper";
export default Helper.helper(function(params) {
export default Helper.helper(function (params) {
let currencySign;
switch (params[0]) {
@@ -24,5 +24,5 @@ export default Helper.helper(function(params) {
currencySign = "$";
}
return currencySign + params.map(p => p.toUpperCase()).join(" ");
return currencySign + params.map((p) => p.toUpperCase()).join(" ");
});
@@ -2,7 +2,7 @@ import { registerUnbound } from "discourse-common/lib/helpers";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { htmlSafe } from "@ember/template";
registerUnbound("format-unix-date", function(timestamp) {
registerUnbound("format-unix-date", function (timestamp) {
if (timestamp) {
const date = new Date(moment.unix(timestamp).format());
@@ -10,7 +10,7 @@ registerUnbound("format-unix-date", function(timestamp) {
autoUpdatingRelativeAge(date, {
format: "medium",
title: true,
leaveAgo: true
leaveAgo: true,
})
);
}
@@ -1,6 +1,6 @@
import Helper from "@ember/component/helper";
export default Helper.helper(function(params) {
export default Helper.helper(function (params) {
const payment = params[0];
return `<a href=\"${payment.url}\">${payment.payment_intent_id}</a>`;
@@ -1,7 +1,7 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import User from "discourse/models/user";
export default registerUnbound("user-viewing-self", function(model) {
export default registerUnbound("user-viewing-self", function (model) {
if (User.current()) {
return (
User.current().username.toLowerCase() === model.username.toLowerCase()
@@ -4,7 +4,7 @@ import I18n from "I18n";
export default {
name: "setup-subscriptions",
initialize(container) {
withPluginApi("0.8.11", api => {
withPluginApi("0.8.11", (api) => {
const siteSettings = container.lookup("site-settings:main");
const isNavLinkEnabled =
siteSettings.discourse_subscriptions_extra_nav_subscribe;
@@ -12,9 +12,9 @@ export default {
api.addNavigationBarItem({
name: "subscribe",
displayName: I18n.t("discourse_subscriptions.navigation.subscribe"),
href: "/s"
href: "/s",
});
}
});
}
},
};
@@ -29,7 +29,7 @@ const AdminPlan = Plan.extend({
type: this.type,
product: this.product,
metadata: this.metadata,
active: this.active
active: this.active,
};
return ajax("/s/admin/plans", { method: "post", data });
@@ -40,25 +40,25 @@ const AdminPlan = Plan.extend({
nickname: this.nickname,
trial_period_days: this.parseTrialPeriodDays,
metadata: this.metadata,
active: this.active
active: this.active,
};
return ajax(`/s/admin/plans/${this.id}`, { method: "patch", data });
}
},
});
AdminPlan.reopenClass({
findAll(data) {
return ajax("/s/admin/plans", { method: "get", data }).then(result =>
result.map(plan => AdminPlan.create(plan))
return ajax("/s/admin/plans", { method: "get", data }).then((result) =>
result.map((plan) => AdminPlan.create(plan))
);
},
find(id) {
return ajax(`/s/admin/plans/${id}`, { method: "get" }).then(plan =>
return ajax(`/s/admin/plans/${id}`, { method: "get" }).then((plan) =>
AdminPlan.create(plan)
);
}
},
});
export default AdminPlan;
@@ -14,13 +14,13 @@ const AdminProduct = EmberObject.extend({
name: this.name,
statement_descriptor: this.statement_descriptor,
metadata: this.metadata,
active: this.active
active: this.active,
};
return ajax("/s/admin/products", {
method: "post",
data
}).then(product => AdminProduct.create(product));
data,
}).then((product) => AdminProduct.create(product));
},
update() {
@@ -28,31 +28,31 @@ const AdminProduct = EmberObject.extend({
name: this.name,
statement_descriptor: this.statement_descriptor,
metadata: this.metadata,
active: this.active
active: this.active,
};
return ajax(`/s/admin/products/${this.id}`, {
method: "patch",
data
data,
});
}
},
});
AdminProduct.reopenClass({
findAll() {
return ajax("/s/admin/products", { method: "get" }).then(result => {
return ajax("/s/admin/products", { method: "get" }).then((result) => {
if (result === null) {
return { unconfigured: true };
}
return result.map(product => AdminProduct.create(product));
return result.map((product) => AdminProduct.create(product));
});
},
find(id) {
return ajax(`/s/admin/products/${id}`, {
method: "get"
}).then(product => AdminProduct.create(product));
}
method: "get",
}).then((product) => AdminProduct.create(product));
},
});
export default AdminProduct;
@@ -21,22 +21,24 @@ const AdminSubscription = EmberObject.extend({
destroy() {
return ajax(`/s/admin/subscriptions/${this.id}`, {
method: "delete"
}).then(result => AdminSubscription.create(result));
}
method: "delete",
}).then((result) => AdminSubscription.create(result));
},
});
AdminSubscription.reopenClass({
find() {
return ajax("/s/admin/subscriptions", {
method: "get"
}).then(result => {
method: "get",
}).then((result) => {
if (result === null) {
return { unconfigured: true };
}
return result.map(subscription => AdminSubscription.create(subscription));
return result.map((subscription) =>
AdminSubscription.create(subscription)
);
});
}
},
});
export default AdminSubscription;
@@ -4,11 +4,11 @@ import EmberObject from "@ember/object";
const Customer = EmberObject.extend({
save() {
const data = {
source: this.source
source: this.source,
};
return ajax("/s/customers", { method: "post", data });
}
},
});
export default Customer;
@@ -9,11 +9,11 @@ Group.reopenClass({
find() {
return ajax(`/groups/${this.subscriptionGroup}`, { method: "get" }).then(
result => {
(result) => {
return Group.create(result.group);
}
);
}
},
});
export default Group;
@@ -11,7 +11,7 @@ const Plan = EmberObject.extend({
const decimal = parseFloat(value) * 100;
this.set("unit_amount", decimal);
return value;
}
},
}),
@discourseComputed("recurring.interval")
billingInterval(interval) {
@@ -21,15 +21,15 @@ const Plan = EmberObject.extend({
@discourseComputed("amountDollars", "currency", "billingInterval")
subscriptionRate(amountDollars, currency, interval) {
return `${amountDollars} ${currency.toUpperCase()} / ${interval}`;
}
},
});
Plan.reopenClass({
findAll(data) {
return ajax("/s/plans", { method: "get", data }).then(result =>
result.map(plan => Plan.create(plan))
return ajax("/s/plans", { method: "get", data }).then((result) =>
result.map((plan) => Plan.create(plan))
);
}
},
});
export default Plan;
@@ -5,16 +5,16 @@ const Product = EmberObject.extend({});
Product.reopenClass({
findAll() {
return ajax("/s/products", { method: "get" }).then(result =>
result.map(product => Product.create(product))
return ajax("/s/products", { method: "get" }).then((result) =>
result.map((product) => Product.create(product))
);
},
find(id) {
return ajax(`/s/products/${id}`, { method: "get" }).then(product =>
return ajax(`/s/products/${id}`, { method: "get" }).then((product) =>
Product.create(product)
);
}
},
});
export default Product;
@@ -11,19 +11,19 @@ const Subscription = EmberObject.extend({
save() {
const data = {
customer: this.customer,
plan: this.plan
plan: this.plan,
};
return ajax("/s/subscriptions", { method: "post", data });
}
},
});
Subscription.reopenClass({
findAll() {
return ajax("/s/subscriptions", { method: "get" }).then(result =>
result.map(subscription => Subscription.create(subscription))
return ajax("/s/subscriptions", { method: "get" }).then((result) =>
result.map((subscription) => Subscription.create(subscription))
);
}
},
});
export default Subscription;
@@ -4,9 +4,9 @@ export default {
finalize(transaction, plan) {
const data = {
transaction: transaction,
plan: plan
plan: plan,
};
return ajax("/s/subscriptions/finalize", { method: "post", data });
}
},
};
@@ -6,17 +6,17 @@ const UserPayment = EmberObject.extend({
@discourseComputed("amount")
amountDollars(amount) {
return parseFloat(amount / 100).toFixed(2);
}
},
});
UserPayment.reopenClass({
findAll() {
return ajax("/s/user/payments", { method: "get" }).then(result =>
result.map(payment => {
return ajax("/s/user/payments", { method: "get" }).then((result) =>
result.map((payment) => {
return UserPayment.create(payment);
})
);
}
},
});
export default UserPayment;
@@ -21,20 +21,20 @@ const UserSubscription = EmberObject.extend({
destroy() {
return ajax(`/s/user/subscriptions/${this.id}`, {
method: "delete"
}).then(result => UserSubscription.create(result));
}
method: "delete",
}).then((result) => UserSubscription.create(result));
},
});
UserSubscription.reopenClass({
findAll() {
return ajax("/s/user/subscriptions", { method: "get" }).then(result =>
result.map(subscription => {
return ajax("/s/user/subscriptions", { method: "get" }).then((result) =>
result.map((subscription) => {
subscription.plan = Plan.create(subscription.plan);
return UserSubscription.create(subscription);
})
);
}
},
});
export default UserSubscription;
@@ -2,5 +2,5 @@ export default {
resource: "user.userActivity",
map() {
this.route("payments");
}
},
};

Some files were not shown because too many files have changed in this diff Show More