-
Couldn't load subscription status.
- Fork 25
Initial PR #4
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
Initial PR #4
Conversation
This reverts commit cf25dc6.
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.
Happy to discuss some of these if you don't agree. Great work!
public/index.html Outdated
| <noscript> | ||
| You need to enable JavaScript to run this app. | ||
| </noscript> | ||
| <div id="root" class="app-container" \></div> |
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.
What is the \ for?
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.
Looks like a typo that miraculously didn't blow things up.
src/App.js Outdated
| @@ -0,0 +1,57 @@ | |||
| import React, { Component } from "react"; | |||
| | |||
| import Header from "./components/Header"; | |||
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.
Just a suggestions, it might be a bit cleaner to export these from an index.js and have
import { Header, Body } from "./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.
Yes, I like that a lot.
| sortField | ||
| }; | ||
| } | ||
| |
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 could be simplified with destructuring
function filterSearchParameters({ current, filters, resultsPerPage, searchTerm, sortDirection, sortField }) { return { current, filters, resultsPerPage, searchTerm, sortDirection, sortField }; } | }); | ||
| } | ||
| }); | ||
| }; |
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.
Is there any reason the server would ever respond with an error? If so, might be good to have a .catch here
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.
Totally overlooked error handling, thanks.
| searchTerm, | ||
| sortDirection, | ||
| sortField | ||
| }); |
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.
Is there a reason you are destructuring and re-adding the entire state instead of:
removeFilter = (name, value) => { const { filters } = this.state; const updatedFilters = filters.filter(filter => !(filter[name] === value)); this._updateSearchResults({ ...this.state, current: 1, filters: updatedFilters }); }; 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 hadn't considered doing that. It's primarily because that method doesn't need the entire state, it just needs 5 fields from the state. It should be harmless to pass the extra fields though.
I could also possibly update the _updateSearchResults to simply do that piece of it inside of the method. So default to current state if a particular field isn't passed.
src/config/engine.json.example Outdated
| "sortFields": [ | ||
| "title", | ||
| "anotherField" | ||
| ] |
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.
Missing comma
src/containers/Facets.js Outdated
| | ||
| import withAppSearch from "../app-search/withAppSearch"; | ||
| import Facets from "../components/Facets"; | ||
| import Facet from "../components/Facet"; |
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.
Same here about index.js as above
src/containers/Paging.js Outdated
| | ||
| import withAppSearch from "../app-search/withAppSearch"; | ||
| | ||
| // App search is currently limited to 100 pages, so we need to make sure |
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.
"App Search" (caps)
| totalResults <= resultsPerPage | ||
| ? totalResults | ||
| : start + resultsPerPage - 1; | ||
| |
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've always heard to have the operators at the end of the line. What about this?
const end = totalResults <= resultsPerPage ? totalResults : start + resultsPerPage - 1; 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.
That may have been autoformatted, I'll have to check.
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.
It was autoformatted that way, plus, I think I prefer that anyway.
src/containers/Results.js Outdated
| | ||
| import withAppSearch from "../app-search/withAppSearch"; | ||
| import Results from "../components/Results"; | ||
| import Result from "../components/Result"; |
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.
Same here about index.js as above
| I agree with all of your feedback, thanks! Going to make updates accordingly right now. |
- Support config in test - index.js for components - destructure `filterSearchParameters` - Added error handling - Refactor _updateSearchResults - Changed all actions to call _updateSearchResults only with updated values. _updateSearchResults then defaults unprovided values to current state. - Expanded on driver param in provider - Explicitly specified the shape of the driver in PropTypes. - Simplified toSingleValue - URLManager code style changes - Added index.js for containers - Simplify map in jsx - Use template string in className - Reword comment to not say 'user' - Use brackets for long single line if - Use simple field assignment in config file - Missing comma - App Search with caps in comment
| @scottybollinger Ready for a second look |
| options={[{ value: "1", count: 1 }, { value: "2", count: 1 }]} | ||
| /> | ||
| ); | ||
| expect(wrapper).toMatchSnapshot(); |
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 could be a little cleaner and DRY.
import React from "react"; import Facet from "./Facet"; import { shallow } from "enzyme"; const props = { name: "Facet", onRemove: () => {}, onSelect: () => {}, options: [{ value: "1", count: 1 }, { value: "2", count: 1 }] } it("renders correctly when a value is selected", () => { const wrapper = shallow(<Facet {...props} value="value" />); expect(wrapper).toMatchSnapshot(); }); it("renders correctly when a value is not selected", () => { const wrapper = shallow(<Facet {...props} />); expect(wrapper).toMatchSnapshot(); }); | import React from "react"; | ||
| import Result from "./Result"; | ||
| import { shallow } from "enzyme"; | ||
| |
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.
Same as above with share props object
| import ResultsPerPage from "./ResultsPerPage"; | ||
| import { shallow } from "enzyme"; | ||
| | ||
| it("renders correctly when there is a selected value", () => { |
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.
Same as above with share props object
| import React from "react"; | ||
| import SearchBox from "./SearchBox"; | ||
| import { shallow } from "enzyme"; | ||
| |
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.
Same as above with share props object
| import React from "react"; | ||
| import Sorting from "./Sorting"; | ||
| import { shallow } from "enzyme"; | ||
| |
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.
Same as above with share props object
| sortField | ||
| } = { | ||
| ...this.state, | ||
| ...searchParameters |
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.
TIL this. ☝ Nicely done!
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.
Me too ¯_(ツ)_/¯
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.
LGTM other than the test DRY stuff. 👍
| @scottybollinger Good call on cleaning those tests up. Ready for another look! |
Reverting a temporary commit, which deleted all code, in order to open up a PR.
This reverts commit cf25dc6.