Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new entry point to the SDK's source. This entry point defines a class,
AnswersSearchBar
, that powers aSearchBar
only integration. The class is defined inanswers-search-bar.js
, which bears many similarities toanswers-umd.js
. There are a few key differences:FilterNodeFactory
,formatRichText
, andprocessTranslations
methods are not exported on the top-level object. These are not needed for this type of integration.TemplateBundle
on their own and we will not need to load it for them. So, theDefaultTemplateLoader
is not used.A new registry of
Components
, specific to this type of integration, was added. This registry was put in a new file,search-bar-only-registry.js
. At first, I attempted to export a second registry from the existingregistry.js
. But, Gulp's tree-shaking was still including allComponent
classes in theSearchBar
-only bundle. Creating a new file solved that issue.Finally, the
ComponentManager
class is no longer a singleton. This is because it can now accept differentcomponentRegistry
s. I don't think this should cause an issue. If you attempt toinit
twice on your page, you wouldalready get the same
componentManager
sinceANSWERS
itself is a singleton. Likewise if you tried to make multiple instances of either on your page.The Gulp infrastructure of the SDK was modified to support building the assets for this integration. There is a new top-level command,
npm run build-search-bar-only
. The existingnpm run build
,npm run build-languages
, andnpm run build-locales
commands work as before. They do not produce the assets for this integration. Thebuild-search-bar-only
command has not been added to the CI either. We still need to determine what the automated build/release process for this integration looks like. It is versioned separately from the SDK. One thing to note is that Product asked the same asset names (answers.js
,answers.min.js
,answers.css
, etc.) be used for this integration.J=SLAP-1271
TEST=auto,manual
Built a new JS and TemplateBundle asset from this entry point. Verified the following:
SearchBar
appears on the page and works as expected.Autocomplete
works as expected.setContext
method could add a context to the search.redirectUrl
worked as expected and the correct query params were added to it.defaultInitialSearch
worked as expected.SearchBar
component.setSessionsOptIn
method worked as expected.A new acceptance test was added for this integration. I verified it passed when the integration's assets were present in
dist
. Note that the test is not run by default since we do not build this integration's assets by default.