From e9bfdb8d904227c9685463c293f8c9a277ce847b Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:15:52 -0600 Subject: [PATCH 1/7] feat: remove unused "shop/getBaseLanguage" method --- .../server/methods/shop/getBaseLanguage.js | 18 ------------------ .../core/core/server/methods/shop/index.js | 2 -- 2 files changed, 20 deletions(-) delete mode 100644 imports/plugins/core/core/server/methods/shop/getBaseLanguage.js diff --git a/imports/plugins/core/core/server/methods/shop/getBaseLanguage.js b/imports/plugins/core/core/server/methods/shop/getBaseLanguage.js deleted file mode 100644 index 80196aa6424..00000000000 --- a/imports/plugins/core/core/server/methods/shop/getBaseLanguage.js +++ /dev/null @@ -1,18 +0,0 @@ -import { Reaction } from "/lib/api"; -import ReactionError from "@reactioncommerce/reaction-error"; -import { Shops } from "/lib/collections"; - -/** - * @name shop/getBaseLanguage - * @method - * @memberof Shop/Methods - * @summary Return the shop's base language ISO code - * @return {String} ISO lang code - */ -export default function getBaseLanguage() { - if (!Reaction.hasPermission()) { - throw new ReactionError("access-denied", "Access Denied"); - } - const shopId = Reaction.getShopId(); - return Shops.findOne(shopId).language; -} diff --git a/imports/plugins/core/core/server/methods/shop/index.js b/imports/plugins/core/core/server/methods/shop/index.js index dc1ccd7008e..73e38f06c55 100644 --- a/imports/plugins/core/core/server/methods/shop/index.js +++ b/imports/plugins/core/core/server/methods/shop/index.js @@ -3,7 +3,6 @@ import createShop from "./createShop"; import createTag from "./createTag"; import fetchCurrencyRate from "./fetchCurrencyRate"; import flushCurrencyRate from "./flushCurrencyRate"; -import getBaseLanguage from "./getBaseLanguage"; import getCurrencyRates from "./getCurrencyRates"; import getLocale from "./getLocale"; import getWorkflow from "./getWorkflow"; @@ -32,7 +31,6 @@ export default { "shop/createTag": createTag, "shop/fetchCurrencyRate": fetchCurrencyRate, "shop/flushCurrencyRate": flushCurrencyRate, - "shop/getBaseLanguage": getBaseLanguage, "shop/getCurrencyRates": getCurrencyRates, "shop/getLocale": getLocale, "shop/getWorkflow": getWorkflow, From 0a9b370f66a5637ab56e5c505a58f058723c22fa Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:22:17 -0600 Subject: [PATCH 2/7] feat: remove unnecessary "shop/getCurrencyRates" method --- .../server/methods/shop/getCurrencyRates.js | 27 ------------------- .../core/server/methods/shop/getLocale.js | 7 ++--- .../core/core/server/methods/shop/index.js | 2 -- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 imports/plugins/core/core/server/methods/shop/getCurrencyRates.js diff --git a/imports/plugins/core/core/server/methods/shop/getCurrencyRates.js b/imports/plugins/core/core/server/methods/shop/getCurrencyRates.js deleted file mode 100644 index 08630380ab2..00000000000 --- a/imports/plugins/core/core/server/methods/shop/getCurrencyRates.js +++ /dev/null @@ -1,27 +0,0 @@ -import { check } from "meteor/check"; -import { Reaction } from "/lib/api"; -import { Shops } from "/lib/collections"; - -/** - * @name shop/getCurrencyRates - * @method - * @memberof Shop/Methods - * @summary It returns the current exchange rate against the shop currency - * usage: Meteor.call("shop/getCurrencyRates","USD") - * @param {String} currency code - * @return {Number|Object} currency conversion rate - */ -export default function getCurrencyRates(currency) { - check(currency, String); - this.unblock(); - - const field = `currencies.${currency}.rate`; - const shop = Shops.findOne(Reaction.getShopId(), { - fields: { - [field]: 1 - } - }); - - return typeof shop.currencies[currency].rate === "number" && - shop.currencies[currency].rate; -} diff --git a/imports/plugins/core/core/server/methods/shop/getLocale.js b/imports/plugins/core/core/server/methods/shop/getLocale.js index 665e1e41929..818d21f1575 100644 --- a/imports/plugins/core/core/server/methods/shop/getLocale.js +++ b/imports/plugins/core/core/server/methods/shop/getLocale.js @@ -72,7 +72,6 @@ export default function getLocale() { // localeCurrency is an array of allowed currencies _.each(localeCurrency, (currency) => { - let exchangeRate; if (shop.currencies[currency]) { result.currency = shop.currencies[currency]; // only fetch rates if locale and shop currency are not equal @@ -82,10 +81,8 @@ export default function getLocale() { const exchangeConfig = settings.openexchangerates || {}; if (exchangeConfig.appId) { - exchangeRate = Meteor.call("shop/getCurrencyRates", currency); - - if (typeof exchangeRate === "number") { - result.currency.exchangeRate = exchangeRate; + if (typeof result.currency.rate === "number") { + result.currency.exchangeRate = result.currency.rate; } else { Logger.warn("Failed to get currency exchange rates."); } diff --git a/imports/plugins/core/core/server/methods/shop/index.js b/imports/plugins/core/core/server/methods/shop/index.js index 73e38f06c55..18dfd574254 100644 --- a/imports/plugins/core/core/server/methods/shop/index.js +++ b/imports/plugins/core/core/server/methods/shop/index.js @@ -3,7 +3,6 @@ import createShop from "./createShop"; import createTag from "./createTag"; import fetchCurrencyRate from "./fetchCurrencyRate"; import flushCurrencyRate from "./flushCurrencyRate"; -import getCurrencyRates from "./getCurrencyRates"; import getLocale from "./getLocale"; import getWorkflow from "./getWorkflow"; import hideHeaderTag from "./hideHeaderTag"; @@ -31,7 +30,6 @@ export default { "shop/createTag": createTag, "shop/fetchCurrencyRate": fetchCurrencyRate, "shop/flushCurrencyRate": flushCurrencyRate, - "shop/getCurrencyRates": getCurrencyRates, "shop/getLocale": getLocale, "shop/getWorkflow": getWorkflow, "shop/hideHeaderTag": hideHeaderTag, From ca8d58e00d83aefc32c51a88ed4bff21cd75d182 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:23:16 -0600 Subject: [PATCH 3/7] feat: remove unused "shop/getWorkflow" method --- .../core/server/methods/shop/getWorkflow.js | 27 ------------------- .../core/core/server/methods/shop/index.js | 2 -- 2 files changed, 29 deletions(-) delete mode 100644 imports/plugins/core/core/server/methods/shop/getWorkflow.js diff --git a/imports/plugins/core/core/server/methods/shop/getWorkflow.js b/imports/plugins/core/core/server/methods/shop/getWorkflow.js deleted file mode 100644 index 16d3adf56d9..00000000000 --- a/imports/plugins/core/core/server/methods/shop/getWorkflow.js +++ /dev/null @@ -1,27 +0,0 @@ -import { check } from "meteor/check"; -import { Shops } from "/lib/collections"; - -/** - * @name shop/getWorkflow - * @method - * @memberof Shop/Methods - * @summary gets the current shop workflows - * @param {String} name - workflow name - * @return {Array} returns workflow array - */ -export default function getWorkflow(name) { - check(name, String); - - const shopWorkflows = Shops.findOne({ - defaultWorkflows: { - $elemMatch: { - provides: name - } - } - }, { - fields: { - defaultWorkflows: true - } - }); - return shopWorkflows; -} diff --git a/imports/plugins/core/core/server/methods/shop/index.js b/imports/plugins/core/core/server/methods/shop/index.js index 18dfd574254..388ff177f3b 100644 --- a/imports/plugins/core/core/server/methods/shop/index.js +++ b/imports/plugins/core/core/server/methods/shop/index.js @@ -4,7 +4,6 @@ import createTag from "./createTag"; import fetchCurrencyRate from "./fetchCurrencyRate"; import flushCurrencyRate from "./flushCurrencyRate"; import getLocale from "./getLocale"; -import getWorkflow from "./getWorkflow"; import hideHeaderTag from "./hideHeaderTag"; import locateAddress from "./locateAddress"; import removeHeaderTag from "./removeHeaderTag"; @@ -31,7 +30,6 @@ export default { "shop/fetchCurrencyRate": fetchCurrencyRate, "shop/flushCurrencyRate": flushCurrencyRate, "shop/getLocale": getLocale, - "shop/getWorkflow": getWorkflow, "shop/hideHeaderTag": hideHeaderTag, "shop/locateAddress": locateAddress, "shop/removeHeaderTag": removeHeaderTag, From 14ff3e7676f74e2cb5b24d4d525e339a481d2a12 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:26:53 -0600 Subject: [PATCH 4/7] feat: remove unused "getTemplateByName" method --- imports/plugins/core/layout/server/index.js | 3 --- .../plugins/core/layout/server/methods/index.js | 10 ---------- .../core/layout/server/methods/templates.js | 14 -------------- 3 files changed, 27 deletions(-) delete mode 100644 imports/plugins/core/layout/server/methods/index.js delete mode 100644 imports/plugins/core/layout/server/methods/templates.js diff --git a/imports/plugins/core/layout/server/index.js b/imports/plugins/core/layout/server/index.js index 9b9e10c7e52..455c7687378 100644 --- a/imports/plugins/core/layout/server/index.js +++ b/imports/plugins/core/layout/server/index.js @@ -1,5 +1,2 @@ -import { registerMethods } from "./methods"; import "./publications/templates"; import "./i18n"; - -registerMethods(); diff --git a/imports/plugins/core/layout/server/methods/index.js b/imports/plugins/core/layout/server/methods/index.js deleted file mode 100644 index c6417681b77..00000000000 --- a/imports/plugins/core/layout/server/methods/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import { Meteor } from "meteor/meteor"; -import { getTemplateByName } from "./templates"; - -export function registerMethods() { - Meteor.methods({ - getTemplateByName - }); -} - -export { getTemplateByName }; diff --git a/imports/plugins/core/layout/server/methods/templates.js b/imports/plugins/core/layout/server/methods/templates.js deleted file mode 100644 index 08820f263fd..00000000000 --- a/imports/plugins/core/layout/server/methods/templates.js +++ /dev/null @@ -1,14 +0,0 @@ -import { check } from "meteor/check"; -import { Templates } from "/lib/collections"; -import Reaction from "/imports/plugins/core/core/server/Reaction"; - -export function getTemplateByName(name, shopId) { - check(name, String); - - const template = Templates.findOne({ - name, - shopId: shopId || Reaction.getShopId() - }); - - return template; -} From 1de05d5421fa1bafb8a1f543a9d57922cd5734b3 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:34:24 -0600 Subject: [PATCH 5/7] feat: remove unnecessary "orders/addOrderEmail" method --- .../checkout/client/components/addEmail.js | 122 ------------------ .../client/components/completedOrder.js | 7 +- .../plugins/core/email/server/i18n/ar.json | 1 - .../plugins/core/email/server/i18n/bg.json | 1 - .../plugins/core/email/server/i18n/cs.json | 1 - .../plugins/core/email/server/i18n/de.json | 1 - .../plugins/core/email/server/i18n/el.json | 1 - .../plugins/core/email/server/i18n/en.json | 1 - .../plugins/core/email/server/i18n/es.json | 1 - .../plugins/core/email/server/i18n/fr.json | 1 - .../plugins/core/email/server/i18n/hr.json | 1 - .../plugins/core/email/server/i18n/hu.json | 1 - .../plugins/core/email/server/i18n/it.json | 1 - .../plugins/core/email/server/i18n/my.json | 1 - .../plugins/core/email/server/i18n/nl.json | 1 - .../plugins/core/email/server/i18n/pl.json | 1 - .../plugins/core/email/server/i18n/pt.json | 1 - .../plugins/core/email/server/i18n/ro.json | 1 - .../plugins/core/email/server/i18n/ru.json | 1 - .../plugins/core/email/server/i18n/sl.json | 1 - .../plugins/core/email/server/i18n/sv.json | 1 - .../plugins/core/email/server/i18n/tr.json | 1 - .../plugins/core/email/server/i18n/vi.json | 1 - .../plugins/core/email/server/i18n/zh.json | 1 - .../orders/server/methods/addOrderEmail.js | 29 ----- .../core/orders/server/methods/index.js | 2 - tests/meteor/orders.app-test.js | 20 --- 27 files changed, 4 insertions(+), 198 deletions(-) delete mode 100644 imports/plugins/core/checkout/client/components/addEmail.js delete mode 100644 imports/plugins/core/orders/server/methods/addOrderEmail.js diff --git a/imports/plugins/core/checkout/client/components/addEmail.js b/imports/plugins/core/checkout/client/components/addEmail.js deleted file mode 100644 index 4916389e0a5..00000000000 --- a/imports/plugins/core/checkout/client/components/addEmail.js +++ /dev/null @@ -1,122 +0,0 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; -import { Meteor } from "meteor/meteor"; -import { Orders } from "/lib/collections"; -import { Reaction, i18next } from "/client/api"; -import { Components } from "@reactioncommerce/reaction-components"; - -/** - * @file AddEmail React Component allows user to add an email after completing an order - * - * @module AddEmail - * @extends Component - */ - -class AddEmail extends Component { - constructor(props) { - super(props); - this.state = { - hasEmail: !!this.props.orderEmail, - order: this.props.order - }; - - this.handleSubmit = this.handleSubmit.bind(this); - this.handleFieldChange = this.handleFieldChange.bind(this); - } - - /** - * @name handleFieldChange() - * @method - * @summary handle setting state whenever the field on the form change - * @param {Event} event - the event that fired - * @param {String} value - the new value for the field - * @param {String} field - which field to modify it's value - * @return {null} null - */ - handleFieldChange = (event, value, field) => { - this.setState({ - [field]: value - }); - }; - - /** - * @name handleSubmit() - * @method - * @summary Handle submitting the email form - * @param {Event} event - the event that fired - * @returns {null} null - */ - handleSubmit(event) { - event.preventDefault(); - const cartId = Reaction.Router.getQueryParam("_id"); - - Meteor.call("orders/addOrderEmail", cartId, this.state.email, (err, results) => { - if (err) { - Alerts.toast(i18next.t("mail.alerts.cantSendEmail"), "error"); - } else { - const order = Orders.findOne({ cartId }); - Meteor.call("orders/sendNotification", order._id, (error) => { - if (!error) { - Alerts.toast(i18next.t("mail.alerts.emailSent"), "success"); - this.setState({ - hasEmail: true - }); - } else { - Alerts.toast(i18next.t("mail.alerts.addOrderEmailFailed"), "error"); - } - }); - } - return results; - }); - } - - render() { - if (this.state.hasEmail) { - return ( -

- -  {this.props.orderEmail} -

- ); - } - return ( -
-
-
- -
- - -
- -
-
-
- ); - } -} - -/** - * @name AddEmail propTypes - * @type {propTypes} - * @param {Object} props - React PropTypes - * @property {Object} order - An object representing the order - * @property {String} orderEmail - a string containing the email attached to the order if it exists - * @return {Node} React node containing input box when no email has been attached to the order - */ -AddEmail.propTypes = { - order: PropTypes.object, - orderEmail: PropTypes.string -}; - -export default AddEmail; diff --git a/imports/plugins/core/checkout/client/components/completedOrder.js b/imports/plugins/core/checkout/client/components/completedOrder.js index 23fc2bc07ab..5b036144b6e 100644 --- a/imports/plugins/core/checkout/client/components/completedOrder.js +++ b/imports/plugins/core/checkout/client/components/completedOrder.js @@ -4,7 +4,6 @@ import { Components } from "@reactioncommerce/reaction-components"; import CompletedShopOrders from "./completedShopOrders"; import CompletedOrderPaymentMethod from "./completedOrderPaymentMethods"; import CompletedOrderSummary from "./completedOrderSummary"; -import AddEmail from "./addEmail"; /** * @summary Displays a summary/information about the order the user has just completed @@ -36,8 +35,10 @@ const CompletedOrder = ({ order, paymentMethods, isProfilePage }) => { {/* This is the left side / main content */}

