These are chat archives for reactioncommerce/reaction

17th
May 2016
Kevin Kwon
@kvnkwon
May 17 2016 04:17
Hello guys! I have been playing around with reaction and I think it's awesome. I was wondering if I could get some help with a particular issue I've been having. I was able to change the index page to render my custom template, but I can't seem to figure out how to create new routes. The route that I need in particular is to go back to the products grid page that was the default index page. How do I define new routes? I wasn't sure on what the Packages.registry was that is mentioned in the docs. Thank you!
Brent Hoover
@zenweasel
May 17 2016 04:25
@kvnkwon Check out this tutorial I am writing. It covers adding custom routes:
https://hackmd.io/CYUxA4CNgVgNgLQE4DsBjATAgLAZgAyJJwpIIBmAhrnDPgIzhyT7ZA==#
Look for the section "Adding Custom Page/Routes"
xiaoc li
@brianxcli
May 17 2016 05:26
@zenweasel I think Reaction is using a different way managing collections on the server side? From Meteor Guide I got something that it uses minimongo package on the client side and the package cannot write back to Mongo engine. But actually I can directly write back to Mongo, but meanwhile cannot read up-to-date data.
Brent Hoover
@zenweasel
May 17 2016 05:28
No, we are just using Meteor collections and publications and subscriptions
Publications and Subscriptions are probably the most difficult aspect of Meteor to get a handle on
but we aren’t doing anything special
xiaoc li
@brianxcli
May 17 2016 05:30
Got it
Brent Hoover
@zenweasel
May 17 2016 05:33
I recommend checking out the videos by Evented Mind
If you want to get into the details of how that stuff works
xiaoc li
@brianxcli
May 17 2016 05:35
That's good, I am writing an introduction of how our project uses Reaction. It can be good material for me.
xiaoc li
@brianxcli
May 17 2016 05:41
It seems that the client side writes back to Mongo exactly after one product is inserted into memory and then the client side memory is cleared quickly.
Brent Hoover
@zenweasel
May 17 2016 05:42
well, the client side can never actually write back into the database, only through a Meteor.method
it just writes to minimongo as an “optomistic concurrency” option
xiaoc li
@brianxcli
May 17 2016 05:45
The interesting thing is, I really see the data from database... that's why I am confused
Brent Hoover
@zenweasel
May 17 2016 05:46
I don’t know what you mean by “really see” the data
xiaoc li
@brianxcli
May 17 2016 05:47
Using a tool to see the data in Mongo
Brent Hoover
@zenweasel
May 17 2016 05:48
Can you give me an example of what’s confusing you?
xiaoc li
@brianxcli
May 17 2016 05:50
Just a sample code, where I insert a data using Products.insert() when clicking a button. I defined it in events.
Since I did not use Meteor.method to write back, that product is supposed not to exist in the data, am I right?
in Mongo, I mean
Brent Hoover
@zenweasel
May 17 2016 05:52
do you have something like autopublish on?
xiaoc li
@brianxcli
May 17 2016 05:52
I don't know, where to find it?
Brent Hoover
@zenweasel
May 17 2016 05:53
I think by default, if you have a blank Meteor project, autopublish is on which allows direct communication with the db
of course it’s off in Reaction
it’s just a package that would be in your packages file in your .meteor directory
xiaoc li
@brianxcli
May 17 2016 05:56
nothing like that
Brent Hoover
@zenweasel
May 17 2016 06:03
Yeah, so insert is slightly different (I had to go read the docs quickly). If you don’t set up any allow/deny rules then this applies:
"When insert is called from untrusted client code, it will be allowed only if passes any applicable allow and deny rules."
so collections can define whether or not, and underwhat circumstances they can be directly modified

An update is more locked down:
"Trusted code can modify multiple documents at once by setting multi to true, and can use an arbitrary Mongo selector to find the documents to modify. It bypasses any access control rules set up by allow and deny. The number of affected documents will be returned from the update call if you don't pass a callback.

Untrusted code can only modify a single document at once, specified by its _id. The modification is allowed only after checking any applicable allow and deny rules. The number of affected documents will be returned to the callback. Untrusted code cannot perform upserts, except in insecure mode."

