Skip to content

Conversation

@JasonStoltz
Copy link
Member

Reverting a temporary commit, which deleted all code, in order to open up a PR.

This reverts commit cf25dc6.

This reverts commit cf25dc6.
Copy link

@scottybollinger scottybollinger left a 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!

<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root" class="app-container" \></div>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the \ for?

Copy link
Member Author

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";

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" 
Copy link
Member Author

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
};
}

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 }; } 
});
}
});
};

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

Copy link
Member Author

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
});

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 }); }; 
Copy link
Member Author

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.

"sortFields": [
"title",
"anotherField"
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma


import withAppSearch from "../app-search/withAppSearch";
import Facets from "../components/Facets";
import Facet from "../components/Facet";

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


import withAppSearch from "../app-search/withAppSearch";

// App search is currently limited to 100 pages, so we need to make sure

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;

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; 
Copy link
Member Author

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.

Copy link
Member Author

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.


import withAppSearch from "../app-search/withAppSearch";
import Results from "../components/Results";
import Result from "../components/Result";

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

@JasonStoltz
Copy link
Member Author

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
@JasonStoltz
Copy link
Member Author

@scottybollinger Ready for a second look

options={[{ value: "1", count: 1 }, { value: "2", count: 1 }]}
/>
);
expect(wrapper).toMatchSnapshot();

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";

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", () => {

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";

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";

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL this. ☝ Nicely done!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too ¯_(ツ)_/¯

Copy link

@scottybollinger scottybollinger left a 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. 👍

@JasonStoltz
Copy link
Member Author

@scottybollinger Good call on cleaning those tests up. Ready for another look!

@JasonStoltz JasonStoltz merged commit f17fd2d into master Aug 21, 2018
@JasonStoltz JasonStoltz deleted the review branch August 21, 2018 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants