-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use React components for footer and header #3257
Use React components for footer and header #3257
Conversation
1) layoutHeader This template was used for most cases (coreLayout). But since coreLayout.js does include the new Components.NavBar React component, it's obsolete 2) checkoutHeader This was a customized version of the header for the checkout workflow. Nowadays the checkout workflow also uses the standard NavBar component. Therefore it's obsolete, too.
Additionally, the old way of customizing parts of the layout is retained, namely to use registry's layout structure to decide on a per-workflow basis which footer & header component is choosen. If this prooves to be unnecessary, we could eliminate that part altogether. This changeset only does ensure feature-parity with old system: | Old: | New: -------------------------+--------------------------+-------------------------- Replacing components | Template.replace | replaceComponent in general | | -------------------------+--------------------------+-------------------------- Replacing parts of | layoutHeader designates | layoutHeader designates layout per workflow | Blaze template name | React comp's name | layoutFooter designates | layoutFooter designates | Blaze template name | React comp's name
@@ -50,7 +50,7 @@ Reaction.registerPackage({ | |||
enabled: true, | |||
structure: { | |||
template: "dashboardPackages", | |||
layoutHeader: "layoutHeader", | |||
layoutHeader: "NavBar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any time these values change, you'll need to write a migration. This goes for all the register.js
files modified.
Migrations can be found in /imports/plugins/core/versions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. I've written a migration for it.
return ( | ||
<div className={pageClassName} id="reactionAppContainer"> | ||
<Components.NavBar /> | ||
|
||
{ headerComponent && React.createElement(headerComponent, {}) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No extra space with the {}
in JSX templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Btw, is this enforced by eslint?
import { registerComponent } from "/imports/plugins/core/components/lib"; | ||
import { Reaction } from "/client/api"; | ||
|
||
const Footer = () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always wrap arrow functions in ()
or {}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I'm assuming you mean like this:
const Footer = () => (
<div/>
);
@@ -21,11 +21,11 @@ | |||
{{> Template.dynamic template=template}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need this file anymore? This should no longer be used, as it's been replaced with React components app.js
(located in core/ui package) and coreLayout.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not, as i've stated in the getFooterComponent helper function. I'm going to delete this file.
@@ -10,6 +10,7 @@ import ToolbarContainer from "/imports/plugins/core/dashboard/client/containers/ | |||
import Toolbar from "/imports/plugins/core/dashboard/client/components/toolbar"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need this file anymore? I think all of this has been moved to various react components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not, as i've stated in the getFooterComponent helper function. I'm going to delete this file.
layoutFooter: "", | ||
// layoutFooter: "Footer", // TODO: decide if it's desirable to display standard footer in product grid for a stock installation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted comment. layout is retained as was, e.g. no footer will be displayed.
@@ -0,0 +1,19 @@ | |||
import React from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a footer requires design direction from @rymorgan since for the longest time, we've not had one displayed. And the question is, should we even be adding visible one now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Footer should not be displayed anywhere, if it wasn't already before..
Right now it's nothing more than an exemplary placeholder that's available for usage when implementing plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then, a plugin would have its own requirements on how the Footer is supposed to be rendered. Maybe it's just unnecessary to have it in its own place.
|
||
const Footer = () => | ||
<div className="reaction-navigation-footer footer-default"> | ||
<nav className="navbar-bottom " role="navigation"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space in quote "navbar-bottom "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@mikemurray Changes implemented. Btw, is there a button or something to signal you, when I've done the requested changes? Or how is your workflow regarding review->change->review cycle? |
@prinzdezibel there is no magic ping button other than [at]-ing someone in a comment, they noticing changes to the PR / branch, or notifying directly. I'll take a look at this soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting this error on an existing app on the homepage
layoutHeader not registered.
at _getComponent (app.js:102296)
at CoreLayout (app.js:61466)
at modules.js:108189
at measureLifeCyclePerf (modules.js:107959)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (modules.js:108188)
at ReactCompositeComponentWrapper._constructComponent (modules.js:108163)
at ReactCompositeComponentWrapper.mountComponent (modules.js:108071)
at Object.mountComponent (modules.js:100902)
at ReactCompositeComponentWrapper.performInitialMount (modules.js:108254)
at ReactCompositeComponentWrapper.mountComponent (modules.js:108141)
@mikemurray Sorry, I've forgotten to also migrate the Shops collection and additionally there were an error with my previous attempt. (using I was ensuring that migration was executing properly, but only in RoboMongo. Should have tested it better. Sorry for that. |
@mikemurray Hi Mike, maybe you can have another look into it. should work as suspected now. |
@prinzdezibel looking now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the following error:
Uncaught Error: Component checkoutHeader not registered.
at _getComponent (components.js:92)
at CoreLayout (coreLayout.js:16)
at modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108189
at measureLifeCyclePerf (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:107959)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108188)
at ReactCompositeComponentWrapper._constructComponent (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108163)
at ReactCompositeComponentWrapper.mountComponent (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108071)
at Object.mountComponent (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:100902)
at ReactCompositeComponentWrapper.performInitialMount (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108254)
at ReactCompositeComponentWrapper.mountComponent (modules.js?hash=1d95b8a00969795e9c25b7e6569113f786616bf2:108141)
Checkout header is used, needs to be converted to react. #3255
@prinzdezibel I don't think we should be working on a footer w/out thinking of what the broader approach to having a footer? Can you outline your plan for adding a footer is in this PR? Are you going to add an empty footer that will make it easier down the line when we're ready to add a footer option for admins? |
@rymorgan Right now the Footer is just a placeholder that basically doesn't (read: should not do) anything. As long as the footer was not shown before in any of the available views/routes, it also will not be displayed now. It's purpose is more to serve as hint for plugin developers/ customers on how to override/use this Footer. Albeit the footer is really just a link to the root URL, a.k.a. home. It's not useful to use as off-the-shelf component - really it's more the starting point that's getting copied from the developer into his custom plugin directory and modded there. Maybe it can serve as base for later plans, when we're going to offer Footer - Declarations through the Admin-UI (if you meant that – not sure), but then again: We're talking about 10 lines of code. Not really something of substance. |
After talking to @mikemurray it seems that the migration has failed, because it was locked in db. Now for the PR to work it's absolutely necessary that the migrations run. |
@prinzdezibel That makes sense 👍 |
@mikemurray Please give it another try from a fresh master with this feature branch merged into. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the comments above, I like your updates the navbar for visibility
@@ -36,4 +37,23 @@ function composer(props, onData) { | |||
|
|||
registerComponent("NavBar", NavBar, composeWithTracker(composer)); | |||
|
|||
registerComponent("NavBarCheckout", (props, context) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One component per file. Also, separate the registration of the component and the definition of the component like we do in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<div className="reaction-navigation-footer footer-default"> | ||
<nav className="navbar-bottom" role="navigation"> | ||
<div className="row"> | ||
<a href={Reaction.Router.pathFor("/")}>Home</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, removed the link from the component.
- One component per file - Separate component and hoc container - Remove link from Footer component
@mikemurray Hope that's ok now. Thanks for your time! |
@prinzdezibel looks good but you have some linting issues. |
@prinzdezibel I went ahead and fixed the linting issues. Adding @zenweasel as a reviewer to take it over the line if necessary. |
@rymorgan |
@zenweasel Yep, we're reverting back to how it was originally. Navigation at checkout is a conversion no-no. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw one React error but have not been able to reproduce it so I removed that comment. Tested with the fixed version of the example-plugin and all works great. Nice work!
@mikemurray thanks for the fixing the linting errors. I'm still not familiar with my new IDE. |
Previously, I use custom footer template to replace core footer template.
Then I updated Reaction it's self with some "fix" release. If you guys made some changes that break some thing, please do not put it under "Fixes". Peace ✌️ |
@yiwan In the future how do you think we could do a better job of communicating "breaking" changes? We have an ongoing project to replace Blaze components with React which will shortly result in the complete elimination of Blaze. |
…footer-and-header Use React components for footer and header
This changeset is about using React components for header and footer.
Additionally, the old way of customizing parts of the layout is retained,
namely to use registry's layout structure to decide on a per-workflow
basis which footer & header component is choosen.
If this prooves to be unnecessary, we could eliminate that part
altogether. This changeset is also about ensuring feature-parity with old
system: