Skip to content

Conversation

benkeen
Copy link
Member

@benkeen benkeen commented Feb 19, 2016

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.

@benkeen benkeen force-pushed the design-doc-selector-update branch 2 times, most recently from 8155e8c to 6e7d807 Compare February 19, 2016 23:25
@benkeen
Copy link
Member Author

benkeen commented Feb 19, 2016

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):

  1. editing a view and select "_sum" as the optional reduce option.
  2. result: it shows a single doc (the summed doc).

So far, this seems correct to me.

  1. now click back to all docs, then click on the View that you just added _sum to.
  2. That page then shows all docs in the view, not a single _sum result.

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?

@robertkowalski
Copy link
Member

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

@benkeen
Copy link
Member Author

benkeen commented Feb 22, 2016

Great, thanks Robert. I'll patch that up with this ticket and write a test for it.

@benkeen benkeen force-pushed the design-doc-selector-update branch from 6e7d807 to de6e249 Compare February 22, 2016 17:00
@benkeen
Copy link
Member Author

benkeen commented Feb 22, 2016

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.

@benkeen benkeen force-pushed the design-doc-selector-update branch from de6e249 to 525a8ec Compare February 22, 2016 17:29
return;
}

var doc = this.refs.designDocSelector.getDesignDoc();
Copy link
Member

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

Copy link
Member Author

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.

@benkeen benkeen force-pushed the design-doc-selector-update branch from 525a8ec to 7331351 Compare February 22, 2016 22:46
@benkeen
Copy link
Member Author

benkeen commented Feb 22, 2016

Here we go. I slimmed down the component further to remove the getter and the Backbone props (Document + design doc collection).

@robertkowalski
Copy link
Member

+1 after using this.state

database: this.state.database,
newView: this.state.isNewView,
viewName: this.state.viewName,
designDoc: indexEditorStore.getSaveDesignDoc(),
Copy link
Member

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 :)

@benkeen
Copy link
Member Author

benkeen commented Feb 23, 2016

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.
@benkeen benkeen force-pushed the design-doc-selector-update branch from 7331351 to 37cfb74 Compare February 23, 2016 15:24
@asfgit asfgit merged commit 37cfb74 into apache:master Feb 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants