-
Notifications
You must be signed in to change notification settings - Fork 227
Make DesignDocSelector into a dumb component #650
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
Conversation
8155e8c
to
6e7d807
Compare
Hey @robertkowalski, there's a failing test on this one, but it may have uncovered a related problem so I wanted to confirm the behaviour before fixing it. Here's the scenario (do this on master):
So far, this seems correct to me.
Is this behaviour correct? Seems strange to me... shouldn't that View now always just show the single document when you've selected _sum for a View, like the test is confirming? |
yes that sounds like a bug |
Great, thanks Robert. I'll patch that up with this ticket and write a test for it. |
6e7d807
to
de6e249
Compare
Okay, I pared back this ticket a bit. I was a little overambitious in my refactoring. The next PR [https://github.com//pull/651] moves the Views to their own page and will remove the need for some of the logic to dynamically reload the result list. |
de6e249
to
525a8ec
Compare
return; | ||
} | ||
|
||
var doc = this.refs.designDocSelector.getDesignDoc(); |
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.
hmmm, not feeling comfortable by calling a getter on a view to get data. we used to do that with backbone a lot and it got us really into trouble.
maybe we can put that into a store and let the component fire an action? the dumb component does not need to be connected directly to the store, it could get the data updates as props from the parent component
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.
Blerg. I agree. Let me see what I can do.
525a8ec
to
7331351
Compare
Here we go. I slimmed down the component further to remove the getter and the Backbone props (Document + design doc collection). |
+1 after using this.state |
database: this.state.database, | ||
newView: this.state.isNewView, | ||
viewName: this.state.viewName, | ||
designDoc: indexEditorStore.getSaveDesignDoc(), |
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.
this.state.saveDesignDoc
saves performance & is in general nicer :)
Nice, thanks Robert! Yeah I stuck the store call at that location because technically it was only needed at that point: and calling it always would call it before the data was actually ready. Not a big deal at all, I can just add in a clause to clear it up, and I agree it's cleaner to put them all in state. |
The dumbifies the DesignDocSelector to remove all ties a to store and passes everything via props so we can get more use out of it. Specifically, I need this for my next PR which includes a new, generic Clone Index modal that'll use this component in different contexts (i.e. all index types). - Includes validation in the component to make it more self-contained and allows for better UX by focusing on error fields. - Save action significantly simplied to remove custom update logic and always redirect to appropriate View page.
7331351
to
37cfb74
Compare
The dumbifies the DesignDocSelector to remove all ties a to
store and passes everything via props so we can get more use out
of it. Specifically, I need this for my next PR which includes
a new, generic Clone Index modal that'll use this component
in different contexts (i.e. all index types).
Also includes validation in the component to make it more
self-contained and allows for better UX by focusing on error fields.