Order ID {order._id}

- {/* show a different message depending on whether we have an email or not */} - +

+ +  {order.email} +

{/* This is the left side / main content*/}
); diff --git a/imports/plugins/core/email/server/i18n/ar.json b/imports/plugins/core/email/server/i18n/ar.json index 3f23336ac92..edfa7d641dc 100644 --- a/imports/plugins/core/email/server/i18n/ar.json +++ b/imports/plugins/core/email/server/i18n/ar.json @@ -81,7 +81,6 @@ "saveFailed": "فشل حفظ إعدادات البريد {{error}}", "cantSendEmail": "خطأ الخادم: لا يمكن إرسال إشعار البريد الإلكتروني.", "emailSent": "إشعار البريد الإلكتروني المرسلة.", - "addOrderEmailFailed": "أخفقت إضافة رسالة إلكترونية إلى الطلب", "addCartEmailFailed": "أخفقت إضافة البريد الإلكتروني إلى سلة التسوق" } } diff --git a/imports/plugins/core/email/server/i18n/bg.json b/imports/plugins/core/email/server/i18n/bg.json index f7278ba95a4..1be0ad0b8d3 100644 --- a/imports/plugins/core/email/server/i18n/bg.json +++ b/imports/plugins/core/email/server/i18n/bg.json @@ -81,7 +81,6 @@ "saveFailed": "Неуспех при запазване на настройките поща. {{error}}", "cantSendEmail": "Грешка в сървъра: Не може да се изпрати уведомление по имейл.", "emailSent": "изпратено уведомление Email.", - "addOrderEmailFailed": "Добавянето на имейл към поръчката не бе успешно", "addCartEmailFailed": "Добавянето на имейл в кошницата не бе успешно" } } diff --git a/imports/plugins/core/email/server/i18n/cs.json b/imports/plugins/core/email/server/i18n/cs.json index 6ad650ce1ea..ffb8fc3f814 100644 --- a/imports/plugins/core/email/server/i18n/cs.json +++ b/imports/plugins/core/email/server/i18n/cs.json @@ -81,7 +81,6 @@ "saveFailed": "Nepodařilo se uložit nastavení pošty. {{error}}", "cantSendEmail": "Chyba serveru: Nelze odeslat e-mailové oznámení.", "emailSent": "Upozornění na e-mail odeslán.", - "addOrderEmailFailed": "Přidání e-mailu na objednávku selhalo", "addCartEmailFailed": "Přidání e-mailu do košíku se nezdařilo" } } diff --git a/imports/plugins/core/email/server/i18n/de.json b/imports/plugins/core/email/server/i18n/de.json index ffce6185a39..296033b1cde 100644 --- a/imports/plugins/core/email/server/i18n/de.json +++ b/imports/plugins/core/email/server/i18n/de.json @@ -81,7 +81,6 @@ "saveFailed": "Die E-Mail-Einstellungen konnten nicht gespeichert werden. {{error}}", "cantSendEmail": "Server-Fehler: Kann keine E-Mail-Benachrichtigung senden.", "emailSent": "E-Mail-Benachrichtigung gesendet.", - "addOrderEmailFailed": "Hinzufügen von E-Mails zur Bestellung fehlgeschlagen", "addCartEmailFailed": "Hinzufügen von E-Mails zum Warenkorb fehlgeschlagen" } } diff --git a/imports/plugins/core/email/server/i18n/el.json b/imports/plugins/core/email/server/i18n/el.json index 709d794b3d9..c94a4c20161 100644 --- a/imports/plugins/core/email/server/i18n/el.json +++ b/imports/plugins/core/email/server/i18n/el.json @@ -81,7 +81,6 @@ "saveFailed": "Αποτυχία για να αποθηκεύσετε τις ρυθμίσεις αλληλογραφίας. {{error}}", "cantSendEmail": "Σφάλμα διακομιστή: Δεν είναι δυνατή η αποστολή ειδοποίηση μέσω ηλεκτρονικού ταχυδρομείου.", "emailSent": "ειδοποίηση μέσω ηλεκτρονικού ταχυδρομείου που αποστέλλονται.", - "addOrderEmailFailed": "Η προσθήκη ηλεκτρονικού ταχυδρομείου στην παραγγελία απέτυχε", "addCartEmailFailed": "Η προσθήκη ηλεκτρονικού ταχυδρομείου στο καλάθι απέτυχε" } } diff --git a/imports/plugins/core/email/server/i18n/en.json b/imports/plugins/core/email/server/i18n/en.json index 628a28d12e6..e4e0bd77008 100644 --- a/imports/plugins/core/email/server/i18n/en.json +++ b/imports/plugins/core/email/server/i18n/en.json @@ -81,7 +81,6 @@ "saveFailed": "Failed to save mail settings. {{error}}", "cantSendEmail": "Server Error: Can't send email notification.", "emailSent": "Email notification sent.", - "addOrderEmailFailed": "Adding email to order failed", "addCartEmailFailed": "Adding email to cart failed" } } diff --git a/imports/plugins/core/email/server/i18n/es.json b/imports/plugins/core/email/server/i18n/es.json index dad8446ff85..fc535a1fe94 100644 --- a/imports/plugins/core/email/server/i18n/es.json +++ b/imports/plugins/core/email/server/i18n/es.json @@ -81,7 +81,6 @@ "saveFailed": "Error al guardar las opciones de correo. {{error}}", "cantSendEmail": "Error de servidor: No se puede enviar una notificación por correo electrónico.", "emailSent": "notificación por correo electrónico enviado.", - "addOrderEmailFailed": "No se pudo agregar el correo electrónico al pedido.", "addCartEmailFailed": "Error al agregar el correo electrónico al carro" } } diff --git a/imports/plugins/core/email/server/i18n/fr.json b/imports/plugins/core/email/server/i18n/fr.json index d2a27ab119e..8b8f3aaebf1 100644 --- a/imports/plugins/core/email/server/i18n/fr.json +++ b/imports/plugins/core/email/server/i18n/fr.json @@ -81,7 +81,6 @@ "saveFailed": "Impossible de sauvegarder les paramètres de messagerie. {{error}}", "cantSendEmail": "Erreur de serveur: Vous ne pouvez pas envoyer une notification par e-mail.", "emailSent": "notification par courrier électronique envoyé.", - "addOrderEmailFailed": "L'ajout d'un e-mail à la commande a échoué", "addCartEmailFailed": "L'ajout d'un e-mail au panier a échoué" } } diff --git a/imports/plugins/core/email/server/i18n/hr.json b/imports/plugins/core/email/server/i18n/hr.json index 69bf3c08910..624923dae66 100644 --- a/imports/plugins/core/email/server/i18n/hr.json +++ b/imports/plugins/core/email/server/i18n/hr.json @@ -81,7 +81,6 @@ "saveFailed": "Neuspjelo spremanje postavki pošte. {{error}}", "cantSendEmail": "Pogreška poslužitelja: Ne mogu poslati e-mail obavijesti.", "emailSent": "poslao e-mail obavijesti.", - "addOrderEmailFailed": "Dodavanje e-pošte na narudžbu nije uspjelo", "addCartEmailFailed": "Dodavanje e-pošte u košaricu nije uspjelo" } } diff --git a/imports/plugins/core/email/server/i18n/hu.json b/imports/plugins/core/email/server/i18n/hu.json index 4b85d333e87..f1f6eaba594 100644 --- a/imports/plugins/core/email/server/i18n/hu.json +++ b/imports/plugins/core/email/server/i18n/hu.json @@ -81,7 +81,6 @@ "saveFailed": "Nem sikerült menteni mail beállításokat. {{error}}", "cantSendEmail": "Szerver hiba: Nem lehet elküldeni e-mail értesítést.", "emailSent": "E-mail értesítést küldeni.", - "addOrderEmailFailed": "E-mail hozzáadása megrendeléshez nem sikerült", "addCartEmailFailed": "E-mail hozzáadása a kosárba nem sikerült" } } diff --git a/imports/plugins/core/email/server/i18n/it.json b/imports/plugins/core/email/server/i18n/it.json index 640128dd944..9d38f7e6d62 100644 --- a/imports/plugins/core/email/server/i18n/it.json +++ b/imports/plugins/core/email/server/i18n/it.json @@ -81,7 +81,6 @@ "saveFailed": "Impossibile salvare le impostazioni di posta elettronica. {{error}}", "cantSendEmail": "Errore del server: Non è possibile inviare e-mail di notifica.", "emailSent": "Email di notifica inviato.", - "addOrderEmailFailed": "L'aggiunta dell'email all'ordine non è riuscita", "addCartEmailFailed": "L'aggiunta di email al carrello non è riuscita" } } diff --git a/imports/plugins/core/email/server/i18n/my.json b/imports/plugins/core/email/server/i18n/my.json index 95d123b0a59..745a67f95fa 100644 --- a/imports/plugins/core/email/server/i18n/my.json +++ b/imports/plugins/core/email/server/i18n/my.json @@ -81,7 +81,6 @@ "saveFailed": "mail settings ကိုကယ်တင်ရန်မအောင်မြင်ခဲ့ပါ။ {{error}}", "cantSendEmail": "Server ကိုအမှား: အီးမေးလ်အကြောင်းကြားစာမပို့နိုင်သ။", "emailSent": "အီးမေးလ်အကြောင်းကြားစာကိုစေလွှတ်။ ,", - "addOrderEmailFailed": "မအောင်မြင်မိန့်အီးမေးလ်ပေါင်းထည့်ခြင်း", "addCartEmailFailed": "လှည်းအီးမေးလ်မအောင်မြင်ပါထည့်သွင်းခြင်း" } } diff --git a/imports/plugins/core/email/server/i18n/nl.json b/imports/plugins/core/email/server/i18n/nl.json index 02246c62e04..c47e180b976 100644 --- a/imports/plugins/core/email/server/i18n/nl.json +++ b/imports/plugins/core/email/server/i18n/nl.json @@ -81,7 +81,6 @@ "saveFailed": "Kan mail instellingen op te slaan. {{error}}", "cantSendEmail": "Server Error: Kan geen email melding sturen.", "emailSent": "E-mail melding verzonden.", - "addOrderEmailFailed": "Het toevoegen van e-mail naar bestelling mislukt", "addCartEmailFailed": "Het toevoegen van e-mail naar cart is mislukt" } } diff --git a/imports/plugins/core/email/server/i18n/pl.json b/imports/plugins/core/email/server/i18n/pl.json index 4f91b66ff51..c3232150ead 100644 --- a/imports/plugins/core/email/server/i18n/pl.json +++ b/imports/plugins/core/email/server/i18n/pl.json @@ -81,7 +81,6 @@ "saveFailed": "Nie udało się zapisać ustawienia poczty. {{error}}", "cantSendEmail": "Błąd serwera: nie można wysłać powiadomienie e-mail.", "emailSent": "Powiadomienie e-mail wysłana.", - "addOrderEmailFailed": "Dodanie poczty e-mail do zamówienia nie powiodło się", "addCartEmailFailed": "Dodanie poczty e-mail do koszyka nie powiodło się" } } diff --git a/imports/plugins/core/email/server/i18n/pt.json b/imports/plugins/core/email/server/i18n/pt.json index dcdd1304bd9..6941dac615a 100644 --- a/imports/plugins/core/email/server/i18n/pt.json +++ b/imports/plugins/core/email/server/i18n/pt.json @@ -81,7 +81,6 @@ "saveFailed": "Falha ao guardar definições do correio. {{error}}", "cantSendEmail": "Erro de servidor: Não é possível enviar uma notificação de e-mail.", "emailSent": "notificação de e-mail enviado.", - "addOrderEmailFailed": "Adicionando e-mail ao pedido falhou", "addCartEmailFailed": "Adicionar email ao carrinho falhou" } } diff --git a/imports/plugins/core/email/server/i18n/ro.json b/imports/plugins/core/email/server/i18n/ro.json index 78f11dffa43..f18ffd82b5f 100644 --- a/imports/plugins/core/email/server/i18n/ro.json +++ b/imports/plugins/core/email/server/i18n/ro.json @@ -81,7 +81,6 @@ "saveFailed": "pentru a salva setările de mail a eșuat. {{error}}", "cantSendEmail": "Eroare de server: Nu se poate trimite o notificare de e-mail.", "emailSent": "Notificare e-mail trimis.", - "addOrderEmailFailed": "Adăugarea e-mailului la comandă a eșuat", "addCartEmailFailed": "Adăugarea e-mailului în căruciar a eșuat" } } diff --git a/imports/plugins/core/email/server/i18n/ru.json b/imports/plugins/core/email/server/i18n/ru.json index c6130204dd2..11471d2a16b 100644 --- a/imports/plugins/core/email/server/i18n/ru.json +++ b/imports/plugins/core/email/server/i18n/ru.json @@ -81,7 +81,6 @@ "saveFailed": "Не удалось сохранить настройки почты. {{error}}", "cantSendEmail": "Ошибка сервера: Не удается отправить уведомление по электронной почте.", "emailSent": "уведомление по электронной почте.", - "addOrderEmailFailed": "Не удалось добавить адрес электронной почты для заказа", "addCartEmailFailed": "Ошибка добавления электронной почты в корзину" } } diff --git a/imports/plugins/core/email/server/i18n/sl.json b/imports/plugins/core/email/server/i18n/sl.json index 1ae3cd8cab0..63fb7e96b1c 100644 --- a/imports/plugins/core/email/server/i18n/sl.json +++ b/imports/plugins/core/email/server/i18n/sl.json @@ -81,7 +81,6 @@ "saveFailed": "Ni bilo mogoče shraniti nastavitve pošte. {{error}}", "cantSendEmail": "Napaka strežnika: Ne morem poslati e-poštno obvestilo.", "emailSent": "e-poštno obvestilo poslano.", - "addOrderEmailFailed": "Dodajanje e-pošte po naročilu ni uspelo", "addCartEmailFailed": "Dodajanje e-pošte v košarico ni uspelo" } } diff --git a/imports/plugins/core/email/server/i18n/sv.json b/imports/plugins/core/email/server/i18n/sv.json index da1bf811518..30263a18bd1 100644 --- a/imports/plugins/core/email/server/i18n/sv.json +++ b/imports/plugins/core/email/server/i18n/sv.json @@ -81,7 +81,6 @@ "saveFailed": "Det gick inte att spara postinställningar. {{error}}", "cantSendEmail": "Server Error: Kan inte skicka e-postmeddelande.", "emailSent": "E-postmeddelande skickas.", - "addOrderEmailFailed": "Lägga till e-post i order misslyckades", "addCartEmailFailed": "Lägga till e-post i kundvagn misslyckades" } } diff --git a/imports/plugins/core/email/server/i18n/tr.json b/imports/plugins/core/email/server/i18n/tr.json index 45fd5ad026e..a024bf26960 100644 --- a/imports/plugins/core/email/server/i18n/tr.json +++ b/imports/plugins/core/email/server/i18n/tr.json @@ -81,7 +81,6 @@ "saveFailed": "posta ayarlarını kaydedilemedi. {{error}}", "cantSendEmail": "Sunucu Hatası: E-posta bildirimi göndermek olamaz.", "emailSent": "E-posta bildirimi gönderilir.", - "addOrderEmailFailed": "Siparişe e-posta eklenemedi", "addCartEmailFailed": "E-postaya alışveriş sepetine eklenemedi." } } diff --git a/imports/plugins/core/email/server/i18n/vi.json b/imports/plugins/core/email/server/i18n/vi.json index e1eb6ba4f1d..94e72bed61c 100644 --- a/imports/plugins/core/email/server/i18n/vi.json +++ b/imports/plugins/core/email/server/i18n/vi.json @@ -81,7 +81,6 @@ "saveFailed": "Không lưu cài đặt mail. {{error}}", "cantSendEmail": "Server Error: Không thể gửi email thông báo.", "emailSent": "Thông báo email gửi đi.", - "addOrderEmailFailed": "Thêm email theo đơn đặt hàng không thành công", "addCartEmailFailed": "Thêm email vào giỏ hàng không thành công" } } diff --git a/imports/plugins/core/email/server/i18n/zh.json b/imports/plugins/core/email/server/i18n/zh.json index a48a838dd4d..ee8a61d9d2e 100644 --- a/imports/plugins/core/email/server/i18n/zh.json +++ b/imports/plugins/core/email/server/i18n/zh.json @@ -81,7 +81,6 @@ "saveFailed": "保存邮件设置失败。{{error}}", "cantSendEmail": "服务器错误:无法发送电子邮件通知。", "emailSent": "电子邮件通知发送。", - "addOrderEmailFailed": "添加电子邮件订单失败", "addCartEmailFailed": "添加电子邮件到购物车失败" } } diff --git a/imports/plugins/core/orders/server/methods/addOrderEmail.js b/imports/plugins/core/orders/server/methods/addOrderEmail.js deleted file mode 100644 index 12b45b1784c..00000000000 --- a/imports/plugins/core/orders/server/methods/addOrderEmail.js +++ /dev/null @@ -1,29 +0,0 @@ -import { check } from "meteor/check"; -import ReactionError from "@reactioncommerce/reaction-error"; -import { Orders } from "/lib/collections"; -import Reaction from "/imports/plugins/core/core/server/Reaction"; - -/** - * @name orders/addOrderEmail - * @method - * @memberof Orders/Methods - * @summary Adds email to order, used for guest users - * @param {String} cartId - add tracking to orderId - * @param {String} email - valid email address - * @return {String} returns order update result - */ -export default function addOrderEmail(cartId, email) { - check(cartId, String); - check(email, String); - /** - *Instead of checking the Orders permission, we should check if user is - *connected.This is only needed for guest where email is - *provided for tracking order progress. - */ - - if (!Reaction.getUserId()) { - throw new ReactionError("access-denied", "Access Denied. You are not connected."); - } - - return Orders.update({ cartId }, { $set: { email } }); -} diff --git a/imports/plugins/core/orders/server/methods/index.js b/imports/plugins/core/orders/server/methods/index.js index 1de7bb10b98..7b61d3cd436 100644 --- a/imports/plugins/core/orders/server/methods/index.js +++ b/imports/plugins/core/orders/server/methods/index.js @@ -1,4 +1,3 @@ -import addOrderEmail from "./addOrderEmail"; import approvePayment from "./approvePayment"; import cancelOrder from "./cancelOrder"; import capturePayments from "./capturePayments"; @@ -26,7 +25,6 @@ import updateShipmentTracking from "./updateShipmentTracking"; */ export default { - "orders/addOrderEmail": addOrderEmail, "orders/approvePayment": approvePayment, "orders/cancelOrder": cancelOrder, "orders/capturePayments": capturePayments, diff --git a/tests/meteor/orders.app-test.js b/tests/meteor/orders.app-test.js index a4e20b08e5f..a91e2d9f020 100644 --- a/tests/meteor/orders.app-test.js +++ b/tests/meteor/orders.app-test.js @@ -35,7 +35,6 @@ describe("orders test", function () { "shipmentDelivered": Meteor.server.method_handlers["orders/shipmentDelivered"], "sendNotification": Meteor.server.method_handlers["orders/sendNotification"], "updateShipmentTracking": Meteor.server.method_handlers["orders/updateShipmentTracking"], - "addOrderEmail": Meteor.server.method_handlers["orders/addOrderEmail"], "updateHistory": Meteor.server.method_handlers["orders/updateHistory"], "capturePayments": Meteor.server.method_handlers["orders/capturePayments"], "refunds/list": Meteor.server.method_handlers["orders/refunds/list"], @@ -446,25 +445,6 @@ describe("orders test", function () { }); }); - describe("orders/addOrderEmail", function () { - it("should return if userId is not available", function () { - spyOnMethod("addOrderEmail"); - function addOrderEmail() { - const email = "sample@email.com"; - return Meteor.call("orders/addOrderEmail", order.cartId, email); - } - expect(addOrderEmail).to.throw(ReactionError, /Access Denied. You are not connected./); - }); - - it("should add the email to the order", function () { - spyOnMethod("addOrderEmail", order.userId); - const email = "sample@email.com"; - Meteor.call("orders/addOrderEmail", order.cartId, email); - const orders = Orders.findOne({ _id: order._id }); - expect(orders.email).to.equal(email); - }); - }); - describe("orders/updateHistory", function () { it("should return Access denied if user does not have permission", function () { sandbox.stub(Reaction, "hasPermission", () => false); From 3d9c84fdf0806afbc44fae97146b89cf08874ce6 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 06:57:07 -0600 Subject: [PATCH 6/7] feat: remove unnecessary "taxes/updateTaxCode" method --- .../client/containers/publishContainer.js | 1 - imports/plugins/core/taxes/server/index.js | 1 - imports/plugins/core/taxes/server/methods.js | 58 ------------------- 3 files changed, 60 deletions(-) delete mode 100644 imports/plugins/core/taxes/server/methods.js diff --git a/imports/plugins/core/catalog/client/containers/publishContainer.js b/imports/plugins/core/catalog/client/containers/publishContainer.js index b0789e2bd3e..e47255c4439 100644 --- a/imports/plugins/core/catalog/client/containers/publishContainer.js +++ b/imports/plugins/core/catalog/client/containers/publishContainer.js @@ -11,7 +11,6 @@ import PublishControls from "../components/publishControls"; */ class PublishContainer extends Component { publishToCatalog(collection, documentIds) { - Meteor.call("taxes/updateTaxCode", this.props.documents); Meteor.call(`catalog/publish/${collection}`, documentIds, (error, result) => { if (result) { Alerts.toast(i18next.t("admin.catalogProductPublishSuccess", { defaultValue: "Product published to catalog" }), "success"); diff --git a/imports/plugins/core/taxes/server/index.js b/imports/plugins/core/taxes/server/index.js index cc2df722d90..0590155b9bc 100644 --- a/imports/plugins/core/taxes/server/index.js +++ b/imports/plugins/core/taxes/server/index.js @@ -1,4 +1,3 @@ import "./i18n"; import "../lib/extendCoreSchemas"; -import "./methods"; import "./api/import"; diff --git a/imports/plugins/core/taxes/server/methods.js b/imports/plugins/core/taxes/server/methods.js deleted file mode 100644 index a87c628d8da..00000000000 --- a/imports/plugins/core/taxes/server/methods.js +++ /dev/null @@ -1,58 +0,0 @@ -import ReactionError from "@reactioncommerce/reaction-error"; -import { Meteor } from "meteor/meteor"; -import { check } from "meteor/check"; -import Reaction from "/imports/plugins/core/core/server/Reaction"; -import { Catalog } from "/lib/api"; -import { Products } from "/lib/collections"; - -/** - * @file Methods for Taxes. Run these methods using `Meteor.call()`. - * - * - * @namespace Taxes/Methods -*/ - -const methods = { - /** - * @name taxes/updateTaxCode - * @method - * @memberof Methods/Taxes - * @summary updates the tax code on all options of a product. - * @param {String} products array of products to be updated. - * @return {Number} returns number of options updated - */ - "taxes/updateTaxCode"(products) { - check(products, Array); - - // check permissions to create product - // to check if user can update the product - if (!Reaction.hasPermission("createProduct")) { - throw new ReactionError("access-denied", "Access Denied"); - } - - // number of options that get updated. - let updatedOptions = 0; - - products.forEach((product) => { - let variants = [product]; - if (product.type === "simple") { - variants = Catalog.getVariants(product._id); - } - variants.forEach((variant) => { - const options = Catalog.getVariants(variant._id); - options.forEach((option) => { - updatedOptions += Products.update({ - _id: option._id - }, { - $set: { - taxCode: variant.taxCode - } - }, { selector: { type: "variant" }, publish: true }); - }); - }); - }); - return updatedOptions; - } -}; - -Meteor.methods(methods); From b9a1f13300878f6840a78161e09056f14d320ec2 Mon Sep 17 00:00:00 2001 From: Eric Dobbertin Date: Wed, 21 Nov 2018 07:09:38 -0600 Subject: [PATCH 7/7] feat: remove unused workflow methods --- .../methods/coreOrderCompletedWorkflow.js | 24 ------------------- .../methods/coreOrderProcessingWorkflow.js | 20 ---------------- .../core/orders/server/methods/index.js | 6 +---- 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 imports/plugins/core/orders/server/methods/coreOrderCompletedWorkflow.js delete mode 100644 imports/plugins/core/orders/server/methods/coreOrderProcessingWorkflow.js diff --git a/imports/plugins/core/orders/server/methods/coreOrderCompletedWorkflow.js b/imports/plugins/core/orders/server/methods/coreOrderCompletedWorkflow.js deleted file mode 100644 index 11763751895..00000000000 --- a/imports/plugins/core/orders/server/methods/coreOrderCompletedWorkflow.js +++ /dev/null @@ -1,24 +0,0 @@ -import _ from "lodash"; -import { check, Match } from "meteor/check"; - -/** - * @name coreOrderWorkflow/coreOrderCompleted - * @method - * @memberof Workflow/Methods - * @summary Performs various checks to determine if an order may be moved into the completed phase. - * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. - * @param {Object} options An object containing arbitrary data - * @return {Boolean} true to allow action, false to cancel execution of hook - * @see packages/reaction-schema/common/hooks/orders.js - * @see packages/reaction-core/common/methods/workflow.js - */ -export default function coreOrderCompletedWorkflow(options) { - check(options, Match.OrderHookOptions()); - - const { order } = options; - - const orderItems = order.shipping.reduce((list, group) => [...list, ...group.items], []); - const result = _.every(orderItems, (item) => _.includes(item.workflow.workflow, "coreOrderItemWorkflow/completed")); - - return result; -} diff --git a/imports/plugins/core/orders/server/methods/coreOrderProcessingWorkflow.js b/imports/plugins/core/orders/server/methods/coreOrderProcessingWorkflow.js deleted file mode 100644 index d91d0ae6b19..00000000000 --- a/imports/plugins/core/orders/server/methods/coreOrderProcessingWorkflow.js +++ /dev/null @@ -1,20 +0,0 @@ -import { check, Match } from "meteor/check"; -import Reaction from "/imports/plugins/core/core/server/Reaction"; - -/** - * @name coreOrderWorkflow/coreOrderProcessing - * @method - * @memberof Workflow/Methods - * @summary Checks permissions for a given user to allow them to move an order into the processing phase. - * @description Step 4 of the "workflow/pushOrderWorkflow" flow - called from Orders.before.update hook. - * @param {Object} options An object containing arbitrary data - * @return {Boolean} true to allow action, false to cancel execution of hook - * @see packages/reaction-schema/common/hooks/orders.js - * @see packages/reaction-core/common/methods/workflow.js - */ -export default function coreOrderProcessingWorkflow(options) { - check(options, Match.OrderHookOptions()); - const { userId } = options; - - return Reaction.hasPermission(["dashboard/orders"], userId); -} diff --git a/imports/plugins/core/orders/server/methods/index.js b/imports/plugins/core/orders/server/methods/index.js index 7b61d3cd436..7863b286fec 100644 --- a/imports/plugins/core/orders/server/methods/index.js +++ b/imports/plugins/core/orders/server/methods/index.js @@ -1,8 +1,6 @@ import approvePayment from "./approvePayment"; import cancelOrder from "./cancelOrder"; import capturePayments from "./capturePayments"; -import coreOrderCompletedWorkflow from "./coreOrderCompletedWorkflow"; -import coreOrderProcessingWorkflow from "./coreOrderProcessingWorkflow"; import createRefund from "./createRefund"; import listRefunds from "./listRefunds"; import makeAdjustmentsToInvoice from "./makeAdjustmentsToInvoice"; @@ -40,7 +38,5 @@ export default { "orders/shipmentPicked": shipmentPicked, "orders/shipmentShipped": shipmentShipped, "orders/updateHistory": updateHistory, - "orders/updateShipmentTracking": updateShipmentTracking, - "workflow/coreOrderWorkflow/coreOrderProcessing": coreOrderProcessingWorkflow, - "workflow/coreOrderWorkflow/coreOrderCompleted": coreOrderCompletedWorkflow + "orders/updateShipmentTracking": updateShipmentTracking };