-
Notifications
You must be signed in to change notification settings - Fork 72
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
adjust compatibility with the new search protocol #328
adjust compatibility with the new search protocol #328
Conversation
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
react/components/SearchQuery.js
Outdated
const pageRef = useRef(page) | ||
const isCurrentDifferent = (ref, currentVal) => ref.current !== currentVal | ||
|
||
const useShouldResetPage = (query, map, orderBy) => { | ||
const queryRef = useRef(query) |
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 this might be a moment to refactor all of these refs to use a reducer state model.
Then you can just dispatch the reset action when needed. It may be done in a later PR though.
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.
Nice suggestion! I could make this PR by myself when I have a chance.
I have just created an issue about that.
#330
react/hooks/useFacetNavigation.js
Outdated
map: `${currentMap}`, | ||
query: `/${currentQuery}`, | ||
page: undefined, | ||
}) | ||
} | ||
if (fuzzy) queries.fuzzy = fuzzy |
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.
better to keep pattern and use if (x) { fn() }
react/hooks/useFetchMore.js
Outdated
setQuery({ page: pageState.previousPage }, { replace: true, merge: true }) | ||
|
||
const queries = { page: pageState.previousPage } | ||
if (fuzzy) queries.fuzzy = fuzzy |
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.
you should abstract this logic in a function, its used like 5 times.
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 just realized that I can accomplish the same result by using fuzzy: fuzzy || fuzzy
.
I think it is better now.
react/FilterNavigator.js
Outdated
}) | ||
|
||
if (loading && !mobileLayout) { |
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.
Why did you move separate ifs to nested ternaries?
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.
Now, this statement is inside a Fragment
, and I can't use the if
inside the curly braces.
Do you think I should create a new function to handle this JSX? This way, I would be able to use the if
again.
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 this linked in this workspace? If so, non-ft pages seem to be broken. Also, have you rebased this app? There may be some conflicts with the new URL change.
@iaronaraujo I forgot to mention that I have rebased the app today, the last release was the v3.51.4. It looks ok to me! |
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.
Code LGTM, but if possible link this with our normal search and check if the page URL parameter is still working as intended, please!
b9c462b
to
ad4dc02
Compare
ad4dc02
to
b0661ec
Compare
b0661ec
to
7cc0e93
Compare
What problem is this solving?
Currently, VTEX has its own protocol between the search API and the UX components. This protocol forces new search-engines to implement specific rules to communicate with the UI. The search-protocol project purposes a generic way to make the UI/API communication.
This PR adds a "compatibility layer" to handle the new
search-protocol
. With this layer, there is no need to make further changes in the UI components.It also adds three new props that are essential for new search engines. They are:
fuzzy
,operator
andsearchState
. These props are in the URL as queryStrings.Finally, this PR makes a slight improvement in the FilterNavigator by avoiding unnecessary mounting.
How should this be manually tested?
I have created two workspaces, each one with a search engine
search-graphql
enginevtex-search
engine - It only solves full text searches.Types of changes
Notes
This PR depends on
Don't publish it before them!