I forget exactly how you turn on/off “insecure mode"
Spencer Norman
@spencern
May 17 2016 06:06
insecure mode is turned off by removing the insecure package
or by not ever installing it
Brent Hoover
@zenweasel
May 17 2016 06:07
Yeah, so typically I never run autopublish or insecure
Geez @spencern you’re up late
Spencer Norman
@spencern
May 17 2016 06:07
same
per usual ;)
Brent Hoover
@zenweasel
May 17 2016 06:08
So I would say my statement about not being able to modify collections from the client is generally true about Reaction (there are probably some exceptions)
But not necessarily true of Meteor in general. Although probably true in most production applications
@brianxcli Does that clear it up, or muddy it up?
Kevin Kwon
@kvnkwon
May 17 2016 06:19
@zenweasel Thank you Brent! Your tutorial has definitely given me more insight to how everything works and it's great that you are doing this! I am, however, still getting problems with creating the route (it still shows up as page not found). So in my register.js file, I have...
registry: [
    {
      provides: "dashboard",
      template: "routerDashboard",
      label: "Routing",
      description: "Routing utilities",
      icon: "fa fa-share-square-o",
      priority: 1,
      container: "utilities"
    },
    {
      route: "/store",
      name: "store",
      template: "productGrid",
      workflow: "coreWorkflow"
    }
  ]
Brent Hoover
@zenweasel
May 17 2016 06:21
Did you do a ./reaction reset?
Kevin Kwon
@kvnkwon
May 17 2016 06:21
Yeah
Brent Hoover
@zenweasel
May 17 2016 06:22
Are you using https://localhost:3000/<site_name>/store ?
e.g. https://localhost:3000/reaction/store
Spencer Norman
@spencern
May 17 2016 06:22
@zenweasel do you know what version of Mongo you guys run on? Preference between 3.2 and 3.0?
+639278148667
@wazmigs2902_twitter
May 17 2016 06:23
it will be fix later.. forsure
Brent Hoover
@zenweasel
May 17 2016 06:26
@spencern I actually don’t know know. I know we went back and forth between 3.0 and latest but I don’t remember where it ended up
Kevin Kwon
@kvnkwon
May 17 2016 06:29
@zenweasel Ah that was it! Thank you! Now this goes to my next question- Is there a way to have it as localhost:3000/store?
Brent Hoover
@zenweasel
May 17 2016 06:30
well, I personally don’t know. But I think you are in luck, because I think the two other guys in this chat room do know
Spencer Norman
@spencern
May 17 2016 06:31
yep, we did that a bit ago, lemme look up exactly what we did. Was pretty simple though
@kvnkwon replace that line with
prefix: “”
Brent Hoover
@zenweasel
May 17 2016 06:35
We need to make that a configurable option for sure
Spencer Norman
@spencern
May 17 2016 06:35
assumes you have only one shop
but I think that was to stop the linter from complaining
Kevin Kwon
@kvnkwon
May 17 2016 06:40
@spencern Works perfectly! Thank you so much
Sorry for the barrage of questions, but visiting the route I created asks users to be signed in.. Is there a way to change the permissions for the route?
Brent Hoover
@zenweasel
May 17 2016 06:42
You need to add the role to the defaultVisitorRole
and defaultRoles and wells
and then reset it again
xiaoc li
@brianxcli
May 17 2016 06:50
@zenweasel Yes, I think I got you. Insecure code is not recommended, even though it works somehow.
Brent Hoover
@zenweasel
May 17 2016 06:51
it would depend on what sort of site you are doing, but I think most sites would at least want some security
I think the insecure mode is mostly for prototyping
Kevin Kwon
@kvnkwon
May 17 2016 06:59
@zenweasel Which file do I change to adjust the roles? I found some in reaction-sample-data folder in the Shops.json file, is that the right one?
Brent Hoover
@zenweasel
May 17 2016 07:00
Yep, that’s the one. The section of the tutorial on fixtures tells you how to create your own version of those files
xiaoc li
@brianxcli
May 17 2016 12:50
@zenweasel I found why some guys had blank pages when running Reaction and getting lines of errors saying packages not found in console.
I remember meteor 1.3.1 introduces a new way of managing npm packages. There is conflict between declaring bunyan-format dependencies under project root and in Logger package, such that NpmCheckVersion() cannot find this package.
xiaoc li
@brianxcli
May 17 2016 12:56
Solution is removing Reaction-Logger's dependency for bunyan-format package.
Or just remove NpmCheckVersion() in reaction-logger/client/main.js if we are confident about the versions.
shane
@51smith
May 17 2016 19:17
@zenweasel pretty cool tutorial, thank you! Found your code on github, but coudn’t google the tutorial
Spencer Norman
@spencern
May 17 2016 19:43
@zenweasel is the fix-17 branch on reaction-stripe safe for me to pull in for deployment?
Aaron Judd
@aaronjudd
May 17 2016 19:56
@spencern I think it should be, I’ll probably pull that and @paulgrever’s PR tonight and publish after talking to @zenweasel
@brianxcli is that still true if you run npm install in the project root? npmcheckversion is just checking that it’s installed somewhere..
Michael Jenny
@prinzdezibel
May 17 2016 20:04
How can I make the zurb email templates to display correctly? When checking the html files directly in a browser (html files in package reaction-email-templates) they look decent. But not so when reaction is sending an email. Looks like plain text. How can I control this?
Jeremy Shimko
@jshimko
May 17 2016 20:06
@prinzdezibel how are you rendering them? are you just replacing default reaction templates?
Michael Jenny
@prinzdezibel
May 17 2016 20:06
@jshimko haven't configured anything. just used stock RC.
what am I supposed to do / configurate/ install to have them shown properly?
Jeremy Shimko
@jshimko
May 17 2016 20:07
What have you tried that ended up appearing as plain text?
Michael Jenny
@prinzdezibel
May 17 2016 20:07
besides the reaction.json , where I configured the mail server..
For example the order/complete email, where an order is confirmed.
Jeremy Shimko
@jshimko
May 17 2016 20:08
oh, you mean the default reaction emails are showing up as html in plain text?
Michael Jenny
@prinzdezibel
May 17 2016 20:08
Screen Shot 2016-05-17 at 22.08.25.png
Jeremy Shimko
@jshimko
May 17 2016 20:09
That looks like html to me
simple html, but html
Michael Jenny
@prinzdezibel
May 17 2016 20:09
this is not how the templates look in package reaction-email-templates
Jeremy Shimko
@jshimko
May 17 2016 20:12
I don’t follow.
Michael Jenny
@prinzdezibel
May 17 2016 21:08
@jshimko Yes, exactly. But it has nice inline CSS. if you look at it in the browser it looks different from the screenshot you see above.
Ok, I've had a look at the email source. The CSS is there. But it's not rendered as HTML mail it seems.
MIME looks ok: Content-Type: text/html; charset=utf-8
Mike Murray
@mikemurray
May 17 2016 21:17
@prinzdezibel what mail client are you using? Some of them might strip <style> tag CSS rules
Kevin Kwon
@kvnkwon
May 17 2016 21:18
Has anyone had any luck with adjusting permissions for visitors going to custom routes? I have a custom route, but it is making users sign in before they are able to view the page. My custom route is called "store," and I tried adding this:
'''"defaultVisitorRole": [
"anonymous",
"guest",
"product",
"tag",
"index",
"cart/checkout",
"cart/completed",
"store"
],
"defaultRoles": [
"account/profile",
"guest",
"product",
"tag",
"index",
"cart/checkout",
"cart/completed",
"store"
]''' in Shops.json
Brent Hoover
@zenweasel
May 17 2016 21:19
Yes, that’s correct
Did you verify in the db that that role is getting written?
Kevin Kwon
@kvnkwon
May 17 2016 21:21
I have not.. I just tried resetting the project
Brent Hoover
@zenweasel
May 17 2016 21:22
Try doing a ./reaction pull. There was a fix just put in place yesterday for an issue with fixtures not writing correctly
Spencer Norman
@spencern
May 17 2016 21:23
I may need to cherrypick that fix as well, do you know what commit?
Brent Hoover
@zenweasel
May 17 2016 21:23
@spencern 44fa8fa46e815b254d4448cdde3d70201a08b286
Spencer Norman
@spencern
May 17 2016 21:23
thanks
Kevin Kwon
@kvnkwon
May 17 2016 21:28
@zenweasel The pull did the trick! Thanks!
xiaoc li
@brianxcli
May 17 2016 22:20
@aaronjudd The version when we first updated to 1.3 did not have bunyan-format in the root package.json. Many including me got a list of errors. Later I removed that error by meteor update upgrade NpmCheckVersion from 1.3.0 to 1.3.1, and then errors solved but I got a console warning instead. But NpmCheckVersion still failed to find bunyan-format version.
xiaoc li
@brianxcli
May 17 2016 22:27
@aaronjudd Running npm install makes everything looks fine, but I still did not see bunyan-fomat when I debugged in the browser.
when require('bunyan-format/package.json'), it calls fileResolve(), and it searches all the parent folders until it finds root node_modules where I found bunyan, react, react-dom, but not bunyan-format, so NpmCheckVersion failed to find bunyan-format version